15 · AI

Tool

state running · waiting · done · error · denied

Represents a tool or integration the AI can use, with status and scope.

A tool running until it finishes

sefaz.autorizar NF-e 48.211
.heex
<.tool id="tool-1" variant="panel" icon="tool" state="running" indicator="ring" title="sefaz.autorizar" description="NF-e 48.211" class="max-w-[460px]" />

state running · waiting · done · error · denied

Transmitindo à SEFAZ running
Aguardando aprovação waiting
XML assinado done
Certificado vencido error
Acesso negado denied
.heex
<div class="flex flex-col gap-2">
  <.tool id="tool-running" variant="panel" icon="tool" state="running" title="Transmitindo à SEFAZ" class="max-w-[460px]" />
  <.tool id="tool-waiting" variant="panel" icon="tool" state="waiting" title="Aguardando aprovação" class="max-w-[460px]" />
  <.tool id="tool-done" variant="panel" icon="tool" state="done" title="XML assinado" class="max-w-[460px]" />
  <.tool id="tool-error" variant="panel" icon="tool" state="error" title="Certificado vencido" class="max-w-[460px]" />
  <.tool id="tool-denied" variant="panel" icon="tool" state="denied" title="Acesso negado" class="max-w-[460px]" />
</div>

Usage

<.tool name="Stripe" status={:connected} scopes={~w(read:subscriptions)} />

Rules

  • Scopes in mono; status with a badge + a switch to enable it.

API reference

Todos os function components, atributos, valores e slots que este componente cobre.

A tool call an agent makes (running a command, reading a file), from input to output, as a line of a LedgerUI.Components.Trace.trace/1: a plain line while it runs, a step that opens on its output once it has one, red when it fails. A call that waits for the user is a tool_approval/1 card with Deny and Approve.

<.trace>
  <.tool id="t1" state="running" subject="pnpm install" />
  <.tool id="t2" state="done" subject="node --version" output="v24.18.0" />
  <.tool id="t3" state="error" subject="pnpm lint" output={@stderr} />
</.trace>

States

state line title (en / pt_BR)
running running (spinner) Running ... / Rodando ...
waiting pending (faded) Waiting to run ... / Aguardando ...
done plain Ran ... / Rodou ...
error error (red) Failed to run ... / Falhou ao rodar ...
denied plain Denied ... / Negado ...

verbs overrides them per state (verbs={%{done: "Read", running: "Reading"}}) and title replaces the whole title. subject is drawn as code.

variant="panel" draws the call as a panel (tool icon, title, state badge or spinner) instead of a line of a trace; input / output are only shown by the line variant.

<.tool>

One tool call, as a line of a trace/1 (or a panel).

Attr Type Default Values / notes
id (required) :string Names the output block.
state :string "done" running, waiting, done, error, denied
subject :string nil What the tool acted on, drawn as code.
title :string nil The whole title, in place of verb and subject.
verbs :map %{} Verbs per state (atom keys), over the locale ones.
locale :string "en" en, pt_BR
icon :string "terminal"
description :any nil
input :string nil
output :string nil
open :boolean false
variant :string "line" line, panel
indicator :string "badge" badge, ring - panel only: the state badge, or a spinner while running.
class :any nil

Any other HTML/phx attribute goes to the root element.

<.tool_approval>

A tool call that waits for the user: the question, the input and Deny / Approve.

Attr Type Default Values / notes
id (required) :string
subject :string nil What would run, drawn as code in the question.
title :string nil The question, in place of "Run subject?".
description :string nil
input :string nil
icon :string "terminal"
value :any nil Sent with both events.
on_approve :any nil
on_deny :any nil
target :any nil
approve_label :string nil
deny_label :string nil
locale :string "en" en, pt_BR
class :any nil

Any other HTML/phx attribute goes to the root element.