###############################################################################
# MIGRATED TIM CONTAS - agent_framework_oci
# Source of truth for shared platform settings: official agent_framework_oci .env
# Contas-specific variables follow and are adapted to the same local model/DB/region.
###############################################################################

###############################################################################
# AI AGENT PLATFORM - CONFIGURAÇÃO ÚNICA
# Este arquivo é lido por Pydantic Settings no framework e no backend template.
###############################################################################

APP_NAME=ai-agent-template
APP_ENV=local
LOG_LEVEL=INFO
API_HOST=0.0.0.0
API_PORT=8000
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173

###############################################################################
# LLM - OCI Generative AI como provider principal
###############################################################################
# Opções: mock, oci_openai, oci_sdk, openai_compatible
LLM_PROVIDER=oci_sdk
LLM_TEMPERATURE=0.2
LLM_MAX_TOKENS=2048
LLM_TIMEOUT_SECONDS=120

# OCI OpenAI-compatible endpoint
OCI_GENAI_BASE_URL=https://inference.generativeai.us-chicago-1.oci.oraclecloud.com
OCI_GENAI_MODEL=openai.gpt-4.1
OCI_GENAI_API_KEY=<API_KEY>
OCI_GENAI_PROJECT_OCID=

#OCI_GENAI_BASE_URL=https://pegruagntaiatenddev.pe.inference.generativeai.sa-saopaulo-1.oci.oraclecloud.com
#OCI_GENAI_MODEL=openai.gpt-4.1
#OCI_GENAI_API_KEY=
#OCI_GENAI_PROJECT_OCID=


# OCI_AUTH_MODE=config_file|instance_principal|resource_principal
OCI_AUTH_MODE=config_file
# OCI SDK / signer / profiles
OCI_CONFIG_FILE=~/.oci/config
OCI_PROFILE=LATINOAMERICA-Chicago
OCI_COMPARTMENT_ID=ocid1.compartment.oc1..<COMPARTMENT_OCID>
OCI_REGION=us-chicago-1

###############################################################################
# Persistência
###############################################################################
# Opções: memory, autonomous, mongodb
SESSION_REPOSITORY_PROVIDER=autonomous
MEMORY_REPOSITORY_PROVIDER=autonomous
CHECKPOINT_REPOSITORY_PROVIDER=autonomous

# Autonomous Database
ADB_USER=admin
ADB_PASSWORD=<PASSWORD>
ADB_DSN=<TNS_ALIAS_OR_CONNECTION_DSN>
ADB_WALLET_LOCATION=/path/to/<REDACTED>
ADB_WALLET_PASSWORD=<PASSWORD>
ADB_TABLE_PREFIX=AGENTFW

# MongoDB - também pode representar Autonomous usando API compatível com Mongo, se habilitada no ambiente
MONGODB_URI=mongodb://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB>?<PARAMS>
MONGODB_DATABASE=agent_platform

# Redis
REDIS_URL=redis://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB>
ENABLE_REDIS_CACHE=false

###############################################################################
# RAG / Vector / Graph
###############################################################################
VECTOR_STORE_PROVIDER=autonomous
GRAPH_STORE_PROVIDER=autonomous
RAG_TOP_K=5
EMBEDDING_PROVIDER=oci
OCI_EMBEDDING_MODEL=cohere.embed-multilingual-v3.0
RAG_FILE_GLOBS=*.md,*.txt,*.yaml,*.yml,*.json

###############################################################################
# Observabilidade
###############################################################################
ENABLE_LANGFUSE=true
 # Opcional: verbose, compact
LANGFUSE_TRACE_MODE=compact
# Nome customizado do trace pai, ex.: backoffice.checklist.workflow ou backoffice.emulador.workflow
LANGFUSE_COMPACT_VISIBLE_EVENT_PREFIXES=AGA.,NOC., IC.
LANGFUSE_COMPACT_SUPPRESSED_PREFIXES=llm.chat_completion
LANGFUSE_IGNORE_HEALTHCHECKS=true
LANGFUSE_IGNORED_PATHS=/health,/ready,/metrics
LANGFUSE_PUBLIC_KEY=<PUBLIC_KEY>
LANGFUSE_SECRET_KEY=<SECRET_KEY>
LANGFUSE_HOST=http://<HOST>/<PATH>
ENABLE_OTEL=false
OTEL_EXPORTER_OTLP_ENDPOINT=
OTEL_SERVICE_NAME=ai-agent-template
ENABLE_LANGFUSE_OPENAI_AUTO_INSTRUMENTATION=true
ENABLE_LANGFUSE_ANALYTICS_PUBLISHER=false

