import type { AgentTurnParams, AgentTurnResult } from "../agents/unified-runner.js";
import type { SymiConfig } from "../config/config.js";
import { type DispatchMiddleware, type DispatchOutcome, DispatchOutcome as DispatchOutcomeCtor } from "./reply/dispatch-middleware.js";
import { type PayloadDelivery, type PayloadHandler, type PayloadKind, type PayloadMiddleware, PayloadDelivery as PayloadDeliveryCtor } from "./reply/payload-middleware.js";
import type { TurnMiddleware, TurnRunner } from "./reply/turn-middleware.js";
import type { FinalizedMsgContext } from "./templating.js";
/** Surface tag — drives which middlewares are enabled. */
export type TurnSurface = "glass-ui" | "tui" | "channel" | "cli" | "cron";
/**
 * Composition profile for a given surface. Lists the middlewares to
 * enable at each of the three layers. Profiles are STATIC per surface —
 * the same profile shape works for every turn on that surface.
 *
 * Phase 13-15 wires the production callers to construct these profiles.
 */
export interface SurfaceProfile {
    surface: TurnSurface;
    /** Pre-flight middlewares (run before the agent turn starts). */
    dispatchMiddlewares: readonly DispatchMiddleware[];
    /** Turn-level middlewares (wrap the agent runner). */
    turnMiddlewares: readonly TurnMiddleware[];
    /** Per-payload middlewares (wrap each delivery). */
    payloadMiddlewares: readonly PayloadMiddleware[];
    /** Leaf payload handler — terminates the payload stack. */
    payloadHandler: PayloadHandler;
}
/** Inputs for one unified turn. */
export interface UnifiedTurnInput {
    /**
     * Per-message context. Required for surface="channel"; optional for
     * other surfaces (Glass UI / CLI / TUI / cron don't have inbound
     * messages in the channel sense).
     */
    ctx?: FinalizedMsgContext;
    /** Symi config. */
    cfg: SymiConfig;
    /** Agent turn parameters for the inner runner. */
    turnParams: AgentTurnParams;
    /**
     * Override the inner runner (for tests + Phase 13-15 migrations that
     * need to wrap or substitute). Defaults to the production
     * `runAgentTurn` from unified-runner.ts.
     */
    innerRunner?: TurnRunner;
}
/** Capture of one payload that flowed through the chain. */
export interface PayloadDispatchRecord {
    kind: PayloadKind;
    delivery: PayloadDelivery;
}
/** Outcome of a unified turn. */
export interface UnifiedTurnResult {
    /** Pre-flight verdict (proceed / skipped / aborted). */
    outcome: DispatchOutcome;
    /** Turn result — present only when outcome.kind === "proceed". */
    turnResult?: AgentTurnResult;
    /** Per-payload delivery records — captures every emit that flowed. */
    payloadDispatches: PayloadDispatchRecord[];
    /** Counts derived from payloadDispatches (delivered vs dropped). */
    counts: {
        delivered: number;
        dropped: number;
        perKind: Record<PayloadKind, {
            delivered: number;
            dropped: number;
        }>;
    };
}
/**
 * Execute one unified turn. Composes all three middleware layers per
 * the supplied profile and routes the inner runner's emissions through
 * the payload chain.
 *
 * On aborted dispatch outcomes (e.g. fast-abort), the abort payload is
 * delivered as a `final` payload through the same payload chain — so
 * routing/TTS/dispatcher all apply uniformly to abort responses.
 *
 * On skipped outcomes (e.g. duplicate inbound), no payload is delivered
 * and `turnResult` is undefined. Callers should branch on
 * `result.outcome.kind`.
 */
export declare function runUnifiedTurn(input: UnifiedTurnInput, profile: SurfaceProfile): Promise<UnifiedTurnResult>;
export { PayloadDeliveryCtor as PayloadDelivery, DispatchOutcomeCtor as DispatchOutcome };
