0xNyk/council-of-high-intelligence
council
VerifiedConvene the Council of High Intelligence — multi-persona deliberation with historical thinkers for deeper analysis of complex problems.
scripts/detect-providers.sh
View on GitHub#!/usr/bin/env bash
set -euo pipefail
# Council of High Intelligence — Provider Detection Script
# Detects available LLM providers and outputs structured JSON to stdout.
# Usage: ./scripts/detect-providers.sh
TIMEOUT_SECONDS=5
# --- Helper functions ---
json_provider() {
local name="$1" available="$2" exec_method="$3" binary="$4" models="$5"
printf '{"name":"%s","available":%s,"exec_method":"%s","binary":"%s","models":[%s]}' \
"$name" "$available" "$exec_method" "$binary" "$models"
}
check_command() {
command -v "$1" 2>/dev/null || echo ""
}
# macOS-compatible timeout using perl (no coreutils required)
run_with_timeout() {
perl -e '
use POSIX ":sys_wait_h";
my $timeout = shift @ARGV;
my $pid = fork();
if ($pid == 0) { exec @ARGV; exit 1; }
my $elapsed = 0;
while ($elapsed < $timeout) {
if (waitpid($pid, WNOHANG) > 0) { exit ($? >> 8); }
select(undef, undef, undef, 0.1);
$elapsed += 0.1;
}
kill("TERM", $pid);
waitpid($pid, 0);
exit 124;
' "$TIMEOUT_SECONDS" "$@" 2>/dev/null
}
# --- Detect each provider ---
providers=()
# Anthropic — always available (host runtime)
providers+=("$(json_provider "anthropic" "true" "subagent" "native" '"opus","sonnet","haiku"')")
# OpenAI via Codex CLI
codex_bin="$(check_command codex)"
if [[ -n "$codex_bin" ]] && run_with_timeout codex --version >/dev/null 2>&1; then
providers+=("$(json_provider "openai" "true" "codex_exec" "$codex_bin" '"gpt-5.4"')")
else
providers+=("$(json_provider "openai" "false" "codex_exec" "${codex_bin:-not_found}" '')")
fi
# Google via Gemini CLI
gemini_bin="$(check_command gemini)"
if [[ -n "$gemini_bin" ]] && run_with_timeout gemini --version >/dev/null 2>&1; then
providers+=("$(json_provider "google" "true" "gemini_cli" "$gemini_bin" '"gemini-3-pro"')")
else
providers+=("$(json_provider "google" "false" "gemini_cli" "${gemini_bin:-not_found}" '')")
fi
# Ollama (local models)
ollama_bin="$(check_command ollama)"
ollama_available=false
ollama_models=""
if [[ -n "$ollama_bin" ]]; then
# Check if ollama server is running by listing models
if model_list="$(run_with_timeout ollama list 2>/dev/null)"; then
# Parse model names from 'ollama list' output (skip header line, take first column)
ollama_models="$(echo "$model_list" | tail -n +2 | awk '{print $1}' | head -5 | \
sed 's/.*/"&"/' | paste -sd ',' -)"
# Only mark available when at least one model is actually installed —
# otherwise the auto-router will dispatch a seat to a provider that
# has nothing to run.
if [[ -n "$ollama_models" ]]; then
ollama_available=true
fi
fi
fi
providers+=("$(json_provider "ollama" "$ollama_available" "ollama_run" "${ollama_bin:-not_found}" "$ollama_models")")
# Cursor via Cursor CLI (cursor-agent) — model aggregator: serves GPT-5.x,
# Claude, Gemini, and Grok families through one binary + CURSOR_API_KEY.
cursor_bin="$(check_command cursor-agent)"
if [[ -n "$cursor_bin" ]] && run_with_timeout cursor-agent --version >/dev/null 2>&1; then
# Cross-family defaults so a Cursor seat adds real diversity, not a
# second Anthropic-biased model. Verify live IDs with `cursor-agent --list-models`.
providers+=("$(json_provider "cursor_cli" "true" "cursor_cli" "$cursor_bin" '"gpt-5.4-high","claude-opus-4-7-thinking-high","gemini-3-pro","grok-4"')")
else
providers+=("$(json_provider "cursor_cli" "false" "cursor_cli" "${cursor_bin:-not_found}" '')")
fi
# NVIDIA NIM (OpenAI-compatible hosted endpoint at build.nvidia.com)
# Detection: NVIDIA_API_KEY env var + optional reachability check.
nim_available=false
nim_models=""
nim_endpoint="https://integrate.api.nvidia.com/v1"
if [[ -n "${NVIDIA_API_KEY:-}" ]]; then
# Verify the key is not a placeholder (real keys start with nvapi-)
if [[ "${NVIDIA_API_KEY}" =~ ^nvapi- ]]; then
# Optional: confirm catalog reachability. Skip if curl missing or offline.
# The auth header is passed via process substitution so the key never
# appears in curl's argv (visible to other local users via `ps`).
if command -v curl >/dev/null 2>&1; then
if run_with_timeout curl -sf -o /dev/null \
-H @<(printf 'Authorization: Bearer %s\n' "${NVIDIA_API_KEY}") \
"${nim_endpoint}/models" 2>/dev/null; then
nim_available=true
fi
else
# Curl unavailable; trust env var presence + key prefix as availability signal.
nim_available=true
fi
# Default model suggestions (verify live IDs at build.nvidia.com/models).
nim_models='"deepseek-ai/deepseek-v4-pro","moonshotai/kimi-k2.6","minimaxai/minimax-m2.7","z-ai/glm-5.1","qwen/qwen3.5-397b-a17b"'
fi
fi
providers+=("$(json_provider "nvidia_nim" "$nim_available" "openai_compatible_api" "$nim_endpoint" "$nim_models")")
# --- Build JSON output ---
available_count=0
for p in "${providers[@]}"; do
if echo "$p" | grep -q '"available":true'; then
((available_count+=1))
fi
done
multi_provider=false
if [[ "$available_count" -ge 2 ]]; then
multi_provider=true
fi
# Assemble providers array
provider_json=""
for i in "${!providers[@]}"; do
if [[ $i -gt 0 ]]; then
provider_json+=","
fi
provider_json+="${providers[$i]}"
done
printf '{"providers":[%s],"provider_count":%d,"multi_provider":%s}\n' \
"$provider_json" "$available_count" "$multi_provider"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |