# Track 9 QA lab template (do not commit real secrets into .env.production)

# Core runtime
CC_DATA_DIR=.data
DATABASE_URL=postgresql://mvp:mvp@<postgres-host>:5432/mvpcc
SCHEMA_MANAGEMENT_MODE=migrations

# Internal service URLs (cluster/internal or host-routed URLs)
INTERACTION_SERVICE_URL=http://interaction-service:8000
VOICE_ADAPTER_SERVICE_URL=http://voice-adapter-service:8000
RECORDING_SERVICE_URL=http://recording-service:8000
TELEGRAM_ADAPTER_SERVICE_URL=http://telegram-adapter-service:8000
AI_ORCHESTRATOR_SERVICE_URL=http://ai-orchestrator-service:8000
AI_VOICE_RUNTIME_SERVICE_URL=http://ai-voice-runtime-service:8000
SALES_SERVICE_URL=http://sales-service:8000
SALES_TELEGRAM_BRIDGE_ENABLED=1
SALES_VOICE_RUNTIME_ENABLED=1

# Telegram real-bot chat (Track 15)
TELEGRAM_BOT_ENABLED=1
TELEGRAM_BOT_TOKEN=<telegram-bot-token>
TELEGRAM_WEBHOOK_SECRET=<telegram-webhook-secret>
TELEGRAM_DEFAULT_QUEUE_ID=<platform-telegram-queue-id>
TELEGRAM_BOT_API_BASE=https://api.telegram.org
WHATSAPP_DEFAULT_QUEUE_ID=<platform-whatsapp-queue-id-or-q_whatsapp>
WHATSAPP_WEBHOOK_SECRET=<legacy-whatsapp-webhook-secret-optional>
WHATSAPP_META_ACCESS_TOKEN=<meta-whatsapp-access-token>
WHATSAPP_META_PHONE_NUMBER_ID=<meta-whatsapp-phone-number-id>
WHATSAPP_META_VERIFY_TOKEN=<meta-whatsapp-verify-token>
WHATSAPP_META_APP_SECRET=<meta-app-secret>
WHATSAPP_META_GRAPH_API_VERSION=v22.0
WHATSAPP_OUTBOUND_ENABLED=0
AI_PROVIDER=openai_compatible
AI_API_BASE=https://<llm-host>/v1
AI_API_KEY=<llm-api-key>
AI_MODEL=<llm-model>
AI_TIMEOUT_SECONDS=20
AI_CUSTOMER_PERSONA_MODE=operator_humanlike
AI_DISCLOSURE_MODE=hidden
AI_TELEGRAM_ENABLED=0
AI_TELEGRAM_ALWAYS_REPLY=0
AI_TELEGRAM_MAX_CONTEXT_MESSAGES=12
AI_TELEGRAM_MAX_KB_RESULTS=3
AI_TELEGRAM_CONFIDENCE_HANDOFF_THRESHOLD=0.65
AI_WHATSAPP_ENABLED=0
AI_WHATSAPP_ALWAYS_REPLY=0
AI_WHATSAPP_MAX_CONTEXT_MESSAGES=12
AI_WHATSAPP_MAX_KB_RESULTS=3
AI_WHATSAPP_CONFIDENCE_HANDOFF_THRESHOLD=0.65
AI_VOICE_ENABLED=0
AI_VOICE_POLICY_MODE=v2_fast_conversational
AI_VOICE_QUEUE_CONFIG_JSON={"voice_lab_ai":{"mode":"ai_first","agent_profile":"voice_support","handoff_queue_code":"voice_lab","language":"ru"}}
AI_VOICE_ASR_PROVIDER=elevenlabs
AI_VOICE_TTS_PROVIDER=elevenlabs
AI_VOICE_V2_ENABLED=1
AI_VOICE_V2_QUEUE_CODES=voice_lab,voice_lab_ai,ivr_sales_ai_ru,ivr_support_ai_ru,ivr_sales_ai_kz,ivr_support_ai_kz
AI_VOICE_V2_ACK_MODE=immediate_short
AI_VOICE_V2_DUPLEX_ENABLED=1
AI_VOICE_V2_STREAMING_ASR_BACKEND=elevenlabs_realtime
AI_VOICE_V2_STREAMING_ASR_BASE_URL=http://streaming-asr-sidecar:8021
AI_VOICE_V2_STREAMING_ASR_TIMEOUT_SECONDS=4
AI_VOICE_V2_STREAMING_ASR_MODEL=base
AI_VOICE_V2_STREAMING_ASR_COMPUTE_TYPE=int8
AI_VOICE_V2_STREAMING_ASR_DEVICE=cpu
AI_VOICE_V2_STREAMING_ASR_CACHE_DIR=/models/faster_whisper
AI_VOICE_V2_STREAMING_ASR_SUPPORTED_LANGUAGES=ru,kk,kz
AI_VOICE_V2_PREBAKED_ACK_ENABLED=1
AI_VOICE_V2_PREBAKED_ACK_DIR=/app/.data/voice_v2_ack_bank
AI_VOICE_V2_STREAMING_TTS=1
AI_VOICE_V2_PARTIAL_ASR=1
AI_VOICE_V2_EMOTIVE_ACK_ENABLED=1
AI_VOICE_V2_EMOTIVE_ACK_RU_ONLY=1
AI_VOICE_AUDIOSOCKET_ENABLED=1
AI_VOICE_AUDIOSOCKET_HOST=0.0.0.0
AI_VOICE_AUDIOSOCKET_PORT=9019
AI_VOICE_ASR_MODEL=gpt-4o-mini-transcribe
AI_VOICE_ASR_ELEVENLABS_API_BASE=https://api.elevenlabs.io
AI_VOICE_ASR_ELEVENLABS_API_KEY=<elevenlabs-api-key-optional>
AI_VOICE_ASR_ELEVENLABS_MODEL_ID=scribe_v1
AI_VOICE_ASR_ELEVENLABS_LANGUAGE=ru
AI_VOICE_ASR_ELEVENLABS_SAMPLE_RATE_HZ=16000
AI_VOICE_ASR_ELEVENLABS_REALTIME_MODEL_ID=scribe_v2_realtime
AI_VOICE_ASR_ELEVENLABS_REALTIME_AUDIO_FORMAT=pcm_16000
AI_VOICE_ASR_ELEVENLABS_REALTIME_COMMIT_STRATEGY=manual
AI_VOICE_ASR_ELEVENLABS_REALTIME_FINALIZE_TIMEOUT_SECONDS=2.5
AI_VOICE_TTS_MODEL=gpt-4o-mini-tts
AI_VOICE_TTS_VOICE=alloy
AI_VOICE_TTS_YANDEX_API_BASE=https://tts.api.ml.yandexcloud.kz
AI_VOICE_TTS_YANDEX_API_KEY=<yandex-api-key-optional>
AI_VOICE_TTS_YANDEX_IAM_TOKEN=<yandex-iam-token-optional>
AI_VOICE_TTS_YANDEX_FOLDER_ID=<yandex-folder-id-for-user-iam-token-optional>
AI_VOICE_TTS_YANDEX_VOICE=jane
AI_VOICE_TTS_YANDEX_KK_VOICE=amira
AI_VOICE_TTS_YANDEX_SPEED=1.0
AI_VOICE_TTS_YANDEX_ROLE=
# backward-compatible alias for old v1-style config
AI_VOICE_TTS_YANDEX_EMOTION=
AI_VOICE_TTS_YANDEX_SAMPLE_RATE_HZ=8000
AI_VOICE_TTS_ELEVENLABS_API_BASE=https://api.elevenlabs.io
AI_VOICE_TTS_ELEVENLABS_API_KEY=<elevenlabs-api-key-optional>
AI_VOICE_TTS_ELEVENLABS_MODEL_ID=eleven_v3
AI_VOICE_TTS_ELEVENLABS_OUTPUT_FORMAT=pcm_16000
AI_VOICE_TTS_ELEVENLABS_RU_VOICE_ID=nPczCjzI2devNBz1zQrb
AI_VOICE_TTS_ELEVENLABS_RU_LANGUAGE_CODE=ru
AI_VOICE_TTS_ELEVENLABS_KK_VOICE_ID=nPczCjzI2devNBz1zQrb
AI_VOICE_TTS_ELEVENLABS_KK_LANGUAGE_CODE=kk
AI_VOICE_TTS_CACHE_ENABLED=1
AI_VOICE_TTS_CACHE_DIR=/app/.data_local/ai_voice_tts_cache
AI_VOICE_VAD_MIN_SPEECH_MS=300
AI_VOICE_VAD_TRAILING_SILENCE_MS=400
AI_VOICE_VAD_RMS_THRESHOLD=250
AI_VOICE_TURN_MAX_MS=10000
AI_VOICE_MEDIA_IDLE_TIMEOUT_SECONDS=15
AI_VOICE_MAX_CONTEXT_SEGMENTS=12
AI_VOICE_HANDOFF_TIMEOUT_SECONDS=8
AI_VOICE_RUNTIME_TRUSTED_SERVICE_SUBJECTS=svc:ai-voice-runtime

