$\cases{u_{tt}=c^2u_{xx}, \hspace{0.5cm} x>0, \hspace{0.5cm} t>0 \\
u(x,0) = \cos(x) = f(x) \\
\frac{\partial u}{\partial t}(x,0) = 0 = g(x) \\
u(0,t) = e^{-t}}$
The general solution of our PDE is: $$u(x,t) = F(x-ct)+G(x+ct)$$
We know that $$F(x) = \frac{1}{2}f(x)-\frac{1}{2c}\int_0^x g(\bar{x}) d\bar{x} \\ G(x) = \frac{1}{2}f(x)+\frac{1}{2c}\int_0^x g(\bar{x}) d\bar{x}$$
So we have $$F(x) = G(x) = \frac{1}{2}\cos(x) \hspace{2mm}, \hspace{2mm} x<0 $$
Now let us look at the boundary condition: $$u(0,t)= F(-ct)+G(ct)= e^{-t}$$
If $x<-ct$, both the arguments of F and G are negative and we have that $$u(x,t) = F(x-ct) + G(x+ct) = \frac{1}{2}\cos(x-ct)+ \frac{1}{2}\cos(x+ct) = \cos(x)\cos(ct)$$
If $x>-ct$, the argument of G becomes positive (while the argument of F stays negative). From the boundary condition we then find that $$G(ct) = e^{-t}-F(-ct) \hspace{2mm}, \hspace{2mm} t>0$$
If we let $z=ct$ we then obtain $$G(z) = e^{-\frac{z}{c}}-F(-z) \hspace{2mm}, \hspace{2mm} z>0$$
So for $x>-ct$ we find that the solution is
\begin{equation}
\begin{split}
u(x,t) &= F(x-ct)+G(x+ct) \\
&= F(x-ct)+e^{-\frac{x}{c}-t}- F(x+ct)\\
&= \frac{1}{2}\cos(x-ct)+ e^{-\frac{x}{c}-t} + \frac{1}{2}\cos(x-ct) \\
&= \sin(x)\sin(ct)+ e^{-\frac{x}{c}-t}
\end{split}
\end{equation}
In summary we have:
$$u(x,t)=
\cases{\cos(x)\cos(ct) \hspace{2cm}, \hspace{2mm} x+ct< 0\\ \sin(x)\sin(ct)+ e^{-\frac{x}{c}-t} \hspace{4mm},\hspace{2mm} x+ct>0 }$$