# deploy/compose — the v0.12 control-plane stack (P4) + its readiness proof (P5, gate:compose).
#
# The stack-readiness proof (tests/stack_test.py) owns the full up→prove→down lifecycle in its
# session fixture, so `make stack-test` is the one entrypoint the gate calls. The bare up/down
# targets below are for hand-driving the stack during development.
PROJECT ?= vexa-v012
BROWSER_IMAGE ?= mock-bot:dev
EMAIL ?= self-host@vexa.ai
SCOPES ?= bot,tx
COMPOSE  = docker compose -p $(PROJECT) -f docker-compose.yml
# Install pulls the published bot (vexaai/vexa-bot:$IMAGE_TAG — release-validated).
# `make bot` builds from source into the LOCAL namespace (vexa/, like vexa/meet-join-env:dev) so a
# source build can never shadow the published pointer (#569).
REPO_ROOT := $(abspath ../..)
BOT_IMAGE ?= vexa/vexa-bot:dev

.PHONY: stack-test stack-test-bot stack-test-mock stack-test-v010 provision-token up dev digest-audit down destroy help build ps logs bot _preflight _bot_check _creds_check _access _storage_note migrate-storage rotate-db-password

## provision-token — mint (idempotently) an API token on this deployment.
## Needs ADMIN_TOKEN (the stack admin secret). Prints ONLY the token, so it pipes into a command:
##   KEY=$$(make -s provision-token ADMIN_TOKEN=<secret>)
## ADMIN_API_URL is resolved HERE, from this deployment's own .env, because the script has no
## default any more: it mints a token, and a guessed host port mints it on a neighbouring stack.
## Same resolution `_access` already does — one deployment, one place that knows its port.
provision-token:
	@APORT=$$(grep -E "^ADMIN_API_PORT=" .env 2>/dev/null | head -1 | cut -d= -f2- | sed -E 's/[[:space:]]+#.*$$//; s/[[:space:]]+$$//'); APORT=$${APORT:-18057}; \
	 ADMIN_TOKEN="$(ADMIN_TOKEN)" EMAIL="$(EMAIL)" SCOPES="$(SCOPES)" \
	 ADMIN_API_URL="$${ADMIN_API_URL:-http://127.0.0.1:$$APORT}" ./bin/provision-token

## rotate-db-password — give an EXISTING database a fresh password (postgres refuses to start on an
## unset or published DB_PASSWORD, and an install made from an older .env.example holds `postgres`).
## Mints the value into .env, starts postgres alone with it (an initialised data directory ignores
## POSTGRES_PASSWORD), applies it inside the database over the local socket — no old password needed,
## and the value is never on a command line or printed — then recreates the stack on the new value.
rotate-db-password:
	@test -f .env || { echo "no .env here — a new install mints DB_PASSWORD with 'make up'"; exit 1; }
	@user=$$(grep -E '^DB_USER=' .env | head -1 | cut -d= -f2- | tr -d '[:space:]'); user=$${user:-postgres}; \
	 new=$$(openssl rand -hex 32); \
	 if grep -qE '^DB_PASSWORD=' .env; then sed -i.bak "s|^DB_PASSWORD=.*|DB_PASSWORD=$$new|" .env && rm -f .env.bak; \
	 else echo "DB_PASSWORD=$$new" >> .env; fi; \
	 $(COMPOSE) up -d --no-build postgres; \
	 for i in $$(seq 1 30); do $(COMPOSE) exec -T postgres pg_isready -U "$$user" -q && break; sleep 2; done; \
	 printf "ALTER USER \"%s\" PASSWORD '%s';\n" "$$user" "$$new" \
	   | $(COMPOSE) exec -T postgres psql -U "$$user" -d postgres -v ON_ERROR_STOP=1 -q; \
	 $(COMPOSE) up -d --no-build; \
	 echo "rotated the database password of $$user; the new value is in .env"

## stack-test — the always-on gate:compose proof (brings the stack up + down itself).
stack-test:
	./bin/stack-test

## stack-test-bot — + the real bot-spawn proof (COMPOSE_BOT=1; slow, needs vexaai/vexa-bot:$IMAGE_TAG).
stack-test-bot:
	COMPOSE_BOT=1 ./bin/stack-test

## stack-test-stress — the control plane under CONCURRENT load (A:V2): N mock bots at once, no cap overspill.
## Needs mock-bot:dev. Tune STRESS_N / STRESS_CAP. Pass COMPOSE_PROJECT + STORAGE_HOST_PORT to isolate on a shared dev host.
stack-test-stress:
	COMPOSE_STRESS=1 MOCK_BOT=1 BROWSER_IMAGE=$(BROWSER_IMAGE) ./bin/stack-test

