{% extends "space-settings-base.html" %} {% from "icons.html" import icon %} {% from "ui.html" import action, when with context %} {% from "routine-ui.html" import schedule, outputs with context %} {% set section = "routines" %} {% set base = "/o/" ~ org.slug ~ "/" ~ space.slug ~ "/-/routines" %} {% set wiki = "/o/" ~ org.slug ~ "/" ~ space.slug %} {% set triggers = {'schedule': _("scheduled"), 'manual': _("manual")} %} {% block section %}

{{ icon('chevron-left', 14) }}{{ _("All routines") }}

{{ routine.name }}

{{ schedule(routine, weekdays) }} ({{ space.tidy_timezone }}) {% set upcoming = next_run(routine, space) %}{% if upcoming %}{{ (_("Next run: {when}")|e).format(when=when(upcoming)) }}{% endif %}

{{ _("Enabled", context="routine") if routine.enabled else _("Disabled", context="routine") }}
{% if manage %}
{% if ai_configured and not spending.exhausted %}{{ action(base ~ "/" ~ routine.id ~ "/run", _("Run now"), confirm=_("Run the routine now? The run uses tokens counted in the month's budget."), kind="primary") }}{% endif %} {{ _("Edit") }} {{ action(base ~ "/" ~ routine.id ~ "/toggle", _("Deactivate") if routine.enabled else _("Enable"), kind="quiet") }} {{ action(base ~ "/" ~ routine.id ~ "/delete", _("Delete"), confirm=_("Delete the “{name}” routine? Its runs stay counted in the month's budget, and its report page stays in the wiki.", name=routine.name), kind="danger") }}
{% endif %} {% if not ai_configured %}

{{ _("No AI provider is configured for the organization: routines cannot run.") }}

{% endif %}
{{ _("Scope") }}
{% if routine.scope %}{% for folder in routine.scope %}{{ folder }}/{% if not loop.last %}, {% endif %}{% endfor %}{% else %}{{ _("The whole space") }}{% endif %}
{{ _("Outputs") }}
{{ outputs(routine, wiki) }}
{{ _("Instructions") }}
{{ routine.instructions }}

{{ _("Runs") }}

{% if poll %}{% endif %}
{% if routine.requested %}

{{ _("Waiting for the worker") }}

{{ _("The run starts as soon as the worker is free (never during a tidy-up run of the space).") }}

{% endif %} {% for view in runs %}{% set run = view.run %}{% set why = view.explanation %}

{%- if run.status == 'running' %}{{ _("Running…") }} {%- elif run.status == 'failed' %}{{ _("Failed · {cause}", cause=_(why.label)) }} {%- else %}{{ _("Done") }}{% endif -%}

{{ when(run.started_at) }} · {{ triggers.get(run.trigger, run.trigger) }}

{% if run.summary %}

{{ log_text(run.summary) }}

{% endif %} {% if why %}
{% if manage %}

{{ _(why.message, **why.params) }} {{ _("Nothing was published.") }}

{% if why.show_detail %}

{{ _("Technical detail: {detail}", detail=why.detail) }}

{% endif %} {% else %}

{{ _("Cause: {cause}.", cause=_(why.label)) }} {{ _("Nothing was published.") }}

{% endif %}
{% endif %} {% set out = run.outputs or {} %} {% if out %}
    {% if out.page %}
  • {{ _("Page rewritten") }} {{ out.page }}
  • {% endif %} {% if out.inbox %}
  • {{ _(pl(out.inbox|length, "{n} item dropped into the inbox", "{n} items dropped into the inbox"), n=out.inbox|length) }} {{ out.inbox|join(" · ") }}
  • {% endif %} {% if out.emails is defined %}
  • {{ _(pl(out.emails, "{n} email sent", "{n} emails sent"), n=out.emails) }}
  • {% endif %} {% if out.webhook %}
  • {{ _("routine.done webhook sent") }}
  • {% endif %}
{% endif %} {% if run.report %}
{{ _("Output text") }}
{{ run.report }}
{% endif %} {% if run.status != 'running' and (run.model or view.tokens or run.commit) %}
{% if run.model %}{{ _("Model: {model}", model=run.model) }} · {% endif %}{{ _(pl(view.tokens, "{n} token", "{n} tokens"), n="{:,}".format(view.tokens).replace(",", " ")) }}{% if run.cost is not none %} · {{ _("≈ {amount}", amount=run.cost|euros) }}{% endif %}{% if run.quota %} · {{ _("subscription quota: {usage}", usage=run.quota|quota_summary) }}{% endif %}{% if run.commit %} · {{ run.commit[:10] }}{% endif %}
{% endif %}
{% else %} {% if not routine.requested %}

{{ _("No runs yet.") }}

{% endif %} {% endfor %}
{% endblock %}