The invariant projection on endomorphisms is normalized trace
Fix the source's global arithmetic datum $D$ as described below. Assume complete reducibility for every finite-dimensional representation over a characteristic-zero field given by operators $E_{ab}$ satisfying the $\mathfrak{gl}_n$ commutator relations and decomposing into simultaneous integral weight spaces for the $E_{aa}$.
Let $K$ have characteristic zero, $L$ be finite-dimensional over $K$, and $(E_{ab})_{1\le a,b\le n}$ be such a representation. Let $v_0\ne0$ be a highest-weight vector of weight $\lambda\in\mathbb Z^n$: $$E_{aa}v_0=\lambda_av_0,\qquad E_{ab}v_0=0\quad(a<b).$$ Suppose the vectors obtained by applying all words in the $E_{ab}$ to $v_0$ span $L$. On $\operatorname{End}_K(L)$ use the action $T\mapsto E_{ab}T-TE_{ab}$. Let $P$ be a $K$-linear map on this endomorphism space that is the identity on the subspace generated by highest-weight vectors of weight zero and their translates, and zero on every such subspace of nonzero highest weight. Then for every $T\in\operatorname{End}_K(L)$, $$ (\dim_KL)P(T)=\operatorname{tr}(T)\operatorname{id}_L.$$
The datum $D$ is the source's full arithmetic package: number fields $E/F$ and a totally complex Galois coefficient field, with specified conjugations and compatible complex embeddings; rank and signature parameters and Hermitian spaces with positive volume factors; integral lattices, levels, determinant characters, automorphic spaces and their period maps; and local Galois, period and theta-jet data with the prescribed comparison identities.
Translates here mean the results of applying finite words in the indicated Lie operators. The commutator relation is $[E_{ab},E_{cd}]=\delta_{bc}E_{ad}-\delta_{da}E_{cb}$.