import type { WorkflowExecution } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
import type { ApprovalAction, FileDecisionAction } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
import { type FileDecisionOptions } from "../execution/useFileReview.js";
/** Options for {@link useWorkflowExecutionActions}. */
export interface UseWorkflowExecutionActionsOptions {
    /**
     * Called after any lifecycle action (cancel, terminate, pause, resume,
     * recover) succeeds. Receives the updated execution returned by the
     * server. Useful for triggering a refetch of execution data so the UI
     * reflects the new phase.
     *
     * Not called for approval submissions — those are background operations
     * whose effects arrive via the event stream.
     */
    readonly onSuccess?: (execution: WorkflowExecution) => void;
}
/** Return value of {@link useWorkflowExecutionActions}. */
export interface UseWorkflowExecutionActionsReturn {
    /** Cancel a running execution gracefully. */
    readonly cancel: (reason?: string) => Promise<WorkflowExecution | null>;
    /** Terminate a running execution immediately. */
    readonly terminate: (reason?: string) => Promise<WorkflowExecution | null>;
    /** Pause a running execution. */
    readonly pause: (reason?: string) => Promise<WorkflowExecution | null>;
    /** Resume a paused execution. */
    readonly resume: () => Promise<WorkflowExecution | null>;
    /**
     * Recover a failed execution with task-level resume.
     *
     * Terminates stale workflows, re-resolves environment variables (picks up
     * any config fixes), and starts a fresh run in recovery mode. Completed
     * tasks are skipped — their outputs are restored from the event log —
     * and execution resumes from the first incomplete or failed task.
     *
     * @param reason - Optional audit trail message explaining why recovery
     *   was triggered (e.g., "Rotated API key").
     */
    readonly recover: (reason?: string) => Promise<WorkflowExecution | null>;
    /** Submit an approval decision for a child agent's tool execution. */
    readonly submitApproval: (toolCallId: string, action: ApprovalAction, comment?: string) => Promise<WorkflowExecution | null>;
    /**
     * Submit a reviewer's decision for a workflow-level human_input task.
     *
     * Unlike `submitApproval` (which forwards agent tool approvals),
     * this sends a Temporal signal to the workflow runner's human_input
     * orchestrator, unblocking the task with the selected outcome.
     */
    readonly submitTaskApproval: (taskName: string, outcome: string, formData?: Record<string, unknown>, comment?: string) => Promise<WorkflowExecution | null>;
    /**
     * Submit a keep/discard decision for a child agent's file review, surfaced on
     * this workflow via `status.pending_file_reviews`. The file-review sibling of
     * {@link submitApproval}: the server forwards it to the child's
     * `AgentExecution.submitFileDecision`.
     *
     * `childAgentExecutionId` comes from the surfaced
     * `WorkflowPendingFileReview` reference. `options` carries the same
     * per-decision detail as {@link FileReviewCard}'s `onSubmit` (scope,
     * `fileChangeId`, `expectedDigest`, `reason`, `acknowledgeUnreviewable`).
     */
    readonly submitFileDecision: (childAgentExecutionId: string, changeSetId: string, action: FileDecisionAction, options?: FileDecisionOptions) => Promise<WorkflowExecution | null>;
    /**
     * `true` while a **lifecycle** action (cancel/terminate/pause/resume/recover)
     * is in flight. Approvals are excluded — they are per-gate, so read their
     * in-flight state from {@link approvalSubmittingToolCallIds} /
     * {@link taskApprovalSubmittingTaskNames} instead.
     */
    readonly isSubmitting: boolean;
    /**
     * Error from the last failed **lifecycle** action, or `null`. Approval
     * failures are per-gate and live in {@link approvalErrorsByToolCallId} /
     * {@link taskApprovalErrorsByTaskName} so each surfaces beside the gate that
     * failed — never in this shared scalar (which backs the header banner).
     */
    readonly error: Error | null;
    /** Reset the lifecycle {@link error} to `null`. */
    readonly clearError: () => void;
    /**
     * Tool-call ids whose agent-tool approval is currently being submitted, keyed
     * exactly like {@link approvalErrorsByToolCallId}. A workflow can hold many
     * concurrent gates, so deciding one must not spin or disable the others.
     */
    readonly approvalSubmittingToolCallIds: ReadonlySet<string>;
    /**
     * Per-gate agent-tool approval failures, keyed by `toolCallId`. Consumed by
     * {@link WorkflowExecutionApprovalCard} to surface the failure in-card,
     * beside the gate that failed. Cleared for a gate when it is retried.
     */
    readonly approvalErrorsByToolCallId: ReadonlyMap<string, Error>;
    /**
     * Task names whose human_input task approval is currently being submitted,
     * keyed exactly like {@link taskApprovalErrorsByTaskName}.
     */
    readonly taskApprovalSubmittingTaskNames: ReadonlySet<string>;
    /**
     * Per-gate human_input task approval failures, keyed by `taskName`. Consumed
     * by `WorkflowTaskApprovalCard` to surface the failure in-card, beside
     * the gate that failed. Cleared for a gate when it is retried.
     */
    readonly taskApprovalErrorsByTaskName: ReadonlyMap<string, Error>;
    /**
     * Decision keys currently being submitted for file reviews, keyed exactly like
     * {@link FileReviewCard}'s `submittingDecisionKeys` (via {@link fileDecisionKey}
     * — the change set id for a whole-set decision, `changeSetId:fileChangeId` for a
     * per-file one). Pass straight through to each surfaced card.
     */
    readonly fileDecisionSubmittingKeys: ReadonlySet<string>;
    /**
     * Per-decision file-review failures, keyed like {@link fileDecisionSubmittingKeys}.
     * Pass straight through to {@link FileReviewCard}'s `decisionErrors`.
     */
    readonly fileDecisionErrorsByKey: ReadonlyMap<string, Error>;
}
/**
 * Behavior hook that encapsulates workflow execution lifecycle actions.
 *
 * Each action calls the corresponding RPC and returns the updated
 * execution, or `null` on failure (with `error` populated).
 *
 * Pass `null` for `executionId` to disable all actions (they become
 * no-ops that return `null`).
 *
 * @example
 * ```tsx
 * const actions = useWorkflowExecutionActions(executionId, {
 *   onSuccess: () => refetchExecution(),
 * });
 *
 * <button onClick={() => actions.cancel("No longer needed")} disabled={actions.isSubmitting}>
 *   Cancel
 * </button>
 * ```
 */
export declare function useWorkflowExecutionActions(executionId: string | null, options?: UseWorkflowExecutionActionsOptions): UseWorkflowExecutionActionsReturn;
//# sourceMappingURL=useWorkflowExecutionActions.d.ts.map