Add option to run extensions in a container (#6590)

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Jack Amadeo
2026-01-27 16:30:51 -05:00
committed by GitHub
parent 03109aabf4
commit 3fcf022236
12 changed files with 194 additions and 34 deletions
+31 -1
View File
@@ -10,7 +10,7 @@ use axum::{
routing::{get, post},
Json, Router,
};
use goose::agents::ExtensionLoadResult;
use goose::agents::{Container, ExtensionLoadResult};
use goose::goose_apps::{fetch_mcp_apps, GooseApp, McpAppCache};
use base64::Engine;
@@ -105,6 +105,12 @@ pub struct RemoveExtensionRequest {
session_id: String,
}
#[derive(Deserialize, utoipa::ToSchema)]
pub struct SetContainerRequest {
session_id: String,
container_id: Option<String>,
}
#[derive(Deserialize, utoipa::ToSchema)]
pub struct ReadResourceRequest {
session_id: String,
@@ -634,6 +640,29 @@ async fn agent_remove_extension(
Ok(StatusCode::OK)
}
#[utoipa::path(
post,
path = "/agent/set_container",
request_body = SetContainerRequest,
responses(
(status = 200, description = "Container set successfully"),
(status = 401, description = "Unauthorized - invalid secret key"),
(status = 424, description = "Agent not initialized"),
(status = 500, description = "Internal server error")
)
)]
async fn set_container(
State(state): State<Arc<AppState>>,
Json(request): Json<SetContainerRequest>,
) -> Result<StatusCode, ErrorResponse> {
let agent = state.get_agent(request.session_id.clone()).await?;
let container = request.container_id.map(Container::new);
agent.set_container(container).await;
Ok(StatusCode::OK)
}
#[utoipa::path(
post,
path = "/agent/stop",
@@ -1157,6 +1186,7 @@ pub fn routes(state: Arc<AppState>) -> Router {
.route("/agent/update_from_session", post(update_from_session))
.route("/agent/add_extension", post(agent_add_extension))
.route("/agent/remove_extension", post(agent_remove_extension))
.route("/agent/set_container", post(set_container))
.route("/agent/stop", post(stop_agent))
.with_state(state)
}