File size: 1,296 Bytes
921792c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2cb8f5c
921792c
2cb8f5c
921792c
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Architecture

## Overview

`autonomy-labs` is a single-container FastAPI app intended to run on Hugging Face Spaces (Docker). It serves:
- static pages (`static/index.html`, `static/dashboard.html`)
- REST APIs for chat + Codex + MCP
- a WebSocket PTY-backed terminal (`/ws/terminal`)

## Backend layout

- `main.py`: minimal entrypoint (loads dotenv, creates app).
- `app/server.py`: app factory + lifespan lifecycle.
- `app/routes/*`: feature routers:
  - `base.py`: `/`, `/health`, `/config`
  - `chat.py`: `/api/chat`, `/api/proxy/models`
  - `codex.py`: `/api/codex*` and Codex login helpers
  - `mcp.py`: `/api/mcp/*`
  - `terminal.py`: `/ws/terminal`
  - `user.py`: `/api/me` and per-user persisted config (e.g., MCP registry)
- `app/auth.py`: Supabase access-token verification (server-side) with small TTL cache.
- `app/storage.py`: per-user server-side persistence directory selection (`/data` preferred).

## Frontend layout

Currently the UI is primarily `static/dashboard.html` with inline JS/CSS and CDN dependencies (Tailwind, xterm, etc).

## Execution safety model

The following capabilities are high-risk and gated:
- web terminal
- Codex execution endpoints
- MCP tool calls

Auth is enforced server-side via Supabase access tokens. Feature flags can disable them entirely.