/**
 * LangChainAdapter -- Orchestrator adapter for the LangChain framework.
 *
 * Hook surface: LangChain's stable BaseCallbackHandler callback interface.
 * The adapter exposes a toCallbackHandler() factory that returns a
 * BaseCallbackHandler subclass. Consumers wire the returned handler into
 * their chain config:
 *
 *   const adapter = new LangChainAdapter(config);
 *   adapter.initialize(orchConfig);
 *   const chain = new LLMChain({ ..., callbacks: [adapter.toCallbackHandler()] });
 *
 * Agent support: both legacy AgentExecutor pattern and the newer
 * LangGraph-based create_react_agent. When the adapter detects a
 * LangGraph-based agent at dispatch time, it delegates to LangGraphAdapter
 * and emits orchestrator:framework-dispatch DEBUG at the handoff boundary.
 * No duplicate audit event is emitted for the same operation.
 *
 * Agent scratchpad auditing: when the chain invokes a tool, the scratchpad
 * contents from the run's metadata feed into TaskContext.
 *
 * No real @langchain/core package is installed. This adapter shims the
 * BaseCallbackHandler shape and can be exercised fully in tests without
 * the live SDK.
 *
 * Spec: P3-ORCH-01, Section 2.6, AC 12-13
 * @connexum/ai-governance
 */
import { BaseOrchestratorAdapter } from './base';
import { OrchestratorCapabilities, WorkflowContext, WorkflowDecision, WorkflowStepContext, WorkflowStepDecision, WorkflowResult, RoleEdgeContext, RoleEdgeDecision, OrchestratorError } from './index';
import type { TaskContext, TaskDecision, PlanContext, PlanDecision, DelegationContext, DelegationDecision } from './orchestrator-adapter';
/** Minimal shim for a LangChain serialized record. */
export interface LCSerialised {
    lc_serializable?: boolean;
    lc_kwargs?: Record<string, unknown>;
    [key: string]: unknown;
}
/** Shim for LangChain chain run start event. */
export interface LCChainStartEvent {
    /** Run ID from LangChain's run manager */
    runId: string;
    /** Chain class name (e.g. "LLMChain", "AgentExecutor") */
    chainType: string;
    /** Input passed to the chain */
    inputs: Record<string, unknown>;
    /** Run metadata from LangChain (may include scratchpad) */
    metadata?: Record<string, unknown>;
    /** Whether this chain is a LangGraph-based agent */
    isLangGraph?: boolean;
    /** Tag list for the run */
    tags?: string[];
}
/** Shim for LangChain chain run end event. */
export interface LCChainEndEvent {
    runId: string;
    outputs: Record<string, unknown>;
    metadata?: Record<string, unknown>;
}
/** Shim for LangChain tool run start event. */
export interface LCToolStartEvent {
    runId: string;
    /** Tool name (e.g. "Bash", "web_search") */
    toolName: string;
    /** Tool input */
    input: string | Record<string, unknown>;
    /** Scratchpad from the agent so far */
    scratchpad?: string;
    metadata?: Record<string, unknown>;
}
/** Shim for LangChain tool run end event. */
export interface LCToolEndEvent {
    runId: string;
    toolName: string;
    output: string | Record<string, unknown>;
    metadata?: Record<string, unknown>;
}
/** Shim for LangChain tool run error event. */
export interface LCToolErrorEvent {
    runId: string;
    toolName: string;
    error: unknown;
}
/**
 * Shimmed LangChain BaseCallbackHandler.
 *
 * Mirrors the stable interface from @langchain/core/callbacks/base:
 *   on_chain_start, on_chain_end, on_tool_start, on_tool_end, on_tool_error
 *
 * Consumers integrate via:
 *   const handler = adapter.toCallbackHandler();
 *   chain.invoke(input, { callbacks: [handler] });
 */
