/**
 * LangGraphAdapter -- Orchestrator adapter for the LangGraph framework.
 *
 * Hook surface: LangGraph's interrupt_before / interrupt_after on node
 * entry/exit. The adapter exposes a factory that produces a CheckpointSaver
 * subclass the customer plugs into their StateGraph:
 *
 *   const adapter = new LangGraphAdapter(config);
 *   adapter.initialize(orchConfig);
 *   const graph = workflow.compile({ checkpointer: adapter.toCheckpointSaver() });
 *
 * Edge traversal audit: each edge traversal emits orchestrator:role-edge-invoked
 * at DEBUG severity. Conditional edges include the branching decision in the
 * context payload.
 *
 * Command primitive support: LangGraph's Command (used for supervisor->worker
 * routing) maps onto the DelegationDecision contract. A DelegationDecision is
 * produced per Command invocation.
 *
 * No real @langchain/langgraph or @langchain/langgraph-checkpoint package is
 * installed. This adapter shims the CheckpointSaver abstract shape and can
 * be exercised fully in tests without the live SDK.
 *
 * Spec: P3-ORCH-01, Section 2.5, AC 10-11
 * @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';
/** State snapshot stored in the checkpoint. */
export interface LGCheckpointSnapshot {
    /** Unique checkpoint ID */
    checkpointId: string;
    /** The node that produced this checkpoint */
    nodeId: string;
    /** Full graph state at this checkpoint */
    state: Record<string, unknown>;
    /** ISO-8601 timestamp */
    timestamp: string;
    /** Thread ID (LangGraph conversation thread) */
    threadId?: string;
    /** Metadata from the graph run */
    metadata?: Record<string, unknown>;
}
/** LangGraph node entry event (interrupt_before hook). */
export interface LGNodeEntryEvent {
    /** Run ID from the graph execution */
    runId: string;
    /** Thread ID (LangGraph conversation thread) */
    threadId: string;
    /** Node identifier in the StateGraph */
    nodeId: string;
    /** Role label of this node (used for governance policy dispatch) */
    role: string;
    /** State passed into this node */
    inputState: Record<string, unknown>;
    /** Metadata from the graph run */
    metadata?: Record<string, unknown>;
}
/** LangGraph node exit event (interrupt_after hook). */
export interface LGNodeExitEvent {
    runId: string;
    threadId: string;
    nodeId: string;
    role: string;
    /** State produced by this node */
    outputState: Record<string, unknown>;
    /** Whether this is a terminal node */
    isFinal?: boolean;
    metadata?: Record<string, unknown>;
}
/** LangGraph edge traversal event. */
export interface LGEdgeEvent {
    runId: string;
    threadId: string;
    /** Source node */
    fromNodeId: string;
    /** Destination node */
    toNodeId: string;
    /** Source role */
    fromRole: string;
    /** Destination role */
    toRole: string;
    /** Whether this edge is a conditional edge */
    isConditional: boolean;
    /** Branching decision context (for conditional edges) */
    branchDecision?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
}
/**
 * LangGraph Command primitive -- used for supervisor->worker routing.
 * Mirrors the Command dataclass from langgraph.types.
 */
export interface LGCommand {
    /** Target node to route to */
    goto: string;
    /** Role of the target node */
    targetRole: string;
    /** Update to apply to graph state before routing */
    update?: Record<string, unknown>;
    /** Source node issuing the command */
    sourceNodeId: string;
    /** Source role */
    sourceRole: string;
    /** Run metadata */
    metadata?: Record<string, unknown>;
}
/**
 * Shimmed LangGraph CheckpointSaver.
 *
 * Mirrors the abstract CheckpointSaver from
 * @langchain/langgraph-checkpoint as of 2024-2026.
 *
 * Consumers integrate via:
 *   const saver = adapter.toCheckpointSaver();
 *   const graph = workflow.compile({ checkpointer: saver });
 *
 * The saver intercepts put() calls at policy boundaries (interrupt_before /
 * interrupt_after transitions) and dispatches governance checks to the adapter.
 */
