async fn drain_and_collect(
stdout: ChildStdout,
tx: &UnboundedSender<AgentEvent>,
child: &mut Child,
) -> Result<AgentRunResult, String>Expand description
Drain stdout line-by-line through ClaudeTranslator, forward
every emitted event on tx, accumulate the terminal Cost /
Done event payloads into an AgentRunResult, wait for the
child to exit, and return the result.
Split out from run_agent so it can be unit-tested against
in-memory readers without spawning a real subprocess. Used by
the integration test below as drain_async_reader_for_test.