## stack-test-chaos — the control plane RECOVERS from injected faults (A:V3): a redis/meeting-api blip
## (docker pause/unpause) mid-run → the FSM still reaches terminal. Needs mock-bot:dev.
stack-test-chaos:
	COMPOSE_CHAOS=1 MOCK_BOT=1 BROWSER_IMAGE=$(BROWSER_IMAGE) ./bin/stack-test chaos_test.py

## stack-test-mock — the FULL control-plane lifecycle at L3 via the mock bot (A:V1). Needs mock-bot:dev
## (build: docker build -f ../../core/meetings/services/bot/Dockerfile.mock -t mock-bot:dev ../../). Runs
## the always-on subset PLUS the MOCK_BOT scenarios (normal/reject/crash/timeout/emit/stop/max-bots/
## speak/canAccess) — no browser/STT. Pass COMPOSE_PROJECT to isolate on a shared host.
stack-test-mock:
	MOCK_BOT=1 BROWSER_IMAGE=$(BROWSER_IMAGE) ./bin/stack-test

## stack-test-v010 — the 0.10 API backward-compat behavioral suite (release DoD 6): a 0.10-style
## client's real REST + WS flows against the running 0.12 stack, MOCK_BOT scenarios only. Opt-in
## via V010_COMPAT=1 (without it the compat dir is not even collected — the default gate:compose
## collection is unchanged). Needs mock-bot:dev, like stack-test-mock. Runs ONLY tests/compat/.
stack-test-v010:
	V010_COMPAT=1 MOCK_BOT=1 BROWSER_IMAGE=$(BROWSER_IMAGE) ./bin/stack-test compat

## stack-test-client-compat — the `client-compat` check (Task #1919): what clients already deployed
## against 0.12 still need from a 0.13.4 stack (`/ws?api_key=`, a bot-only key streaming its own
## meeting, nothing for another user's). One file of the compat suite above, run on its own; the
## release-validate `validate-v010-compat` leg collects it with that suite. Needs mock-bot:dev. Pass
## IMAGE_TAG + COMPOSE_NO_BUILD=1 to run it against published images (IMAGE_TAG=v0.13.4-rc.1 is the
## negative control: tests 1 and 2 fail there).
stack-test-client-compat:
	V010_COMPAT=1 MOCK_BOT=1 BROWSER_IMAGE=$(BROWSER_IMAGE) ./bin/stack-test compat/client_compat_test.py

