Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions crates/goose-sdk-types/src/custom_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ pub struct CustomMethodSchema {
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(method = "_goose/unstable/session/extensions/add", response = EmptyResponse)]
#[serde(rename_all = "camelCase")]
pub struct AddExtensionRequest {
pub struct AddSessionExtensionRequest {
pub session_id: String,
/// Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform).
#[serde(default)]
pub config: serde_json::Value,
pub extension: GooseExtension,
}

/// Remove an extension from an active session.
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(method = "_goose/unstable/session/extensions/remove", response = EmptyResponse)]
#[serde(rename_all = "camelCase")]
pub struct RemoveExtensionRequest {
pub struct RemoveSessionExtensionRequest {
pub session_id: String,
pub name: String,
}
Expand Down Expand Up @@ -303,7 +301,7 @@ pub struct GetSessionExtensionsRequest {

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
pub struct GetSessionExtensionsResponse {
pub extensions: Vec<serde_json::Value>,
pub extensions: Vec<GooseExtension>,
}

/// Read allowlisted user preferences. Empty `keys` means all supported preferences.
Expand Down
4 changes: 0 additions & 4 deletions crates/goose-server/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ derive_utoipa!(IconTheme as IconThemeSchema);
super::routes::schedule::kill_running_job,
super::routes::schedule::inspect_running_job,
super::routes::schedule::sessions_handler,
super::routes::recipe::create_recipe,
super::routes::recipe::encode_recipe,
super::routes::recipe::decode_recipe,
super::routes::recipe::scan_recipe,
Expand Down Expand Up @@ -597,9 +596,6 @@ derive_utoipa!(IconTheme as IconThemeSchema);
super::routes::schedule::ListSchedulesResponse,
super::routes::schedule::SessionsQuery,
super::routes::schedule::SessionDisplayInfo,
super::routes::recipe::CreateRecipeRequest,
super::routes::recipe::AuthorRequest,
super::routes::recipe::CreateRecipeResponse,
super::routes::recipe::EncodeRecipeRequest,
super::routes::recipe::EncodeRecipeResponse,
super::routes::recipe::DecodeRecipeRequest,
Expand Down
98 changes: 0 additions & 98 deletions crates/goose-server/src/routes/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,6 @@ use crate::routes::recipe_utils::{
};
use crate::state::AppState;

#[derive(Debug, Deserialize, ToSchema)]
pub struct CreateRecipeRequest {
session_id: String,
#[serde(default)]
author: Option<AuthorRequest>,
}

#[derive(Debug, Deserialize, ToSchema)]
pub struct AuthorRequest {
#[serde(default)]
contact: Option<String>,
#[serde(default)]
metadata: Option<String>,
}

#[derive(Debug, Serialize, ToSchema)]
pub struct CreateRecipeResponse {
recipe: Option<Recipe>,
error: Option<String>,
}

#[derive(Debug, Deserialize, ToSchema)]
pub struct EncodeRecipeRequest {
recipe: Recipe,
Expand Down Expand Up @@ -148,82 +127,6 @@ pub struct RecipeToYamlResponse {
yaml: String,
}

#[utoipa::path(
post,
path = "/recipes/create",
request_body = CreateRecipeRequest,
responses(
(status = 200, description = "Recipe created successfully", body = CreateRecipeResponse),
(status = 400, description = "Bad request"),
(status = 412, description = "Precondition failed - Agent not available"),
(status = 500, description = "Internal server error")
),
tag = "Recipe Management"
)]
async fn create_recipe(
State(state): State<Arc<AppState>>,
Json(request): Json<CreateRecipeRequest>,
) -> Result<Json<CreateRecipeResponse>, StatusCode> {
tracing::info!(
"Recipe creation request received for session_id: {}",
request.session_id
);

let session = match state
.session_manager()
.get_session(&request.session_id, true)
.await
{
Ok(session) => session,
Err(e) => {
tracing::error!("Failed to get session: {}", e);
return Err(StatusCode::INTERNAL_SERVER_ERROR);
}
};

let conversation = match session.conversation.clone() {
Some(conversation) => conversation,
None => {
let error_message = "Session has no conversation".to_string();
let error_response = CreateRecipeResponse {
recipe: None,
error: Some(error_message),
};
return Ok(Json(error_response));
}
};

let agent = state.get_agent_for_route(request.session_id).await?;

let recipe_result = agent.create_recipe(&session.id, conversation).await;

match recipe_result {
Ok(mut recipe) => {
if let Some(author_req) = request.author {
recipe.author = Some(goose::recipe::Author {
contact: author_req.contact,
metadata: author_req.metadata,
});
}

Ok(Json(CreateRecipeResponse {
recipe: Some(recipe),
error: None,
}))
}
Err(e) => {
tracing::error!("Error details: {:?}", e);
#[cfg(feature = "telemetry")]
goose::posthog::emit_error("recipe_create_failed", &e.to_string());
let error_response = CreateRecipeResponse {
recipe: None,
error: Some(format!("Failed to create recipe: {}", e)),
};
Ok(Json(error_response))
}
}
}

#[utoipa::path(
post,
path = "/recipes/encode",
Expand Down Expand Up @@ -571,7 +474,6 @@ async fn recipe_to_yaml(

pub fn routes(state: Arc<AppState>) -> Router {
Router::new()
.route("/recipes/create", post(create_recipe))
.route("/recipes/encode", post(encode_recipe))
.route("/recipes/decode", post(decode_recipe))
.route("/recipes/scan", post(scan_recipe))
Expand Down
4 changes: 2 additions & 2 deletions crates/goose/acp-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"methods": [
{
"method": "_goose/unstable/session/extensions/add",
"requestType": "AddExtensionRequest_unstable",
"requestType": "AddSessionExtensionRequest_unstable",
"responseType": "EmptyResponse"
},
{
"method": "_goose/unstable/session/extensions/remove",
"requestType": "RemoveExtensionRequest_unstable",
"requestType": "RemoveSessionExtensionRequest_unstable",
"responseType": "EmptyResponse"
},
{
Expand Down
Loading
Loading