# `SuperPi.UI.PermissionPrompt`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/ui/permission_prompt.ex#L1)

Asks a human whether a blocked tool call may run. Used by `SuperPi.Plugins.Permissions` and
`SuperPi.Plugins.Hooks`.

The question travels as a `permission_request` event through `SuperPi.UI.Broker`. The answer is
the `option_id` of one of the four options (ACP `PermissionOptionKind`): `allow_once`,
`allow_always`, `reject_once`, `reject_always`.

**Fail closed.** `ask/2` returns `:unavailable` when no client can answer, when the question times
out or is cancelled, and when the answer cannot be read. A caller treats `:unavailable` exactly like
the block that it would have returned without a prompt, with the same message. Prompting is on by
default and `config :super_pi, :permissions, interactive_prompts: false` turns it off.

# `answer`

```elixir
@type answer() ::
  :allow_once | :allow_always | :reject_once | :reject_always | :unavailable
```

# `ask`

```elixir
@spec ask(map(), map()) :: answer()
```

Asks about one tool call. `fields` has `"tool_name"`, `"arguments"`, `"reason"` and `"risk"`.
`ctx` supplies `:conversation_id`, `:tool_call_id` and `:turn_id`.

# `available?`

```elixir
@spec available?(integer() | nil, map()) :: boolean()
```

True when a prompt can be shown now: enabled, and a client answers for the conversation.

# `enabled?`

```elixir
@spec enabled?(map()) :: boolean()
```

True when prompts are enabled in `settings`.

---

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