{# an agent's face: the first letter of its name on its own colour #} {% macro avatar(agent, size="sm") %}
{{ agent.name[:1] | upper }}
{% endmacro %} {# a plugin's logo, standing for its name; a puzzle piece for a kind without one #} {% macro logo(kind) %}{% include ["agents/logos/" ~ kind ~ ".svg", "agents/icons/puzzle.svg"] %}{% endmacro %} {# how an agent is: at work for how long, idle, failed and why, or offline while its computer is away #} {% macro status(row) %} {% set state = row.state %} {% if state == "working" %}{{ row.activity.working.since_ms | lasted }} {% elif state == "failed" %}{{ row.activity.reason or t.text("agents.state.failed") }} {% elif state == "offline" %}{{ t.text("agents.state.offline") }} {% else %}{{ t.text("agents.idle") }}{% endif %} {% endmacro %} {# where an agent talks: a line a channel, its logo and the bot's name as its connection reported it #} {% macro channels(row) %}
{% for provider in row.kept.agent.channel %} {% set link = (row.activity.channels | selectattr("connection", "equalto", provider.connection) | first | default(none)) if row.activity else none %} {{ logo(provider.kind) }}{{ (link.identity.name or link.identity.id) if link and link.identity else "—" }} {% else %}—{% endfor %}
{% endmacro %} {% macro quota(row, provider, detailed=false) %} {% set runtime = (row.activity.runtimes | selectattr("connection", "equalto", provider.connection) | first | default(none)) if row.activity else none %} {% if runtime and runtime.quota and runtime.quota.windows %}
{% for window in runtime.quota.windows %} {% set minutes = window.duration_minutes %} {% set pct = "%g" | format(window.remaining_pct | round(1)) %} {% set reset = detailed and window.resets_at_ms is not none %} {{ pct }}% {% if window.name or minutes or reset %} {% if window.name or minutes %} {%- if window.name %}{{ window.name }} {% endif -%} {%- if minutes and minutes % 1440 == 0 %}{{ t.text("agents.quota.days", {"n": minutes // 1440}) }}{% elif minutes and minutes % 60 == 0 %}{{ t.text("agents.quota.hours", {"n": minutes // 60}) }}{% elif minutes %}{{ t.text("agents.quota.minutes", {"n": minutes}) }}{% endif -%} {% endif %} {% if reset %}{{ t.text("agents.quota.resets", {"when": window.resets_at_ms | moment}) }}{% endif %} {% endif %} {% endfor %}
{% else %}
{{ t.text("agents.quota.unknown") }}
{% endif %} {% endmacro %} {# what an agent runs on, in the order it tries them: the first in use, the rest standing by #} {% macro runtimes(row) %}
{% for provider in row.kept.agent.harness %}
{{ logo(provider.kind) }} {{ provider["values"].get("model") or t.text("agents.model.default") }} {% if not loop.first %}{{ t.text("agents.standby") }}{% endif %} {{ quota(row, provider) }}
{% else %}—{% endfor %}
{% endmacro %} {# today's tokens and what they cost #} {% macro usage(row) %} {% if row.activity and (row.activity.usage.input or row.activity.usage.output) %}
{{ (row.activity.usage.input + row.activity.usage.output) | tokens }}{% if row.activity.usage.cost is not none %}${{ "%.2f" | format(row.activity.usage.cost) }}{% endif %}
{% else %}
—
{% endif %} {% endmacro %} {# a channel of the draft by the bot its connection reported, else its first value; a runtime by its model #} {% macro headline(row, label, item) -%} {% if label == "harness" %}{{ item["values"].get("model") or t.text("agents.model.default") }} {%- else %}{% set link = (row.activity.channels | selectattr("connection", "equalto", item.connection) | first | default(none)) if row and row.activity and item.connection else none %}{{ (link.identity.name or link.identity.id) if link and link.identity else (item["values"].values() | select("string") | first | default("—")) }}{% endif %} {%- endmacro %} {# what else an item holds, in its plugin's words: values worded where the plugin words them, efforts after their field's name, credentials only as saved, typed or how an empty one runs #} {% macro summary(schema, item) -%} {% set parts = [] %} {% for name, field in (schema.get("properties") or {}).items() %} {% set value = item["values"].get(name) %} {% if field.get("writeOnly") %} {% if name in item.new %}{% set _ = parts.append(t.text("agents.secret.typed", {"name": schema | word(name ~ ".title", name)})) %} {% elif name in item.secrets %}{% set _ = parts.append(t.text("agents.secret.saved_named", {"name": schema | word(name ~ ".title", name)})) %} {% elif schema | word(name ~ ".empty") %}{% set _ = parts.append(schema | word(name ~ ".empty")) %}{% endif %} {% elif field.get("x-inspect") == "models" or value is none or value == "" %} {% elif field.get("x-inspect") == "efforts" %}{% set _ = parts.append((schema | word(name ~ ".title", name)) ~ " " ~ (schema | word(name ~ "." ~ value, value | string))) %} {% else %}{% set _ = parts.append(schema | word(name ~ "." ~ value, value | string)) %}{% endif %} {% endfor %} {{- parts | join(" · ") -}} {%- endmacro %}