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
Theroom package provides room management functionality for collaborative sessions, including workspace isolation, client connections, and resource cleanup.
Types
Manager
Manages all active rooms and their lifecycle.Room
Represents a collaborative session with shared terminal and AI chat.Client
Represents a connected user in a room.RoomEvent
Events broadcast to room participants.AIMessage
AI chat message stored in room history.Manager Functions
NewManager
Creates a new room manager instance.URL for the AI worker service (empty string disables AI features)
Shared AI client for all rooms
Logger instance for room events
CreateRoom
Creates a new collaborative room with isolated workspace.Username of the room host
Room description (used to generate workspace name)
*Room: The created room with unique IDerror: If workspace creation fails
- Slugified description if provided (e.g., “my project” → “my-project”)
- Random readable name if empty (e.g., “swift-phoenix”, “cosmic-dragon”)
- Max 30 characters
GetRoom
Retrieves an existing room by ID.Unique room identifier
*Room: The requested roomerror:ErrRoomNotFoundif room doesn’t exist
LeaveRoom
Removes a client from a room and cleans up if empty.Room to leave
Client identifier
true if the room was destroyed (last client left)
Cleanup Actions:
- Closes terminal if exists
- Removes workspace directory
- Calls worker API to cleanup sandbox resources
- Deletes room from manager
GetAIClient
Retrieves the shared AI client.RoomCount
Returns the number of active rooms.Room Methods
AddClient
Adds a client to the room and broadcasts join event.Client to add (replaces existing client with same ID)
RemoveClient
Removes a client and broadcasts leave event.BroadcastEvent
Sends an event to all clients except one.Event to broadcast
Client ID to exclude (typically the sender)
GetClients
Returns a copy of all connected clients.ClientCount
Returns the number of connected clients.SetAIMessages / GetAIMessages
Thread-safe AI message history management.Errors
Workspace Isolation
Each room gets an isolated workspace directory:- Production: Copies
/app/workspace-template/to/app/workspaces/{name}/ - Development: Creates empty directory in temp folder