export declare class LangChainCallbackHandler {
    /** The adapter this handler dispatches to */
    private adapter;
    constructor(adapter: LangChainAdapter);
    /** Maps to LangChain's on_chain_start. Governance approval check before chain runs. */
    on_chain_start(event: LCChainStartEvent): Promise<void>;
    /** Maps to LangChain's on_chain_end. Audit hook after chain completes. */
    on_chain_end(event: LCChainEndEvent): Promise<void>;
    /** Maps to LangChain's on_tool_start. Governance check before tool invocation. */
    on_tool_start(event: LCToolStartEvent): Promise<void>;
    /** Maps to LangChain's on_tool_end. Audit hook after tool invocation. */
    on_tool_end(event: LCToolEndEvent): Promise<void>;
    /** Maps to LangChain's on_tool_error. Error translation hook. */
    on_tool_error(event: LCToolErrorEvent): Promise<void>;
}
export interface LangChainAdapterConfig {
    /**
     * Task types allowed when LangChain chains invoke the governance layer.
     * An empty array causes all tasks to be denied (fail closed).
     */
    allowedChainTypes: string[];
    /**
     * Tool names that always require reviewer approval regardless of other rules.
     * Applies to on_tool_start governance checks.
     */
    sensitiveTools: string[];
    /**
     * Maximum number of concurrent chain runs governed by this adapter instance.
     * Excess concurrent runs are denied.
     */
    maxConcurrentRuns?: number;
    /**
     * Maximum number of steps in a governed plan.
     * Plans exceeding this limit are denied. Undefined means no limit.
     */
    maxPlanSteps?: number;
}
export declare class LangChainAdapter extends BaseOrchestratorAdapter {
    readonly adapterId = "langchain";
    readonly orchestratorId = "langchain";
    private langchainConfig;
    /**
     * Reference to the LangGraphAdapter for delegation when a LangGraph-based
     * agent is detected. Injected lazily; consumers can set this explicitly.
     */
    langgraphAdapter?: import('./langgraph').LangGraphAdapter;
    /** Track active run IDs for concurrency enforcement */
    private activeRunIds;
    /** C1 fix: track tool-start auditIds by runId so handleToolEnd can call postActionClassify */
    private _toolAuditIds;
    constructor(config: LangChainAdapterConfig);
    /**
     * Return a LangChainCallbackHandler shimmed to this adapter.
     * The consumer passes the returned handler into the chain's callbacks config.
     */
    toCallbackHandler(): LangChainCallbackHandler;
    /**
     * Governance check on chain start (on_chain_start).
     * If a LangGraph-based agent is detected, delegates to LangGraphAdapter
     * and emits orchestrator:framework-dispatch at the handoff boundary.
     * Does NOT emit a duplicate audit event for the same operation.
     */
    handleChainStart(event: LCChainStartEvent): Promise<TaskDecision>;
    /** Audit hook on chain end (on_chain_end). */
    handleChainEnd(event: LCChainEndEvent): Promise<void>;
    /**
     * Governance check on tool start (on_tool_start).
     * Scratchpad contents from event.scratchpad feed into TaskContext.input.
     * Sensitive tools route to human-reviewer tier.
     */
    handleToolStart(event: LCToolStartEvent): Promise<TaskDecision>;
    /** Audit hook on tool end (on_tool_end).
     *
     * C1 fix: calls postActionClassify() to run G-series classification
     * on the tool output. Previously only emitted a canonical event with
     * no output screening.
     */
    handleToolEnd(event: LCToolEndEvent): Promise<void>;
    /** Error translation on tool error (on_tool_error). */
    handleToolError(event: LCToolErrorEvent): Promise<void>;
    startWorkflow(ctx: WorkflowContext): Promise<WorkflowDecision>;
    stepWorkflow(ctx: WorkflowStepContext): Promise<WorkflowStepDecision>;
    completeWorkflow(ctx: WorkflowContext, result: WorkflowResult): Promise<void>;
    preTask(task: TaskContext): Promise<TaskDecision>;
    postTask(task: TaskContext, result: Record<string, unknown>): Promise<void>;
    prePlan(plan: PlanContext): Promise<PlanDecision>;
    postPlan(plan: PlanContext, result: Record<string, unknown>): Promise<void>;
    preDelegation(d: DelegationContext): Promise<DelegationDecision>;
    postDelegation(d: DelegationContext, result: Record<string, unknown>): Promise<void>;
    invokeRoleEdge(edge: RoleEdgeContext): Promise<RoleEdgeDecision>;
    translateError(raw: unknown): OrchestratorError;
    getOrchestratorCapabilities(): OrchestratorCapabilities;
}
//# sourceMappingURL=langchain.d.ts.map