# `Dsxir.Adapter`

Adapter behaviour: turn a signature + inputs + demos into LM messages, and
parse the LM response back into a typed field map.

Two implementations ship in v0:

  * `Dsxir.Adapter.Chat` — `[[ ## marker ## ]]` text protocol, default.
  * `Dsxir.Adapter.Json` — provider-native structured output, added later.

# `adapter_error`

```elixir
@type adapter_error() ::
  Dsxir.Errors.Adapter.ParseError.t()
  | Dsxir.Errors.Adapter.ZoiValidation.t()
  | Dsxir.Errors.Adapter.FallbackExhausted.t()
```

# `lm_response`

```elixir
@type lm_response() :: String.t()
```

# `messages`

```elixir
@type messages() :: [Sycophant.Message.t()]
```

# `signature`

```elixir
@type signature() :: module() | Dsxir.Signature.Compiled.t()
```

# `format`

```elixir
@callback format(signature(), map(), list(), keyword()) :: messages()
```

# `format_and_call`
*optional* 

```elixir
@callback format_and_call(signature(), map(), list(), keyword()) ::
  {:ok, map(), Dsxir.LM.usage(), term()} | {:fallback, Exception.t()}
```

# `lm_mode`
*optional* 

```elixir
@callback lm_mode() :: :text | :object
```

# `parse`

```elixir
@callback parse(signature(), lm_response() | map(), keyword()) ::
  {:ok, map()} | {:error, adapter_error()}
```

---

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