import { DefaultToolCall, InferToolOutput, ToolCallFromTool } from "../types.messages.js"; import { AssembledToolCall } from "../client/stream/handles/tools.js"; import { AgentTypeConfigLike, CompiledSubAgentLike, DeepAgentTypeConfigLike, DefaultSubagentStates, ExtractAgentConfig, ExtractDeepAgentConfig, ExtractSubAgentMiddleware, InferAgentToolCalls, InferDeepAgentSubagents, InferSubagentByName, InferSubagentNames, InferSubagentState, IsAgentLike, IsDeepAgentLike, SubAgentLike, SubagentStateMap, SubagentToolCall } from "../ui/types.js"; import { InferBag, InferNodeNames, InferStateType as InferStateType$1, InferSubagentStates as InferSubagentStates$1, InferToolCalls as InferToolCalls$1 } from "../ui/stream/index.js"; import { BaseMessage } from "@langchain/core/messages"; //#region src/stream/types-inference.d.ts /** @internal Map a {@link ToolCallFromTool} message shape to {@link AssembledToolCall}. */ type AssembledToolCallFromToolCall; }, TOutput = unknown> = TCall extends { name: infer N; args: infer A; } ? N extends string ? A extends Record ? AssembledToolCall : never : never : never; /** * Infer the streaming {@link AssembledToolCall} handle for a single * LangChain tool. * * Parallel to {@link ToolCallFromTool} for message-level tool calls — * use this when a component receives one entry from `stream.toolCalls` * and you know which tool definition it came from. * * @example * ```ts * const searchWeb = tool(/* ... *\/); * * function SearchWebCall({ toolCall }: { * toolCall: AssembledToolCallFromTool; * }) { * // toolCall.name is "search_web", args/input are schema-inferred * } * * v1 framework packages (`@langchain/react`, `@langchain/vue`, etc.) re-export * this type as {@link ToolCallFromTool}. {@link AssembledToolCall.output} is * `null` until the call succeeds; use {@link status} / {@link error} for UI. * ``` */ type AssembledToolCallFromTool = AssembledToolCallFromToolCall, InferToolOutput>; /** @internal Resolve a tool definition's registered name. */ type ToolNameOf = T extends { name: infer N extends string; } ? N : T extends { tool: { name: infer N extends string; }; } ? N : never; /** @internal Look up the return type of a tool in a tuple by its `name`. */ type MatchedToolOutput = Tools extends readonly [infer First, ...infer Rest] ? ToolNameOf extends N ? InferToolOutput : MatchedToolOutput : unknown; /** * @internal Bridge a message-level tool-call shape from {@link InferToolCallsFromUi} * to a streaming {@link AssembledToolCall}, resolving `output` from the agent's * declared tool list. */ type AssembledFromMessageToolCall; }, Tools extends readonly unknown[]> = TC extends { name: infer N; } ? N extends string ? AssembledToolCallFromToolCall> : AssembledToolCall : AssembledToolCall; /** * Unwrap the state shape from a compiled graph, a create-agent brand, * or a plain type. Used by `useStream()` to resolve `T = typeof * agent` into the state the `values`/`messages` projections observe. * * Structurally identical to the legacy * `@langchain/langgraph-sdk/ui` helper of the same name; kept here as * a framework-facing re-export so bindings can import from the * stream subpath without needing the UI module. */ type InferStateType = InferStateType$1; /** * Infer the discriminated union of {@link AssembledToolCall} handles * from an agent brand, an array of LangChain tools, or fall back to the * untyped default handle. * * Pass `typeof agent` or `typeof tools` and narrow on `name` / `args` * (aliases for `input`) in tool-call UI components. */ type InferToolCalls = T extends readonly unknown[] ? AssembledToolCallFromTool : ExtractAgentConfig["Tools"] extends infer Tools extends readonly unknown[] ? InferToolCalls$1 extends infer TC ? TC extends { name: string; args: Record; } ? AssembledFromMessageToolCall : AssembledToolCall : AssembledToolCall : AssembledToolCall; /** * Infer the subagent → state map from a DeepAgent brand. Non-brands * collapse to {@link DefaultSubagentStates}. */ type InferSubagentStates = InferSubagentStates$1; /** * Widen an update type so its `messages` field also accepts * `@langchain/core` {@link BaseMessage} class instances (single or * array). Framework bindings apply this to `submit()` so callers can * write `stream.submit({ messages: [new HumanMessage("hi")] })`. * * Port of the legacy `AcceptBaseMessages` helper; the public name * matches the v1 spec in `plan-types.md` §8. */ type WidenUpdateMessages = T extends Record ? { [K in keyof T]: K extends "messages" ? T[K] | BaseMessage | BaseMessage[] : T[K] } : T; //#endregion export { AssembledToolCallFromTool, InferStateType, InferSubagentStates, InferToolCalls, WidenUpdateMessages }; //# sourceMappingURL=types-inference.d.ts.map