import { BaseChannel } from "../../channels/base.js"; import { OverwriteValue } from "../../constants.js"; import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types"; //#region src/graph/zod/meta.d.ts declare const META_EXTRAS_DESCRIPTION_PREFIX = "lg:"; /** @internal */ type ReducedZodChannel = T & { lg_reducer_schema: TReducerSchema; }; /** @internal */ type InteropZodToStateDefinition> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel ? Schema extends InteropZodType ? ReducerSchema extends InteropZodType ? BaseChannel | U> : never : never : TShape[key] extends InteropZodType ? BaseChannel : never }; type UpdateType> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel ? Schema extends InteropZodType ? ReducerSchema extends InteropZodType ? OverwriteValue | U : never : never : TShape[key] extends InteropZodType ? U : never }; interface SchemaMeta { jsonSchemaExtra?: { langgraph_nodes?: string[]; langgraph_type?: "prompt" | "messages"; [key: string]: unknown; }; reducer?: { schema?: InteropZodType; fn: (a: TValue, b: TUpdate) => TValue; }; default?: () => TValue; } /** * A registry for storing and managing metadata associated with schemas. * This class provides methods to get, extend, remove, and check metadata for a given schema. */ declare class SchemaMetaRegistry { /** * Internal map storing schema metadata. * @internal */ _map: Map>; /** * Cache for extended schemas. * @internal */ _extensionCache: Map>; /** * Retrieves the metadata associated with a given schema. * @template TValue The value type of the schema. * @template TUpdate The update type of the schema (defaults to TValue). * @param schema The schema to retrieve metadata for. * @returns The associated SchemaMeta, or undefined if not present. */ get(schema: InteropZodType): SchemaMeta | undefined; /** * Extends or sets the metadata for a given schema. * @template TValue The value type of the schema. * @template TUpdate The update type of the schema (defaults to TValue). * @param schema The schema to extend metadata for. * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata. */ extend(schema: InteropZodType, predicate: (meta: SchemaMeta | undefined) => SchemaMeta): void; /** * Removes the metadata associated with a given schema. * @param schema The schema to remove metadata for. * @returns The SchemaMetaRegistry instance (for chaining). */ remove(schema: InteropZodType): this; /** * Checks if metadata exists for a given schema. * @param schema The schema to check. * @returns True if metadata exists, false otherwise. */ has(schema: InteropZodType): boolean; /** * Returns a mapping of channel instances for each property in the schema * using the associated metadata in the registry. * * This is used to create the `channels` object that's passed to the `Graph` constructor. * * @template T The shape of the schema. * @param schema The schema to extract channels from. * @returns A mapping from property names to channel instances. */ getChannelsForSchema(schema: T): InteropZodToStateDefinition; /** * Returns a modified schema that introspectively looks at all keys of the provided * object schema, and applies the augmentations based on meta provided with those keys * in the registry and the selectors provided in the `effects` parameter. * * This assumes that the passed in schema is the "root" schema object for a graph where * the keys of the schema are the channels of the graph. Because we need to represent * the input of a graph in a couple of different ways, the `effects` parameter allows * us to apply those augmentations based on pre determined conditions. * * @param schema The root schema object to extend. * @param effects The effects that are being applied. * @returns The extended schema. */ getExtendedChannelSchemas(schema: T, effects: { /** * Augments the shape by using the reducer's schema if it exists */ withReducerSchema?: boolean; /** * Applies the stringified jsonSchemaExtra as a description to the schema. */ withJsonSchemaExtrasAsDescription?: boolean; /** * Applies the `.partial()` modifier to the schema. */ asPartial?: boolean; }): InteropZodObject; } declare const schemaMetaRegistry: SchemaMetaRegistry; declare function withLangGraph>(schema: TSchema, meta: SchemaMeta & { reducer?: undefined; }): TSchema; declare function withLangGraph>(schema: TSchema, meta: SchemaMeta): ReducedZodChannel>; //#endregion export { InteropZodToStateDefinition, META_EXTRAS_DESCRIPTION_PREFIX, ReducedZodChannel, SchemaMeta, SchemaMetaRegistry, UpdateType, schemaMetaRegistry, withLangGraph }; //# sourceMappingURL=meta.d.ts.map