{% import "activity/macros.html" as m with context %} {% set short = ref(agent.id) %} {# the record follows the agent from its oldest line shown on: a change draws every line from there again, the newest at the top; a page further down moves where that is #} {% set oldest = events[-1].id if events else none %} {% set following = "/ui/activity/log/" ~ short ~ "/rows?filter=" ~ chosen ~ ("&start=" ~ oldest if oldest else "") %} {% if day is none %} {% elif oldest %}{% endif %} {% set kept = namespace(day=day) %} {% for event in events %} {% set source = sources[event.name] %} {% set named = names.get(event.thread_id) %} {% set turn = turns.get((agent.id, event.turn_id)) %} {% set when = event.at_ms | dated %} {% if when != kept.day %}
{{ when }}
{% set kept.day = when %}{% endif %}
{{ (event.at_ms | time)[:5] }} {{ t.text("activity.source." ~ source) }} {% if event.name in ("harness.turn.requested", "runtime.request.turn.started") %} {{ t.text("activity.log.started") }} {{ m.conversation(named) }} {{ models.get(event.context.get("connection")) or "" }} {% elif event.name in ("harness.completed", "runtime.turn.completed") %} {{ t.text("activity.log.completed") }} · {{ m.conversation(named) }} {% if turn and turn.ended_ms %}{{ (turn.ended_ms - turn.started_ms) | duration }} · {{ t.text("activity.input") }} {{ (turn.input + turn.cached) | tokens }} · {{ t.text("activity.output") }} {{ turn.output | tokens }} · {{ t.text("activity.hits") }} {{ m.hits(turn) }}{% if turn.calls.total %} · {{ t.text("activity.log.tools", {"n": turn.calls.total}) }}{% endif %}{% endif %} {% elif event.name in ("harness.cancelled", "runtime.turn.cancelled") %} {{ t.text("activity.log.cancelled") }} · {{ m.conversation(named) }} {% elif event.name in ("harness.failed", "runtime.turn.failed", "runtime.turn.unknown") %} {{ m.icon("triangle-alert") }}{{ t.text("activity.log.failed") }} · {{ m.conversation(named) }} {{ event.error or "" }} {% elif event.name == "channel.inbound.persisted" %} {% set grouped = named is not none and named.kind == "group" %} {{ t.text("activity.log.received") }} {{ m.sender(event) }}{% if grouped %} {{ t.text("activity.log.in") }} {{ m.conversation(named) }}{% endif %} {{ t.text("activity.log.message") }} {% if grouped %}{{ m.conversation(named) }} · {% endif %}“{{ event.metadata.get("text") or "" }}” {% elif event.name in ("channel.outbound.sent", "channel.outbound.partial", "channel.outbound.queued") %} {{ t.text("activity.log.replied") }} {{ m.conversation(named) }} “{{ event.metadata.get("text") or "" }}” {% elif event.name in ("channel.outbound.failed", "channel.outbound.unknown") %} {{ m.icon("triangle-alert") }}{{ t.text("activity.log.unsent") }} · {{ m.conversation(named) }} {{ event.error or "" }} {% elif event.name == "channel.connection.connected" %} {% set identity = event.payload.get("identity") or {} %} {{ m.logo(event.context.get("channel")) }}{{ t.text("activity.log.reconnected" if event.id in back else "activity.log.connected") }} {{ identity.get("name") or identity.get("id") or "" }} {% elif event.name == "channel.connection.failed" %} {% set retry = event.payload.get("retry_in_ms") %} {{ m.icon("triangle-alert") }}{{ m.logo(event.context.get("channel")) }}{{ t.text("activity.log.disconnected") }} {% if event.error %}{{ event.error }} · {% endif %}{{ t.text("activity.log.retry", {"n": (retry / 1000) | round | int}) if retry is not none else t.text("activity.log.given_up") }} {% elif event.name in ("harness.tool.completed", "harness.tool.failed") and calls.get(event.id) %} {% set call = calls[event.id] %} {% set detail = call.detail %} {% if event.name == "harness.tool.failed" %}{{ m.icon("triangle-alert") }}{% endif %}{{ m.call(call) }} {{ m.about(call) }}{% if event.name == "harness.tool.failed" and event.error %} {{ event.error }}{% endif %}{% if event.omitted %} · {{ t.text("activity.log.omitted") }}{% endif %} {%- if detail.kind == "command" and detail.exit_code is not none %}{{ t.text("activity.log.exit", {"code": detail.exit_code}) }}{% endif %} {%- if detail.kind == "command" and detail.exit_code is not none and call.duration_ms is not none %} · {% endif %} {%- if detail.kind == "command" and call.duration_ms is not none %}{{ call.duration_ms | duration }}{% endif %} {%- if detail.kind == "command" and detail.output and not event.omitted %}{% endif -%} {% if detail.kind == "command" and detail.output %}
{% endif %}
  {% elif event.name in ("harness.tool.completed", "harness.tool.failed", "tool_call.completed", "tool_call.failed") %}
  {# a call 0.2 kept by its name, or one whose start is gone too #}
  {% if event.name.endswith(".failed") %}{{ m.icon("triangle-alert") }}{% endif %}{{ t.text("activity.call.tool") }} {{ event.metadata.get("name") or "—" }}
  {% if event.omitted %}{{ t.text("activity.log.omitted") }}{% endif %}
  {% elif event.name == "harness.pool.banned" %}
  {% set banned = event.context.get("connection") %}
  {% set fallback = event.payload.get("fallback") %}
  {{ m.icon("triangle-alert") }}{{ t.text("activity.log.banned_to" if fallback else "activity.log.banned", {"from": models.get(banned) or banned or "—", "to": models.get(fallback) or fallback}) }}
  {{ m.conversation(named) }}
  {% elif event.name == "reminder.fired" %}
  {{ t.text("activity.reminder") }} · {{ event.metadata.get("title") or "" }}
  {{ event.metadata.get("title") or "" }} · {{ m.conversation(named) }}
  {% endif %}
{% else %} {% if day is none %}

{{ t.text("activity.log.none") }}

{% endif %} {% endfor %} {% if more %}
{% endif %}