/**
 * Shared run-cancellation path.
 *
 * `cancelRunWithReason` is the single canonical implementation of "cancel
 * this whole run, recording a reason". It is invoked by:
 *
 *  - the operator-facing `POST /api/v1/admin/runs/:runId/cancel` route
 *    (user-initiated `kici cancel`), and
 *  - the WorkflowDeadlineDetector, which cancels runs that exceeded their
 *    workflow-level wall-clock timeout (TimeoutReason.workflow_timeout).
 *
 * Keeping one implementation means the deadline enforcer and the user cancel
 * follow identical mechanics: send `job.cancel` to the agents running the
 * run's jobs, cancel queued dispatch rows, mark pending/queued jobs cancelled,
 * stamp the failure reason, and drive the run terminal when no agent work is
 * outstanding.
 */
import type { Kysely } from 'kysely';
import type { Database } from '../db/types.js';
import type { JobQueue } from '../queue/job-queue.js';
import type { Dispatcher } from '../agent/dispatcher.js';
import type { AgentRegistry } from '../agent/registry.js';
import type { ExecutionTracker } from '../reporting/execution-tracker.js';
export interface CancelRunDeps {
    db: Kysely<Database>;
    jobQueue: JobQueue;
    dispatcher: Dispatcher;
    registry: AgentRegistry;
    executionTracker: ExecutionTracker;
}
export interface CancelRunOptions {
    /** Force immediate SIGKILL on the agent (skip graceful hooks). */
    force?: boolean;
    /** Attribution stamped into execution_runs.cancelled_by. */
    cancelledBy?: string;
}
export interface CancelRunResult {
    /** Number of `job.cancel` messages dispatched to agents (running jobs). */
    agentsNotified: number;
    /** Number of pending/queued execution_jobs rows marked cancelled. */
    pendingCancelled: number;
}
/**
 * Cancel a whole run, recording `reason` on its cancelled jobs and (if not
 * already set) on the run's failure_reason. Sends `job.cancel` to every agent
 * holding a dispatched job for the run; cancels queued dispatch rows; marks
 * pending/queued jobs cancelled. When no agent had outstanding work, drives
 * the run to its terminal status immediately so the run does not linger in
 * `cancelling`.
 *
 * Idempotent against terminal runs: callers should pre-check terminal state
 * (the cancel route returns 409); the underlying UPDATEs are status-guarded so
 * a double-call is harmless.
 */
export declare function cancelRunWithReason(deps: CancelRunDeps, runId: string, reason: string, options?: CancelRunOptions): Promise<CancelRunResult>;
//# sourceMappingURL=cancel-run.d.ts.map