Altar.ADM.FunctionDeclaration (Altar v0.1.2)

View Source

FunctionDeclaration represents a callable function's contract in the ADM.

This structure mirrors industry patterns (e.g., Gemini, OpenAPI) while remaining intentionally simple. It defines the function's name, human-readable description, and a parameters schema (as a map for now).

Use new/1 to construct validated instances.

Summary

Types

The parameters schema represented as a plain map for now (OpenAPI Schema-like).

t()

The validated FunctionDeclaration struct.

Functions

Construct a new validated FunctionDeclaration.

Types

parameters_schema()

@type parameters_schema() :: map()

The parameters schema represented as a plain map for now (OpenAPI Schema-like).

t()

@type t() :: %Altar.ADM.FunctionDeclaration{
  description: String.t(),
  name: String.t(),
  parameters: parameters_schema()
}

The validated FunctionDeclaration struct.

Functions

new(attrs)

@spec new(map() | keyword()) :: {:ok, t()} | {:error, String.t()}

Construct a new validated FunctionDeclaration.

Accepts a map or keyword list with:

  • :name (required): string matching ~r/^[a-zA-Z0-9_-]{1,64}$/
  • :description (required): non-empty string
  • :parameters (optional): map() – defaults to %{}

Returns {:ok, %FunctionDeclaration{}} on success or {:error, reason}.