Consider a principal-agent problem where effort is observable. Let $\pi$ denote profit, let $w$ denote the wage to be paid to the agent, and let $f(\pi|e)$ denote the pdf of the profit, conditional on effort $e$. Further, $e \in \{e_L,e_H\}$. The problem for the principal is then as follows: For each level of effort, $e$: $$ \min_w\int w(\pi) f(\pi|e)\, d\pi$$ subject to $$\int v(w(\pi)) f(\pi|e)\,d\pi - g(e) \ge \overline u$$ (Here, $v$ is the utility function for the agent, $g$ is the cost function of effort and $\overline u$ is the outside option for the agent). Then, choose $e$ that gives maximum profit given the wage $w$, which has now been solved for at each effort level.
I'm not sure how to take the first order conditions in the minimisation problem above. If $w$ were the argument for the integral, it'd be manageable.