diff --git a/src/basic/keywords/use_tool.rs b/src/basic/keywords/use_tool.rs index c8073f0d..50419b94 100644 --- a/src/basic/keywords/use_tool.rs +++ b/src/basic/keywords/use_tool.rs @@ -199,16 +199,12 @@ fn associate_tool_with_session( ) -> Result { use crate::core::shared::models::schema::session_tool_associations; - // Check if tool's .mcp.json file exists in work directory - let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string()); - let gb_dir = format!("{}/gb", home_dir); - // Get bot name to construct the path let bot_name = get_bot_name_from_id(state, &user.bot_id)?; - let work_path = Path::new(&gb_dir) - .join("work") - .join(format!("{}.gbai/{}.gbdialog", bot_name, bot_name)); - let mcp_path = work_path.join(format!("{}.mcp.json", tool_name)); + let bot_subpath = format!("{}.gbai/{}.gbdialog", bot_name, bot_name); + let tool_file = format!("{}.mcp.json", tool_name); + + let mcp_path = Path::new("./work").join(&bot_subpath).join(&tool_file); trace!("Checking for tool .mcp.json at: {:?}", mcp_path); diff --git a/src/core/bot/tool_context.rs b/src/core/bot/tool_context.rs index 25a7bf10..e4928c61 100644 --- a/src/core/bot/tool_context.rs +++ b/src/core/bot/tool_context.rs @@ -36,18 +36,18 @@ pub fn get_session_tools( } // Build path to work/{bot_name}.gbai/{bot_name}.gbdialog directory - let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string()); - let gb_dir = format!("{}/gb", home_dir); - let work_path = Path::new(&gb_dir).join("work").join(format!("{}.gbai/{}.gbdialog", bot_name, bot_name)); + let bot_subpath = format!("{}.gbai/{}.gbdialog", bot_name, bot_name); + let work_path = Path::new("./work").join(&bot_subpath); - info!("Loading {} tools for session {} from {:?}", tool_names.len(), session_id, work_path); + info!("Loading {} tools for session {}", tool_names.len(), session_id); let mut tools = Vec::new(); for tool_name in &tool_names { // Find the .mcp.json file for this tool - let mcp_path = work_path.join(format!("{}.mcp.json", tool_name)); - + let tool_file = format!("{}.mcp.json", tool_name); + + let mcp_path = work_path.join(&tool_file); if !mcp_path.exists() { warn!("Tool JSON file not found: {:?}", mcp_path); continue; diff --git a/src/llm/glm.rs b/src/llm/glm.rs index e5eda1a0..ef0078cb 100644 --- a/src/llm/glm.rs +++ b/src/llm/glm.rs @@ -340,7 +340,7 @@ impl LLMProvider for GLMClient { } // Keep unprocessed data in buffer - if let Some(last_newline) = data.rfind('\n') { + if let Some(last_newline) = buffer.iter().rposition(|&b| b == b'\n') { buffer = buffer[last_newline + 1..].to_vec(); } }