{# Guided agent setup (ADR-0018's onboarding half) as ONE flow with numbered stages: Endpoint -> Harness -> MCP config -> Try it. It has two entry points (/setup/agent and /settings/agent) and one implementation; Settings -> Status re-runs the Try it check from the same service call. Every fact is the service's own (clear_record.service.setup / clear_record.service.agent_flow): the resolved endpoint and model, the config problems, what a probe found, and the hello-world check's finding. The console only renders and translates -- it never recomputes the service's answer. A credential is never shown and never written: api_key_env is a variable NAME, and a local endpoint has none at all. #} {# No id here: index.html's mount owns #agent-setup, and this fragment is swapped into it -- a second id would make the htmx target ambiguous. #}
{% if setup.state == 'ready' %} {{ tr("agent ready") }} {% elif setup.state == 'problem' %} {{ tr("agent config problem") }} {% else %} {{ tr("no endpoint configured") }} {% endif %}
{% if error %}{% endif %} {% if notice %}

{{ notice }}

{% endif %}
  1. {{ tr("Endpoint") }}

    {{ tr("Connect an OpenAI-compatible model endpoint. The same endpoint is what the agent tasks and the MCP harness use.") }}

    {% if setup.state == 'ready' %}

    {{ tr("Endpoint: {endpoint}", endpoint=setup.endpoint or tr("the configured command template")) }}

    {% if setup.model %}

    {{ tr("Model: {model}", model=setup.model) }}

    {% endif %} {% if setup.api_key_env %}

    {{ tr("Key read from the environment variable {name}; never stored.", name=setup.api_key_env) }}

    {% endif %} {% if setup.api_key_env %}
    export {{ setup.api_key_env }}='your-key'
    {% endif %} {% if setup.commands %}

    {{ tr("Command templates: {kinds}", kinds=setup.commands | join(', ')) }}

    {% endif %} {% else %}

    {{ tr("No agent endpoint is configured yet, so agent tasks cannot run. Start a local OpenAI-compatible server (Ollama, LM Studio or llama.cpp) and detect it, or enter an address below.") }}

    {% endif %} {% for problem in setup.problems %} {# The service's own wording, shown verbatim: a config problem is a runtime string (it embeds the config path), not an extractable message ID, so wrapping it in tr() was a no-op. The console never restates the rule. #} {% endfor %} {% if setup.detection %}
      {% for probe in setup.detection.probes %}
    • {{ probe.candidate.label }} {{ probe.candidate.base_url }} {% if probe.verified %} {{ tr("verified") }} {% elif probe.reachable %} {{ tr("reachable") }} {% else %} {{ tr("not running") }} {% endif %}
      {% if probe.verified %}
      {{ tr("Verified with a test call to {model}.", model=probe.verified_model or tr("the server's model")) }}
      {% elif probe.reachable %} {% if probe.verify_detail %}{% endif %} {% if probe.models %}
      {{ tr("Models:") }} {{ probe.models | join(', ') }}
      {% else %}
      {{ tr("The server answers but serves no model yet.") }}
      {% endif %} {% else %} {% if probe.detail %}
      {{ probe.detail.render(tr) }}
      {% endif %} {# The hint is the plain "what to install or run" this rung owes the user. #}
      {{ tr(probe.candidate.install_hint) }}
      {% endif %} {% if not setup.configured and probe.reachable %} {# hx-vals carries the probed endpoint, so the form stays exactly the user's editable model field -- and no field markup the CSS scanner would read as a utility class. #}
      {% endif %} {% if not setup.configured and probe.pull_supported %}
      {% endif %}
    • {% endfor %}
    {% else %}

    {% endif %} {% if not setup.configured %}

    {{ tr("clear-record never stores a key: a hosted endpoint names the environment variable that holds it, and a local endpoint needs none.") }}

    export MY_KEY='your-key'

    {{ tr("Run that export in the shell that launches clear-record (or restart the server after setting it), then type the same variable name in the field above. A local endpoint needs no key.") }}

    {% endif %}
  2. {{ tr("Harness") }}

    {% include "_harness_setup.html" %}
  3. {{ tr("MCP config") }}

    {% include "_mcp_config.html" %}
  4. {{ tr("Try it") }}

    {{ tr("Run the whole chain once: a hello-world tape through transcription, read back as the transcript an MCP agent receives.") }}

    {% include "_hello_check.html" %}