import type { AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
/**
 * Lifecycle phases for the workflow execution diagnosis flow.
 *
 * - `idle` — mounted, waiting for auto-start or manual trigger
 * - `starting` — creating session + execution
 * - `streaming` — agent is analyzing (tool calls, reasoning visible)
 * - `complete` — agent finished, YAML fix extracted (diff available)
 * - `ready` — agent finished without YAML (runtime error explanation),
 *   or user accepted/discarded a fix; follow-up available
 * - `error` — a failure occurred (RPC, stream)
 */
export type DiagnosePhase = "idle" | "starting" | "streaming" | "complete" | "ready" | "error";
/** Options for {@link useDiagnoseExecutionFlow}. */
export interface UseDiagnoseExecutionFlowOptions {
    /** ID of the failed workflow execution to diagnose. */
    readonly executionId: string;
    /** Organization slug for session and execution creation. */
    readonly org: string;
    /** Current workflow YAML for diff computation (optional). */
    readonly currentWorkflowYaml?: string;
    /**
     * Whether to start diagnosis automatically on mount.
     * @default true
     */
    readonly autoStart?: boolean;
    /** Called when any step fails. Also available via the `error` return. */
    readonly onError?: (message: string) => void;
}
/** Return value of {@link useDiagnoseExecutionFlow}. */
export interface UseDiagnoseExecutionFlowReturn {
    /** Current lifecycle phase. */
    readonly phase: DiagnosePhase;
    /** Completed execution snapshots for MessageThread (chronological). */
    readonly completedExecutions: readonly AgentExecution[];
    /** Currently streaming execution, or null when idle/between turns. */
    readonly activeExecution: AgentExecution | null;
    /** `true` while the agent execution is actively streaming. */
    readonly isStreaming: boolean;
    /** Extracted YAML fix from the latest turn (null unless phase is `complete`). */
    readonly extractedYaml: string | null;
    /** Agent's explanation prose from the latest turn. */
    readonly explanation: string | null;
    /** Human-readable error message, or `null` when healthy. */
    readonly error: string | null;
    /** Start or restart the diagnosis. Callable from `idle` or `error` phases. */
    readonly diagnose: () => Promise<void>;
    /** Send a follow-up question within the same session. */
    readonly sendFollowUp: (message: string) => Promise<void>;
    /** Accept the extracted YAML fix. Returns the YAML string. Transitions to `ready`. */
    readonly acceptFix: () => string | null;
    /** Discard the extracted YAML without applying. Transitions to `ready`. */
    readonly discardFix: () => void;
    /** Reset all state to initial values. Does not delete the server-side session. */
    readonly reset: () => void;
}
/**
 * Behavior hook that orchestrates agent-powered workflow execution
 * diagnosis using the built-in Workflow Architect system agent.
 *
 * Manages a multi-turn conversation within a single Session:
 * - First turn creates a Session + AgentExecution with diagnosis context
 * - Subsequent turns reuse the Session (conversational context)
 * - Each turn streams agent messages via {@link useExecutionStream}
 * - YAML is extracted from agent responses via {@link extractWorkflowYaml}
 *   — presence of YAML indicates a definition fix; absence indicates a
 *   runtime error with explanation only
 *
 * Auto-starts diagnosis on mount by default (AD-B5-002). The agent uses
 * `get_workflow_execution` and `get_workflow_execution_events` MCP tools
 * to inspect the failure autonomously.
 *
 * Framework-agnostic (DD-004), referentially stable returns (DD-010).
 *
 * @example
 * ```tsx
 * const flow = useDiagnoseExecutionFlow({
 *   executionId: "wex_abc123",
 *   org: "acme",
 *   onError: (msg) => toast.error(msg),
 * });
 *
 * <WorkflowRepairCard flow={flow} onApplyFix={...} onClose={...} />
 * ```
 */
export declare function useDiagnoseExecutionFlow(options: UseDiagnoseExecutionFlowOptions): UseDiagnoseExecutionFlowReturn;
//# sourceMappingURL=useDiagnoseExecutionFlow.d.ts.map