Files
kuentagym/api
dsantillan 238eb635c5
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Configure the Coach from the environment
An instance can now be pointed at a model entirely from its environment — so a
container is redeployed with the Coach already working, and nobody has to open
an admin screen:

    COACH_PROVIDER=compatible
    COACH_BASE_URL=https://ai.example.com     # WITHOUT /v1 — the adapter adds it
    COACH_MODEL=vendor/model-name
    COACH_API_KEY=sk-...                      # or the provider's own variable

Naming a provider is the whole configuration, so it also turns the Coach on: an
instance started this way that then reported itself "off" would be a puzzle with
no clue in it.

Three decisions worth stating:

- The environment is the *base*, the way DEFAULTS is, and the saved file is
  layered on top: an admin who picked a provider in the app meant it, and this
  only fills what is absent.

- The key is deliberately NOT a field of the config. That object is cached,
  written to data/coach.json by any admin action, and included in the backup the
  docs tell people to make. envCredentialFor reads it from the process
  environment instead, so it is written nowhere and never surfaced by any route
  that reports configuration. A pasted credential still outranks it, and a filed
  one that fails to decrypt stays a failure rather than quietly falling back to
  a key nobody knows is being spent.

- What the environment supplies is stripped before the file is written. A saved
  config used to be written back whole, which would have frozen this start-up's
  values on disk — and since the file outranks the environment, a later change
  to COACH_MODEL would have been silently ignored.

Verified through the server's own path (config → credentialFor → jobEnv →
adapter) against the OpenAI-compatible router this fork runs on: a chest+triceps
request came back as a six-exercise routine with the cardio row first and
correctly marked `mode: cardio`.
2026-09-21 15:16:50 -04:00
..