###############################################################################
# Analytics / Observer corporativo
###############################################################################
# Quando true, AgentObserver publica eventos IC.*, NOC.* e GRL.* nos providers abaixo.
ENABLE_ANALYTICS=false
# Providers aceitos: oci_streaming,pubsub,noop
ANALYTICS_PROVIDERS=oci_streaming
# Compatibilidade FIRST/TIM: pode informar AGENT_PUBSUB_TOPIC diretamente.
AGENT_PUBSUB_TOPIC=
GCP_PUBSUB_TOPIC_PATH=
GCP_PROJECT_ID=
GCP_PUBSUB_TOPIC=
GCP_PUBSUB_TIMEOUT_SECONDS=30
# Credencial GCP segue padrão Google:
# GOOGLE_APPLICATION_CREDENTIALS=/path/to/<CREDENTIAL_FILE>

###############################################################################
# OCI Streaming
###############################################################################
ENABLE_OCI_STREAMING=false
OCI_STREAM_ENDPOINT=
OCI_STREAM_OCID=
OCI_STREAM_PARTITION_KEY=agent-events

###############################################################################
# Guardrails, Judges, Supervisor
###############################################################################
ENABLE_INPUT_GUARDRAILS=true
ENABLE_OUTPUT_GUARDRAILS=true
ENABLE_JUDGES=true
ENABLE_SUPERVISOR=true
ENABLE_OUTPUT_SUPERVISOR=true
ENABLE_PARALLEL_GUARDRAILS=true
GUARDRAILS_FAIL_FAST=true
OUTPUT_SUPERVISOR_MAX_RETRIES=3
GUARDRAILS_CONFIG_PATH=./config/guardrails.yaml
JUDGES_CONFIG_PATH=./config/judges.yaml
PROMPT_POLICY_PATH=./config/prompt_policy.yaml

###############################################################################
# Gateway de canais
###############################################################################
DEFAULT_CHANNEL=web
# embedded = backend may parse simple/native channel payloads.
# external = backend only accepts GatewayRequest normalized by an external Channel Gateway.
FRAMEWORK_CHANNEL_INPUT_MODE=embedded
ENABLE_VOICE_ADAPTER=true
ENABLE_WHATSAPP_ADAPTER=true
ENABLE_TEXT_ADAPTER=true

#################################################
# ENTERPRISE ROUTING
#################################################
# Arquivo YAML com intents, keywords, políticas de estado e fallback.
ROUTING_CONFIG_PATH=./config/routing.yaml
# true = usa LLM para classificar quando keywords/estado não resolverem.
# Em produção, costuma ser útil; em desenvolvimento, false evita custo e latência.
ENABLE_LLM_ROUTER=true

# Semantic route stickiness (optional).
# Uses a lightweight LLM profile to decide only CONTINUE vs ROUTE.
# There are no regexes or deterministic language rules.
ENABLE_ROUTE_STICKINESS=true
ROUTE_STICKINESS_LLM_PROFILE=route_continuity
ROUTE_STICKINESS_CONFIDENCE_THRESHOLD=0.90
ROUTE_STICKINESS_HISTORY_TURNS=2
ROUTE_STICKINESS_MAX_TOKENS=80
HUMAN_HANDOFF_MESSAGE=Vou encaminhar seu atendimento para uma pessoa.
END_SESSION_MESSAGE=Atendimento encerrado. Obrigado pelo contato.

###############################################################################
# MCP / Tools
###############################################################################
ENABLE_MCP_TOOLS=true
MCP_SERVERS_CONFIG_PATH=./config/mcp_servers.yaml
TOOLS_CONFIG_PATH=./config/tools.yaml
MCP_TOOL_TIMEOUT_SECONDS=30

# router = EnterpriseRouter seleciona um agente; supervisor = pode acionar múltiplos agentes
ROUTING_MODE=router

# Usage/cost accounting
USAGE_REPOSITORY_PROVIDER=autonomous
IDENTITY_CONFIG_PATH=./config/identity.yaml
MCP_PARAMETER_MAPPING_PATH=./config/mcp_parameter_mapping.yaml

# -----------------------------------------------------------------------------
# ConversationSummaryMemory / compressão de contexto conversacional
# -----------------------------------------------------------------------------
ENABLE_CONVERSATION_SUMMARY_MEMORY=true
MEMORY_CONTEXT_STRATEGY=summary
MEMORY_HISTORY_LIMIT=80
MEMORY_RECENT_MESSAGES_LIMIT=8
MEMORY_SUMMARY_TRIGGER_MESSAGES=20
MEMORY_MAX_SUMMARY_CHARS=6000
MEMORY_SUMMARY_USE_LLM=true
MEMORY_INJECT_RECENT_MESSAGES=true
MEMORY_INJECT_SUMMARY=true

