steer_tools/tools/
bash.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use thiserror::Error;
4
5use crate::ToolSpec;
6use crate::error::ToolExecutionError;
7use crate::result::BashResult;
8
9pub const BASH_TOOL_NAME: &str = "bash";
10
11pub struct BashToolSpec;
12
13impl ToolSpec for BashToolSpec {
14 type Params = BashParams;
15 type Result = BashResult;
16 type Error = BashError;
17
18 const NAME: &'static str = BASH_TOOL_NAME;
19 const DISPLAY_NAME: &'static str = "Bash";
20
21 fn execution_error(error: Self::Error) -> ToolExecutionError {
22 ToolExecutionError::Bash(error)
23 }
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Error)]
27#[serde(tag = "code", rename_all = "snake_case")]
28pub enum BashError {
29 #[error("command is disallowed: {command}")]
30 DisallowedCommand { command: String },
31
32 #[error("io error: {message}")]
33 Io { message: String },
34
35 #[error("{message}")]
36 Other { message: String },
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
40pub struct BashParams {
41 pub command: String,
43 #[schemars(range(min = 1, max = 3_600_000))]
45 pub timeout: Option<u64>,
46}