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 nametype- The capability typeenabled- Whether the capability is currently enableddescription- Optional descriptionconfig- Capability-specific configurationpermissions- 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
@type capability_type() ::
:tool
| :resource
| :prompt
| :sampling
| :file_access
| :network_access
| :code_execution
Functions
@spec all_types() :: [capability_type()]
Returns all valid capability types.
Disables a capability.
Enables a capability.
@spec from_map(map()) :: {:ok, t()} | {:error, AgentSessionManager.Core.Error.t()}
Reconstructs a capability from a map.
@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}}
Converts a capability to a map suitable for JSON serialization.
Checks if the given type is a valid capability type.