JBoggsy/ues

The User Environment Simulator (UES) is an AI-driven testing and prototyping tool for AI personal assistants, providing a simple web app-based UI through which the developer can simulate a variety of different input modalities to a personal assistant agent, allowing for customizable and replicable testing of AI capabilities.

โ˜… 0Forks 0PythonGitHub โ†—Compare

README

User Environment Simulator (UES)

Python 3.12+ FastAPI License: MIT Tests

An AI-driven testing and prototyping tool for AI personal assistants. UES provides a simple web-based UI and comprehensive REST API for simulating a variety of input modalities, enabling customizable and reproducible testing of AI agent capabilities.

โœจ Features

  • Multi-Modal Simulation: Email, SMS, Calendar, Chat, Location, Weather, and more
  • REST API: 95 endpoints for complete control over simulation state
  • API Access Control: Key-based authentication with fine-grained permissions
  • Real-time Updates: WebSocket and Webhook support for event notifications
  • Python Client Library: Sync and async support for easy integration
  • Web UI: Modern React-based interface for interactive scenario design
  • Scenario Management: Save, export, and replay test scenarios
  • Time Control: Manual, event-driven, or auto-advance simulation modes
  • Agent Testing Harness: Evaluate AI agent performance with customizable criteria
  • Multi-Agent Coordination: Hold system for synchronizing concurrent agents

๐Ÿš€ Quick Start

Installation

# Using pip
pip install ues

# Using uv (recommended)
uv add ues

Start the API Server

# Using the CLI
ues server

# With auto-reload for development
ues server --reload

# Or directly with uvicorn
uvicorn main:app --reload

The API is now available at:

Basic Usage

Note: When the server starts, an admin API key is printed to the console. Save this key for authentication.

from ues.client import UESClient

# Connect to the server with your API key
client = UESClient("http://localhost:8000", api_key="ues_your_key_here...")

# Get current simulation time
time_state = client.time.get_state()
print(f"Simulator time: {time_state.current_time}")

# Simulate receiving an email
client.email.receive(
    from_addr="[email protected]",
    to_addr="[email protected]",
    subject="Meeting Tomorrow",
    body="Don't forget our 9am meeting!"
)

# Check email state
email_state = client.email.get_state()
print(f"Inbox has {len(email_state.inbox)} emails")

# Advance time by 1 hour
client.time.advance(hours=1)

๐Ÿ“ฆ Development Setup

Prerequisites

  • Python 3.12+
  • uv (recommended) or pip
  • Node.js 18+ (for Web UI)

Clone and Install

# Clone the repository
git clone https://github.com/JBoggsy/ues.git
cd ues

# Install Python dependencies
uv sync

# Install Web UI dependencies
cd webapp && npm install

Running Development Servers

# Terminal 1: Start API server with auto-reload
uv run ues server --reload

# Terminal 2: Start Web UI
cd webapp && npm run dev

Access:

Running Tests

# Run all tests
uv run pytest

# Run specific test file
uv run pytest tests/api/modalities/test_email_routes.py -v

# Run with coverage
uv run pytest --cov=api --cov=models

๐Ÿ“š Documentation

Document Description
Documentation Index Full documentation table of contents
REST API Reference Complete API endpoint documentation
Authentication API key authentication and permissions
Modality Routes Modality-specific endpoint patterns
Python Client Client library usage guide
Agent Integration Integrating AI agents with UES
Agent Testing Testing harness for evaluating AI agents
Scenarios Saving and loading test scenarios
WebSocket Real-time event notifications
Webhooks HTTP callback notifications

๐ŸŽฏ Supported Modalities

Modality Status Description
Email โœ… Complete Inbox, folders, threads, labels (19 operations)
SMS/RCS โœ… Complete Text messaging with reactions (13 actions)
Calendar โœ… Complete Events, recurrence, invitations
Chat โœ… Complete Conversational interface
Location โœ… Complete GPS coordinates, named places
Weather โœ… Complete Conditions, temperature, forecasts
Contacts ๐Ÿ“‹ Planned Contact database
File System ๐Ÿ“‹ Planned Directory tree, file operations
Discord/Slack ๐Ÿ“‹ Planned Messaging platforms
Social Media ๐Ÿ“‹ Planned Posts, feeds, interactions

๐Ÿ—๏ธ Architecture

