@langchain/langgraph 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/channels/binop.cjs +13 -2
  2. package/dist/channels/binop.cjs.map +1 -1
  3. package/dist/channels/binop.d.cts +4 -2
  4. package/dist/channels/binop.d.cts.map +1 -1
  5. package/dist/channels/binop.d.ts +4 -2
  6. package/dist/channels/binop.d.ts.map +1 -1
  7. package/dist/channels/binop.js +14 -3
  8. package/dist/channels/binop.js.map +1 -1
  9. package/dist/constants.cjs +78 -0
  10. package/dist/constants.cjs.map +1 -1
  11. package/dist/constants.d.cts +49 -1
  12. package/dist/constants.d.cts.map +1 -1
  13. package/dist/constants.d.ts +49 -1
  14. package/dist/constants.d.ts.map +1 -1
  15. package/dist/constants.js +76 -1
  16. package/dist/constants.js.map +1 -1
  17. package/dist/func/index.cjs +1 -1
  18. package/dist/func/index.d.cts +1 -1
  19. package/dist/func/index.d.ts +1 -1
  20. package/dist/func/index.js +1 -1
  21. package/dist/graph/annotation.cjs.map +1 -1
  22. package/dist/graph/annotation.d.cts +3 -2
  23. package/dist/graph/annotation.d.cts.map +1 -1
  24. package/dist/graph/annotation.d.ts +3 -2
  25. package/dist/graph/annotation.d.ts.map +1 -1
  26. package/dist/graph/annotation.js.map +1 -1
  27. package/dist/graph/graph.cjs +3 -6
  28. package/dist/graph/graph.cjs.map +1 -1
  29. package/dist/graph/graph.d.cts +2 -2
  30. package/dist/graph/graph.d.cts.map +1 -1
  31. package/dist/graph/graph.d.ts +2 -2
  32. package/dist/graph/graph.d.ts.map +1 -1
  33. package/dist/graph/graph.js +3 -6
  34. package/dist/graph/graph.js.map +1 -1
  35. package/dist/graph/index.cjs +1 -1
  36. package/dist/graph/index.d.ts +1 -1
  37. package/dist/graph/index.js +1 -1
  38. package/dist/graph/messages_annotation.d.cts +3 -2
  39. package/dist/graph/messages_annotation.d.cts.map +1 -1
  40. package/dist/graph/messages_annotation.d.ts +3 -2
  41. package/dist/graph/messages_annotation.d.ts.map +1 -1
  42. package/dist/graph/state.cjs +1 -1
  43. package/dist/graph/state.d.cts +1 -1
  44. package/dist/graph/state.d.ts +1 -1
  45. package/dist/graph/state.js +1 -1
  46. package/dist/graph/types.cjs +1 -1
  47. package/dist/graph/types.d.cts +1 -1
  48. package/dist/graph/types.d.ts +1 -1
  49. package/dist/graph/types.js +1 -1
  50. package/dist/graph/zod/meta.cjs.map +1 -1
  51. package/dist/graph/zod/meta.d.cts +3 -2
  52. package/dist/graph/zod/meta.d.cts.map +1 -1
  53. package/dist/graph/zod/meta.d.ts +3 -2
  54. package/dist/graph/zod/meta.d.ts.map +1 -1
  55. package/dist/graph/zod/meta.js.map +1 -1
  56. package/dist/index.cjs +2 -1
  57. package/dist/index.d.cts +2 -2
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.js +2 -2
  60. package/dist/interrupt.cjs +1 -1
  61. package/dist/interrupt.js +1 -1
  62. package/dist/prebuilt/react_agent_executor.cjs +1 -1
  63. package/dist/prebuilt/react_agent_executor.d.cts +5 -5
  64. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  65. package/dist/prebuilt/react_agent_executor.d.ts +5 -5
  66. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  67. package/dist/prebuilt/react_agent_executor.js +1 -1
  68. package/dist/prebuilt/tool_node.cjs +1 -1
  69. package/dist/prebuilt/tool_node.d.cts +1 -1
  70. package/dist/prebuilt/tool_node.d.ts +1 -1
  71. package/dist/prebuilt/tool_node.js +1 -1
  72. package/dist/pregel/algo.cjs +1 -1
  73. package/dist/pregel/algo.d.ts +1 -1
  74. package/dist/pregel/algo.js +1 -1
  75. package/dist/pregel/index.cjs +13 -1
  76. package/dist/pregel/index.cjs.map +1 -1
  77. package/dist/pregel/index.d.cts +2 -1
  78. package/dist/pregel/index.d.cts.map +1 -1
  79. package/dist/pregel/index.d.ts +2 -1
  80. package/dist/pregel/index.d.ts.map +1 -1
  81. package/dist/pregel/index.js +14 -2
  82. package/dist/pregel/index.js.map +1 -1
  83. package/dist/pregel/io.cjs +1 -1
  84. package/dist/pregel/io.js +1 -1
  85. package/dist/pregel/loop.cjs +1 -1
  86. package/dist/pregel/loop.js +1 -1
  87. package/dist/pregel/read.cjs +4 -1
  88. package/dist/pregel/read.cjs.map +1 -1
  89. package/dist/pregel/read.d.cts.map +1 -1
  90. package/dist/pregel/read.d.ts.map +1 -1
  91. package/dist/pregel/read.js +4 -1
  92. package/dist/pregel/read.js.map +1 -1
  93. package/dist/pregel/remote.cjs +1 -1
  94. package/dist/pregel/remote.js +1 -1
  95. package/dist/pregel/retry.cjs +1 -1
  96. package/dist/pregel/retry.js +1 -1
  97. package/dist/pregel/runner.cjs +1 -1
  98. package/dist/pregel/runner.js +1 -1
  99. package/dist/pregel/stream.cjs +81 -0
  100. package/dist/pregel/stream.cjs.map +1 -1
  101. package/dist/pregel/stream.d.ts +2 -1
  102. package/dist/pregel/stream.js +81 -1
  103. package/dist/pregel/stream.js.map +1 -1
  104. package/dist/pregel/types.cjs.map +1 -1
  105. package/dist/pregel/types.d.cts +27 -2
  106. package/dist/pregel/types.d.cts.map +1 -1
  107. package/dist/pregel/types.d.ts +27 -2
  108. package/dist/pregel/types.d.ts.map +1 -1
  109. package/dist/pregel/types.js.map +1 -1
  110. package/dist/pregel/write.cjs +2 -1
  111. package/dist/pregel/write.cjs.map +1 -1
  112. package/dist/pregel/write.d.cts +1 -1
  113. package/dist/pregel/write.d.cts.map +1 -1
  114. package/dist/pregel/write.d.ts +1 -1
  115. package/dist/pregel/write.d.ts.map +1 -1
  116. package/dist/pregel/write.js +2 -1
  117. package/dist/pregel/write.js.map +1 -1
  118. package/dist/state/schema.cjs.map +1 -1
  119. package/dist/state/schema.d.cts +3 -2
  120. package/dist/state/schema.d.cts.map +1 -1
  121. package/dist/state/schema.d.ts +3 -2
  122. package/dist/state/schema.d.ts.map +1 -1
  123. package/dist/state/schema.js.map +1 -1
  124. package/dist/web.cjs +2 -1
  125. package/dist/web.d.cts +2 -2
  126. package/dist/web.d.ts +2 -2
  127. package/dist/web.js +2 -2
  128. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"meta.js","names":[],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAI,wBAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAI,UAAU,MAAM,QAAQ;;AAGhD,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,QAAQ,CACrC,QAAQ,GAAG,OAAO,MAAM,KAAK,CAC7B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CACtC,KAAK,CAAC,GAA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;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