export declare class LangGraphCheckpointSaver {
    private adapter;
    /** In-memory snapshot store (keyed by checkpointId). Production consumers
     *  replace this with a persistent store via subclassing. */
    private snapshots;
    constructor(adapter: LangGraphAdapter);
    /**
     * Called by the LangGraph runtime before node execution (interrupt_before).
     * Governance check; throws if denied.
     */
    beforeNode(event: LGNodeEntryEvent): Promise<TaskDecision>;
    /**
     * Called by the LangGraph runtime after node execution (interrupt_after).
     * Audit hook; persists snapshot.
     */
    afterNode(event: LGNodeExitEvent): Promise<void>;
    /**
     * Called when the LangGraph runtime traverses an edge.
     * Emits orchestrator:role-edge-invoked DEBUG event.
     */
    onEdge(event: LGEdgeEvent): Promise<RoleEdgeDecision>;
    /**
     * Called when the supervisor issues a Command.
     * Maps onto DelegationDecision contract.
     */
    onCommand(command: LGCommand): Promise<DelegationDecision>;
    /**
     * Persist a checkpoint snapshot (shimmed put() method).
     * In production this writes to a durable store.
     */
    put(snapshot: LGCheckpointSnapshot): Promise<void>;
    /**
     * Retrieve a snapshot by checkpoint ID (shimmed get() method).
     */
    get(checkpointId: string): Promise<LGCheckpointSnapshot | undefined>;
    /**
     * List all stored checkpoints (shimmed list() method).
     */
    list(): Promise<LGCheckpointSnapshot[]>;
}
export interface LangGraphAdapterConfig {
    /**
     * Node role IDs that are permitted to execute.
     * An empty array causes all node entries to be denied (fail closed).
     */
    allowedRoles: string[];
    /**
     * Commands (goto targets) that are treated as sensitive delegations
     * and require reviewer approval.
     */
    sensitiveCommandTargets: string[];
    /**
     * Whether to emit a checkpoint snapshot event on every interrupt_after.
     * Defaults to true.
     */
    checkpointOnExit?: boolean;
    /**
     * Maximum number of steps in a governed plan.
     * Plans exceeding this limit are denied. Undefined means no limit.
     */
    maxPlanSteps?: number;
}
export declare class LangGraphAdapter extends BaseOrchestratorAdapter {
    readonly adapterId = "langgraph";
    readonly orchestratorId = "langgraph";
    private langgraphConfig;
    constructor(config: LangGraphAdapterConfig);
    /**
     * Return a LangGraphCheckpointSaver wired to this adapter.
     * Consumers plug the returned saver into StateGraph.compile().
     */
    toCheckpointSaver(): LangGraphCheckpointSaver;
    /**
     * Governance check on node entry (interrupt_before).
     * Dispatches per-role policy check for the node's role.
     * Throws RoleNotRegisteredError if the role is not in the registry.
     */
    handleNodeEntry(event: LGNodeEntryEvent): Promise<TaskDecision>;
    /**
     * Audit hook on node exit (interrupt_after).
     * Emits orchestrator:plan-step-end. Optionally emits checkpoint event.
     */
    handleNodeExit(event: LGNodeExitEvent): Promise<void>;
    /**
     * Edge traversal audit.
     * Emits orchestrator:role-edge-invoked DEBUG with branching decision
     * context for conditional edges.
     */
    handleEdgeTraversal(event: LGEdgeEvent): Promise<RoleEdgeDecision>;
    /**
     * Command (supervisor->worker delegation) governance.
     * Maps LangGraph Command primitive onto DelegationDecision contract.
     * Sensitive command targets require reviewer approval.
     */
    handleCommand(command: LGCommand): Promise<DelegationDecision>;
    /**
     * Checkpoint persistence hook.
     * Emits a plan-step-begin event to record the policy boundary snapshot.
     */
    handleCheckpointPut(snapshot: LGCheckpointSnapshot): 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=langgraph.d.ts.map