From d95270da5ae6f996e137eca0cf31d93a997fcce3 Mon Sep 17 00:00:00 2001 From: anierbeck Date: Sat, 21 Mar 2026 18:16:16 +0100 Subject: [PATCH] Fix agent template spawning - Ensure all templates have manifest_toml field - Use spawnFromTemplate for templates with manifest_toml - Fix spawnBuiltin to handle missing fields gracefully - Update HTML template to call correct spawn method --- crates/openfang-api/src/routes.rs | 6 ++-- crates/openfang-api/static/index_body.html | 2 +- crates/openfang-api/static/js/pages/agents.js | 35 ++++++++++++------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/crates/openfang-api/src/routes.rs b/crates/openfang-api/src/routes.rs index 3d06b459..3ceb8c99 100644 --- a/crates/openfang-api/src/routes.rs +++ b/crates/openfang-api/src/routes.rs @@ -3104,8 +3104,9 @@ pub async fn list_templates() -> impl IntoResponse { .to_string_lossy() .to_string(); - let description = std::fs::read_to_string(&manifest_path) - .ok() + let manifest_content = std::fs::read_to_string(&manifest_path).ok(); + let description = manifest_content + .as_ref() .and_then(|content| toml::from_str::(&content).ok()) .map(|m| m.description) .unwrap_or_default(); @@ -3117,6 +3118,7 @@ pub async fn list_templates() -> impl IntoResponse { "name": name, "description": description, "category": category, + "manifest_toml": manifest_content.unwrap_or_default(), })); } } diff --git a/crates/openfang-api/static/index_body.html b/crates/openfang-api/static/index_body.html index f9e5dffb..c22b74ac 100644 --- a/crates/openfang-api/static/index_body.html +++ b/crates/openfang-api/static/index_body.html @@ -881,7 +881,7 @@