diff --git a/src/basic/keywords/use_tool.rs b/src/basic/keywords/use_tool.rs index c8073f0d6..c65c9d29f 100644 --- a/src/basic/keywords/use_tool.rs +++ b/src/basic/keywords/use_tool.rs @@ -3,7 +3,7 @@ use crate::core::shared::state::AppState; use diesel::prelude::*; use log::{error, info, trace, warn}; use rhai::{Dynamic, Engine}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::sync::Arc; use uuid::Uuid; pub fn use_tool_keyword(state: Arc, user: UserSession, engine: &mut Engine) { @@ -200,8 +200,10 @@ fn associate_tool_with_session( 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); + // Use relative path from botserver binary location + let gb_dir = std::env::current_dir() + .unwrap_or_else(|_| PathBuf::from(".")) + .join("botserver-stack/data/system"); // Get bot name to construct the path let bot_name = get_bot_name_from_id(state, &user.bot_id)?; diff --git a/src/core/bot/tool_context.rs b/src/core/bot/tool_context.rs index 25a7bf107..2e668817a 100644 --- a/src/core/bot/tool_context.rs +++ b/src/core/bot/tool_context.rs @@ -1,7 +1,7 @@ use diesel::prelude::*; use log::{debug, info, warn}; use serde_json::{json, Value}; -use std::path::Path; +use std::path::{Path, PathBuf}; use uuid::Uuid; use crate::core::shared::utils::DbPool; @@ -36,8 +36,10 @@ 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); + // Use relative path from botserver binary location + let gb_dir = std::env::current_dir() + .unwrap_or_else(|_| PathBuf::from(".")) + .join("botserver-stack/data/system"); let work_path = Path::new(&gb_dir).join("work").join(format!("{}.gbai/{}.gbdialog", bot_name, bot_name)); info!("Loading {} tools for session {} from {:?}", tool_names.len(), session_id, work_path);