Skip to main content

plexus_substrate/activations/bash/
types.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use thiserror::Error;
4
5/// Stream events from bash command execution
6#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
7#[serde(tag = "type", rename_all = "snake_case")]
8pub enum BashEvent {
9    /// Standard output line
10    Stdout { line: String },
11    /// Standard error line
12    Stderr { line: String },
13    /// Exit code when process completes
14    Exit { code: i32 },
15    /// Error from the executor itself (not the command)
16    Error { message: String },
17}
18
19// Keep the old name as an alias for backwards compatibility
20pub type BashOutput = BashEvent;
21
22/// Typed errors from the bash executor
23#[derive(Debug, Error)]
24pub enum ExecutorError {
25    #[error("failed to spawn bash (command='{command}'): {source}")]
26    SpawnFailed {
27        command: String,
28        source: std::io::Error,
29    },
30
31    #[error("failed to capture {stream} from bash process (command='{command}')")]
32    StdioCaptureFailed {
33        stream: &'static str,
34        command: String,
35    },
36
37    #[error("failed to wait for bash process (command='{command}'): {source}")]
38    WaitFailed {
39        command: String,
40        source: std::io::Error,
41    },
42}