# `A2UIAgent.CatalogResolver`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_agent/lib/a2ui_agent/catalog_resolver.ex#L1)

Negotiates the catalogs that are active for one renderer.

A renderer sends its capabilities keyed by protocol version, for
example `%{"v1.0" => %{"supportedCatalogIds" => [...], "inlineCatalogs" => [...]}}`.
`resolve/3` returns the agent's catalogs that the renderer names, in the
renderer's order of preference, ignoring ids the agent does not hold.

When the agent accepts inline catalogs, each inline catalog becomes an
active catalog of its own after the registered ones, unless an active
catalog already has its id. Otherwise inline catalogs are dropped, but
they are still checked, since a malformed one makes the capabilities
malformed whether or not the agent uses it.

Registered catalogs resolve to their transformed form; inline catalogs
are not transformed.

# `resolve`
*since 0.1.0* 

```elixir
@spec resolve([A2UIAgent.CatalogConfig.t()], map() | nil, keyword()) ::
  {:ok, [A2UICore.Catalog.t()]} | {:error, A2UICore.Error.t()}
```

Returns the active catalogs.

`capabilities` of `nil` (a request that carries none) activates every
registered catalog in registration order. Option:
`:accepts_inline_catalogs` (default `false`).

Errors:

  * `:catalog` — capabilities are given and no catalog is active (the
    renderer names none of the registered catalogs, or none are
    registered); `inlineCatalogs` is not a list of catalog objects, or
    an inline catalog has no non-empty `catalogId`; the registered
    catalogs span protocol versions that read different capabilities
    entries;
  * `:validation` — the capabilities have no valid entry for the
    registered catalogs' protocol version.

---

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