## up — the INSTALL entrypoint: PULLS the published, release-validated images (#569 — what users
## run must be the bytes the release machinery proved; a local build must never shadow a published
## release tag). Seeds .env from .env.example if absent and mints every secret the services refuse
## to boot without (mint-dev-env.sh — never overwrites a value already set), pulls everything (services + the
## build-only agent-worker profile + the bot), brings the stack up WITHOUT building, then mints +
## prints an API key. Building from source is `make dev` (images tagged :dev, never a release tag).
up:
	@$(MAKE) --no-print-directory _preflight
	@./mint-dev-env.sh .env
	$(COMPOSE) pull
	@_tag=$$(grep -E '^IMAGE_TAG=' .env | head -1 | cut -d= -f2- | tr -d '[:space:]'); _tag=$${_tag:-$$(grep -E '^IMAGE_TAG=' .env.example | head -1 | cut -d= -f2-)}; \
	 echo "→ pulling spawn-time images (agent-worker is a build-only compose profile pull skips)"; \
	 docker pull "vexaai/vexa-agent-worker:$$_tag"; \
	 _bi=$$(grep -E '^BROWSER_IMAGE=' .env | head -1 | cut -d= -f2- | sed -E 's/[[:space:]]+#.*$$//; s/[[:space:]]+$$//'); \
	 _bi=$$(printf '%s' "$$_bi" | sed "s/\$${IMAGE_TAG}/$$_tag/; s/\$$IMAGE_TAG/$$_tag/"); \
	 case "$$_bi" in vexaai/*) docker pull "$$_bi";; esac
	$(COMPOSE) up -d --no-build || { $(MAKE) --no-print-directory _storage_note; exit 1; }
	@$(MAKE) --no-print-directory _storage_note
	@$(MAKE) --no-print-directory _bot_check
	@$(MAKE) --no-print-directory _creds_check
	@$(MAKE) --no-print-directory _access

## dev — build the whole stack FROM THIS CHECKOUT, tagged :dev (the repo-wide 'dev = locally-built'
## convention) so a source build can never impersonate a published release image. The running stack's
## interpolated refs (AGENT_WORKER_IMAGE etc.) follow IMAGE_TAG=dev coherently.
dev:
	@$(MAKE) --no-print-directory _preflight
	@./mint-dev-env.sh .env
	IMAGE_TAG=dev $(COMPOSE) up -d --build || { $(MAKE) --no-print-directory _storage_note; exit 1; }
	@$(MAKE) --no-print-directory _storage_note
	@# Every remaining step must RUN and the target must exit non-zero naming EVERY gap. A failed
	@# agent-worker build (a transient apt flake, #716) must NOT abort BEFORE the bot-image check —
	@# that is exactly how a stack came up "healthy" but spawned dead bots with no signal (#718 C4).
	@fail=""; \
	 IMAGE_TAG=dev $(COMPOSE) build agent-worker || fail="$$fail agent-worker-build"; \
	 $(MAKE) --no-print-directory _bot_check BOT_CHECK_STRICT=1 || fail="$$fail bot-image-missing"; \
	 $(MAKE) --no-print-directory _creds_check; \
	 $(MAKE) --no-print-directory _access; \
	 if [ -n "$$fail" ]; then \
	   echo ""; \
	   echo "✗ make dev did not fully succeed —$$fail (see the messages above)."; \
	   echo "  The stack is up, but spawned bots may fail to start until every item above is resolved."; \
	   exit 1; \
	 fi

## _storage_note — surface the latest storage WARNING or STOP without failing if logs are unavailable.
_storage_note:
	@$(COMPOSE) logs --no-log-prefix --tail 20 storage-init 2>/dev/null | grep -E '^\[storage-init\] (WARNING|STOP):' | tail -n 1 || true

## digest-audit — the #569 negative control: every vexaai/*:$IMAGE_TAG image on this host must
## carry a RepoDigest (= came from the registry). A locally-built image has NO RepoDigest, so a
## shadowed pointer fails here loudly. Run after `make up` to prove the install is artifact-true.
digest-audit:
	@_tag=$$(grep -E '^IMAGE_TAG=' .env 2>/dev/null | cut -d= -f2- | tr -d '[:space:]'); _tag=$${_tag:-$$(grep -E '^IMAGE_TAG=' .env.example | head -1 | cut -d= -f2-)}; \
	 fail=0; \
	 for img in $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep -E "^vexaai/.*:$$_tag$$"); do \
	   d=$$(docker image inspect --format '{{if .RepoDigests}}{{index .RepoDigests 0}}{{end}}' "$$img"); \
	   if [ -z "$$d" ]; then echo "✗ $$img has NO registry digest — locally built, shadows the published pointer"; fail=1; \
	   else echo "✓ $$img ⇐ $$d"; fi; \
	 done; \
	 [ "$$fail" = 0 ] && echo "✓ digest audit clean — every $$_tag image on this host is the published artifact" || exit 1

## _preflight — fail fast on a too-old Docker engine: agent workers mount workspaces via the Mounts
## API's named-volume Subpath, which needs engine ≥ v26 — an older engine fails every worker create
## AFTER the stack looks healthy, which is far harder to diagnose than failing here.
_preflight:
	@v=$$(docker version --format '{{.Server.Version}}' 2>/dev/null); v=$${v#v}; \
	 if [ -z "$$v" ]; then echo "✗ cannot reach the Docker engine — is Docker running?"; exit 1; fi; \
	 major=$${v%%.*}; \
	 case "$$major" in \
	   ''|*[!0-9]*) echo "⚠ unrecognized Docker engine version '$$v' — continuing (this stack needs ≥ v26)";; \
	   *) if [ "$$major" -lt 26 ]; then \
	        echo ""; \
	        echo "✗ Docker engine v$$v is too old — this stack requires engine ≥ v26."; \
	        echo "  Agent workers mount workspaces with named-volume subpaths (Mounts API"; \
	        echo "  VolumeOptions.Subpath); older engines reject the container create."; \
	        echo "  Upgrade Docker, then re-run: make all"; \
	        exit 1; \
	      fi;; \
	 esac

## bot — build the meeting bot FROM SOURCE for development, tagged into the LOCAL vexa/ namespace
## (BOT_IMAGE, default vexa/vexa-bot:dev) so it can never shadow the published vexaai/vexa-bot release tag
## the install pulls. (vexaai/vexa-bot:dev on Docker Hub is the OLDER 0.10 line — neither pulled nor
## overwritten here.) Builds the join-env base first, then the bot. Point BROWSER_IMAGE (.env) at
## BOT_IMAGE so the runtime spawns your build.
bot:
	@echo "→ [1/2] join-env base: vexa/meet-join-env:dev"
	docker build -f $(REPO_ROOT)/core/meetings/modules/join/Dockerfile.env -t vexa/meet-join-env:dev $(REPO_ROOT)/core/meetings/modules/join
	@echo "→ [2/2] meeting bot: $(BOT_IMAGE)"
	@# VEXA_IMAGE_VERSION stamps the build into every captured-signal tape this image produces
	@# (telemetry.ts sessionHeader/sidecarHeader). A dirty tree still stamps its HEAD sha — the tape
	@# says which commit, never which uncommitted edit, so a fixture from a local build is labelled
	@# approximately rather than falsely precisely.
	docker build -t $(BOT_IMAGE) \
	  --build-arg VEXA_IMAGE_VERSION=$$(git -C $(REPO_ROOT) rev-parse --short HEAD 2>/dev/null || echo unknown) \
	  -f $(REPO_ROOT)/core/meetings/services/bot/Dockerfile $(REPO_ROOT)
	@_rt=$$($(COMPOSE) ps -q runtime 2>/dev/null); _live=""; \
	 [ -n "$$_rt" ] && _live=$$(docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' $$_rt 2>/dev/null \
	   | grep '^BROWSER_IMAGE=' | cut -d= -f2-); \
	 if [ "$$_live" = "$(BOT_IMAGE)" ]; then \
	   echo "✓ built $(BOT_IMAGE) — done. The running stack spawns bots from this tag;"; \
	   echo "  the next bot will use the image you just built (no restart needed)."; \
	 else \
	   echo "✓ built $(BOT_IMAGE) — set BROWSER_IMAGE=$(BOT_IMAGE) in .env, then: make all"; \
	 fi

## _bot_check — FAIL LOUD if the meeting bot image isn't built locally. The bot is built here, never
## pulled (the published vexaai/vexa-bot:dev is the old 0.10 line). Without this the failure was silent:
## bots sat in `requested` and the meeting was reaped to `completed`/0-segments. Now it is screamingly visible.
##
## BOT_CHECK_STRICT=1 turns the warning into a non-zero EXIT (used by `dev` — an aborted build must never
## leave a stack that spawns dead bots with no signal, #718 C4). `up` calls it warn-only (the published
## image is pulled elsewhere), so the shared default stays a warning. Check-and-instruct only — it prints
## the `make bot` / `docker pull` line and NEVER forces a 3.6GB pull mid-`make dev`.
_bot_check:
	@_bi=$$(grep -E '^BROWSER_IMAGE=' .env 2>/dev/null | head -1 | cut -d= -f2- | sed -E 's/[[:space:]]+#.*$$//; s/[[:space:]]+$$//'); \
	 if [ -n "$$_bi" ] && ! docker image inspect "$$_bi" >/dev/null 2>&1; then \
	   echo ""; \
	   echo "═══════════════════════════════════════════════════════════"; \
	   echo "  ⚠️  meeting bot image '$$_bi' is not present on this host."; \
	   case "$$_bi" in \
	     vexaai/*) echo "      It is PUBLISHED — pull it:  docker pull $$_bi";; \
	     *)        echo "      It looks locally-built (dev path) — build it:"; \
	               echo "          make -C deploy/compose bot   (tags $(BOT_IMAGE))";; \
	   esac; \
	   echo "      Bots will FAIL TO JOIN until the image exists."; \
	   echo "═══════════════════════════════════════════════════════════"; \
	   echo ""; \
	   if [ -n "$(BOT_CHECK_STRICT)" ]; then exit 1; fi; \
	 fi

## _creds_check — WARN (never fail) when .env leaves a capability unconfigured: empty STT creds mean
## bots join + record but produce NO transcript; no model credential means agent chat refuses at first
## use. Mirrors agent-api's config.v1 `model_inference` capability (mode=any: any ONE key configures it).
_creds_check:
	@_envv() { grep -E "^$$1=" .env 2>/dev/null | head -1 | cut -d= -f2- | sed -E 's/[[:space:]]+#.*$$//; s/[[:space:]]+$$//'; }; \
	 stt=1; [ -n "$$(_envv TRANSCRIPTION_SERVICE_URL)" ] && [ -n "$$(_envv TRANSCRIPTION_SERVICE_TOKEN)" ] && stt=0; \
	 model=1; for k in CLAUDE_CODE_OAUTH_TOKEN ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN HOST_CLAUDE_CREDENTIALS; do \
	   [ -n "$$(_envv $$k)" ] && model=0; done; \
	 if [ $$stt -eq 1 ] || [ $$model -eq 1 ]; then \
	   echo ""; \
	   echo "═══════════════════════════════════════════════════════════"; \
	   if [ $$stt -eq 1 ]; then \
	     echo "  ⚠️  transcription is NOT configured (TRANSCRIPTION_SERVICE_URL /"; \
	     echo "      TRANSCRIPTION_SERVICE_TOKEN empty in .env)."; \
	     echo "      Bots will join and record but produce NO transcript."; \
	     echo "      Get a free token at https://vexa.ai/account (or self-host"; \
	     echo "      deploy/transcription), set both, then: make all"; \
	   fi; \
	   if [ $$stt -eq 1 ] && [ $$model -eq 1 ]; then echo "  ─────────────────────────────────────────────────────────"; fi; \
	   if [ $$model -eq 1 ]; then \
	     echo "  ⚠️  no model credential is configured — agent chat will refuse to run."; \
	     echo "      Set ONE of CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY,"; \
	     echo "      ANTHROPIC_AUTH_TOKEN or HOST_CLAUDE_CREDENTIALS"; \
	     echo "      in .env, then: make all — or configure Settings → Models in the UI."; \
	   fi; \
	   echo "═══════════════════════════════════════════════════════════"; \
	   echo ""; \
	 fi
## migrate-storage — upgrading a stack that ran MinIO: copy every object from the old MinIO into the
## `storage` service and verify each one by SHA-256 (deploy/storage/migrate-from-minio.sh + s3_copy.py,
## run with the meeting-api image's Python). Resumable; deletes nothing; the old volume is only read.
## It reads through the old `minio` container while Compose still runs it as an orphan, else through a
## temporary MinIO started from that container's image, else LEGACY_MINIO_IMAGE if it is on this
## machine (nothing is pulled). The new storage uses the .env MINIO_* pair; the old MinIO the pair
## mint-dev-env.sh kept as LEGACY_MINIO_* when it replaced a published one, else the same MINIO_* pair.
## Guide: docs/docs/upgrade-from-minio.mdx.
LEGACY_MINIO_CONTAINER ?= $(PROJECT)-minio-1
LEGACY_MINIO_VOLUME    ?= $(PROJECT)_minio-data
LEGACY_MINIO_IMAGE     ?=
# Empty uses MINIO_BUCKET from .env (or vexa); overrides both migration bucket defaults.
MIGRATE_BUCKET        ?=
migrate-storage:
	@set -e; \
	envv() { grep -E "^$$1=" .env 2>/dev/null | head -1 | cut -d= -f2- | sed -E 's/[[:space:]]+#.*$$//; s/[[:space:]]+$$//'; }; \
	AK=$$(envv MINIO_ACCESS_KEY); SK=$$(envv MINIO_SECRET_KEY); \
	[ -n "$$AK" ] && [ -n "$$SK" ] || { echo "no MINIO_ACCESS_KEY / MINIO_SECRET_KEY in .env — run ./mint-dev-env.sh .env (make up does)"; exit 1; }; \
	LAK=$$(envv LEGACY_MINIO_ACCESS_KEY); LSK=$$(envv LEGACY_MINIO_SECRET_KEY); \
	BK="$(MIGRATE_BUCKET)"; BK=$${BK:-$$(envv MINIO_BUCKET)}; BK=$${BK:-vexa}; TAG=$$(envv IMAGE_TAG); TAG=$${IMAGE_TAG:-$${TAG:-dev}}; \
	$(COMPOSE) up -d --no-build storage; \
	NETWORK=$(PROJECT)_vexa LEGACY_VOLUME=$(LEGACY_MINIO_VOLUME) LEGACY_CONTAINER=$(LEGACY_MINIO_CONTAINER) \
	LEGACY_IMAGE="$(LEGACY_MINIO_IMAGE)" LEGACY_ACCESS_KEY="$${LEGACY_MINIO_ACCESS_KEY:-$${LAK:-$$AK}}" \
	LEGACY_SECRET_KEY="$${LEGACY_MINIO_SECRET_KEY:-$${LSK:-$$SK}}" LEGACY_BUCKET="$${LEGACY_MINIO_BUCKET:-$$BK}" \
	TARGET_ENDPOINT=http://storage:9000 TARGET_ACCESS_KEY="$$AK" TARGET_SECRET_KEY="$$SK" TARGET_BUCKET="$$BK" \
	STORAGE_VOLUME=$(PROJECT)_storage-data RUN_IMAGE="vexaai/vexa-meeting-api:$$TAG" RUN_PYTHON=python \
	TOOLS_DIR=$(REPO_ROOT)/deploy/storage NAME_PREFIX=$(PROJECT) RETRY_HINT="make -C deploy/compose migrate-storage" \
	COPY_ARGS="$(COPY_ARGS)" $(REPO_ROOT)/deploy/storage/migrate-from-minio.sh

## down — remove containers and the network; keep all data volumes.
down:
	$(COMPOSE) down --remove-orphans

## destroy — explicitly delete this stack's data volumes, including the database and recordings.
destroy:
ifeq ($(DESTROY),yes)
	$(COMPOSE) down -v --remove-orphans
	@echo "Deleted stack volumes: $(PROJECT)_redis-data $(PROJECT)_postgres-data $(PROJECT)_storage-data $(PROJECT)_agent-workspaces"
else
	@echo "Refusing to delete data volumes. Use make destroy DESTROY=yes to delete the database, recordings, Redis data and agent workspaces."
	@exit 1
endif

help:
	@echo "  make up                         # pull and start the stack"
	@echo "  make down                       # stop/remove containers; keep data volumes"
	@echo "  make destroy DESTROY=yes        # delete stack data volumes (database, recordings, Redis, agent workspaces)"
	@echo "  make migrate-storage            # copy and verify recordings from an older MinIO install"

## _access — wait for admin-api, mint the self-host API key, print it + the URLs (used by `up`).
_access:
	@_envv() { grep -E "^$$1=" .env | head -1 | cut -d= -f2- | sed -E 's/[[:space:]]+#.*$$//; s/[[:space:]]+$$//'; }; \
	 ADMIN_TOKEN=$$(_envv ADMIN_TOKEN); \
	 APORT=$$(_envv ADMIN_API_PORT); APORT=$${APORT:-18057}; \
	 GW=$$(_envv API_GATEWAY_HOST_PORT); GW=$${GW:-18056}; \
	 UI=$$(_envv TERMINAL_PORT); UI=$${UI:-13000}; \
	 echo "⏳ minting your self-host API key..."; \
	 KEY=""; for i in $$(seq 1 60); do \
	   KEY=$$(ADMIN_TOKEN=$$ADMIN_TOKEN ADMIN_API_URL=http://127.0.0.1:$$APORT EMAIL=$(EMAIL) SCOPES=$(SCOPES) ./bin/provision-token 2>/dev/null) && [ -n "$$KEY" ] && break; \
	   sleep 2; done; \
	 echo ""; \
	 echo "═══════════════════════════════════════════════════════════"; \
	 echo "  Vexa is up."; \
	 echo "    Terminal UI : http://localhost:$$UI"; \
	 echo "    API gateway : http://localhost:$$GW"; \
	 if [ -n "$$KEY" ]; then echo "    API key     : $$KEY"; \
	 else echo "    API key     : admin-api not ready — mint later with:"; \
	      echo "                  make -s provision-token ADMIN_TOKEN=<your ADMIN_TOKEN>"; fi; \
	 STT=1; [ -n "$$(_envv TRANSCRIPTION_SERVICE_URL)" ] && [ -n "$$(_envv TRANSCRIPTION_SERVICE_TOKEN)" ] && STT=0; \
	 MODEL=1; for k in CLAUDE_CODE_OAUTH_TOKEN ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN HOST_CLAUDE_CREDENTIALS; do \
	   [ -n "$$(_envv $$k)" ] && MODEL=0; done; \
	 if [ $$STT -eq 1 ]; then echo "    ⚠ transcription: not configured — bots record, NO transcript"; fi; \
	 if [ $$MODEL -eq 1 ]; then echo "    ⚠ agent chat  : no model credential — chat will refuse"; fi; \
	 echo "═══════════════════════════════════════════════════════════"
build:
	$(COMPOSE) build
ps:
	$(COMPOSE) ps
logs:
	$(COMPOSE) logs -f
