import { KVMap, BaseRun } from "langsmith/schemas"; import { AgentAction, AgentFinish, BaseMessage, ChainValues, LLMResult } from "../../schema/index.js"; import { Serialized } from "../../load/serializable.js"; import { BaseCallbackHandler, BaseCallbackHandlerInput, NewTokenIndices } from "../base.js"; import { Document } from "../../document.js"; export type RunType = "llm" | "chain" | "tool"; export interface Run extends BaseRun { id: string; start_time: number; execution_order: number; child_runs: this[]; child_execution_order: number; events: Array<{ name: string; time: number; kwargs?: Record; }>; } export interface AgentRun extends Run { actions: AgentAction[]; } export declare abstract class BaseTracer extends BaseCallbackHandler { protected runMap: Map; constructor(_fields?: BaseCallbackHandlerInput); copy(): this; protected abstract persistRun(run: Run): Promise; protected _addChildRun(parentRun: Run, childRun: Run): void; protected _startTrace(run: Run): void; protected _endTrace(run: Run): Promise; protected _getExecutionOrder(parentRunId: string | undefined): number; handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: KVMap, tags?: string[], metadata?: KVMap): Promise; handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: KVMap, tags?: string[], metadata?: KVMap): Promise; handleLLMEnd(output: LLMResult, runId: string): Promise; handleLLMError(error: Error, runId: string): Promise; handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap): Promise; handleChainEnd(outputs: ChainValues, runId: string): Promise; handleChainError(error: Error, runId: string): Promise; handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap): Promise; handleToolEnd(output: string, runId: string): Promise; handleToolError(error: Error, runId: string): Promise; handleAgentAction(action: AgentAction, runId: string): Promise; handleAgentEnd(action: AgentFinish, runId: string): Promise; handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap): Promise; handleRetrieverEnd(documents: Document>[], runId: string): Promise; handleRetrieverError(error: Error, runId: string): Promise; handleText(text: string, runId: string): Promise; handleLLMNewToken(token: string, idx: NewTokenIndices, runId: string): Promise; onLLMStart?(run: Run): void | Promise; onLLMEnd?(run: Run): void | Promise; onLLMError?(run: Run): void | Promise; onChainStart?(run: Run): void | Promise; onChainEnd?(run: Run): void | Promise; onChainError?(run: Run): void | Promise; onToolStart?(run: Run): void | Promise; onToolEnd?(run: Run): void | Promise; onToolError?(run: Run): void | Promise; onAgentAction?(run: Run): void | Promise; onAgentEnd?(run: Run): void | Promise; onRetrieverStart?(run: Run): void | Promise; onRetrieverEnd?(run: Run): void | Promise; onRetrieverError?(run: Run): void | Promise; onText?(run: Run): void | Promise; onLLMNewToken?(run: Run): void | Promise; }