update
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user