claude_agent/tools/
env.rs

1//! Tool execution environment.
2
3use std::sync::Arc;
4
5use super::ProcessManager;
6use super::context::ExecutionContext;
7use crate::session::session_state::ToolState;
8
9/// Execution environment for tools including security context and shared state.
10#[derive(Clone)]
11pub struct ToolExecutionEnv {
12    pub context: ExecutionContext,
13    pub tool_state: Option<ToolState>,
14    pub process_manager: Option<Arc<ProcessManager>>,
15}
16
17impl ToolExecutionEnv {
18    pub fn new(context: ExecutionContext) -> Self {
19        Self {
20            context,
21            tool_state: None,
22            process_manager: None,
23        }
24    }
25
26    pub fn with_tool_state(mut self, state: ToolState) -> Self {
27        self.tool_state = Some(state);
28        self
29    }
30
31    pub fn with_process_manager(mut self, pm: Arc<ProcessManager>) -> Self {
32        self.process_manager = Some(pm);
33        self
34    }
35}
36
37impl Default for ToolExecutionEnv {
38    fn default() -> Self {
39        Self::new(ExecutionContext::default())
40    }
41}