This commit is contained in:
2026-08-10 09:43:35 +07:00
parent 92b3e4081f
commit 189bc2efcf
4 changed files with 31 additions and 35 deletions
+4 -4
View File
@@ -3,7 +3,7 @@ module toolRegistry
export loadTools, registerTool, getTools, clearTools
using Dates
using JSON
using JSON, DataStructures
using ..type
# Global registry — populated at runtime by loadTools() or registerTool()
@@ -92,12 +92,12 @@ end
# Errors
- Throws `ArgumentError` if a tool file does not define a `getTool` function
"""
function loadTools(dir::String)::Vector{agentTool}
function loadTools(dir::String)::OrderedDict{String, agentTool}
if !isdir(dir)
throw(ArgumentError("Tool directory does not exist: $dir"))
end
tools = agentTool[]
tools = OrderedDict{String, agentTool}()
jl_files = filter(f -> endswith(f, ".jl") && !occursin(r"(?i)registry", f), readdir(dir))
sort!(jl_files)
@@ -143,7 +143,7 @@ function loadTools(dir::String)::Vector{agentTool}
# functions. Without this, GC could collect the module.
push!(_tool_modules, mod)
push!(_registry, tool)
push!(tools, tool)
tools[tool.name] = tool
println("[toolRegistry] Loaded tool: $(tool.name)$(tool.label)")
catch e
if e isa UndefVarError || occursin("getTool", sprint(showerror, e))