A comprehensive AI agent monitoring and safety system that tracks agent behaviors, assesses risks in real-time, and provides alerts when agents cross safety thresholds.
- Agent Registration: Register AI agents with unique API keys for monitoring
- Behavior Logging: Track and log agent actions with risk scores
- Risk Assessment: Real-time risk evaluation with multiple factors
- Alert System: Automatic alerts when risk levels reach high/critical thresholds
- Real-time Dashboard: Live monitoring with WebSocket updates
- Data Visualization: Interactive charts for risk trends and behavior analysis
- Settings Management: Configurable risk thresholds and notification preferences
autoguard-ai/
├── apps/
│ ├── api/ # Express.js backend API
│ └── web/ # React frontend dashboard
└── packages/
└── shared/ # Shared TypeScript types and utilities
- Backend: Node.js, Express, TypeScript, WebSocket (ws)
- Frontend: React, TypeScript, TailwindCSS, Recharts
- Build: pnpm workspaces, Vite
- Node.js 18+
- pnpm 8+
# Clone the repository
git clone <repository-url>
cd autoguard-ai
# Install dependencies
pnpm install
# Build shared package
pnpm --filter @autoguard-ai/shared build# Start API server (from root)
pnpm --filter @autoguard-ai/api dev
# Start web dev server (in another terminal)
pnpm --filter @autoguard-ai/web devThe API server runs on http://localhost:3000 and WebSocket on ws://localhost:3001.
The web app runs on http://localhost:5173.
# Build all packages
pnpm build
# Or build individually
pnpm --filter @autoguard-ai/api build
pnpm --filter @autoguard-ai/web buildMost endpoints require an API key in the X-API-Key header. Get your API key when registering an agent.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/agents |
List all agents |
| GET | /api/agents/:id |
Get agent by ID |
| POST | /api/agents |
Create new agent |
| PUT | /api/agents/:id |
Update agent |
| DELETE | /api/agents/:id |
Delete agent |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/logs |
Submit behavior log (auth required) |
| GET | /api/agents/:id/logs |
Get agent's behavior logs |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/agents/:id/risk |
Get agent's risk assessment |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/alerts |
List all alerts |
| GET | /api/alerts/recent |
Get recent alerts |
| GET | /api/alerts/:id |
Get alert by ID |
| POST | /api/alerts |
Create alert |
| POST | /api/alerts/:id/acknowledge |
Acknowledge alert |
| POST | /api/alerts/:id/resolve |
Resolve alert |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/settings |
Get all settings |
| PUT | /api/settings |
Update settings |
| GET | /api/settings/thresholds |
Get risk thresholds |
| PUT | /api/settings/thresholds |
Update thresholds |
curl -X POST http://localhost:3000/api/agents \
-H "Content-Type: application/json" \
-d '{"name": "My Agent", "description": "A helpful AI assistant"}'Response:
{
"success": true,
"data": {
"id": "1234567890-abc123",
"name": "My Agent",
"description": "A helpful AI assistant",
"apiKey": "ag-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"status": "active",
"riskLevel": "low",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
}curl -X POST http://localhost:3000/api/logs \
-H "Content-Type: application/json" \
-H "X-API-Key: ag-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-d '{
"agentId": "agent-id",
"action": "data_access",
"description": "Accessed user profile data",
"riskScore": 25
}'| Level | Score Range | Description |
|---|---|---|
| Low | 0-24 | Normal, safe behavior |
| Medium | 25-49 | Minor concerns, monitor closely |
| High | 50-74 | Significant risk, review recommended |
| Critical | 75-100 | Severe risk, immediate action required |
The system evaluates risk based on multiple factors:
- Activity Frequency: Number of recent actions
- High-Risk Actions: Count of actions with high risk scores
- Behavior Consistency: Variance in behavior patterns
- Risk Trend: Direction of risk level changes
Connect to ws://localhost:3001 for real-time updates:
const ws = new WebSocket('ws://localhost:3001');
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
console.log('Event:', message.type, message.payload);
};agent:created- New agent registeredagent:updated- Agent details changedagent:deleted- Agent removedbehavior:logged- New behavior log submittedrisk:updated- Agent risk level changedalert:created- New alert triggeredalert:acknowledged- Alert acknowledgedalert:resolved- Alert resolved
# API Server
PORT=3000
# WebSocket Server (runs on port + 1)
WS_PORT=3001Access the Settings page in the dashboard to configure:
- Risk Thresholds: Customize score boundaries for each risk level
- Alert Rules: Enable/disable automatic alert triggers
- Notifications: Configure email and webhook notifications
Express.js backend with:
- RESTful API routes
- WebSocket server for real-time updates
- In-memory storage (can be extended to use databases)
- Risk calculation algorithms
React frontend with:
- Dashboard with real-time charts
- Agent registration and management
- Detailed agent view with risk assessment
- Settings configuration
- Responsive design with TailwindCSS
Shared TypeScript types and utilities:
- Type definitions for all data models
- API request/response types
- Risk calculation functions
- ID and API key generation
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT