fix(tools): Update .mcp.json discovery to prioritize local ./work over /opt/gbo/data
This commit is contained in:
parent
de017241f2
commit
c07aee708f
3 changed files with 11 additions and 15 deletions
|
|
@ -199,16 +199,12 @@ fn associate_tool_with_session(
|
||||||
) -> Result<String, String> {
|
) -> Result<String, String> {
|
||||||
use crate::core::shared::models::schema::session_tool_associations;
|
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
|
// Get bot name to construct the path
|
||||||
let bot_name = get_bot_name_from_id(state, &user.bot_id)?;
|
let bot_name = get_bot_name_from_id(state, &user.bot_id)?;
|
||||||
let work_path = Path::new(&gb_dir)
|
let bot_subpath = format!("{}.gbai/{}.gbdialog", bot_name, bot_name);
|
||||||
.join("work")
|
let tool_file = format!("{}.mcp.json", tool_name);
|
||||||
.join(format!("{}.gbai/{}.gbdialog", bot_name, bot_name));
|
|
||||||
let mcp_path = work_path.join(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);
|
trace!("Checking for tool .mcp.json at: {:?}", mcp_path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,18 +36,18 @@ pub fn get_session_tools(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build path to work/{bot_name}.gbai/{bot_name}.gbdialog directory
|
// Build path to work/{bot_name}.gbai/{bot_name}.gbdialog directory
|
||||||
let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
|
let bot_subpath = format!("{}.gbai/{}.gbdialog", bot_name, bot_name);
|
||||||
let gb_dir = format!("{}/gb", home_dir);
|
let work_path = Path::new("./work").join(&bot_subpath);
|
||||||
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);
|
info!("Loading {} tools for session {}", tool_names.len(), session_id);
|
||||||
|
|
||||||
let mut tools = Vec::new();
|
let mut tools = Vec::new();
|
||||||
|
|
||||||
for tool_name in &tool_names {
|
for tool_name in &tool_names {
|
||||||
// Find the .mcp.json file for this tool
|
// 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() {
|
if !mcp_path.exists() {
|
||||||
warn!("Tool JSON file not found: {:?}", mcp_path);
|
warn!("Tool JSON file not found: {:?}", mcp_path);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ impl LLMProvider for GLMClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep unprocessed data in buffer
|
// 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();
|
buffer = buffer[last_newline + 1..].to_vec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue