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

The direct JSON inference format: the model writes A2UI messages as
JSON between `<a2ui-json>` and `</a2ui-json>` tags, guided by the
protocol and catalog JSON schemas in its prompt.

    {:ok, format} = A2UIAgent.DirectJson.new(catalogs, examples: [example_turn])
    {:ok, prompt} = A2UIAgent.DirectJson.prompt(format)
    parser = A2UIAgent.DirectJson.parser(format)

Options:

  * `:examples` — few-shot example turns (lists of messages) rendered
    into the prompt;
  * `:allowed_messages` — the message actions the prompt describes
    (`nil`, the default, describes all of them);
  * `:progressive_keys` — string properties the streaming parser may
    emit before their closing quote (`progressive_keys/0` lists the
    usual ones).

See `A2UIAgent.DirectJson.Prompt` for the prompt and
`A2UIAgent.DirectJson.Parser` for reading responses.

# `t`
*since 0.1.0* 

```elixir
@type t() :: %A2UIAgent.DirectJson{
  allowed_messages: [String.t()] | nil,
  catalogs: [A2UICore.Catalog.t()],
  examples: [[map()]] | nil,
  progressive_keys: [String.t()]
}
```

# `new`
*since 0.1.0* 

```elixir
@spec new([A2UICore.Catalog.t()], keyword()) ::
  {:ok, t()} | {:error, A2UICore.Error.t()}
```

Creates the format. The catalogs must be non-empty, have distinct ids
and share a protocol version.

# `parser`
*since 0.1.0* 

```elixir
@spec parser(t()) :: A2UIAgent.DirectJson.Parser.t()
```

A fresh parser for the format's catalogs.

# `progressive_keys`
*since 0.1.0* 

```elixir
@spec progressive_keys() :: [String.t()]
```

The string properties commonly healed while streaming.

    iex> "text" in A2UIAgent.DirectJson.progressive_keys()
    true

# `prompt`
*since 0.1.0* 

```elixir
@spec prompt(t()) :: {:ok, String.t()} | {:error, A2UICore.Error.t()}
```

The system prompt snippet; see `A2UIAgent.DirectJson.Prompt`.

---

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