1
+ {"version":3,"file":"meta.js","names":[],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAI,wBAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAI,UAAU,MAAM,QAAQ;;AAGhD,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,QAAQ,CACrC,QAAQ,GAAG,OAAO,MAAM,KAAK,CAC7B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAA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,OAAO,cAAc,KAAK;AAC7C,SAAO"}
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_async_local_storage = require('./setup/async_local_storage.cjs');
3
+ const require_constants = require('./constants.cjs');
3
4
  const require_errors = require('./errors.cjs');
4
5
  const require_base = require('./channels/base.cjs');
5
6
  const require_binop = require('./channels/binop.cjs');
6
7
  const require_annotation = require('./graph/annotation.cjs');
7
- const require_constants = require('./constants.cjs');
8
8
  const require_config = require('./pregel/utils/config.cjs');
9
9
  const require_interrupt = require('./interrupt.cjs');
10
10
  const require_graph = require('./graph/graph.cjs');
@@ -81,6 +81,7 @@ exports.MessagesZodMeta = require_messages_annotation.MessagesZodMeta;
81
81
  exports.MessagesZodState = require_messages_annotation.MessagesZodState;
82
82
  exports.MultipleSubgraphsError = require_errors.MultipleSubgraphsError;
83
83
  exports.NodeInterrupt = require_errors.NodeInterrupt;
84
+ exports.Overwrite = require_constants.Overwrite;
84
85
  exports.ParentCommand = require_errors.ParentCommand;
85
86
  exports.REMOVE_ALL_MESSAGES = require_messages_reducer.REMOVE_ALL_MESSAGES;
86
87
  exports.ReducedValue = require_reduced.ReducedValue;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "./channels/base.cjs";
2
+ import { Command, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, isCommand, isInterrupted } from "./constants.cjs";
2
3
  import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.cjs";
3
4
  import { AnyValue } from "./channels/any_value.cjs";
4
5
  import { LastValue } from "./channels/last_value.cjs";
@@ -11,7 +12,6 @@ import { LangGraphRunnableConfig, Runtime } from "./pregel/runnable_types.cjs";
11
12
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.cjs";
12
13
  import { RetryPolicy } from "./pregel/utils/index.cjs";
13
14
  import { PregelNode } from "./pregel/read.cjs";
14
- import { Command, CommandParams, END, INTERRUPT, Interrupt, START, Send, isCommand, isInterrupted } from "./constants.cjs";
15
15
  import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.cjs";
16
16
  import { Pregel } from "./pregel/index.cjs";
17
17
  import { CompiledGraph, Graph } from "./graph/graph.cjs";
@@ -32,4 +32,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
32
32
  import { MessagesValue } from "./state/prebuilt/messages.cjs";
33
33
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.cjs";
34
34
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
35
- export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
35
+ export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "./channels/base.js";
2
+ import { Command, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, isCommand, isInterrupted } from "./constants.js";
2
3
  import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.js";
3
4
  import { AnyValue } from "./channels/any_value.js";
4
5
  import { LastValue } from "./channels/last_value.js";
@@ -11,7 +12,6 @@ import { LangGraphRunnableConfig, Runtime } from "./pregel/runnable_types.js";
11
12
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
12
13
  import { RetryPolicy } from "./pregel/utils/index.js";
13
14
  import { PregelNode } from "./pregel/read.js";
14
- import { Command, CommandParams, END, INTERRUPT, Interrupt, START, Send, isCommand, isInterrupted } from "./constants.js";
15
15
  import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.js";
16
16
  import { Pregel } from "./pregel/index.js";
17
17
  import { CompiledGraph, Graph } from "./graph/graph.js";
@@ -32,4 +32,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
32
32
  import { MessagesValue } from "./state/prebuilt/messages.js";
33
33
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.js";
34
34
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
35
- export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
35
+ export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { initializeAsyncLocalStorageSingleton } from "./setup/async_local_storage.js";
2
+ import { Command, END, INTERRUPT, Overwrite, START, Send, isCommand, isInterrupted } from "./constants.js";
2
3
  import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
3
4
  import { BaseChannel } from "./channels/base.js";
4
5
  import { BinaryOperatorAggregate } from "./channels/binop.js";
5
6
  import { Annotation } from "./graph/annotation.js";
6
- import { Command, END, INTERRUPT, START, Send, isCommand, isInterrupted } from "./constants.js";
7
7
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
8
8
  import { interrupt } from "./interrupt.js";
9
9
  import { Graph } from "./graph/graph.js";
@@ -26,5 +26,5 @@ import { writer } from "./writer.js";
26
26
  initializeAsyncLocalStorageSingleton();
27
27
 
28
28
  //#endregion
29
- export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, Command, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, Send, StateGraph, StateGraphInputError, StateSchema, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
29
+ export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, Command, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, Send, StateGraph, StateGraphInputError, StateSchema, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
30
30
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- const require_errors = require('./errors.cjs');
2
1
  const require_constants = require('./constants.cjs');
2
+ const require_errors = require('./errors.cjs');
3
3
  const require_hash = require('./hash.cjs');
4
4
  let _langchain_core_singletons = require("@langchain/core/singletons");
5
5
 
package/dist/interrupt.js CHANGED
@@ -1,5 +1,5 @@
1
- import { GraphInterrupt, GraphValueError } from "./errors.js";
2
1
  import { CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, RESUME } from "./constants.js";
2
+ import { GraphInterrupt, GraphValueError } from "./errors.js";
3
3
  import { XXH3 } from "./hash.js";
4
4
  import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
5
5
 
@@ -1,5 +1,5 @@
1
- const require_annotation = require('../graph/annotation.cjs');
2
1
  const require_constants = require('../constants.cjs');
2
+ const require_annotation = require('../graph/annotation.cjs');
3
3
  const require_messages_reducer = require('../graph/messages_reducer.cjs');
4
4
  const require_state = require('../graph/state.cjs');
5
5
  require('../graph/index.cjs');
@@ -1,9 +1,9 @@
1
- import { BinaryOperatorAggregate } from "../channels/binop.cjs";
1
+ import { BaseChannel } from "../channels/base.cjs";
2
+ import { OverwriteValue, START } from "../constants.cjs";
2
3
  import { LastValue } from "../channels/last_value.cjs";
3
4
  import { InteropZodToStateDefinition } from "../graph/zod/meta.cjs";
4
5
  import { LangGraphRunnableConfig, Runtime } from "../pregel/runnable_types.cjs";
5
6
  import { AnnotationRoot, SingleReducer, StateDefinition } from "../graph/annotation.cjs";
6
- import { START } from "../constants.cjs";
7
7
  import { CompiledStateGraph } from "../graph/state.cjs";
8
8
  import { Messages } from "../graph/messages_reducer.cjs";
9
9
  import { MessagesAnnotation } from "../graph/messages_annotation.cjs";
@@ -40,15 +40,15 @@ type StateModifier = Prompt;
40
40
  /** @deprecated Use Prompt instead. */
41
41
  type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;
42
42
  declare const createReactAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
43
- messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], Messages>;
43
+ messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
44
44
  structuredResponse: {
45
+ (annotation: SingleReducer<T, T>): BaseChannel<T, T | OverwriteValue<T>, unknown>;
45
46
  (): LastValue<T>;
46
- (annotation: SingleReducer<T, T>): BinaryOperatorAggregate<T, T>;
47
47
  Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
48
48
  };
