import { AbstractAgent, BaseEvent, RunAgentInput } from "@ag-ui/client"; import { BaseChatModel } from "@langchain/core/language_models/chat_models"; import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk } from "@langchain/core/messages"; import { DynamicStructuredTool } from "@langchain/core/tools"; import { IterableReadableStream } from "@langchain/core/utils/stream"; import { Observable } from "rxjs"; //#region src/streaming.d.ts /** * LangChain response types that can be returned from chainFn */ type LangChainResponse = string | AIMessage | AIMessageChunk | BaseMessageChunk | IterableReadableStream | IterableReadableStream; //#endregion //#region src/agent.d.ts /** * Parameters passed to chainFn callback */ interface ChainFnParams { /** * Converted LangChain messages */ messages: BaseMessage[]; /** * Converted LangChain tools */ tools: DynamicStructuredTool[]; /** * Application state (can be edited via state tools) */ state?: any; /** * Application context */ context: Array<{ description: string; value: string; }>; /** * Thread ID */ threadId: string; /** * Run ID */ runId: string; /** * Per-request HTTP headers forwarded from the runtime (e.g. x-aimock-context). * Undefined when no headers are set on the agent instance. */ headers?: Record; } /** * Configuration for advanced usage with custom LangChain logic */ interface LangChainAgentChainFnConfig { /** * Custom function that handles LangChain execution * This allows full control over chains, graphs, and custom logic */ chainFn: (params: ChainFnParams) => Promise | LangChainResponse; } /** * Configuration for simple usage with direct model */ interface LangChainAgentModelConfig { /** * LangChain chat model instance */ model: BaseChatModel; /** * Optional system prompt */ prompt?: string; /** * Options to pass to bindTools() */ bindToolsOptions?: Record; } /** * Dual configuration: either chainFn OR model */ type LangChainAgentConfig = LangChainAgentChainFnConfig | LangChainAgentModelConfig; /** * LangChain Agent - bridges AG-UI and LangChain ecosystems * * Supports two usage patterns: * * 1. Advanced (chainFn): Full control over LangChain execution * ```typescript * new LangChainAgent({ * chainFn: async ({ messages, tools }) => { * const model = new ChatOpenAI({ model: "gpt-4" }); * return model.bindTools(tools).stream(messages); * } * }) * ``` * * 2. Simple (model): Direct model usage with automatic plumbing * ```typescript * new LangChainAgent({ * model: new ChatOpenAI({ model: "gpt-4" }), * prompt: "You are a helpful assistant" * }) * ``` */ declare class LangChainAgent extends AbstractAgent { private config; private abortController?; /** * Per-request HTTP headers to forward to the underlying LLM provider. * Set by CopilotKit Runtime via configureAgentForRequest() to propagate * x-aimock-context, x-aimock-strict, x-test-id, and other forwarded headers. */ headers?: Record; constructor(config: LangChainAgentConfig); run(input: RunAgentInput): Observable; /** * Build system prompt with context and state */ private buildSystemPrompt; clone(): LangChainAgent; abortRun(): void; } //#endregion export { ChainFnParams, LangChainAgent, LangChainAgentChainFnConfig, LangChainAgentConfig, LangChainAgentModelConfig }; //# sourceMappingURL=index.d.ts.map