Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Preguntaste si se podía implementar Jev, y con qué API. Resulta que Jev se sirve por OpenCode Zen,
así que una sola cuenta cubre esto y cualquier otra cosa apuntada a ese gateway:
POST https://opencode.ai/zen/v1/systemone Bearer <clave> model: jev-1.13
Y ahí está la razón de que valga la pena: Jev no es un modelo de chat. Le mandás un *estado* y
preguntas tipadas — sí/no (`noul`), opción (`choice`), rúbrica (`score`) — y contesta todas en una
sola petición con el valor **y la probabilidad que le puso**. "62% probable" se puede discutir;
"tomate una semana de descarga" no. Así que no entra por el Coach (que necesita *escribir*) y no se
fuerza dentro de su lista de proveedores: tiene su módulo, sus dos rutas y su tarjeta.
Qué hace. En Salud, arriba de la grilla, una tarjeta con cuatro respuestas: qué tan listo estás para
entrenar fuerte (nivel 1-5, con el número al lado), si la semana pide bajar carga (62% probable), qué
parte del cuerpo parece menos recuperada, y qué métrica de salud merece atención — esa última con la
última lectura de la métrica que nombró, para que "vigilá tu frecuencia en reposo" venga con el 62
que lo motivó. La hoja detrás del ⓘ dice a dónde va y exactamente qué se envía, con el mismo resumen
que devuelve el servidor.
Lo que sale, y lo que no. Se decide en `api/jev.js` y son agregados: una semana de cada métrica por
campo como la escribió el teléfono, series por parte del cuerpo de 4 semanas y de la última, sesiones,
días desde la última, RPE medio, estancamientos *por nombre de ejercicio*, el último pesaje y su
cambio. Ningún identificador: ni perfil, ni nombre, ni títulos de entrenamientos, ni ids de
ejercicios, ni chat — hay un test que lo afirma sobre el JSON, porque es una promesa que hacen los
docs y nada más la miraba. La única excepción es deliberada y está documentada: la nota de
*limitaciones* del cuestionario del Coach, porque "hombro malo" cambia la respuesta. (Los títulos sí
estuvieron un rato ahí: los saqué al escribir ese test, y el test se quedó.)
Un juicio no es una instrucción, y el código lo trata así. Cada respuesta se muestra con su
probabilidad; una pregunta que el modelo no contestó se muestra como no contestada, nunca como un
cero; un nivel que no habíamos ofrecido se marca en vez de disfrazarse de propio; y si los datos
cambiaron desde que se pidió (una sesión registrada, una noche que llegó) la tarjeta lo dice en lugar
de seguir pareciendo actual. Tampoco corre por temporizador: cuesta una petición, así que pasa cuando
alguien aprieta *Preguntar*, con cupo por perfil y por día y un piso de diez minutos aplicados en el
servidor, no en la pantalla.
El Coach, además, lo recibe como `secondOpinion` en su payload **solo si tiene menos de seis horas**,
como evidencia con confianza adjunta para citar en `why`, nunca como una orden ni como un cambio de
plan. Es la mitad que faltaba de "y el Coach escribe con eso".
El lector de respuestas es tolerante a propósito: el contrato de la petición está documentado, la
respuesta no la vimos nunca del servicio real, así que acepta las formas plausibles
(`answers`/`results`, `option`/`answer`/`choice`, `probability` o una distribución sobre los niveles),
normaliza lo que encuentra y devuelve `null` por lo que no puede leer. El cuerpo crudo queda guardado
al lado del parseado (y sale con `?raw=1`): la primera llamada real se puede mirar, y una forma mal
adivinada es un arreglo, no un misterio.
Dos cosas que encontré escribiendo esto y que quedan arregladas: una variable de entorno vacía se
leía como **cero** (`Number('')` pasa un chequeo ingenuo), así que un cupo sin configurar era "cero
peticiones" — un feature que parece configurado y no funciona nunca; y agregar la palabra *Back*
para la espalda redefinió el botón *Atrás* de la app a "Espalda", porque en un objeto literal la
última clave gana y nada lo dice. El catálogo de español tiene ahora un test que falla si una clave
se escribe dos veces, mutación comprobada.
Cobertura: 11 tests del módulo (el estado, las preguntas, cada forma de respuesta, la promesa de
privacidad, el cupo), 5 de las rutas contra un gateway de mentira y el servidor real, 6 del modelo de
vista en el frontend y 5 de render por la tarjeta real. API 259 en verde, frontend 1696, build OK.
216 lines
11 KiB
Bash
216 lines
11 KiB
Bash
# Copy this file to ".env" and adjust for your setup, then: docker compose up -d
|
|
#
|
|
# ── Local testing (default) ────────────────────────────────────────────────
|
|
# Works out of the box on the machine running Docker. Open http://localhost:8080
|
|
RP_ID=localhost
|
|
ORIGIN=http://localhost:8080
|
|
WEB_PORT=8080
|
|
RP_NAME=KuentaGYM
|
|
|
|
# ── Real deployment behind your own HTTPS domain ───────────────────────────
|
|
# Passkeys are bound to the exact hostname, and browsers only allow them over
|
|
# HTTPS (localhost is the one exception). Put KuentaGYM behind a reverse proxy /
|
|
# tunnel that terminates TLS for your domain, then set:
|
|
#
|
|
# RP_ID=gym.example.com
|
|
# ORIGIN=https://gym.example.com
|
|
# WEB_PORT=8080
|
|
# RP_NAME=KuentaGYM
|
|
#
|
|
# (Point your proxy at the web container's WEB_PORT. See docs/SELF_HOSTING.md.)
|
|
|
|
# ── Admin dashboard & invite-only signup (optional) ────────────────────────
|
|
# Both off by default — a fresh instance has open signup and no admin.
|
|
#
|
|
# Make yourself an admin: register your own passkey profile first, find your
|
|
# user id in ./data/db.json ("users"[].id), then list it here (comma-separated
|
|
# for several admins). Admins get an "Admin dashboard" link in Settings to see
|
|
# users, disable accounts, generate invite codes and view workout history.
|
|
#
|
|
# ADMIN_UIDS=youruserid,anotheradmin
|
|
#
|
|
# Require an invite code to create new profiles (existing accounts keep working;
|
|
# generate the codes from the admin dashboard):
|
|
#
|
|
# INVITE_ONLY=1
|
|
#
|
|
# Remove the "Continue without account" button, so a profile is the only way in.
|
|
# Guest mode keeps everything in the browser and never touches this server, but
|
|
# on an instance meant for a known set of people it is still the wrong front
|
|
# door. Anyone already inside as a guest is signed out on their next visit; the
|
|
# data they made stays in that browser. Defaults to on (guests allowed):
|
|
#
|
|
# ALLOW_GUEST=0
|
|
|
|
# ── Activity log (optional) ────────────────────────────────────────────────
|
|
# The admin dashboard shows an activity log: who signed in, who tried and
|
|
# failed, and every admin action (disabling an account, creating or revoking an
|
|
# invite code). It lives in ./data/audit.log, one JSON object per line, so you
|
|
# can also just read it with `tail` or `jq`.
|
|
#
|
|
# It is ON by default. It records strictly less than this instance already
|
|
# holds — every profile is in db.json and every workout is in state-<uid>.json,
|
|
# both readable by any admin — and a log that ships switched off tells you
|
|
# nothing on the day you need it. Turn it off completely with:
|
|
#
|
|
# AUDIT_LOG=0
|
|
#
|
|
# Retention is a cap, not an archive. Whichever limit is reached first wins;
|
|
# set either to 0 to disable that limit:
|
|
#
|
|
# AUDIT_MAX=5000 # events kept
|
|
# AUDIT_DAYS=90 # days kept
|
|
#
|
|
# IP addresses are the one thing that is OFF unless you ask, because they are
|
|
# the only field here that says where somebody physically is. They are also the
|
|
# only way to tell one failed sign-in from twenty. Three settings:
|
|
#
|
|
# AUDIT_IP=off # default — no addresses at all
|
|
# AUDIT_IP=net # network only: 203.0.113.0/24, 2001:db8:1::/48
|
|
# AUDIT_IP=full # the whole address
|
|
#
|
|
# The address is read from CF-Connecting-IP, then the first entry of
|
|
# X-Forwarded-For, then X-Real-IP, and finally the connecting socket itself if
|
|
# none of those is present.
|
|
#
|
|
# A forwarded-for header is only worth anything if whatever sits in front
|
|
# OVERWRITES it instead of passing a client-supplied one through — otherwise a
|
|
# caller simply states the address it would like logged. The web container now
|
|
# overwrites X-Forwarded-For and X-Real-IP with the real peer, and DROPS
|
|
# CF-Connecting-IP, so the bundled stack records an address nobody can choose.
|
|
# (Before, X-Forwarded-For was appended to rather than replaced, and
|
|
# CF-Connecting-IP was passed straight through — both were forgeable.)
|
|
#
|
|
# Cloudflare is first in that list on purpose: a Cloudflare tunnel does not put
|
|
# the visitor in X-Forwarded-For at all, so that header would otherwise record
|
|
# the tunnel itself and look perfectly plausible. If — and only if — Cloudflare
|
|
# is genuinely in front of you, let its header through again:
|
|
#
|
|
# CF_CONNECTING_IP=$http_cf_connecting_ip
|
|
#
|
|
# That is safe there because Cloudflare sets the header itself, replacing
|
|
# anything the client sent. Anywhere else, leave it unset.
|
|
|
|
# ── Session length (optional) ──────────────────────────────────────────────
|
|
# How long a sign-in lasts, in days. Default 90 — long enough that people who
|
|
# train regularly never see a login screen, short enough that a stolen cookie
|
|
# doesn't stay good forever. Lower it for an instance on the open internet,
|
|
# raise it for a private one. Only affects new sign-ins; cookies already handed
|
|
# out keep the lifetime they were issued with. Users can end every session on
|
|
# every device themselves with "Sign out everywhere" in Settings.
|
|
#
|
|
# SESSION_DAYS=90
|
|
|
|
# ── Fitting into an existing stack (optional) ──────────────────────────────
|
|
# The defaults assume KuentaGYM is on its own: an API service called `api` on
|
|
# port 3000, and nginx listening on 80 inside the web container. If you are
|
|
# merging this into a compose file that already has an `api`, or you front the
|
|
# web container with your own reverse proxy, move them here. The web image
|
|
# renders its nginx config at start-up, so these apply to a prebuilt image and
|
|
# need no rebuild. BACKEND and PORT together are what /api is proxied to, so
|
|
# they must name a service the web container can reach on your network:
|
|
#
|
|
# NGINX_PORT=80
|
|
# BACKEND=api
|
|
# PORT=3000
|
|
#
|
|
# Serving KuentaGYM under a subpath (https://example.com/gym/)? If your reverse
|
|
# proxy strips the prefix before the container sees it, set nothing — the app
|
|
# asks its own address for the API. If it passes the prefix through, name it
|
|
# here without a trailing slash:
|
|
#
|
|
# BASE_PATH=/gym
|
|
|
|
# ── Notifications (optional) ───────────────────────────────────────────────
|
|
# Push works out of the box — nothing to set. VAPID keys are generated on first
|
|
# run and saved to ./data/vapid.json. Each user's browser reports its own
|
|
# timezone automatically, so the workout-day reminder fires at their local
|
|
# time regardless of where the server runs or where they're travelling.
|
|
#
|
|
# Push services want a contact address for whoever operates the server, in case
|
|
# they need to get in touch about your pushes. Defaults to your ORIGIN, which is
|
|
# fine; set a mailto: if you would rather they mailed you:
|
|
#
|
|
# VAPID_SUBJECT=mailto:you@example.com
|
|
|
|
# ── AI Coach (optional, off by default) ────────────────────────────────────
|
|
# The Coach stays off until an admin turns it on in Settings → Admin and
|
|
# connects a provider. An instance that never does is byte-for-byte the same
|
|
# app it was before the feature existed.
|
|
#
|
|
# Anthropic, OpenAI, Gemini and any OpenAI-compatible endpoint (Ollama, LM
|
|
# Studio, vLLM, OpenRouter…) are driven over plain HTTPS with an API key and
|
|
# need nothing that is not already in the default image. Nothing to set here.
|
|
#
|
|
# API_TARGET only matters if you want the Claude Agent SDK or the Codex CLI
|
|
# running inside the container. `default` carries no AI runtime at all — no
|
|
# Agent SDK, no Codex, no bubblewrap. `coach` adds them (~300 MB):
|
|
#
|
|
# API_TARGET=coach docker compose up -d --build api
|
|
#
|
|
# COACH_DISABLED is the kill switch that outranks the admin toggle. Set it when
|
|
# you want the Coach off for certain — after an incident, or on an instance
|
|
# where nobody should be able to turn it on:
|
|
#
|
|
# COACH_DISABLED=1
|
|
#
|
|
# COACH_JOB_TIMEOUT_MS gives a job longer than the default five minutes. Only a
|
|
# local model on a CPU needs it — and normally only for the first request after
|
|
# the model server restarts (the api pre-warms the rules cache after that; a
|
|
# warm review on a 3B model takes one to a few minutes, depending on the CPU).
|
|
# A hosted API that needs
|
|
# more has a problem. Never goes below one minute.
|
|
#
|
|
# COACH_JOB_TIMEOUT_MS=1500000
|
|
#
|
|
# ── Configuring the Coach from the environment ─────────────────────────────
|
|
# Optional, and the alternative to the admin screen: an instance can be given
|
|
# its provider at start-up, so a container is redeployed with the Coach already
|
|
# pointed at a model and nobody has to open Settings → AI Coach. Naming a
|
|
# provider here is the whole configuration — it also turns the Coach on — and
|
|
# anything chosen later in the app wins over it.
|
|
#
|
|
# COACH_PROVIDER=compatible
|
|
# COACH_BASE_URL=https://ai.example.com
|
|
# COACH_MODEL=vendor/model-name
|
|
# COACH_API_KEY=sk-...
|
|
#
|
|
# COACH_BASE_URL is the endpoint WITHOUT the /v1 suffix: the adapter appends
|
|
# /v1/chat/completions itself, which is why the built-in OpenAI default is
|
|
# https://api.openai.com and not .../v1. Getting this wrong looks like a
|
|
# mysterious "unexpected response shape" in the job log rather than a 404.
|
|
#
|
|
# COACH_API_KEY may be omitted in favour of the variable the provider itself
|
|
# declares — OPENAI_COMPAT_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY,
|
|
# ANTHROPIC_API_KEY — which is also the name the key is passed under when the
|
|
# request is made.
|
|
#
|
|
# A provider chosen in the app (or a key pasted there) outranks these: the
|
|
# environment configures an instance nobody has set up in the UI, and never
|
|
# overrides a choice someone made in one. What the environment supplies is
|
|
# deliberately NOT written back into ./data/coach.json, so changing a variable
|
|
# and redeploying always takes effect.
|
|
#
|
|
# Credentials never live in the config file. The ones pasted in the app are
|
|
# encrypted into ./data/coach.json, one per provider, or for the Codex provider
|
|
# cached in ./coach-auth — a sibling of ./data, never inside it, so a live
|
|
# sign-in does not ride along in the documented backup archive. A key set here
|
|
# is read from the environment at request time and written nowhere.
|
|
# See docs/AI_COACH.md.
|
|
# ── Hevy map regeneration (developers only) ────────────────────────────────
|
|
# Not used by the running app. End users paste their own key in Settings →
|
|
# Import from Hevy. Set this only to regenerate frontend/src/lib/hevy-id-map.js:
|
|
#
|
|
# HEVY_API_KEY=
|
|
# node scripts/build-hevy-id-map.mjs
|
|
|
|
# --- The second opinion (optional) -------------------------------------------------------------
|
|
# A judgment about the profile's own numbers, answered in probabilities by Jev — TypeSafe's System
|
|
# One model, served by the OpenCode Zen gateway. Off unless a key is set: with no key the card does
|
|
# not exist. Set JEV_MODEL=jev-1.13-free for the gateway's free tier.
|
|
# OPENCODE_API_KEY=…
|
|
# JEV_API_KEY=
|
|
# JEV_MODEL=jev-1.13
|
|
# JEV_BASE_URL=https://opencode.ai/zen
|
|
# JEV_MAX_PER_DAY=12
|