/**
 * Shared turn-execution core for the turn pipeline (`runTurnPipeline` -> `executeTurnCore`).
 * Owns the `agent.run()` event loop: side-event forwarding (`forwardTurnSideEvent`), the
 * `turn.start`/`turn.end`/`turn.error` notification skeleton, and content/usage collection.
 * Path-specific behaviour (transcript persistence, usage tracking, literal-response
 * transforms, skill auto-persist) is supplied via optional hooks.
 */
import type { ChatMessage, TokenUsage, ToolDefinition, TurnConfig, TurnEvent } from "../agent/types.js";
import { type TurnEventForwardHost } from "./turn-event-forwarder.js";
export interface TurnCoreRequest {
    turnId: string;
    sessionId: string;
    messages: ChatMessage[];
    tools: ToolDefinition[];
    systemPrompt: string;
    config: TurnConfig;
}
export interface TurnCoreAgent {
    run(request: TurnCoreRequest, signal?: AbortSignal): AsyncIterable<TurnEvent>;
}
export interface TurnCoreHooks {
    /** Invoked for every side event handled by `forwardTurnSideEvent` (e.g. tool-call accounting). */
    onSideEvent?: (event: TurnEvent) => void;
    /** Transform assistant content before it is emitted in `turn.end` (e.g. literal-response requirements). */
    transformContent?: (content: string) => string;
    /** Extra work after `turn.end` is emitted (usage tracking, `turn.usage_update`, transcript persistence). */
    onEnd?: (event: Extract<TurnEvent, {
        type: "end";
    }>, finalContent: string) => void;
    /** Extra work after `turn.error` is emitted (e.g. usage tracking on the error path). */
    onError?: (event: Extract<TurnEvent, {
        type: "error";
    }>) => void;
    /** Handle a `skill_instruction` event (notify + auto-persist). */
    onSkillInstruction?: (event: Extract<TurnEvent, {
        type: "skill_instruction";
    }>) => void;
}
export interface TurnCoreResult {
    content: string;
    usage?: TokenUsage;
    /** Captured mid-turn error event, surfaced in-band by callers (e.g. ACP session/prompt). */
    error?: {
        message: string;
        code?: string;
        recoverable?: boolean;
    };
    /** Resolved model/provider that actually ran the turn (for the caller's turn.end). */
    model?: string;
    provider?: string;
}
/**
 * Drive a single agent turn to completion, emitting the shared notification stream.
 * The caller is responsible for emitting `turn.start` (for the early-lifecycle
 * contract) before invoking this, and for all pre/post-turn pipeline work.
 */
export declare function executeTurnCore(host: TurnEventForwardHost, agent: TurnCoreAgent, request: TurnCoreRequest, signal: AbortSignal, hooks?: TurnCoreHooks): Promise<TurnCoreResult>;
