# `Beamlet.Config`
[🔗](https://github.com/aaronrussell/beamlet/blob/v0.1.0/lib/beamlet/config.ex#L1)

The `:beamlet` application config.

    config :beamlet,
      data_dir: "/var/lib/beamlet",
      web: [endpoint: MyAppWeb.Endpoint],
      eval: [timeout: 60_000],
      mcp: [request_timeout: 90_000],
      http: [allow: ["homeassistant.local", "192.168.1.0/24"]]

The beamlet checks every key when it starts. A bad value stops the
boot with a message naming the key. A change takes a restart.

Times are in milliseconds and sizes in bytes.

## Keys

* `:data_dir` - The directory where the beamlet keeps everything:
  its databases, the code agents define and the files they keep.
  Required. It must be an absolute path to a directory that already
  exists.
* `:policies` - The policies a token can have besides `default`, as
  a keyword list of name to policy. None by default.
  `Beamlet.Policy` describes how to write one.
* `:eval` - Limits on the `eval` tool. `timeout` is how long one
  evaluation may run (30 seconds). `max_heap_bytes` caps the memory
  it may use (128 MB), and `max_output` the output returned to the
  model (32 KB). `Beamlet.MCP.Eval` says what happens when each is
  reached.
* `:define` - `timeout` is how long one `define` or `patch` may take
  to compile (30 seconds).
* `:mcp` - `request_timeout` is how long the MCP server waits for a
  tool to answer before replying "Server unavailable" (65 seconds).
  It must be longer than the eval and define timeouts, so a slow
  tool reports its own error first.
* `:http` - `allow` lists the hosts on private networks that agent
  code may reach through `Host.HTTP`, as names, IP addresses or CIDR
  blocks. A name must be listed as a name: allowing its address
  or block is not enough. Empty by default, so agent code reaches
  only the public internet.
* `:web` - `endpoint` names the Phoenix endpoint that forwards to
  `Beamlet.Router`. Required. `prefix` is a path to serve the routes
  agents mount under, such as `"/app"`, and cannot be under
  `/beamlet`. Empty by default, which serves them at the root.

# `agent_db_file`

```elixir
@spec agent_db_file() :: Path.t()
```

The agent database file, used by `Host.Repo`.

# `beamlet_db_file`

```elixir
@spec beamlet_db_file() :: Path.t()
```

The beamlet's own database file, used by `Beamlet.Repo`.

# `code_dir`

```elixir
@spec code_dir() :: Path.t()
```

The directory holding the modules agents define, with their git history.

# `data_dir`

```elixir
@spec data_dir() :: Path.t()
```

The data directory, an absolute path.

# `db_dir`

```elixir
@spec db_dir() :: Path.t()
```

The directory holding both database files.

# `define`

```elixir
@spec define() :: keyword()
```

The `:define` settings, with the defaults filled in.

# `eval`

```elixir
@spec eval() :: keyword()
```

The `:eval` settings, with the defaults filled in.

# `files_dir`

```elixir
@spec files_dir() :: Path.t()
```

The directory holding the files agent code keeps through `Host.File`.

# `http`

```elixir
@spec http() :: keyword()
```

The `:http` settings, with the defaults filled in.

# `mcp`

```elixir
@spec mcp() :: keyword()
```

The `:mcp` settings, with the defaults filled in.

# `policies`

```elixir
@spec policies() :: keyword()
```

The policies declared besides `default`.

# `validate!`

```elixir
@spec validate!() :: :ok
```

Checks every key, raising `ArgumentError` for the first at fault.

`Beamlet` calls it before starting anything. It does not check that
an endpoint is set. A full boot checks that afterwards.

# `web`

```elixir
@spec web() :: keyword()
```

The `:web` settings, with the defaults filled in.

---

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