AgentSessionManager.Core.Capability (AgentSessionManager v0.6.0)

Copy Markdown View Source

Represents a capability that can be assigned to an agent.

Capabilities define what an agent can do, including tools, resources, prompts, and various access permissions.

Capability Types

  • :tool - A tool the agent can invoke
  • :resource - A resource the agent can access
  • :prompt - A prompt template
  • :sampling - Sampling/generation capability
  • :file_access - File system access
  • :network_access - Network/HTTP access
  • :code_execution - Code execution capability

Fields

  • name - Unique capability name
  • type - The capability type
  • enabled - Whether the capability is currently enabled
  • description - Optional description
  • config - Capability-specific configuration
  • permissions - List of permissions required/granted

Usage

# Create a capability
{:ok, cap} = Capability.new(%{
  name: "web_search",
  type: :tool,
  description: "Search the web for information"
})

# Disable a capability
disabled = Capability.disable(cap)

Summary

Functions

Returns all valid capability types.

Disables a capability.

Enables a capability.

Reconstructs a capability from a map.

Creates a new capability with the given attributes.

Converts a capability to a map suitable for JSON serialization.

Checks if the given type is a valid capability type.

Types

capability_type()

@type capability_type() ::
  :tool
  | :resource
  | :prompt
  | :sampling
  | :file_access
  | :network_access
  | :code_execution

t()

@type t() :: %AgentSessionManager.Core.Capability{
  config: map(),
  description: String.t() | nil,
  enabled: boolean(),
  name: String.t() | nil,
  permissions: [String.t()],
  type: capability_type() | nil
}

Functions

all_types()

@spec all_types() :: [capability_type()]

Returns all valid capability types.

disable(capability)

@spec disable(t()) :: t()

Disables a capability.

enable(capability)

@spec enable(t()) :: t()

Enables a capability.

from_map(map)

@spec from_map(map()) :: {:ok, t()} | {:error, AgentSessionManager.Core.Error.t()}

Reconstructs a capability from a map.

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, AgentSessionManager.Core.Error.t()}

Creates a new capability with the given attributes.

Required

  • :name - The capability name
  • :type - The capability type

Optional

  • :enabled - Whether enabled (default: true)
  • :description - Description of the capability
  • :config - Configuration map
  • :permissions - List of permission strings

Examples

iex> Capability.new(%{name: "web_search", type: :tool})
{:ok, %Capability{name: "web_search", type: :tool, enabled: true}}

iex> Capability.new(%{name: "", type: :tool})
{:error, %Error{code: :validation_error}}

to_map(capability)

@spec to_map(t()) :: map()

Converts a capability to a map suitable for JSON serialization.

valid_type?(type)

@spec valid_type?(atom()) :: boolean()

Checks if the given type is a valid capability type.