#!/bin/bash
# Bash/Zsh LLM/CC Environment Switch - {{env_name}}
# Generated by fnva

{{#if config.anthropic_auth_token}}
# Anthropic/GLM-CC environment
export ANTHROPIC_AUTH_TOKEN="{{config.anthropic_auth_token}}"
{{/if}}

{{#if config.anthropic_base_url}}
export ANTHROPIC_BASE_URL="{{config.anthropic_base_url}}"
{{/if}}

{{#if config.opus_model}}
export ANTHROPIC_DEFAULT_OPUS_MODEL="{{config.opus_model}}"
{{/if}}

{{#if config.sonnet_model}}
export ANTHROPIC_DEFAULT_SONNET_MODEL="{{config.sonnet_model}}"
{{/if}}

{{#if config.haiku_model}}
export ANTHROPIC_DEFAULT_HAIKU_MODEL="{{config.haiku_model}}"
{{/if}}

{{#if config.default_model}}
export ANTHROPIC_DEFAULT_SONNET_MODEL="{{config.default_model}}"
{{/if}}

{{#if config.api_key}}
export OPENAI_API_KEY="{{config.api_key}}"
{{/if}}

{{#if config.openai_base_url}}
export OPENAI_API_BASE="{{config.openai_base_url}}"
{{/if}}

{{#if config.base_url}}
export OPENAI_API_BASE="{{config.base_url}}"
{{/if}}

{{#if config.model}}
export OPENAI_MODEL="{{config.model}}"
{{/if}}

{{#if config.temperature}}
export OPENAI_TEMPERATURE="{{config.temperature}}"
{{/if}}

{{#if config.max_tokens}}
export OPENAI_MAX_TOKENS="{{config.max_tokens}}"
{{/if}}

# Set fnva environment tracking
export FNVA_CURRENT_{{#if (eq env_type "Cc")}}CC{{else}}LLM{{/if}}="{{env_name}}"
export FNVA_ENV_TYPE="{{#if (eq env_type "Cc")}}CC{{else}}LLM{{/if}}"

# Claude Code specific settings
{{#if config.anthropic_auth_token}}
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
export API_TIMEOUT_MS="30000"
{{/if}}

# Verify the switch
if [[ -z "$_FNVA_QUIET" ]]; then
    echo "[OK] Switched to {{#if (eq env_type "Cc")}}Claude Code (CC){{else}}LLM{{/if}} environment: {{env_name}}"

    {{#if config.anthropic_auth_token}}
    echo "[KEY] Anthropic Auth Token: [SET]"
    {{/if}}

    {{#if config.anthropic_base_url}}
    echo "[URL] Base URL: {{config.anthropic_base_url}}"
    {{/if}}
fi
