From 27d0349989c0cf6900d515966c3ad82b3b65214c Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sat, 18 Oct 2025 12:03:07 -0300 Subject: [PATCH] - Refactoring bot package. --- scripts/mcp/table-editor.json | 18 +++++++++ src/meet/mod.rs | 73 +++++++++++++++++++++++++++++++++++ src/web_server/mod.rs | 41 ++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 scripts/mcp/table-editor.json create mode 100644 src/meet/mod.rs create mode 100644 src/web_server/mod.rs diff --git a/scripts/mcp/table-editor.json b/scripts/mcp/table-editor.json new file mode 100644 index 000000000..8b1f1787b --- /dev/null +++ b/scripts/mcp/table-editor.json @@ -0,0 +1,18 @@ +{ + "name": "generalbots-table-editor", + "version": "6.0.0", + "capabilities": { + "resources": ["spreadsheet", "doc", "slide"], + "tools": [ + "create_sheet", + "read_cell", + "write_cell", + "format_cell", + "create_chart" + ] + }, + "config": { + "supportedFileTypes": [".xlsx", ".csv", ".txt"], + "maxFileSize": "10MB" + } +} diff --git a/src/meet/mod.rs b/src/meet/mod.rs new file mode 100644 index 000000000..d3bab6a8d --- /dev/null +++ b/src/meet/mod.rs @@ -0,0 +1,73 @@ +use actix_web::{web, HttpResponse, Result}; +use log::{error, info}; + +use crate::shared::state::AppState; + +#[actix_web::post("/api/voice/start")] +async fn voice_start( + data: web::Data, + info: web::Json, +) -> Result { + let session_id = info + .get("session_id") + .and_then(|s| s.as_str()) + .unwrap_or(""); + let user_id = info + .get("user_id") + .and_then(|u| u.as_str()) + .unwrap_or("user"); + info!( + "Voice session start request - session: {}, user: {}", + session_id, user_id + ); + + match data + .voice_adapter + .start_voice_session(session_id, user_id) + .await + { + Ok(token) => { + info!( + "Voice session started successfully for session {}", + session_id + ); + Ok(HttpResponse::Ok().json(serde_json::json!({"token": token, "status": "started"}))) + } + Err(e) => { + error!( + "Failed to start voice session for session {}: {}", + session_id, e + ); + Ok(HttpResponse::InternalServerError() + .json(serde_json::json!({"error": e.to_string()}))) + } + } +} + +#[actix_web::post("/api/voice/stop")] +async fn voice_stop( + data: web::Data, + info: web::Json, +) -> Result { + let session_id = info + .get("session_id") + .and_then(|s| s.as_str()) + .unwrap_or(""); + match data.voice_adapter.stop_voice_session(session_id).await { + Ok(()) => { + info!( + "Voice session stopped successfully for session {}", + session_id + ); + Ok(HttpResponse::Ok().json(serde_json::json!({"status": "stopped"}))) + } + Err(e) => { + error!( + "Failed to stop voice session for session {}: {}", + session_id, e + ); + Ok(HttpResponse::InternalServerError() + .json(serde_json::json!({"error": e.to_string()}))) + } + } +} diff --git a/src/web_server/mod.rs b/src/web_server/mod.rs new file mode 100644 index 000000000..0c36d7455 --- /dev/null +++ b/src/web_server/mod.rs @@ -0,0 +1,41 @@ +use actix_web::{HttpRequest, HttpResponse, Result}; +use log::{debug, error, warn}; +use std::fs; + +#[actix_web::get("/")] +async fn index() -> Result { + match fs::read_to_string("web/index.html") { + Ok(html) => Ok(HttpResponse::Ok().content_type("text/html").body(html)), + Err(e) => { + error!("Failed to load index page: {}", e); + Ok(HttpResponse::InternalServerError().body("Failed to load index page")) + } + } +} + +#[actix_web::get("/static/{filename:.*}")] +async fn static_files(req: HttpRequest) -> Result { + let filename = req.match_info().query("filename"); + let path = format!("web/static/{}", filename); + match fs::read(&path) { + Ok(content) => { + debug!( + "Static file {} loaded successfully, size: {} bytes", + filename, + content.len() + ); + let content_type = match filename { + f if f.ends_with(".js") => "application/javascript", + f if f.ends_with(".css") => "text/css", + f if f.ends_with(".png") => "image/png", + f if f.ends_with(".jpg") | f.ends_with(".jpeg") => "image/jpeg", + _ => "text/plain", + }; + Ok(HttpResponse::Ok().content_type(content_type).body(content)) + } + Err(e) => { + warn!("Static file not found: {} - {}", filename, e); + Ok(HttpResponse::NotFound().body("File not found")) + } + } +}