###############################################################################
# LONG-TERM MEMORY
###############################################################################
ENABLE_LONG_TERM_MEMORY=true
LONG_TERM_MEMORY_PROVIDER=sqlite
LONG_TERM_MEMORY_SQLITE_PATH=./data/agent_framework.db
LONG_TERM_MEMORY_TABLE=agentfw_long_term_memory
# For Autonomous/Oracle, defaults to ${ADB_TABLE_PREFIX}_LONG_TERM_MEMORY
# LONG_TERM_MEMORY_ORACLE_TABLE=AGENTFW_LONG_TERM_MEMORY
LONG_TERM_MEMORY_MAX_CONTEXT_ITEMS=20
LONG_TERM_MEMORY_MIN_CONFIDENCE=0.70
LONG_TERM_MEMORY_AUTO_EXTRACT=true
LONG_TERM_MEMORY_INJECT_CONTEXT=true

###############################################################################
# CONTAS DOMAIN / LEGACY COMPATIBILITY (local values aligned to framework above)
###############################################################################
AGENT_NAME=ai-agent-contas
CHECKPOINT_BACKEND=mongodb
ENABLE_CONTROL_EVENTS_OTEL_LOGS=true
ENABLE_NOC_OTEL_LOGS=false
ENV_TESTE=123
GUARDRAIL_LLM="20b"
LANGFUSE_HOST=http://<HOST>/<PATH>
MONGODB_COLLECTION=sales_memory
MONGODB_CONNECTION_STRING=mongodb://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB>?<PARAMS>
OTEL_EXPORTER_OTLP_HOST_HEADER=tim-ai-atend-agnt-opentelemetry
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://<HOST>/<PATH>
PUBSUB_EXCLUDE_NOC=true
PUBSUB_PAYLOAD_MODE=flat
PUBSUB_SEQUENCE_ENABLED=true
PUBSUB_SEQUENCE_PROVIDER=mongodb
PUBSUB_SEQUENCE_MEMORY_FALLBACK=false
PUBSUB_SEQUENCE_MONGODB_COLLECTION=observer_sequences
PUBSUB_SEQUENCE_MONGODB_DATABASE=USR_ADB_AGNTATEND_W_DEV
PUBSUB_SEQUENCE_MONGODB_URI=mongodb://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB>?<PARAMS>
PUBSUB_SEQUENCE_PROVIDER=mongodb
PUBSUB_SEQUENCE_REDIS_URL=redis://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB>
TIM_AGENT_FRAMEWORK_EVENT_PAYLOAD_LOG_ENABLED=true
TIM_AGENT_FRAMEWORK_LOG_EXPORT_ENABLED=true
TIM_AGENT_ID=contas
TIM_APP_HOST=0.0.0.0
TIM_APP_LOG_LEVEL=INFO
TIM_APP_LOG_MASK_SENSITIVE_DATA=true
TIM_APP_PORT=8000
TIM_APP_RELOAD=false
TIM_APP_VERSION=1.0.0
TIM_APP_WS_PING_INTERVAL=10
TIM_APP_WS_PING_TIMEOUT=30
TIM_BLOQUEIO_ACCEPT_ENCODING=gzip,deflate
TIM_BLOQUEIO_CLIENT_ID=AIAGENTCR
TIM_BLOQUEIO_OPERATION_TYPE=block
TIM_BLOQUEIO_TIMEOUT=30
TIM_CANCELAMENTO_TIMEOUT=30
TIM_CANCELAMENTO_URL=http://<HOST>/<PATH>
TIM_CHANNEL_ADAPTER_DEFAULT_CHANNEL=voice
TIM_CHANNEL_ADAPTER_ENABLED=false
TIM_CHANNEL_ADAPTER_SHADOW=false
TIM_COMPLETE_INVOICES_TIMEOUT=30
TIM_COMPLETE_INVOICES_URL=http://<HOST>/<PATH>
TIM_CONSULTA_TIMEOUT=30
TIM_CONTRACT_VERSION=1.0.0
TIM_CONTRATO_TIMEOUT=30
TIM_CONTRATO_URL=http://<HOST>/<PATH>
TIM_CUSTOMER_CONTESTATION_CLIENT_ID=AIAGENTCR
TIM_CUSTOMER_CONTESTATION_TIMEOUT=30
TIM_CUSTOMER_CONTESTATION_URL=http://<HOST>/<PATH>
TIM_CUSTOMER_CONTESTATION_USER_ID=AIAGENTCR
TIM_DEFAULT_CHANNEL=APP
TIM_DEFAULT_CLIENT_ID=CHAT
TIM_DEFAULT_CSP_ID=740
TIM_DIVERGENCIA_TIMEOUT=120
TIM_DIVERGENCIA_URL=http://<HOST>/<PATH>
TIM_DIVERGENCIA_USER=agentecontestacao
TIM_GATEWAY_DEFAULT_TIMEOUT=30
TIM_GATEWAY_MODE=mock
TIM_GATEWAY_RETRY_BACKOFF_FACTOR=0.5
TIM_GATEWAY_RETRY_MAX_RETRIES=3
TIM_INVOICE_RECOVER_CLIENT_ID=AIAGENTCR
TIM_SECURE_PDF_AUTH=Basic <REDACTED_TOKEN>
TIM_INVOICE_RECOVER_TIMEOUT=30
TIM_JUDGES_BASELINE_SCORES=
TIM_JUDGES_MIN_SCORES=CSI=0,ALUC=7,RQLT=6,VCTN=8
#TIM_LLM_EXTRA={"auth_type":"RESOURCE_PRINCIPAL","provider":"meta","oci_use_oke_workload_signer":true}
TIM_LLM_OCI_AUTH_FILE_LOCATION=/path/to/<REDACTED>
TIM_LLM_EXTRA={"auth_type":"API_KEY","auth_profile":"LATINOAMERICA-Chicago","provider":"meta","oci_use_oke_workload_signer":false}
TIM_LLM_GATEWAY_FALLBACK_PROMPT_CONTENT=Você é um agente para operações VAS TIM. Use tools quando precisar executar ações no backend.
TIM_LLM_GATEWAY_FALLBACK_PROMPT_ID=default
TIM_LLM_GATEWAY_LANGFUSE_CACHE_TTL_SECONDS=60
TIM_LLM_GATEWAY_LANGFUSE_DEFAULT_LABEL=production
TIM_LLM_GATEWAY_LANGFUSE_FETCH_TIMEOUT_SECONDS=5
TIM_LLM_GATEWAY_LANGFUSE_HOST=http://<HOST>/<PATH>
TIM_LLM_GATEWAY_LANGFUSE_MASK_SENSITIVE_DATA=true
TIM_LLM_GATEWAY_LANGFUSE_MAX_RETRIES=3
TIM_LLM_GATEWAY_LANGFUSE_PUBLIC_KEY=<PUBLIC_KEY>
TIM_LLM_GATEWAY_LANGFUSE_SECRET_KEY=<SECRET_KEY>
TIM_LLM_GATEWAY_LANGGRAPH_TIMEOUT=5
TIM_LLM_GATEWAY_LOCAL_DIR=prompts
TIM_LLM_GATEWAY_SOURCES=txt
TIM_LLM_MODEL=openai.gpt-4.1
TIM_LLM_OCI_COMPARTMENT_ID=ocid1.compartment.oc1..<COMPARTMENT_OCID>
TIM_LLM_OCI_MODEL_ID=openai.gpt-4.1
TIM_LLM_OCI_MODEL_ID_120B=ocid1.generativeaiendpoint.oc1.<region>.<MODEL_ENDPOINT_OCID>
TIM_LLM_OCI_MODEL_ID_20B=ocid1.generativeaiendpoint.oc1.<region>.<MODEL_ENDPOINT_OCID>
TIM_LLM_OCI_MODEL_KWARGS={"temperature":0.0,"top_p":0.1,"reasoning_effort":"LOW","max_tokens":16384}
TIM_LLM_OCI_MODEL_KWARGS_120B={"temperature":0.0,"top_p":0.1,"reasoning_effort":"LOW","max_tokens":16384}
TIM_LLM_OCI_MODEL_KWARGS_20B={"temperature":0.0,"top_p":0.1,"reasoning_effort":"LOW","max_tokens":5000}
TIM_LLM_OCI_SERVICE_ENDPOINT=https://<HOST>/<PATH>
TIM_LLM_OCI_VARIANT=120b
TIM_LLM_PROVIDER=oci
TIM_MOCK_FIXTURES_DIR=<REDACTED>
TIM_OCI_FINGERPRINT=<OCI_API_KEY_FINGERPRINT>
TIM_OCI_KEY_FILE=/path/to/<REDACTED>
TIM_OCI_REGION=us-chicago-1
TIM_OCI_TENANCY=ocid1.tenancy.oc1..<TENANCY_OCID>
TIM_OCI_USER=ocid1.user.oc1..<USER_OCID>
TIM_PREFETCH_INVOICE_CONTEXT_USE_CACHE=true
TIM_PROFILE_FULL_URL=http://<HOST>/<PATH>
TIM_PROTOCOL_URL=http://<HOST>/<PATH>
TIM_RAG_DB_DSN=<TNS_ALIAS_OR_CONNECTION_DSN>
TIM_RAG_DB_USER=ADMIN
TIM_RAG_DB_PASSWORD=<PASSWORD>
TIM_RAG_DB_CONFIG_DIR=/path/to/<REDACTED>
TIM_RAG_ENABLED=true
TIM_RAG_OCI_AUTH_FILE_LOCATION=/path/to/<REDACTED>
TIM_RAG_OCI_SERVICE_ENDPOINT=https://<HOST>/<PATH>
TIM_RAG_OCI_USE_OKE_WORKLOAD_IDENTITY=true
TIM_SERVICE_REQUEST_STATUS_TIMEOUT=30
TIM_SERVICE_REQUEST_STATUS_URL=http://<HOST>/<PATH>
TIM_SMS_CLIENT_ID=AIAGENTCR
TIM_SMS_SENDER_ADDRESS=324
TIM_SMS_URL=http://<HOST>/<PATH>
TIM_STATE_BACKEND=oracle
#TIM_STATE_ORACLE_CONFIG_DIR=/path/to/<REDACTED>
#TIM_STATE_ORACLE_DSN=<TNS_ALIAS_OR_CONNECTION_DSN>
#TIM_STATE_ORACLE_PASSWORD=<PASSWORD>
TIM_STATE_ORACLE_POOL_ENABLED=true
TIM_STATE_ORACLE_POOL_INCREMENT=1
TIM_STATE_ORACLE_POOL_MAX=8
TIM_STATE_ORACLE_POOL_MIN=1
TIM_STATE_ORACLE_POOL_WAIT_TIMEOUT_MS=5000
#TIM_STATE_ORACLE_USER=admin
TIM_TENANT_ID=tim-brasil
TIM_TRACKING_ACTIVITIES_CHANNEL=AIAGENTCR
TIM_TRACKING_ACTIVITIES_CLIENT_ID=AIAGENTCR
TIM_TRACKING_ACTIVITIES_TIMEOUT=30
TIM_TRACKING_ACTIVITIES_URL=http://<HOST>/<PATH>
TIM_TRACKING_ACTIVITIES_USER_LOGIN=SIEBELPOS_INBOUND
TIM_URL_BLOQUEIO_VAS=http://<HOST>/<PATH>
TIM_URL_CONSULTA_VAS=http://<HOST>/<PATH>
TIM_URL_INVOICE_RECOVER=http://<HOST>/<PATH>
TIM_URL_PERFIL_FATURA=http://<HOST>/<PATH>
TIM_USE_MOCK_GATEWAY=true
TIM_VAS_HISTORY_TIMEOUT=30
TIM_VAS_HISTORY_URL=http://<HOST>/<PATH>
TIM_WORKFLOWS_DIR=workflows
TIM_WORKFLOW_POSTGRES_DSN=
USE_MOCK_LLM=false

