Skip to main content

zag_agent/
progress.rs

1/// Progress and status reporting trait for agent operations.
2///
3/// Library consumers implement this to receive status updates during
4/// agent execution. The CLI binary implements this with terminal spinners
5/// and colored output; programmatic users can use `SilentProgress` or
6/// implement custom reporting.
7pub trait ProgressHandler: Send + Sync {
8    /// A status message about an ongoing operation.
9    fn on_status(&self, _message: &str) {}
10
11    /// An operation completed successfully.
12    fn on_success(&self, _message: &str) {}
13
14    /// A non-fatal warning.
15    fn on_warning(&self, _message: &str) {}
16
17    /// An error occurred.
18    fn on_error(&self, _message: &str) {}
19
20    /// A long-running operation started (e.g., spinner).
21    fn on_spinner_start(&self, _message: &str) {}
22
23    /// The current spinner/long-running operation finished.
24    fn on_spinner_finish(&self) {}
25
26    /// A debug-level message.
27    fn on_debug(&self, _message: &str) {}
28}
29
30/// No-op progress handler for library users who don't need status output.
31pub struct SilentProgress;
32
33impl ProgressHandler for SilentProgress {}
34
35#[cfg(test)]
36#[path = "progress_tests.rs"]
37mod tests;