SuperPi.UI.PermissionPrompt (super_pi v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

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

True when prompts are enabled in settings.

Types

answer()

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

Functions

ask(ctx, fields)

@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?(conversation_id, settings)

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

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

enabled?(settings)

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

True when prompts are enabled in settings.