//! Streaming-output consumer hook. use serde_json::Value; /// Consumer callbacks for a claude run's output streams. Every method has a /// no-op default, so an implementor overrides only what it needs. /// /// Methods are called synchronously from the stdout/stderr readers as lines /// arrive, so keep them cheap — the idiomatic body forwards to a channel or an /// event bus rather than blocking. The driver handles sentinel classification /// (rate-limit, prompt-too-long, …) itself; a sink only *observes* the stream. pub trait Sink { /// A parsed `stream-json` object from stdout (assistant/result/system/… /// event). The driver has already classified it for sentinels. fn on_event(&self, _event: &Value) {} /// A stdout line that was not valid JSON — occasional Claude Code CLI /// chatter rather than conversation content. fn on_stdout_line(&self, _line: &str) {} /// A stderr line, delivered verbatim. The last several are also retained /// by the driver for [`crate::Error::Exit`]. fn on_stderr_line(&self, _line: &str) {} } /// A [`Sink`] that discards everything. Useful for fire-and-forget runs where /// only the [`crate::Outcome`] matters. pub struct NoopSink; impl Sink for NoopSink {}