TOOL_POLICIES_PATH=./config/tool_policies.yaml
SKIP_RAG_WHEN_MCP_SUFFICIENT=true
MCP_TOOL_CACHE_ENABLED=true
MCP_TOOL_CACHE_TTL_SECONDS=60

###############################################################################
# RAG provider selection (mutually exclusive at runtime)
###############################################################################
# standard = RAG original do agent_framework_oci (default, backward compatible)
# kbdb     = KBDB enterprise via PKG_KB_SERVING.SEARCH_KNOWLEDGE_BASE
RAG_PROVIDER=kbdb

# Somente usados quando RAG_PROVIDER=kbdb. Se vazios, credenciais caem para ADB_*.
KBDB_DB_USER=<DB_USER>
KBDB_DB_PASSWORD=<DB_PASSWORD>
KBDB_DB_DSN=db_dsn_high
KBDB_DB_WALLET_LOCATION=/ORACLE/Wallet_kbdb
KBDB_DB_WALLET_PASSWORD=<DB_WALLET_PASSWORD>
KBDB_SEARCH_TYPE=hybrid
KBDB_NODE_EXPANSION=true
KBDB_NODE_MAX_RELATED=8
KBDB_GRAPH_CROSS_REF=false
KBDB_MAX_CROSS_REF_HOPS=1
KBDB_DOCUMENT_TYPE=customer_safe
KBDB_METADATA_JSON=
KBDB_MIN_SCORE=0.5