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
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Regenerate OpenAPI clients after removing endpoint

When this route is removed, the committed generated API artifacts are left stale: ui/desktop/openapi.json, ui/desktop/src/api/sdk.gen.ts, types.gen.ts, and api/index.ts still advertise/export /recipes/create. Any desktop or extension code built against the generated client can still import createRecipe and will compile, but the server now returns 404 for that call; per the repo instructions, server API changes need just generate-openapi so these artifacts drop the endpoint too.

Useful? React with 👍 / 👎.

.route("/recipes/decode", post(decode_recipe))
.route("/recipes/scan", post(scan_recipe))
Expand Down
88 changes: 0 additions & 88 deletions ui/desktop/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2418,45 +2418,6 @@
}
}
},
"/recipes/create": {
"post": {
"tags": [
"Recipe Management"
],
"operationId": "create_recipe",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateRecipeRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Recipe created successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateRecipeResponse"
}
}
}
},
"400": {
"description": "Bad request"
},
"412": {
"description": "Precondition failed - Agent not available"
},
"500": {
"description": "Internal server error"
}
}
}
},
"/recipes/decode": {
"post": {
"tags": [
Expand Down Expand Up @@ -3984,19 +3945,6 @@
}
}
},
"AuthorRequest": {
"type": "object",
"properties": {
"contact": {
"type": "string",
"nullable": true
},
"metadata": {
"type": "string",
"nullable": true
}
}
},
"CallToolRequest": {
"type": "object",
"required": [
Expand Down Expand Up @@ -4482,42 +4430,6 @@
}
}
},
"CreateRecipeRequest": {
"type": "object",
"required": [
"session_id"
],
"properties": {
"author": {
"allOf": [
{
"$ref": "#/components/schemas/AuthorRequest"
}
],
"nullable": true
},
"session_id": {
"type": "string"
}
}
},
"CreateRecipeResponse": {
"type": "object",
"properties": {
"error": {
"type": "string",
"nullable": true
},
"recipe": {
"allOf": [
{
"$ref": "#/components/schemas/Recipe"
}
],
"nullable": true
}
}
},
"CreateScheduleRequest": {
"type": "object",
"required": [
Expand Down
Loading
Loading