export declare const ENSURE_ROLE_EXISTS = "INSERT INTO lt_roles (role) VALUES ($1) ON CONFLICT DO NOTHING";
export declare const CREATE_ESCALATION = "INSERT INTO lt_escalations\n  (type, subtype, description, priority, task_id,\n   origin_id, parent_id, role, envelope, metadata, escalation_payload,\n   workflow_id, task_queue, workflow_type, trace_id, span_id)\nVALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)\nRETURNING *";
export declare const CLAIM_ESCALATION = "WITH prev AS (\n  SELECT assigned_to, assigned_until\n  FROM lt_escalations\n  WHERE id = $1\n),\nupdated AS (\n  UPDATE lt_escalations\n  SET assigned_to = $2,\n      claimed_at = NOW(),\n      assigned_until = NOW() + INTERVAL '1 minute' * $3\n  WHERE id = $1\n    AND status = 'pending'\n    AND (\n      assigned_to IS NULL\n      OR assigned_until <= NOW()\n      OR assigned_to = $2\n    )\n  RETURNING *\n)\nSELECT updated.*,\n       prev.assigned_to AS prev_assigned_to\nFROM updated\nCROSS JOIN prev";
export declare const RESOLVE_ESCALATION = "UPDATE lt_escalations\nSET status = 'resolved',\n    resolved_at = NOW(),\n    resolver_payload = $2\nWHERE id = $1\n  AND status = 'pending'\nRETURNING *";
export declare const UPDATE_ESCALATIONS_PRIORITY = "UPDATE lt_escalations\nSET priority = $1, updated_at = NOW()\nWHERE id = ANY($2::uuid[])\n  AND status = 'pending'";
export declare const GET_ESCALATION_ROLES = "SELECT DISTINCT role FROM lt_escalations WHERE id = ANY($1::uuid[])";
export declare const RELEASE_ESCALATION = "UPDATE lt_escalations\nSET assigned_to = NULL,\n    assigned_until = NULL,\n    claimed_at = NULL\nWHERE id = $1\n  AND status = 'pending'\n  AND assigned_to = $2\nRETURNING *";
export declare const RELEASE_EXPIRED_CLAIMS = "UPDATE lt_escalations\nSET assigned_to = NULL,\n    assigned_until = NULL,\n    claimed_at = NULL\nWHERE status = 'pending'\n  AND assigned_to IS NOT NULL\n  AND assigned_until < NOW()";
export declare const ESCALATE_TO_ROLE = "UPDATE lt_escalations\nSET role = $2,\n    assigned_to = NULL,\n    assigned_until = NULL,\n    claimed_at = NULL,\n    updated_at = NOW()\nWHERE id = $1\n  AND status = 'pending'\nRETURNING *";
export declare const GET_ESCALATION = "SELECT * FROM lt_escalations WHERE id = $1";
export declare const GET_ESCALATIONS_BY_TASK_ID = "SELECT * FROM lt_escalations WHERE task_id = $1 ORDER BY created_at DESC";
export declare const GET_ESCALATIONS_BY_WORKFLOW_ID = "SELECT * FROM lt_escalations WHERE workflow_id = $1 ORDER BY created_at DESC";
export declare const GET_ESCALATIONS_BY_ORIGIN_ID = "SELECT * FROM lt_escalations WHERE origin_id = $1 ORDER BY created_at DESC";
/** Used by both bulkClaimEscalations and bulkAssignEscalations (identical SQL). */
export declare const BULK_CLAIM = "UPDATE lt_escalations\nSET assigned_to = $1,\n    claimed_at = NOW(),\n    assigned_until = NOW() + INTERVAL '1 minute' * $2\nWHERE id = ANY($3::uuid[])\n  AND status = 'pending'\n  AND (\n    assigned_to IS NULL\n    OR assigned_until <= NOW()\n    OR assigned_to = $1\n  )";
export declare const BULK_ASSIGN = "UPDATE lt_escalations\nSET assigned_to = $1,\n    claimed_at = NOW(),\n    assigned_until = NOW() + INTERVAL '1 minute' * $2\nWHERE id = ANY($3::uuid[])\n  AND status = 'pending'\n  AND (\n    assigned_to IS NULL\n    OR assigned_until <= NOW()\n    OR assigned_to = $1\n  )";
export declare const BULK_ESCALATE_TO_ROLE = "UPDATE lt_escalations\nSET role = $1,\n    assigned_to = NULL,\n    assigned_until = NULL,\n    claimed_at = NULL,\n    updated_at = NOW()\nWHERE id = ANY($2::uuid[])\n  AND status = 'pending'";
export declare const BULK_RESOLVE_FOR_TRIAGE = "UPDATE lt_escalations\nSET status = 'resolved',\n    resolved_at = NOW(),\n    resolver_payload = $1\nWHERE id = ANY($2::uuid[])\n  AND status = 'pending'\nRETURNING *";
export declare const UPDATE_ESCALATION_METADATA = "UPDATE lt_escalations\nSET metadata = COALESCE(metadata, '{}'::jsonb) || $2::jsonb,\n    updated_at = NOW()\nWHERE id = $1\nRETURNING *";
export declare const ENRICH_ESCALATION_ROUTING = "UPDATE lt_escalations\nSET metadata = COALESCE(metadata, '{}'::jsonb) || $2::jsonb,\n    workflow_type = COALESCE(workflow_type, $3),\n    workflow_id = COALESCE(workflow_id, $4),\n    task_queue = COALESCE(task_queue, $5),\n    task_id = COALESCE(task_id, $6),\n    updated_at = NOW()\nWHERE id = $1\nRETURNING *";
export declare const LIST_DISTINCT_TYPES = "SELECT DISTINCT type FROM lt_escalations ORDER BY type";
