Altar.LATER.Registry (Altar v0.1.2)

View Source

Registry of tool implementations for the Local Agent & Tool Execution Runtime (LATER).

This module manages an in-process registry of tool functions keyed by their validated Altar.ADM.FunctionDeclaration.name. It is implemented as a GenServer for safe, serialized updates and queries.

State is a map of function_name :: String.t() to implementation functions of arity 1 that accept the tool arguments map.

Summary

Types

The internal state of the registry process.

A tool implementation function. Must be arity-1 and accept a map of arguments.

Functions

Returns a specification to start this module under a supervisor.

Look up a tool implementation by its function name.

Register a tool implementation under the provided declaration's name.

Start the registry process.

Types

state()

@type state() :: %{optional(String.t()) => tool_fun()}

The internal state of the registry process.

tool_fun()

@type tool_fun() :: (map() -> any())

A tool implementation function. Must be arity-1 and accept a map of arguments.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

lookup_tool(registry, function_name)

@spec lookup_tool(GenServer.server(), String.t()) ::
  {:ok, tool_fun()} | {:error, :not_found}

Look up a tool implementation by its function name.

Returns {:ok, fun} when found or {:error, :not_found} otherwise.

register_tool(registry, function_declaration, fun)

@spec register_tool(GenServer.server(), Altar.ADM.FunctionDeclaration.t(), tool_fun()) ::
  :ok | {:error, term()}

Register a tool implementation under the provided declaration's name.

  • registry is the pid or name of the registry process
  • declaration is a validated %Altar.ADM.FunctionDeclaration{}
  • fun is an arity-1 function that accepts a map of arguments

Returns :ok on success or {:error, reason} if registration fails (e.g., name already registered or invalid function arity).

start_link(opts \\ [])

@spec start_link(Keyword.t()) :: GenServer.on_start()

Start the registry process.

Standard GenServer.start_link/3 options are accepted.