{# how the agent, each of its channels and each of its runtimes are, and today's usage, as its computer last said #} {% set activity = row.activity %}

{{ t.text("agents.activity.state") }}

{% if row.online %}{{ t.text("agents.activity.said", {"computer": row.computer.name}) }}{% else %}{{ t.text("agents.activity.away", {"computer": row.computer.name if row.computer else "—"}) }}{% endif %}
{{ t.text("agents.column.agent") }}
{{ t.text("agents.state." ~ row.state if row.state != "idle" else "agents.idle") }}{% if row.state == "working" %} · {{ activity.working.since_ms | lasted }}{% elif row.state == "failed" and activity.reason %} · {{ activity.reason }}{% endif %} {% if activity and activity.started_at_ms %}{{ t.text("agents.activity.running", {"lasted": activity.started_at_ms | lasted, "clock": activity.started_at_ms | clock}) }}{% if activity.event_at_ms %} · {{ t.text("agents.activity.last", {"ago": activity.event_at_ms | ago}) }}{% endif %}{% endif %}

{{ t.text("agents.column.channel") }}

{{ t.text("agents.activity.channels", {"n": agent.channel | length}) }}
{% for provider in agent.channel %} {% set link = (activity.channels | selectattr("connection", "equalto", provider.connection) | first | default(none)) if activity else none %}
{{ m.logo(provider.kind) }}{{ (link.identity.name or link.identity.id) if link and link.identity else provider.kind }}
{% if not link or not row.online %}{{ t.text("agents.state.offline") if not row.online else "—" }} {% elif link.state == "running" %}{% include "agents/icons/check.svg" %}{{ t.text("agents.link.running") }} {% elif link.state == "reconnecting" %}{{ t.text("agents.link.reconnecting", {"n": link.failures}) }} {% elif link.state == "disconnected" %}{{ t.text("agents.link.disconnected") }} {% else %}{{ link.state }}{% endif %} {% if link %}
{{ t.text("agents.link.connected") }}{{ link.connected_at_ms | clock if link.connected_at_ms else "—" }} {{ t.text("agents.link.received") }}{{ link.received_at_ms | ago if link.received_at_ms else "—" }} {{ t.text("agents.link.error") }}{{ link.error or t.text("agents.link.no_error") }}
{% endif %}
{% endfor %}

{{ t.text("agents.column.runtime") }}

{{ t.text("agents.activity.order") }}
{% for provider in agent.harness %}
{{ loop.index }}{{ m.logo(provider.kind) }}{{ provider["values"].get("model") or t.text("agents.model.default") }}
…
{% endfor %}

{{ t.text("agents.column.usage") }}

{% set usage = activity.usage if activity else none %}
{{ (usage.input + usage.output) | tokens if usage else "—" }}tokens{% if usage and usage.cost is not none %} · ${{ "%.2f" | format(usage.cost) }}{% endif %}
{{ t.text("agents.usage.input") }}{{ usage.input | tokens if usage else "—" }}
{{ t.text("agents.usage.cached") }}{% if usage %}{{ usage.cached | tokens }}{% if usage.input %} · {{ (usage.cached * 100 / usage.input) | round | int }}%{% endif %}{% else %}—{% endif %}
{{ t.text("agents.usage.output") }}{{ usage.output | tokens if usage else "—" }}
{{ t.text("agents.usage.cost") }}{{ "$%.2f" | format(usage.cost) if usage and usage.cost is not none else "—" }}
{% include "agents/icons/monitor.svg" %}
{{ t.text("agents.activity.note", {"computer": row.computer.name if row.computer else "—"}) }}