#!/usr/bin/env bash # scripts/install/s2-models.sh — S2: model + aux vision config # # Configures inference via openshell/nemohermes and runs vision smoke test. # Platform-first: all mutations through nemohermes/openshell CLIs. # # Usage: # ./scripts/install/s2-models.sh # (called by install.sh --stage s2) set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Source shared helpers (common.sh sets REPO_ROOT via git rev-parse) # shellcheck source=../lib/common.sh source "$SCRIPT_DIR/../lib/common.sh" # shellcheck source=../lib/env.sh source "$SCRIPT_DIR/../lib/env.sh" # shellcheck source=../lib/vision_smoke.sh source "$SCRIPT_DIR/../lib/vision_smoke.sh" log_section "S2: Model + vision configuration" # ── Load .env ────────────────────────────────────────────────────────────── load_env # ── Validate required keys ───────────────────────────────────────────────── validate_env || exit 1 # ── Check CLI prerequisites ──────────────────────────────────────────────── require_cmd openshell "Install OpenShell CLI (part of NemoClaw platform)" require_cmd nemohermes "Install nemohermes CLI (part of NemoClaw platform)" # ── Verify inference endpoint is reachable ───────────────────────────────── # LUMINA_INFERENCE_BASE_URL includes /v1 (e.g. http://host:port/v1) log_info "Verifying inference endpoint: $LUMINA_INFERENCE_BASE_URL" if ! curl -sf --max-time 15 "${LUMINA_INFERENCE_BASE_URL}/models" &>/dev/null; then log_error "Inference endpoint unreachable at $LUMINA_INFERENCE_BASE_URL" log_error "Check that the model server is running and the URL is correct." log_error "Fix LUMINA_INFERENCE_BASE_URL in .env and re-run." exit 1 fi log_info "Inference endpoint reachable." # ── Configure inference via openshell ────────────────────────────────────── # Only set if the gateway is connected and we can reach it. # If the gateway is not yet set up, we validate the endpoint and skip # the openshell write (S3+ will handle full gateway config). log_info "Checking OpenShell gateway status…" if openshell status &>/dev/null 2>&1; then log_info "Gateway connected — configuring inference route…" # Use openshell inference set to configure the main model. # openshell inference set takes --provider and --model but NOT --url. # The gateway resolves the endpoint URL from its own metadata (the # compatible-endpoint provider reads the URL from the gateway config). # --no-verify skips the endpoint verification that openshell does internally # since we already verified above. if openshell inference set \ --provider compatible-endpoint \ --model "$LUMINA_INFERENCE_MODEL" \ --no-verify 2>&1; then log_info "Inference route configured via openshell." else log_warn "openshell inference set returned non-zero." log_warn "The gateway may already have this route configured, or the gateway" log_warn "requires a different provider name. Check with: openshell inference get" fi else log_warn "OpenShell gateway not connected — skipping inference route configuration." log_warn "Inference will be configured when the gateway is available (S3+)." log_warn "Ensure LUMINA_INFERENCE_BASE_URL and LUMINA_INFERENCE_MODEL are correct in .env." fi # ── Vision smoke test ────────────────────────────────────────────────────── vision_smoke || { log_error "Vision smoke test FAILED." log_error "The inference endpoint does not appear to support multimodal/vision." log_error "Check:" log_error " 1. LUMINA_VISION_MODEL points to a vision-capable model" log_error " 2. The model server supports multimodal inputs" log_error " 3. LUMINA_INFERENCE_BASE_URL is correct" exit 1 } log_info "S2 complete: model configured, vision smoke passed."