# `Layr8.Config`
[🔗](https://github.com/layr8/elixir_sdk/blob/main/lib/layr8/config.ex#L1)

Configuration for a Layr8 client.

Fields can be supplied explicitly or resolved from environment variables:
- `LAYR8_NODE_URL` — WebSocket URL of the cloud-node
- `LAYR8_API_KEY`  — authentication key
- `LAYR8_AGENT_DID` — agent DID (optional; ephemeral DID created on connect if absent)

HTTP(S) URLs are automatically normalized to WebSocket scheme:
- `https://` → `wss://`
- `http://`  → `ws://`

## Example

    config = Layr8.Config.resolve!(%{node_url: "wss://node.example.com/plugin_socket/websocket", api_key: "secret"})

# `t`

```elixir
@type t() :: %Layr8.Config{
  agent_did: String.t(),
  api_key: String.t(),
  node_url: String.t()
}
```

# `resolve!`

```elixir
@spec resolve!(map()) :: t()
```

Resolves a config map or struct, filling missing fields from environment variables,
normalizing the URL scheme, and validating required fields.

Raises `Layr8.Error` if required fields are missing.

# `rest_url_from_websocket`

```elixir
@spec rest_url_from_websocket(String.t()) :: String.t()
```

Derives the REST API base URL from a WebSocket URL.

    iex> Layr8.Config.rest_url_from_websocket("wss://node.example.com/plugin_socket/websocket")
    "https://node.example.com"

    iex> Layr8.Config.rest_url_from_websocket("ws://localhost:4000/plugin_socket/websocket")
    "http://localhost:4000"

---

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