49
49
  }>;
50
50
  declare const PreHookAnnotation: AnnotationRoot<{
51
- llmInputMessages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], Messages>;
51
+ llmInputMessages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
52
52
  }>;
53
53
  type PreHookAnnotation = typeof PreHookAnnotation;
54
54
  type AnyAnnotationRoot = AnnotationRoot<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"react_agent_executor.d.cts","names":[],"sources":["../../src/prebuilt/react_agent_executor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAmDiB,UAAA,gCAEgB,MAAA,gBAAsB,MAAA;EAErD,QAAA,EAAU,WAAA;EAMV,kBAAA,EAAoB,sBAAA;AAAA;AAAA,KAGV,CAAA,UAAW,KAAA;AAAA,KAElB,+BAAA;EAEH,MAAA,EAAQ,cAAA,CAAe,sBAAA,IAA0B,MAAA;EACjD,MAAA;EAEA,MAAA;EAAA,CACC,GAAA;AAAA;AAAA,KAiEE,UAAA,GAAa,MAAA;AAAA,KACb,UAAA,GAAa,uBAAA,GAA0B,WAAA,GAAc,gBAAA;AAAA,KAkR9C,MAAA,GACR,aAAA,cAGE,KAAA,SAAc,kBAAA,CAAmB,KAAA,EACjC,MAAA,EAAQ,uBAAA,KACL,eAAA,QAEH,KAAA,SAAc,kBAAA,CAAmB,KAAA,EACjC,MAAA,EAAQ,uBAAA,KACL,OAAA,CAAQ,eAAA,OACb,QAAA;;KAGQ,aAAA,GAAgB,MAAA;;KAGhB,eAAA,GACR,aAAA,cAEE,QAAA,EAAU,WAAA,OAAkB,WAAA,QAC5B,QAAA,EAAU,WAAA,OAAkB,OAAA,CAAQ,WAAA,OACtC,QAAA;AAAA,cAES,0BAAA,aAEV,MAAA,gBAAA,MAAA,oBAAA,cAAA;2FAAA,yBAAA,CAAA,cAAA;;;;;;;cAsBG,iBAAA,EAAiB,cAAA;mGAKrB,yBAAA,CAAA,cAAA;;KAEG,iBAAA,UAA2B,iBAAA;AAAA,KAG3B,iBAAA,GAAoB,cAAA;AAAA,KAEpB,gBAAA,WAA2B,iBAAA,GAAoB,gBAAA,IAClD,CAAA,SAAU,iBAAA,GACN,CAAA,GACA,CAAA,SAAU,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AA,CAAe,sBAAA,IACf,+BAAA,CAAgC,sBAAA,IAEhC,MAAA;EApIM;;;EAyIV,IAAA;EA3IgC;;;;EAiJhC,WAAA;EA/IE;;;AAEJ;;;EAsJE,gBAAA;EApJC;;;;EA0JD,YAAA,GAAe,YAAA,CACb,gBAAA,CAAiB,CAAA,aAAc,iBAAA,WAC/B,gBAAA,CAAiB,CAAA,cAAe,iBAAA,YAChC,uBAAA;;;;;EAOF,aAAA,GAAgB,YAAA,CACd,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,aACjB,uBAAA;;;;;;;;;;;;EAcF,OAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA7KG;;;iBA6NW,gBAAA,WACJ,iBAAA,GAAoB,gBAAA,UAA0B,kBAAA,mCAEvB,MAAA,gBAAsB,MAAA,yBAC7C,iBAAA,GAAoB,gBAAA,GAAmB,iBAAA,CAAA,CAEjD,MAAA,EAAQ,sBAAA,CAAuB,CAAA,EAAG,wBAAA,EAA0B,CAAA,IAC3D,kBAAA,CACD,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,yBAGV,kBAAA,CAAmB,IAAA,GAAO,gBAAA,CAAiB,CAAA,WAClD,UAAA,QACS,0BAAA,CAA2B,wBAAA,aAElC,gBAAA,CAAiB,CAAA"}
