MingaAgent.Tool.Registry (Minga v0.1.0)

Copy Markdown View Source

ETS-backed registry for agent tool specifications.

Stores MingaAgent.Tool.Spec structs in an ETS table with read_concurrency: true for zero-contention lookups in the hot tool-execution path. Writes happen only at startup (built-in tool registration) and when extensions register custom tools.

Built-in registration

On startup, all tools from MingaAgent.Tools.all/1 are converted to Spec structs and registered. The Registry becomes the single source of truth for tool discovery and lookup.

Usage

MingaAgent.Tool.Registry.lookup("read_file")
#=> {:ok, %MingaAgent.Tool.Spec{name: "read_file", ...}}

MingaAgent.Tool.Registry.registered?("shell")
#=> true

MingaAgent.Tool.Registry.all()
#=> [%MingaAgent.Tool.Spec{}, ...]

Summary

Functions

Returns all registered tool specs.

Looks up a tool spec by name.

Registers a tool spec in the registry.

Returns true if a tool with the given name is registered.

Starts the registry GenServer that owns the ETS table.

Functions

all()

@spec all() :: [MingaAgent.Tool.Spec.t()]

Returns all registered tool specs.

from_req_tool(tool)

@spec from_req_tool(ReqLLM.Tool.t()) :: MingaAgent.Tool.Spec.t()

Converts a ReqLLM.Tool struct to a MingaAgent.Tool.Spec.

Maps the tool name to a category and approval level based on the tool's characteristics.

lookup(name)

@spec lookup(String.t()) :: {:ok, MingaAgent.Tool.Spec.t()} | :error

Looks up a tool spec by name.

Returns {:ok, spec} if found, :error otherwise.

register(spec)

@spec register(MingaAgent.Tool.Spec.t()) :: :ok

Registers a tool spec in the registry.

Overwrites any existing spec with the same name. Returns :ok.

registered?(name)

@spec registered?(String.t()) :: boolean()

Returns true if a tool with the given name is registered.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the registry GenServer that owns the ETS table.