Refactor: fix async errors, CRLF line endings and bot tokens.

This commit is contained in:
2026-03-24 00:02:56 +00:00
parent b7e6239216
commit cb729809a9
6 changed files with 103 additions and 105 deletions

View File

@@ -148,4 +148,3 @@ def gitea_api_url(): return GITEA_API_URL
def supabase_url(): return "https://supabase.reifonas.cloud" def supabase_url(): return "https://supabase.reifonas.cloud"
def supabase_anon_key(): return get_segredo("supabase", "ANON_KEY") def supabase_anon_key(): return get_segredo("supabase", "ANON_KEY")
def supabase_service_role_key(): return get_segredo("supabase", "SERVICE_ROLE_KEY") def supabase_service_role_key(): return get_segredo("supabase", "SERVICE_ROLE_KEY")
print(f" Coolify API: {coolify_api_base()}")

11
main.py
View File

@@ -5,14 +5,14 @@ import time
import json import json
import asyncio import asyncio
from fastapi import FastAPI, Request, Header, Depends, HTTPException, status from fastapi import FastAPI, Request, Header, Depends, HTTPException, status
from fastapi.responses import HTMLResponse, JSONResponse from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from dotenv import load_dotenv from dotenv import load_dotenv
from starlette.concurrency import run_in_threadpool from starlette.concurrency import run_in_threadpool
from ai_agent import query_agent from ai_agent import query_agent
from config import get_config, save_config from config import get_config, save_config
from credential_manager import sync_credentials, sync_from_gitea_repo from credential_manager import fetch_from_gitea_repo_async
from orchestrator import ( from orchestrator import (
orchestrate_async, handle_message_async, get_orchestrator_status, orchestrate_async, handle_message_async, get_orchestrator_status,
get_llm_config, set_llm_config, format_confirmation_message, get_llm_config, set_llm_config, format_confirmation_message,
@@ -30,8 +30,7 @@ templates = Jinja2Templates(directory="templates")
@app.on_event("startup") @app.on_event("startup")
async def startup_event(): async def startup_event():
print("[INIT] Sincronizando credenciais...") print("[INIT] Sincronizando credenciais...")
sync_from_gitea_repo() await fetch_from_gitea_repo_async(force=True)
sync_credentials()
# --- SEGURANÇA --- # --- SEGURANÇA ---
async def verify_password(x_web_password: str = Header(None)): async def verify_password(x_web_password: str = Header(None)):
@@ -41,9 +40,9 @@ async def verify_password(x_web_password: str = Header(None)):
return True return True
# --- WEB UI --- # --- WEB UI ---
@app.get("/", response_class=HTMLResponse) @app.get("/", response_class=FileResponse)
async def read_root(request: Request): async def read_root(request: Request):
return templates.TemplateResponse("index.html", {"request": request}) return FileResponse("templates/index.html")
@app.get("/api/status") @app.get("/api/status")
async def get_system_status(is_auth: bool = Depends(verify_password)): async def get_system_status(is_auth: bool = Depends(verify_password)):