@@ -1,9 +1,9 @@
1
- import { BinaryOperatorAggregate } from "../channels/binop.js";
1
+ import { BaseChannel } from "../channels/base.js";
2
+ import { OverwriteValue, START } from "../constants.js";
2
3
  import { LastValue } from "../channels/last_value.js";
3
4
  import { InteropZodToStateDefinition } from "../graph/zod/meta.js";
4
5
  import { LangGraphRunnableConfig, Runtime } from "../pregel/runnable_types.js";
5
6
  import { AnnotationRoot, SingleReducer, StateDefinition } from "../graph/annotation.js";
6
- import { START } from "../constants.js";
7
7
  import { CompiledStateGraph } from "../graph/state.js";
8
8
  import { Messages } from "../graph/messages_reducer.js";
9
9
  import "../graph/index.js";
@@ -42,15 +42,15 @@ type StateModifier = Prompt;
42
42
  /** @deprecated Use Prompt instead. */
43
43
  type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;
44
44
  declare const createReactAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
45
- messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], Messages>;
45
+ messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
46
46
  structuredResponse: {
47
+ (annotation: SingleReducer<T, T>): BaseChannel<T, T | OverwriteValue<T>, unknown>;
47
48
  (): LastValue<T>;
48
- (annotation: SingleReducer<T, T>): BinaryOperatorAggregate<T, T>;
49
49
  Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
50
50
  };
