diff --git a/core/framework/runner/cli.py b/core/framework/runner/cli.py index 22d2f221..7e3d5a41 100644 --- a/core/framework/runner/cli.py +++ b/core/framework/runner/cli.py @@ -1561,6 +1561,21 @@ def _open_browser(url: str) -> None: pass # Best-effort — don't crash if browser can't open +def _ping_hive_gateway_availability(from_source: str) -> None: + """Ping Hive gateway availability for lightweight reachability logging.""" + from urllib import error, parse, request + + base_url = "https://api.adenhq.com/v1/gateway/availability" + query = parse.urlencode({"from": from_source}) + url = f"{base_url}?{query}" + + try: + with request.urlopen(url, timeout=5) as response: + response.read() + except (error.URLError, TimeoutError, ValueError): + pass + + def _format_subprocess_output(output: str | bytes | None, limit: int = 2000) -> str: """Return subprocess output as trimmed text safe for console logging.""" if not output: @@ -1729,5 +1744,6 @@ def cmd_serve(args: argparse.Namespace) -> int: def cmd_open(args: argparse.Namespace) -> int: """Start the HTTP API server and open the dashboard in the browser.""" + _ping_hive_gateway_availability("hive-open") args.open = True return cmd_serve(args) diff --git a/quickstart.ps1 b/quickstart.ps1 index ded9543f..31d05a57 100644 --- a/quickstart.ps1 +++ b/quickstart.ps1 @@ -23,9 +23,23 @@ $UvHelperPath = Join-Path $ScriptDir "scripts\uv-discovery.ps1" # Hive LLM router endpoint $HiveLlmEndpoint = "https://api.adenhq.com" +$HiveLlmAvailabilityEndpoint = "$HiveLlmEndpoint/v1/gateway/availability" . $UvHelperPath +function Test-HiveGatewayAvailability { + param([string]$From) + + try { + $url = "$HiveLlmAvailabilityEndpoint?from=$From" + $result = Invoke-RestMethod -Uri $url -Method Get -TimeoutSec 5 -ErrorAction Stop + if ($result -eq $true) { return "available" } + return "unavailable" + } catch { + return "unknown" + } +} + # ============================================================ # Colors / helpers # ============================================================ @@ -1119,9 +1133,17 @@ if ($PrevSubMode -or $PrevProvider) { } } +$HiveGatewayAvailability = Test-HiveGatewayAvailability -From "quickstart" + # ── Show unified provider selection menu ───────────────────── Write-Color -Text "Select your default LLM provider:" -Color White Write-Host "" +switch ($HiveGatewayAvailability) { + "available" { Write-Ok "Hive LLM availability check: available" } + "unavailable" { Write-Warn "Hive LLM availability check: currently unavailable" } + default { Write-Warn "Hive LLM availability check: could not verify" } +} +Write-Host "" Write-Color -Text " Subscription modes (no API key purchase needed):" -Color Cyan # 1) Claude Code @@ -1164,6 +1186,11 @@ Write-Host " " -NoNewline Write-Color -Text "6" -Color Cyan -NoNewline Write-Host ") Hive LLM " -NoNewline Write-Color -Text "(use your Hive API key)" -Color DarkGray -NoNewline +switch ($HiveGatewayAvailability) { + "available" { Write-Color -Text " (available)" -Color Green -NoNewline } + "unavailable" { Write-Color -Text " (unavailable)" -Color Yellow -NoNewline } + default { Write-Color -Text " (status unknown)" -Color Yellow -NoNewline } +} if ($HiveCredDetected) { Write-Color -Text " (credential detected)" -Color Green } else { Write-Host "" } # 7) Antigravity diff --git a/quickstart.sh b/quickstart.sh index 0edb2d8c..ef475db6 100755 --- a/quickstart.sh +++ b/quickstart.sh @@ -34,6 +34,22 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Hive LLM router endpoint HIVE_LLM_ENDPOINT="https://api.adenhq.com" +HIVE_LLM_AVAILABILITY_ENDPOINT="$HIVE_LLM_ENDPOINT/v1/gateway/availability" + +check_hive_llm_availability() { + local from_source="$1" + + if ! command -v curl >/dev/null 2>&1; then + return 2 + fi + + local response + response="$(curl -fsSL --max-time 5 "${HIVE_LLM_AVAILABILITY_ENDPOINT}?from=${from_source}" 2>/dev/null)" || return 2 + if [ "$response" = "true" ]; then + return 0 + fi + return 1 +} # Helper function for prompts prompt_yes_no() { @@ -1151,9 +1167,24 @@ if [ -n "$PREV_SUB_MODE" ] || [ -n "$PREV_PROVIDER" ]; then fi fi +HIVE_LLM_AVAILABLE="unknown" +if check_hive_llm_availability "quickstart"; then + HIVE_LLM_AVAILABLE="yes" +elif [ $? -eq 1 ]; then + HIVE_LLM_AVAILABLE="no" +fi + # ── Show unified provider selection menu ───────────────────── echo -e "${BOLD}Select your default LLM provider:${NC}" echo "" +if [ "$HIVE_LLM_AVAILABLE" = "yes" ]; then + echo -e "${GREEN}⬢${NC} Hive LLM availability check: ${DIM}available${NC}" +elif [ "$HIVE_LLM_AVAILABLE" = "no" ]; then + echo -e "${YELLOW}⬢${NC} Hive LLM availability check: ${DIM}currently unavailable${NC}" +else + echo -e "${YELLOW}⬢${NC} Hive LLM availability check: ${DIM}could not verify${NC}" +fi +echo "" echo -e " ${CYAN}${BOLD}Subscription modes (no API key purchase needed):${NC}" # 1) Claude Code @@ -1192,10 +1223,18 @@ else fi # 6) Hive LLM -if [ "$HIVE_CRED_DETECTED" = true ]; then - echo -e " ${CYAN}6)${NC} Hive LLM ${DIM}(use your Hive API key)${NC} ${GREEN}(credential detected)${NC}" +if [ "$HIVE_LLM_AVAILABLE" = "yes" ]; then + HIVE_LLM_STATUS="${GREEN}(available)${NC}" +elif [ "$HIVE_LLM_AVAILABLE" = "no" ]; then + HIVE_LLM_STATUS="${YELLOW}(unavailable)${NC}" else - echo -e " ${CYAN}6)${NC} Hive LLM ${DIM}(use your Hive API key)${NC}" + HIVE_LLM_STATUS="${YELLOW}(status unknown)${NC}" +fi + +if [ "$HIVE_CRED_DETECTED" = true ]; then + echo -e " ${CYAN}6)${NC} Hive LLM ${DIM}(use your Hive API key)${NC} $HIVE_LLM_STATUS ${GREEN}(credential detected)${NC}" +else + echo -e " ${CYAN}6)${NC} Hive LLM ${DIM}(use your Hive API key)${NC} $HIVE_LLM_STATUS" fi # 7) Antigravity