How fuatu/safeai works
SafeAI is a local AI-agent security gateway with a dashboard for reviewing risky actions and session history. Agents send tool calls through the gateway; it identifies the client, evaluates risk, explains the action, masks secrets, and either forwards it or pauses for human approval. The dashboard also manages client connections, policies, and settings, while audit records support session and action history. README capabilities include chat-history ingestion and an OpenAI-compatible proxy; their detailed implementations were not excerpted, so only documented entry points are shown. Edges reflect excerpted calls or README claims.
Main entry points: App.tsx Dashboard App · proxy.py MCP Gateway · api.py Dashboard API · openai_proxy.py OpenAI Proxy
Components 23
Agent Gateway
- MCP Gateway
backend/gateway/proxy.py - OpenAI Proxy
backend/gateway/openai_proxy.py - Client Resolver
backend/gateway/client_resolver.py - MCP Router
backend/gateway/mcp_server.py - Chat History Ingestion
backend/gateway
Security & Decisions
- Risk Scoring
backend/security/engine.py - Secret Masking
backend/security/dlp.py - Action Explainer
backend/explainer/engine.py - Approval Broker
backend/hitl/broker.py
Audit & Configuration
- Dashboard API
backend/routes/api.py - WebSocket Updates
backend/routes/ws.py - Audit Store
backend/storage/audit_store.py - Session & Policy Models
backend/models/schemas.py - Client Config Catalog
backend/gateway/client_configs.py
Dashboard
- Dashboard App
frontend/src/App.tsx - Approval Dialog
frontend/src/components/ApprovalModal.tsx - Session Views
frontend/src/components/SessionsPage.tsx - Session Timeline
frontend/src/components/SessionTimeline.tsx - Live Activity
frontend/src/components/LiveActivityView.tsx - Settings Panel
frontend/src/components/SettingsPanel.tsx - Client Setup Panel
frontend/src/components/ClientConfigPanel.tsx
Other components
- AI Agent
- User
Connections 31
- AI Agent → MCP Router: sends tool calls
README.md - MCP Router → MCP Gateway: routes MCP
backend/gateway/mcp_server.py - MCP Gateway → Client Resolver: resolves client
backend/gateway/proxy.py - MCP Gateway → Risk Scoring: evaluates payload
backend/gateway/proxy.py - MCP Gateway → Secret Masking: masks secrets
backend/gateway/proxy.py - MCP Gateway → Action Explainer: explains action
backend/gateway/proxy.py - MCP Gateway → Approval Broker: requests decision
backend/gateway/proxy.py - Approval Broker → User: requests approval
README.md - User → Dashboard API: submits decision
backend/routes/api.py - Dashboard API → Approval Broker: submits decision
backend/routes/api.py - MCP Gateway → Audit Store: records actions
backend/gateway/proxy.py - Dashboard API → Audit Store: reads sessions
backend/routes/api.py - Audit Store → Session & Policy Models: stores records
backend/storage/audit_store.py - Dashboard API → Risk Scoring: evaluates intercept
backend/routes/api.py - Dashboard API → Action Explainer: explains intercept
backend/routes/api.py - Dashboard API → Client Config Catalog: serves client configs
backend/routes/api.py - OpenAI Proxy → Risk Scoring: evaluates requests
backend/gateway/openai_proxy.py - OpenAI Proxy → Approval Broker: requests decision
backend/gateway/openai_proxy.py - OpenAI Proxy → Secret Masking: masks secrets
backend/gateway/openai_proxy.py - OpenAI Proxy → Action Explainer: explains action
backend/gateway/openai_proxy.py - OpenAI Proxy → Audit Store: records actions
backend/gateway/openai_proxy.py - Dashboard App → Dashboard API: loads dashboard data
- Dashboard App → Approval Dialog: renders approval
frontend/src/App.tsx - Dashboard App → Session Views: renders sessions
frontend/src/App.tsx - Session Views → Session Timeline: renders timeline
- Dashboard App → Live Activity: renders activity
frontend/src/App.tsx - Dashboard App → Settings Panel: renders settings
frontend/src/App.tsx - Dashboard App → Client Setup Panel: renders client setup
frontend/src/App.tsx - Dashboard App → WebSocket Updates: receives updates
- WebSocket Updates → Approval Broker: reports approvals
backend/routes/ws.py - Chat History Ingestion → Audit Store: records conversations
README.md