# Gateway error alerts (Telegram)
ERROR_TELEGRAM_ALERTS=0
ERROR_TELEGRAM_ALERT_BOT_TOKEN=<telegram-bot-token>
ERROR_TELEGRAM_ALERT_CHANNEL_ID=<telegram-channel-id-or-username>
# Alternative: ERROR_TELEGRAM_ALERT_CHAT_IDS=<id1>,<id2>
ERROR_TELEGRAM_ALERT_MIN_STATUS=500
ERROR_TELEGRAM_ALERT_COOLDOWN_SECONDS=60
ERROR_TELEGRAM_ALERT_IGNORE_PATHS=/health

# Event bus compatibility (Track 8 baseline)
EVENT_BUS_ENABLED=1
EVENT_BUS_URL=amqp://guest:guest@<rabbitmq-host>:5672/
EVENT_BUS_EXCHANGE=mvpcc.domain.events
EVENT_BUS_CONSUMER_ENABLED=1

# Asterisk bridge (Track 9)
ASTERISK_BRIDGE_ENABLED=1
ASTERISK_AMI_HOST=<asterisk-linux-vm-host>
ASTERISK_AMI_PORT=5038
ASTERISK_AMI_USERNAME=mvpcc
ASTERISK_AMI_SECRET=<replace-me>
ASTERISK_AMI_EVENT_PREFIX=MVPCC
ASTERISK_QUEUE_MAP_JSON={"voice_lab":"<platform_queue_id>","voice_lab_ai":"<platform_ai_queue_id_or_same_queue_id>","voice_lab_ivr":"<platform_ivr_queue_id>"}
ASTERISK_BRIDGE_POLL_INTERVAL_SECONDS=1
# Bridge internal auth for QA:
# keep legacy_headers for Track 9 acceptance baseline.
# use bearer_first or bearer in Track 9.1 hardening.
ASTERISK_BRIDGE_AUTH_MODE=legacy_headers
ASTERISK_BRIDGE_AUTH_FALLBACK_LEGACY=1
ASTERISK_BRIDGE_AUTH_SUBJECT=svc:asterisk-bridge
ASTERISK_BRIDGE_AUTH_USER=asterisk-bridge
ASTERISK_BRIDGE_AUTH_ROLE=admin
ASTERISK_BRIDGE_AUTH_TOKEN_TTL_SECONDS=300
ASTERISK_IVR_FASTAGI_ENABLED=1
ASTERISK_IVR_FASTAGI_HOST=0.0.0.0
ASTERISK_IVR_FASTAGI_PORT=4573
ASTERISK_IVR_DTMF_TIMEOUT_SECONDS=5
ASTERISK_IVR_MAX_NO_INPUT_RETRIES=2
ASTERISK_IVR_MAX_INVALID_RETRIES=2
ASTERISK_IVR_CALL_LINK_WAIT_SECONDS=5
ASTERISK_CALLCONTROL_ENABLED=0
ASTERISK_CALLCONTROL_ACTION_TIMEOUT_SECONDS=10
ASTERISK_WEBRTC_ENABLED=0
ASTERISK_WEBRTC_WS_URL=wss://<asterisk-linux-vm-host>:8089/ws
ASTERISK_WEBRTC_ICE_SERVERS_JSON=[]
ASTERISK_OPERATOR_EXTENSION_MAP_JSON={"operator_a":"2001","operator_b":"2002"}
ASTERISK_BROWSER_SIP_MAP_JSON={"operator":{"authorization_username":"2001","password":"<browser-sip-password>","display_name":"Operator Browser","operator_extension":"2001"}}
ASTERISK_TRANSFER_TARGET_MAP_JSON={"voice_lab":"2001","voice_lab_ai":"2001","voice_lab_ivr":"7200"}

# Track 9.1 service-token hardening
IVR_RUNTIME_TRUSTED_SERVICE_SUBJECTS=svc:asterisk-bridge
VOICE_ADAPTER_TRUSTED_SERVICE_SUBJECTS=svc:asterisk-bridge,svc:ivr-service
RECORDING_IMPORT_TRUSTED_SERVICE_SUBJECTS=svc:asterisk-bridge
# set to 0 in strict QA/prod mode
RECORDING_IMPORT_ALLOW_ADMIN=1

# SFTP pickup from Asterisk VM
ASTERISK_SFTP_HOST=<asterisk-linux-vm-host>
ASTERISK_SFTP_PORT=22
ASTERISK_SFTP_USERNAME=<linux-user>
ASTERISK_SFTP_PASSWORD=<replace-me>
ASTERISK_SFTP_BASE_PATH=/var/spool/asterisk/monitor
