- Refactoring bot package.
This commit is contained in:
parent
be1e2575f9
commit
27d0349989
3 changed files with 132 additions and 0 deletions
18
scripts/mcp/table-editor.json
Normal file
18
scripts/mcp/table-editor.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
73
src/meet/mod.rs
Normal file
73
src/meet/mod.rs
Normal file
|
|
@ -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<AppState>,
|
||||||
|
info: web::Json<serde_json::Value>,
|
||||||
|
) -> Result<HttpResponse> {
|
||||||
|
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<AppState>,
|
||||||
|
info: web::Json<serde_json::Value>,
|
||||||
|
) -> Result<HttpResponse> {
|
||||||
|
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()})))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/web_server/mod.rs
Normal file
41
src/web_server/mod.rs
Normal file
|
|
@ -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<HttpResponse> {
|
||||||
|
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<HttpResponse> {
|
||||||
|
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"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue