""" FastAPI server for the SQL Debug Environment. Hooks into openenv-core's create_fastapi_app() for the standard /ws endpoint, then slaps on a landing page and health check on top. Nothing fancy. """ from __future__ import annotations import logging from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import HTMLResponse from openenv.core.env_server import create_fastapi_app from server.environment import SQLDebugEnvironment from sql_debug_env.models import SQLAction, SQLObservation logger = logging.getLogger("sql-debug-env") logging.basicConfig(level=logging.INFO) # ── Wire up the OpenEnv app ──────────────────────────────────────── app: FastAPI = create_fastapi_app( env=SQLDebugEnvironment, action_cls=SQLAction, observation_cls=SQLObservation, ) app.title = "SQL Debug Environment" app.description = ( "OpenEnv-compatible environment for SQL debugging and optimization. " "Agents fix broken queries through iterative execution feedback." ) app.version = "1.0.0" app.contact = {"name": "SQL Debug Env Team"} app.license_info = {"name": "MIT", "url": "https://opensource.org/licenses/MIT"} # Wide open CORS — this is a dev/hackathon tool, not a bank app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # ── Landing page ──────────────────────────────────────────────────── # # Just a quick info card so you know it's alive when you hit the root URL. # Nothing too wild — dark theme, lists the tasks, links to the docs. LANDING_HTML = """
Interactive SQL debugging & optimization — powered by OpenEnv
📖 Swagger Docs | 📋 ReDoc