fix: correct tool file path resolution to match architecture
Some checks failed
BotServer CI / build (push) Failing after 1m57s

- Updated get_tool_bas_path to look in /opt/gbo/data (source) first
- Then check botserver-stack/data/system/work (compiled) second
- Removed incorrect $HOME/data and $HOME/gb/work paths
- Fixes 'Tool file not found' error when executing inscricao tool

According to AGENTS.md architecture:
- Bots are in /opt/gbo/data primary
- They are compiled into work directory by local_file_monitor
- tool_executor was looking in wrong directories
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-03-03 10:01:33 -03:00
parent c03398fe56
commit b2d6a51ebd

View file

@ -340,28 +340,30 @@ impl ToolExecutor {
/// Get the path to a tool's .bas file /// Get the path to a tool's .bas file
fn get_tool_bas_path(bot_name: &str, tool_name: &str) -> std::path::PathBuf { fn get_tool_bas_path(bot_name: &str, tool_name: &str) -> std::path::PathBuf {
let home_dir = std::env::var("HOME").unwrap_or_else(|_| ".".to_string()); // Try source directory first (/opt/gbo/data - primary location for bot source files)
let source_path = Path::new("/opt/gbo/data")
// Try data directory first
let data_path = Path::new(&home_dir)
.join("data")
.join(format!("{}.gbai", bot_name)) .join(format!("{}.gbai", bot_name))
.join(format!("{}.gbdialog", bot_name)) .join(format!("{}.gbdialog", bot_name))
.join(format!("{}.bas", tool_name)); .join(format!("{}.bas", tool_name));
if data_path.exists() { if source_path.exists() {
return data_path; return source_path;
} }
// Try work directory (for development/testing) // Try compiled work directory (botserver-stack/data/system/work relative to current dir)
let work_path = Path::new(&home_dir) let work_path = std::env::current_dir()
.join("gb") .unwrap_or_else(|_| PathBuf::from("."))
.join("work") .join("botserver-stack/data/system/work")
.join(format!("{}.gbai", bot_name)) .join(format!("{}.gbai", bot_name))
.join(format!("{}.gbdialog", bot_name)) .join(format!("{}.gbdialog", bot_name))
.join(format!("{}.bas", tool_name)); .join(format!("{}.bas", tool_name));
work_path if work_path.exists() {
return work_path;
}
// Fallback to source path for error messages (even if it doesn't exist)
source_path
} }
} }