feat(experts): add built-in expert skills with per-agent activation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
70
src-tauri/src/web/handlers/experts.rs
Normal file
70
src-tauri/src/web/handlers/experts.rs
Normal file
@@ -0,0 +1,70 @@
|
||||
use axum::Json;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::app_error::AppCommandError;
|
||||
use crate::commands::experts as experts_commands;
|
||||
use crate::commands::experts::{ExpertInstallStatus, ExpertListItem};
|
||||
use crate::models::agent::AgentType;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExpertIdParams {
|
||||
pub expert_id: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExpertAgentParams {
|
||||
pub expert_id: String,
|
||||
pub agent_type: AgentType,
|
||||
}
|
||||
|
||||
pub async fn experts_list() -> Result<Json<Vec<ExpertListItem>>, AppCommandError> {
|
||||
let result = experts_commands::experts_list()
|
||||
.await
|
||||
.map_err(|e| AppCommandError::task_execution_failed(e.to_string()))?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn experts_get_install_status(
|
||||
Json(params): Json<ExpertIdParams>,
|
||||
) -> Result<Json<Vec<ExpertInstallStatus>>, AppCommandError> {
|
||||
let result = experts_commands::experts_get_install_status(params.expert_id)
|
||||
.await
|
||||
.map_err(|e| AppCommandError::task_execution_failed(e.to_string()))?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn experts_link_to_agent(
|
||||
Json(params): Json<ExpertAgentParams>,
|
||||
) -> Result<Json<ExpertInstallStatus>, AppCommandError> {
|
||||
let result = experts_commands::experts_link_to_agent(params.expert_id, params.agent_type)
|
||||
.await
|
||||
.map_err(|e| AppCommandError::task_execution_failed(e.to_string()))?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn experts_unlink_from_agent(
|
||||
Json(params): Json<ExpertAgentParams>,
|
||||
) -> Result<Json<()>, AppCommandError> {
|
||||
experts_commands::experts_unlink_from_agent(params.expert_id, params.agent_type)
|
||||
.await
|
||||
.map_err(|e| AppCommandError::task_execution_failed(e.to_string()))?;
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
pub async fn experts_read_content(
|
||||
Json(params): Json<ExpertIdParams>,
|
||||
) -> Result<Json<String>, AppCommandError> {
|
||||
let result = experts_commands::experts_read_content(params.expert_id)
|
||||
.await
|
||||
.map_err(|e| AppCommandError::task_execution_failed(e.to_string()))?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn experts_open_central_dir() -> Result<Json<String>, AppCommandError> {
|
||||
let result = experts_commands::experts_open_central_dir()
|
||||
.await
|
||||
.map_err(|e| AppCommandError::task_execution_failed(e.to_string()))?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
@@ -2,6 +2,7 @@ mod error;
|
||||
pub mod acp;
|
||||
pub mod chat_channel;
|
||||
pub mod conversations;
|
||||
pub mod experts;
|
||||
pub mod files;
|
||||
pub mod folder_commands;
|
||||
pub mod folders;
|
||||
|
||||
@@ -175,6 +175,13 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
|
||||
.route("/acp_read_agent_skill", post(handlers::acp::acp_read_agent_skill))
|
||||
.route("/acp_save_agent_skill", post(handlers::acp::acp_save_agent_skill))
|
||||
.route("/acp_delete_agent_skill", post(handlers::acp::acp_delete_agent_skill))
|
||||
// ─── Experts ───
|
||||
.route("/experts_list", post(handlers::experts::experts_list))
|
||||
.route("/experts_get_install_status", post(handlers::experts::experts_get_install_status))
|
||||
.route("/experts_link_to_agent", post(handlers::experts::experts_link_to_agent))
|
||||
.route("/experts_unlink_from_agent", post(handlers::experts::experts_unlink_from_agent))
|
||||
.route("/experts_read_content", post(handlers::experts::experts_read_content))
|
||||
.route("/experts_open_central_dir", post(handlers::experts::experts_open_central_dir))
|
||||
// ─── Project boot ───
|
||||
.route("/detect_package_manager", post(handlers::project_boot::detect_package_manager))
|
||||
.route("/create_shadcn_project", post(handlers::project_boot::create_shadcn_project))
|
||||
|
||||
Reference in New Issue
Block a user