Add option to run extensions in a container (#6590)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ use futures::stream::BoxStream;
|
||||
use futures::{stream, FutureExt, Stream, StreamExt, TryStreamExt};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::container::Container;
|
||||
use super::final_output_tool::FinalOutputTool;
|
||||
use super::platform_tools;
|
||||
use super::tool_execution::{ToolCallResult, CHAT_MODE_TOOL_SKIPPED_RESPONSE, DECLINED_RESPONSE};
|
||||
@@ -128,6 +129,7 @@ pub struct Agent {
|
||||
|
||||
pub(super) retry_manager: RetryManager,
|
||||
pub(super) tool_inspection_manager: ToolInspectionManager,
|
||||
container: Mutex<Option<Container>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -212,6 +214,7 @@ impl Agent {
|
||||
tool_result_rx: Arc::new(Mutex::new(tool_rx)),
|
||||
retry_manager: RetryManager::new(),
|
||||
tool_inspection_manager: Self::create_tool_inspection_manager(permission_manager),
|
||||
container: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +412,15 @@ impl Agent {
|
||||
}
|
||||
}
|
||||
|
||||
/// When set, all stdio extensions will be started via `docker exec` in the specified container.
|
||||
pub async fn set_container(&self, container: Option<Container>) {
|
||||
*self.container.lock().await = container.clone();
|
||||
}
|
||||
|
||||
pub async fn container(&self) -> Option<Container> {
|
||||
self.container.lock().await.clone()
|
||||
}
|
||||
|
||||
/// Check if a tool is a frontend tool
|
||||
pub async fn is_frontend_tool(&self, name: &str) -> bool {
|
||||
self.frontend_tools.lock().await.contains_key(name)
|
||||
@@ -740,8 +752,13 @@ impl Agent {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let container = self.container.lock().await;
|
||||
self.extension_manager
|
||||
.add_extension_with_working_dir(extension.clone(), working_dir)
|
||||
.add_extension_with_working_dir(
|
||||
extension.clone(),
|
||||
working_dir,
|
||||
container.as_ref(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user