Room APIs
Rooms also expose a set of room-scoped APIs through the room client:- Agents API
AgentsClient: Manages agent interactions. - Containers API
ContainersClient: Interact with containers on demand in a room. - Database API
DatabaseClient: Provides a simple relational-like API for data storage and retrieval through tables. - Memory API
MemoryClient: Manage room-scoped knowledge memories and recall context. - Developer API
DeveloperClient: Send structured logs to the Developer Console and stream developer log events. - Messaging API
MessagingClient: Enables real-time chat messaging among participants. - Queues API
QueuesClient: Facilitates reliable data/message exchange with other agents or participants. - Secrets API
SecretsClient: Create and manage oauth tokens and user secrets. - Storage API
StorageClient: Manages file storage and retrieval. - Sync API
SyncClient: Offers document synchronization capabilities, listing remote participants, allowing participants to collaborate on shared documents. ServicesClient(Python/TypeScript/Dart): List and restart room services. For deployment patterns, see Services & Containers.
Using the Room APIs with the MeshAgent CLI
The Room APIs are accessible from both the MeshAgent CLI and SDKs. You can explore the CLI for each Room API by running:CLI
Using Room APIs in Deployed Services
If you deploy a MeshAgent service and want that service to use the Room APIs, you must grant the service the appropriate Room API access through its participant tokenapi scope. Deployment alone does not automatically give a service access to storage, database, secrets, containers, or the other Room APIs.
The relevant places to configure that are:
- Service tokens injected through
container.environment[].token: set the token’sapiscope in the service manifest. - MeshAgent endpoints in a service manifest: set the endpoint
apiscope for the participant identity that joins the room.
ApiScope.agent_default()enables Agents, Queues, Messaging, Database, Sync, Storage, Containers, and Developer access.ApiScope.full()adds Secrets, Admin, and Tunnels access on top ofagent_default().
- Storage / Sync: path-based grants
- Database: table-level grants
- Queues: send/receive/list controls
- Messaging: broadcast/list/send controls
- Containers: pull/run/log controls
Getting Started from the CLI
If you want to start using the Room APIs quickly, the simplest path is:bash
- use the Room APIs from the CLI with
--room myroom - connect to
myroomfrom any SDK using the examples in Getting Started - deploy room-scoped services into
myroom
- a room grant allowing it to join the room
- an
apiscope granting access to the Room APIs it needs
Room Class Overview
Core Room behavior is consistent across SDKs, but available sub-clients vary by language. Use the section below that matches your client library.Python
from meshagent.api import RoomClient
- Connect with
async with RoomClient(protocol=...) as room:; the async context manager starts and stops the connection for you. - Issue requests with
await room.send_request(...); session metadata is available viaroom.session_id,room.room_url, androom.room_name. - Register event handlers with
room.on("room.status", handler); useroom.emit(...)to publish custom events. - Access sub-clients through snake_case attributes such as
room.agents,room.containers,room.database,room.developer,room.livekit,room.memory,room.messaging,room.queues,room.secrets,room.services,room.storage, androom.sync.
TypeScript / JavaScript
RoomClient in @meshagent/meshagent
- Instantiate the client with
{ protocol }and callawait room.start({ onDone, onError })to wait forroom_ready. - Clean up with
room.dispose()when you are finished. - Send RPCs with
await room.sendRequest(type, payload, data?); readiness is exposed viaawait room.ready. - Emit events with
room.emit(event)and consume them usingfor await (const evt of room.listen()). - Sub-clients are camelCase properties:
room.agents,room.containers,room.database,room.developer,room.memory,room.messaging,room.queues,room.secrets,room.services,room.storage, androom.sync.
Dart / Flutter
RoomClient in package:meshagent/room_server_client.dart
- Call
await room.start(onDone: ..., onError: ...)after constructing the client;room.readycompletes when the server sendsroom_ready. - Dispose resources with
room.dispose(); useawait room.exec(...)for container execution helpers. - Send requests with
await room.sendRequest(type, payload, data: ...). - Observe room activity with
room.events.listen(handler)or by keeping theStreamSubscriptionreturned fromroom.listen(...). - Access sub-clients via camelCase getters:
room.agents,room.containers,room.database,room.developer,room.memory,room.messaging,room.queues,room.secrets,room.services,room.storage, androom.sync.
.NET
Meshagent.RoomClient
- Construct
var room = new RoomClient(protocol);and callawait room.ConnectAsync();to wait for readiness. - Dispose with
await room.DisposeAsync();orawait using var room = new RoomClient(protocol);. - Send RPCs using
await room.SendRequest(type, payload, data);; session metadata is available viaroom.SessionId,room.RoomUrl, androom.RoomName. - Register handlers with
room.On("room.status", handler)and raise custom events throughroom.Emit(name, data). - Sub-clients are exposed as PascalCase properties:
room.Agents,room.Database,room.Developer,room.Livekit,room.Messaging,room.Queues,room.Secrets,room.Storage, androom.Sync.