# `AgentSessionManager.Core.Capability`
[🔗](https://github.com/nshkrdotcom/agent_session_manager/blob/v0.8.0/lib/agent_session_manager/core/capability.ex#L1)

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)

# `capability_type`

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

# `t`

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

# `all_types`

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

Returns all valid capability types.

# `disable`

```elixir
@spec disable(t()) :: t()
```

Disables a capability.

# `enable`

```elixir
@spec enable(t()) :: t()
```

Enables a capability.

# `from_map`

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

Reconstructs a capability from a map.

# `new`

```elixir
@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`

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

Converts a capability to a map suitable for JSON serialization.

# `valid_type?`

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

Checks if the given type is a valid capability type.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
