{"version":3,"file":"stream.d.ts","names":["UseStreamOptions","InferAgentToolCalls","Message","BagTemplate","UseStream","UseStreamCustom","UseStreamCustomOptions","InferStateType","T","S","Record","O","InferBag","B","useStream","Bag"],"sources":["../../src/react/stream.d.ts"],"sourcesContent":["import type { UseStreamOptions, InferAgentToolCalls } from \"../ui/types.js\";\nimport type { Message } from \"../types.messages.js\";\nimport type { BagTemplate } from \"../types.template.js\";\nimport type { UseStream, UseStreamCustom, UseStreamCustomOptions } from \"./types.js\";\n/**\n * Helper type that infers StateType based on whether T is an agent-like type, a CompiledGraph/Pregel instance, or a state type.\n * - If T has `~agentTypes`, returns a state with typed messages based on the agent's tools\n * - If T has `~RunOutput` (CompiledGraph/CompiledStateGraph), returns the state type\n * - If T has `~OutputType` (Pregel), returns the output type as state\n * - Otherwise, returns T (direct state type)\n */\ntype InferStateType<T> = T extends {\n    \"~agentTypes\": unknown;\n} ? {\n    messages: Message<InferAgentToolCalls<T>>[];\n} : T extends {\n    \"~RunOutput\": infer S;\n} ? S extends Record<string, unknown> ? S : Record<string, unknown> : T extends {\n    \"~OutputType\": infer O;\n} ? O extends Record<string, unknown> ? O : Record<string, unknown> : T extends Record<string, unknown> ? T : Record<string, unknown>;\n/**\n * Helper type that infers Bag based on whether T is an agent-like type.\n * - If T has `~agentTypes`, extracts bag from the agent's tools\n * - Otherwise, returns the default BagTemplate\n */\ntype InferBag<T, B extends BagTemplate = BagTemplate> = T extends {\n    \"~agentTypes\": unknown;\n} ? BagTemplate : B;\n/**\n * A React hook that provides seamless integration with LangGraph streaming capabilities.\n *\n * The `useStream` hook handles all the complexities of streaming, state management, and branching logic,\n * letting you focus on building great chat experiences. It provides automatic state management for\n * messages, interrupts, loading states, and errors.\n *\n * ## Usage with ReactAgent (recommended for createAgent users)\n *\n * When using `createAgent` from `@langchain/langgraph`, you can pass `typeof agent` as the\n * type parameter to automatically infer tool call types:\n *\n * @example\n * ```typescript\n * // In your agent file (e.g., agent.ts)\n * import { createAgent, tool } from \"@langchain/langgraph\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n *   async ({ location }) => `Weather in ${location}`,\n *   { name: \"get_weather\", schema: z.object({ location: z.string() }) }\n * );\n *\n * export const agent = createAgent({\n *   model: \"openai:gpt-4o\",\n *   tools: [getWeather],\n * });\n *\n * // In your React component\n * import { agent } from \"./agent\";\n *\n * function Chat() {\n *   // Tool calls are automatically typed from the agent's tools!\n *   const stream = useStream<typeof agent>({\n *     assistantId: \"agent\",\n *     apiUrl: \"http://localhost:2024\",\n *   });\n *\n *   // stream.toolCalls[0].call.name is typed as \"get_weather\"\n *   // stream.toolCalls[0].call.args is typed as { location: string }\n * }\n * ```\n *\n * ## Usage with StateGraph (for custom LangGraph applications)\n *\n * When building custom graphs with `StateGraph`, embed your tool call types directly\n * in your state's messages property using `Message<MyToolCalls>`:\n *\n * @example\n * ```typescript\n * import { Message } from \"@langchain/langgraph-sdk\";\n *\n * // Define your tool call types as a discriminated union\n * type MyToolCalls =\n *   | { name: \"search\"; args: { query: string }; id?: string }\n *   | { name: \"calculate\"; args: { expression: string }; id?: string };\n *\n * // Embed tool call types in your state's messages\n * interface MyGraphState {\n *   messages: Message<MyToolCalls>[];\n *   context?: string;\n * }\n *\n * function Chat() {\n *   const stream = useStream<MyGraphState>({\n *     assistantId: \"my-graph\",\n *     apiUrl: \"http://localhost:2024\",\n *   });\n *\n *   // stream.values is typed as MyGraphState\n *   // stream.toolCalls[0].call.name is typed as \"search\" | \"calculate\"\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With additional type configuration (interrupts, configurable)\n * interface MyGraphState {\n *   messages: Message<MyToolCalls>[];\n * }\n *\n * function Chat() {\n *   const stream = useStream<MyGraphState, {\n *     InterruptType: { question: string };\n *     ConfigurableType: { userId: string };\n *   }>({\n *     assistantId: \"my-graph\",\n *     apiUrl: \"http://localhost:2024\",\n *   });\n *\n *   // stream.interrupt is typed as { question: string } | undefined\n * }\n * ```\n *\n * @template T Either a ReactAgent type (with `~agentTypes`) or a state type (`Record<string, unknown>`)\n * @template Bag Type configuration bag containing:\n *   - `ConfigurableType`: Type for the `config.configurable` property\n *   - `InterruptType`: Type for interrupt values\n *   - `CustomEventType`: Type for custom events\n *   - `UpdateType`: Type for the submit function updates\n *\n * @see {@link https://docs.langchain.com/langgraph-platform/use-stream-react | LangGraph React Integration Guide}\n */\nexport declare function useStream<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(options: UseStreamOptions<InferStateType<T>, InferBag<T, Bag>>): UseStream<InferStateType<T>, InferBag<T, Bag>>;\n/**\n * A React hook that provides seamless integration with LangGraph streaming capabilities.\n *\n * The `useStream` hook handles all the complexities of streaming, state management, and branching logic,\n * letting you focus on building great chat experiences. It provides automatic state management for\n * messages, interrupts, loading states, and errors.\n *\n * @template T Either a ReactAgent type (with `~agentTypes`) or a state type (`Record<string, unknown>`)\n * @template Bag Type configuration bag containing:\n *   - `ConfigurableType`: Type for the `config.configurable` property\n *   - `InterruptType`: Type for interrupt values\n *   - `CustomEventType`: Type for custom events\n *   - `UpdateType`: Type for the submit function updates\n *\n * @see {@link https://docs.langchain.com/langgraph-platform/use-stream-react | LangGraph React Integration Guide}\n */\nexport declare function useStream<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(options: UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>>): UseStreamCustom<InferStateType<T>, InferBag<T, Bag>>;\nexport {};\n"],"mappings":";;;;;;;;;AAGqF;;;;;KAQhFO,cAGSL,CAAAA,CAAAA,CAAAA,GAHWM,CAGXN,SAAAA;eACVM,EAAAA,OAAAA;;UAEUE,EAHAR,OAGAQ,CAHQT,mBAGRS,CAH4BF,CAG5BE,CAAAA,CAAAA,EAAAA;IAFVF,UAEoCC;cAAIC,EAAAA,KAAAA,EAAAA;IAAxCD,UAAUC,MAAwDF,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GAA9BC,CAA8BD,GAA1BE,MAA0BF,CAAAA,MAAAA,EAAAA,OAAAA,CAAA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