MingaAgent.Tool.Spec (Minga v0.1.0)

Copy Markdown View Source

Source-owned declaration for an agent tool.

A spec describes a tool and how to build its executable callback for a session. It does not own session state, credentials, approval decisions, events, or cleanup. Context-sensitive tools declare their requirements and receive a core-built MingaAgent.Tool.Context only when the executor has one.

Summary

Types

Approval level for tool execution.

Builds an executable callback from a runtime context.

Executable provider-facing callback.

Capability advertised by a tool declaration.

Tool category for grouping and filtering.

Runtime context required before a tool can be built.

Source that contributed this tool.

t()

A tool specification.

Functions

Builds an executable callback for the given runtime context.

Creates a new tool spec from a keyword list or map.

Creates a new tool spec, raising on validation failure.

Types

approval_level()

@type approval_level() :: :auto | :ask | :deny

Approval level for tool execution.

build_fun()

@type build_fun() :: (term() -> callback())

Builds an executable callback from a runtime context.

callback()

@type callback() :: (map() -> term())

Executable provider-facing callback.

capability()

@type capability() ::
  :read_project
  | :mutate_project
  | :run_shell
  | :network
  | :git_read
  | :git_mutate
  | :lsp_read
  | :lsp_mutate
  | :memory_write
  | :spawn_agent
  | atom()

Capability advertised by a tool declaration.

category()

@type category() ::
  :filesystem | :git | :lsp | :shell | :memory | :agent | :network | :custom

Tool category for grouping and filtering.

context_requirement()

@type context_requirement() ::
  :tool_context | :router | :project_root | :parent_session | atom()

Runtime context required before a tool can be built.

source()

@type source() ::
  :builtin
  | :config
  | {:bundle, :read_only_tools}
  | {:bundle, :lsp_tools}
  | {:extension, atom()}

Source that contributed this tool.

t()

@type t() :: %MingaAgent.Tool.Spec{
  approval_level: approval_level(),
  build: build_fun(),
  callback: callback() | nil,
  capabilities: [capability()],
  category: category(),
  context_requirements: [context_requirement()],
  description: String.t(),
  metadata: map(),
  name: String.t(),
  parameter_schema: map(),
  source: source()
}

A tool specification.

Functions

build_callback(spec, context)

@spec build_callback(t(), term()) :: callback()

Builds an executable callback for the given runtime context.

new(attrs)

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

Creates a new tool spec from a keyword list or map.

new!(attrs)

@spec new!(keyword() | map()) :: t()

Creates a new tool spec, raising on validation failure.