#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" TOKEN_FILE="$ROOT_DIR/.secrets/app-server-token" ENV_FILE="$ROOT_DIR/.env" if [[ ! -s "$TOKEN_FILE" || ! -s "$ENV_FILE" ]]; then echo "Run ./scripts/setup.sh first." >&2 exit 1 fi set -a # shellcheck disable=SC1090 source "$ENV_FILE" set +a for command_name in curl python3; do if ! command -v "$command_name" >/dev/null 2>&1; then echo "Missing required command: $command_name" >&2 exit 1 fi done models_json="$(curl -fsS --max-time 10 \ -H "Authorization: Bearer $(<"$TOKEN_FILE")" \ http://127.0.0.1:4500/v1/models)" agent_count="$(python3 -c 'import json, sys; data=json.load(sys.stdin); print(len(data.get("data", [])))' <<<"$models_json")" if [[ "$agent_count" == "0" ]]; then echo "Letta App Server is running, but it reported no local agents." >&2 exit 1 fi webui_version="$(curl -fsS --max-time 10 \ "http://${OPENWEBUI_HOST:-127.0.0.1}:${OPENWEBUI_PORT:-3000}/api/version" \ | python3 -c 'import json, sys; print(json.load(sys.stdin)["version"])')" printf 'Letta App Server: ready (%s agents)\n' "$agent_count" printf 'OpenWebUI: ready (v%s)\n' "$webui_version" printf 'Open: http://%s:%s\n' \ "${OPENWEBUI_HOST:-127.0.0.1}" "${OPENWEBUI_PORT:-3000}"