refactoring

different default system prompts for cli and audio
This commit is contained in:
2026-05-04 21:18:09 +02:00
parent 3d8975cfc1
commit 51b1123cf9
16 changed files with 80 additions and 45 deletions
+3 -1
View File
@@ -11,6 +11,8 @@ use rmcp::ErrorData;
use rmcp::model::ErrorCode;
use thiserror::Error;
use tower_http::auth::AddAuthorization;
use tracing::event;
use tracing::Level;
use uuid::Uuid;
pub(crate) type AuthorizedCaldavClient =
@@ -111,7 +113,7 @@ pub(crate) async fn upload_components(
calendar: &FoundCollection,
components: Vec<impl Into<CalendarComponent>>,
) -> Result<PutResourceResponse, CalendarError> {
println!("uploading components to {}", calendar.href);
event!(Level::INFO, "uploading components to {}", calendar.href);
let mut upload_calendar = Calendar::new();
for todo in components {
+11 -1
View File
@@ -52,7 +52,17 @@ impl DateTimeHandler {
annotations(read_only_hint = true)
)]
fn get_weekday() -> String {
Local::now().weekday().to_string()
use chrono::Weekday::*;
match Local::now().weekday() {
Mon => "Monday",
Tue => "Tuesday",
Wed => "Wednesday",
Thu => "Thursday",
Fri => "Friday",
Sat => "Saturday",
Sun => "Sunday",
}.to_string()
}
}
+11 -13
View File
@@ -6,6 +6,7 @@ pub mod datetime;
pub mod caldav;
mod server_handler;
#[cfg(feature = "caldav")]
use crate::caldav::CalDavHandler;
use crate::config::{Config, ServerConfig};
#[cfg(feature = "datetime")]
@@ -15,13 +16,17 @@ use axum::Router;
use axum::response::Json;
use serde::{Deserialize, Serialize};
use tokio::main;
use tracing::{event, Level};
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use own_assist_common::exit_msg;
#[derive(Debug, Clone, Deserialize, Serialize)]
#[non_exhaustive]
pub enum McpServiceType {
#[cfg(feature = "datetime")]
DateTime,
#[cfg(feature = "caldav")]
CalDav,
}
@@ -32,10 +37,12 @@ pub(crate) async fn mcp_router(
for config in server_configs {
router = match config.r#type {
#[cfg(feature = "datetime")]
McpServiceType::DateTime => router.route_service(
config.path.as_str(),
DateTimeHandler::mcp_service(config.additional_properties.clone()).await?,
),
#[cfg(feature = "caldav")]
McpServiceType::CalDav => router.route_service(
config.path.as_str(),
CalDavHandler::mcp_service(config.additional_properties.clone()).await?,
@@ -65,10 +72,7 @@ async fn main() {
.init();
let config = Config::from_file()
.inspect_err(|e| {
eprintln!("Error loading config: {e}");
std::process::exit(1);
})
.inspect_err(exit_msg!("Error loading config: {e}"))
.unwrap();
let routes = Json(
@@ -82,24 +86,18 @@ async fn main() {
let router = mcp_router(&config.servers)
.await
.inspect_err(|e| {
eprintln!("Error loading config: {e}");
std::process::exit(1);
})
.inspect_err(exit_msg!("Error handling server: {e}"))
.unwrap()
.route("/", axum::routing::get(|| async { routes }));
let bind_address = config
.bind_address
.unwrap_or(url::Url::parse("http://localhost:8000").unwrap());
println!("binding address at {bind_address}");
event!(Level::INFO,"binding address at {bind_address}");
let tcp_listener = tokio::net::TcpListener::bind(bind_address_format(bind_address))
.await
.inspect_err(|e| {
eprintln!("Error bind tcp listener: {e:#?}");
std::process::exit(1);
})
.inspect_err(exit_msg!("Error bind tcp listener: {e:#?}"))
.unwrap();
let ct = tokio_util::sync::CancellationToken::new();