51
51
  }>;
52
52
  declare const PreHookAnnotation: AnnotationRoot<{
53
- llmInputMessages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], Messages>;
53
+ llmInputMessages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
54
54
  }>;
55
55
  type PreHookAnnotation = typeof PreHookAnnotation;
56
56
  type AnyAnnotationRoot = AnnotationRoot<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"react_agent_executor.d.ts","names":[],"sources":["../../src/prebu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;;EA0JD,YAAA,GAAe,YAAA,CACb,gBAAA,CAAiB,CAAA,aAAc,iBAAA,WAC/B,gBAAA,CAAiB,CAAA,cAAe,iBAAA,YAChC,uBAAA;;;;;EAOF,aAAA,GAAgB,YAAA,CACd,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,aACjB,uBAAA;;;;;;;;;;;;EAcF,OAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA7KG;iBA6NW,gBAAA,WACJ,iBAAA,GAAoB,gBAAA,UAA0B,kBAAA,mCAEvB,MAAA,gBAAsB,MAAA,yBAC7C,iBAAA,GAAoB,gBAAA,GAAmB,iBAAA,CAAA,CAEjD,MAAA,EAAQ,sBAAA,CAAuB,CAAA,EAAG,wBAAA,EAA0B,CAAA,IAC3D,kBAAA,CACD,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,yBAGV,kBAAA,CAAmB,IAAA,GAAO,gBAAA,CAAiB,CAAA,WAClD,UAAA,QACS,0BAAA,CAA2B,wBAAA,aAElC,gBAAA,CAAiB,CAAA"}
@@ -1,5 +1,5 @@
1
- import { Annotation } from "../graph/annotation.js";
2
1
  import { END, START, Send } from "../constants.js";
2
+ import { Annotation } from "../graph/annotation.js";
3
3
  import { messagesStateReducer } from "../graph/messages_reducer.js";
4
4
  import { StateGraph } from "../graph/state.js";
5
5
  import "../graph/index.js";
@@ -1,5 +1,5 @@
1
- const require_errors = require('../errors.cjs');
2
1
  const require_constants = require('../constants.cjs');
2
+ const require_errors = require('../errors.cjs');
3
3
  const require_utils = require('../utils.cjs');
4
4
  let _langchain_core_messages = require("@langchain/core/messages");
5
5
 
@@ -1,5 +1,5 @@
1
- import { RunnableCallable } from "../utils.cjs";
2
1
  import { Command, END } from "../constants.cjs";
2
+ import { RunnableCallable } from "../utils.cjs";
3
3
  import { MessagesAnnotation } from "../graph/messages_annotation.cjs";
4
4
  import { RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
5
5
  import { BaseMessage, ToolMessage } from "@langchain/core/messages";
@@ -1,5 +1,5 @@
1
- import { RunnableCallable } from "../utils.js";
2
1
  import { Command, END } from "../constants.js";
2
+ import { RunnableCallable } from "../utils.js";
3
3
  import { MessagesAnnotation } from "../graph/messages_annotation.js";
4
4
  import { RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
5
5
  import { BaseMessage, ToolMessage } from "@langchain/core/messages";
@@ -1,5 +1,5 @@
1
- import { isGraphInterrupt } from "../errors.js";
2
1
  import { Command, END, _isSend, isCommand } from "../constants.js";
2
+ import { isGraphInterrupt } from "../errors.js";
3
3
  import { RunnableCallable } from "../utils.js";
4
4
  import { ToolMessage, isAIMessage, isBaseMessage } from "@langchain/core/messages";
5
5
 
@@ -1,6 +1,6 @@
1
+ const require_constants = require('../constants.cjs');
1
2
  const require_errors = require('../errors.cjs');
2
3
  const require_base = require('../channels/base.cjs');
3
- const require_constants = require('../constants.cjs');
4
4
  const require_hash = require('../hash.cjs');
5
5
  const require_io = require('./io.cjs');
6
6
  const require_types = require('./types.cjs');
@@ -1,6 +1,6 @@
1
1
  import "../channels/base.js";
2
- import "./read.js";
3
2
  import "../constants.js";
3
+ import "./read.js";
4
4
  import "./types.js";
5
5
  import "./stream.js";
6
6
  import { All, BaseCheckpointSaver, BaseStore, Checkpoint, PendingWrite, ReadonlyCheckpoint } from "@langchain/langgraph-checkpoint";
@@ -1,6 +1,6 @@
1
+ import { CACHE_NS_WRITES, CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_TASK_ID, ERROR, INTERRUPT, NO_WRITES, NULL_TASK_ID, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, START, Send, TAG_HIDDEN, TASKS, _isSend, _isSendInterface } from "../constants.js";
1
2
  import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
2
3
  import { createCheckpoint, emptyChannels, getOnlyChannels } from "../channels/base.js";
3
- import { CACHE_NS_WRITES, CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_PREVIOUS_STATE, CONFIG_KEY_READ, CONFIG_KEY_RESUME_MAP, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, CONFIG_KEY_TASK_ID, ERROR, INTERRUPT, NO_WRITES, NULL_TASK_ID, PREVIOUS, PULL, PUSH, RESERVED, RESUME, RETURN, START, Send, TAG_HIDDEN, TASKS, _isSend, _isSendInterface } from "../constants.js";
4
4
  import { XXH3 } from "../hash.js";
5
5
  import { readChannel, readChannels } from "./io.js";
6
6
  import { isCall } from "./types.js";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_constants = require('../constants.cjs');
2
3
  const require_errors = require('../errors.cjs');
3
4
  const require_base = require('../channels/base.cjs');
4
- const require_constants = require('../constants.cjs');
5
5
  const require_config = require('./utils/config.cjs');
6
6
  const require_utils = require('../utils.cjs');
7
7
  const require_write = require('./write.cjs');
@@ -199,6 +199,7 @@ var Pregel = class extends PartialRunnable {
199
199
  * - "updates": Streams state updates after each step
200
200
  * - "messages": Streams messages from within nodes
201
201
  * - "custom": Streams custom events from within nodes
202
+ * - "tools": Streams tool-call lifecycle events (on_tool_start, on_tool_event, on_tool_end, on_tool_error) from LLM tool execution
202
203
  * - "debug": Streams events related to the execution of the graph - useful for tracing & debugging graph execution
203
204
  */
204
205
  streamMode = ["values"];
@@ -980,6 +981,17 @@ var Pregel = class extends PartialRunnable {
980
981
  config.callbacks = copiedCallbacks;
981
982
  }
982
983
  }
984
+ if (streamMode.includes("tools")) {
985
+ const toolStreamer = new require_stream.StreamToolsHandler((chunk) => stream.push(chunk));
986
+ const { callbacks } = config;
987
+ if (callbacks === void 0) config.callbacks = [toolStreamer];
988
+ else if (Array.isArray(callbacks)) config.callbacks = callbacks.concat(toolStreamer);
989
+ else {
990
+ const copiedCallbacks = callbacks.copy();
991
+ copiedCallbacks.addHandler(toolStreamer, true);
992
+ config.callbacks = copiedCallbacks;
993
+ }
994
+ }
983
995
  config.writer ??= (chunk) => {
984
996
  if (!streamMode.includes("custom")) return;
985
997
  const ns = (require_config.getConfig()?.configurable?.[require_constants.CONFIG_KEY_CHECKPOINT_NS])?.split(require_constants.CHECKPOINT_NAMESPACE_SEPARATOR).slice(0, -1);