Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jaypopat/cf_ai_duet/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Duet uses Cloudflare Workers to provide serverless AI-powered pair programming assistance. The worker routes requests to room-specific DuetAgent Durable Object instances based on room IDs extracted from the URL path.Worker Architecture
The main worker acts as a router that:- Extracts room IDs from incoming request URLs
- Routes requests to the appropriate DuetAgent Durable Object
- Handles room cleanup operations
Request Routing
The worker matches URLs against the pattern/api/rooms/{roomId}/{endpoint} using regex:
~/workspace/source/cf-worker/index.ts:28-42
Supported Endpoints
The worker supports three main endpoints:- POST /api/rooms//message - Send messages to the AI agent
- POST /api/rooms//sandbox/exec - Execute commands in the room’s sandbox
- DELETE /api/rooms/ - Clean up room resources
~/workspace/source/cf-worker/index.ts:60-65
Health Check
A simple health check endpoint is available:~/workspace/source/cf-worker/index.ts:34-36
DuetAgent Durable Object
TheDuetAgent class extends the Agent base class and maintains conversation state for each room. Each room gets its own DuetAgent instance.
State Management
~/workspace/source/cf-worker/index.ts:18-27
Request Handling
TheonRequest method routes incoming requests to appropriate handlers:
~/workspace/source/cf-worker/index.ts:92-120
Configuration
The worker is configured viawrangler.toml:
~/workspace/source/cf-worker/wrangler.toml:1-13
The configuration binds:
- DUET_AGENT - DuetAgent Durable Object instances
- Sandbox - Sandbox Durable Object instances
- AI - Cloudflare AI binding for LLM access
Client Integration
The Go backend communicates with the worker using the AI client:~/workspace/source/internal/ai/client.go:68-103
Next Steps
- Durable Objects - Learn about per-room state management
- LLM Integration - See how Llama 3 powers AI responses
- Sandboxes - Understand isolated command execution