from typing import Callable

def emit_step(msg: str, on_stdout: Callable[[str], None] | None, passthrough: bool) -> None:
    """Emit a `Step: …` line to both channels independently when both are set."""
    formatted = f"Step: {msg}"
    if on_stdout is not None:
        on_stdout(formatted)
    if passthrough:
        print(formatted, flush=True)