UES uses an event-sourcing architecture where simulation state progresses through discrete events:

src/ues/                           # Main Python package
    โ”œโ”€โ”€ models/                    # Data models (events, modalities, etc.)
    โ”œโ”€โ”€ api/                       # FastAPI REST endpoints
    โ”œโ”€โ”€ client/                    # Python client library
    โ””โ”€โ”€ agent_testing/             # Testing harness for AI agents
tests/                             # Pytest test suite
webapp/                            # React + TypeScript web UI
docs/                              # Documentation
examples/                          # Example agents and scenarios

Core Components

SimulationEngine (Orchestrator)
    โ”œโ”€โ”€ Environment (Current state)
    โ”‚   โ”œโ”€โ”€ SimulatorTime (Virtual time tracking)
    โ”‚   โ””โ”€โ”€ ModalityStates (Email, Location, Calendar, etc.)
    โ”œโ”€โ”€ EventQueue (Scheduled events)
    โ””โ”€โ”€ SimulationLoop (Auto-advance threading)

Simulation Modes

  • Manual Mode: Time advances only via explicit API calls
  • Event-Driven Mode: Time skips directly to next scheduled event
  • Auto-Advance Mode: Real-time or accelerated time progression

See docs/models/SIMULATION_ENGINE.md for detailed architecture documentation.

๐ŸŒ REST API Overview

Authentication

All API endpoints require an API key via the X-API-Key header:

curl -H "X-API-Key: ues_your_key_here..." http://localhost:8000/simulation/status

An admin key with full permissions is generated at server startup. See Authentication docs for key management and permissions.

Time Control (`/simulator/time`)

GET  /simulator/time          # Get current time state
POST /simulator/time/advance  # Advance time by duration
POST /simulator/time/set      # Jump to specific time
POST /simulator/time/pause    # Freeze time
POST /simulator/time/resume   # Resume time

Events (`/events`)

GET  /events                  # List events with filters
POST /events                  # Schedule new event
POST /events/immediate        # Execute event immediately

Modalities (`/{modality}`)

GET  /{modality}/state        # Get current state
POST /{modality}/query        # Query with filters
POST /{modality}/*            # Modality-specific actions

Full API documentation: http://localhost:8000/docs (when server is running)

๐Ÿ”— External Agent Integration

UES is designed as an agent-interactable simulation platform:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    UES Core (Pure Simulation)               โ”‚
โ”‚  โ€ข Deterministic scenario execution                         โ”‚
โ”‚  โ€ข State management & event scheduling                      โ”‚
โ”‚  โ€ข REST API + WebSocket                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚                  โ”‚                  โ”‚
   Simulator-Side      User-Side Agent    Developer
   Agent (external)    (being tested)     (Web UI)
         โ”‚                  โ”‚                  โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    All use the same REST API

Use Cases:

  • Reactive Agents: Monitor for sent emails, generate replies
  • Content Generation: Use LLMs to create realistic test data
  • Trigger-based Events: Watch for conditions and schedule events
  • Character Simulation: Maintain personalities that respond consistently

Example Agents

The examples/agents/ directory contains complete, runnable agent implementations:

Example Description
simple_email_summary Basic email summarization agent
email_reply_generator Generates contextual email replies
calendar_conflict_resolver Resolves scheduling conflicts
sms_group_chat Multi-character SMS conversation simulator
party_planner Full integration example with testing harness

Agent Testing Harness

Evaluate AI agent performance with the built-in testing framework:

from ues.agent_testing import EvalRunner

runner = EvalRunner(
    scenario_path="./scenario.ues-scenario.json",
    criteria_path="./test_criteria.json",
)
report = await runner.run()
runner.print_report()  # Terminal scoreboard with grades

See docs/agent-testing/AGENT_TESTING.md for complete documentation.

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick Contributing Steps

  1. Fork the repository
  2. Create a feature branch (`git checkout -b feature/amazing-feature`)
  3. Make your changes with tests
  4. Commit (`git commit -m 'Add amazing feature'`)
  5. Push (`git push origin feature/amazing-feature`)
  6. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • FastAPI - Modern Python web framework
  • Pydantic - Data validation using Python type annotations
  • React + Vite - Frontend framework and tooling
  • shadcn/ui - Beautiful UI components

Contributors

JBoggsy

Issues