UNPKG

@langchain/langgraph

Version:
1 lines 1.06 kB
{"version":3,"file":"writer.cjs","names":["AsyncLocalStorageProviderSingleton"],"sources":["../src/writer.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { LangGraphRunnableConfig } from \"./pregel/runnable_types.js\";\n\nexport function writer<T>(chunk: T): void {\n const config: LangGraphRunnableConfig | undefined =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (!config) {\n throw new Error(\"Called interrupt() outside the context of a graph.\");\n }\n\n const conf = config.configurable;\n if (!conf) {\n throw new Error(\"No configurable found in config\");\n }\n\n return conf.writer?.(chunk);\n}\n\nexport type InferWriterType<T> = T extends typeof writer<infer C> ? C : any; // eslint-disable-line @typescript-eslint/no-explicit-any\n"],"mappings":";;AAGA,SAAgB,OAAU,OAAgB;CACxC,MAAM,SACJA,2BAAAA,mCAAmC,mBAAmB;AACxD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qDAAqD;CAGvE,MAAM,OAAO,OAAO;AACpB,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,kCAAkC;AAGpD,QAAO,KAAK,SAAS,MAAM"}