import type { Agent, DAGNode, LinearStep, Model, Span, Tool } from '../../../types';
import type { LlamaIndexInstrumentationHandler } from './types';
/**
 * OpenInference / Phoenix-style LlamaIndex traces.
 * - Exact span names: AgentWorkflow.run, AgentWorkflow.call_tool, OpenAI.astream_chat, etc.
 * - Rich attributes: input.value, output.value, llm.model_name, openinference.span.kind.
 */
export declare class OpenInferenceHandler implements LlamaIndexInstrumentationHandler {
    readonly kind: "openinference";
    private deduplicator;
    private toolAnalyzer;
    constructor();
    /**
     * Returns scoped spans (under AgentWorkflow.run) and unscoped spans (everything else).
     * When there are no workflow roots, scoped = all spans and unscoped = [].
     */
    getWorkflowScopedSpansSplit(spans: Span[]): {
        scoped: Span[];
        unscoped: Span[];
    };
    getWorkflowScopedSpans(spans: Span[]): Span[];
    getTools(spans: Span[]): Tool[];
    getAgents(spans: Span[]): Agent[];
    /** Merge a later agent step (same logical agent) into the first-seen one. */
    private mergeAgentInto;
    private getSpanAttrs;
    /** Trace duration is typically in nanoseconds; return ms for display. */
    private durationMs;
    /** Build parent -> list of child spans. */
    private buildChildMap;
    /** Async-only OpenAI spans (prepare + astream). Safe to hide: standard traces have an OpenInference LLM span for the same call. */
    private isAsyncOnlyModelSpan;
    /** True when this agent step's only model descendants are _prepare_chat_with_tools and astream_chat (async-only). */
    private isAsyncOnlyAgent;
    /** Collect all descendant span IDs of rootId (BFS). */
    private getDescendantIds;
    /** Get token/model rollup from descendant LLM spans (for DAG metadata or agent). */
    private getDescendantModelRollup;
    /** Attach token/model rollup from descendant LLM spans (OpenAI.astream_chat etc.) to this agent. */
    private attachDescendantModelRollup;
    /** Attach tools called in this agent step (from run_agent_step output.value tool_calls) and span ids. */
    private attachToolsCalledFromOutput;
    getModels(spans: Span[]): Model[];
    /**
     * Returns models extracted from unscoped spans only.
     * Used only when scoped and unscoped sets differ (i.e. when there are workflow roots and spans outside them).
     */
    getModelsFromUnscoped(spans: Span[]): Model[];
    generateDag(spans: Span[]): DAGNode[];
    generateLinearFlow(spans: Span[]): LinearStep[];
    private safeParseJson;
    private parseCallToolIo;
    private parseRunAgentStepAgentName;
    /**
     * Parse run_agent_step output (stringified JSON) for tool_calls.
     * Tries: (1) top-level tool_calls, (2) response.additional_kwargs.tool_calls (id/function.name),
     * (3) regex on raw string for "tool_id"/"id" and "tool_name"/"name".
     */
    private parseRunAgentStepToolCalls;
    /** Map tool_id (from call_tool output.value) -> call_tool span id. */
    private buildToolIdToSpanIdMap;
    private isToolSpan;
    /** LangChain/LangGraph-style routing and plumbing (LlamaIndex can use these when built on LangChain). */
    private isInfrastructureWorkflow;
    private isAgentSpan;
    private isModelSpan;
    private extractTool;
    private extractAgent;
    /**
     * OpenInference run_agent_step often encodes agent instructions in input.value->ev(AgentSetup...).
     * Use the first "You are ..." sentence as fallback description when gen_ai.agent.description is absent.
     */
    private parseAgentDescriptionFromSetupInput;
    private extractModel;
    /** TTFT from first event named like "First Token Stream Event" (eventsTimestamp/eventsName or span.events). */
    private getTtftFromFirstTokenEvent;
    private getNodeType;
}
//# sourceMappingURL=openInferenceHandler.d.ts.map