Skip to main content

GatewayProtocol

Defined in the gateway module.
Rust AI Agent SDK Protocol for gateway/control plane implementations. The gateway coordinates communication between clients and agents, manages sessions, and provides health/presence tracking.

Methods

is_running

fn is_running(&self) -> bool
Whether the gateway is currently running.

port

fn port(&self) -> u16
Port the gateway is listening on.

host

fn host(&self) -> &str
Host the gateway is bound to.

start

async fn start(&mut self) -> Result<()>
Start the gateway server.

stop

async fn stop(&mut self) -> Result<()>
Stop the gateway server.

register_agent

fn register_agent(&mut self, agent: Arc<Agent>, agent_id: Option<String>) -> String
Register an agent with the gateway. Parameters:
NameType
agentArc&lt;Agent&gt;
agent_idOption&lt;String&gt;

unregister_agent

fn unregister_agent(&mut self, agent_id: &str) -> bool
Unregister an agent from the gateway. Parameters:
NameType
agent_id&str

get_agent

fn get_agent(&self, agent_id: &str) -> Option<Arc<Agent>>
Get a registered agent by ID. Parameters:
NameType
agent_id&str

list_agents

fn list_agents(&self) -> Vec<String>
List all registered agent IDs.

create_session

fn create_session(
        &mut self,
        agent_id: &str,
        client_id: Option<String>,
        session_id: Option<String>,
    ) -> Result<Box<dyn GatewaySessionProtocol>>
Create a new session. Parameters:
NameType
agent_id&str
client_idOption&lt;String&gt;
session_idOption&lt;String&gt;

get_session

fn get_session(&self, session_id: &str) -> Option<&dyn GatewaySessionProtocol>
Get a session by ID. Parameters:
NameType
session_id&str

close_session

fn close_session(&mut self, session_id: &str) -> bool
Close a session. Parameters:
NameType
session_id&str

list_sessions

fn list_sessions(&self, agent_id: Option<&str>) -> Vec<String>
List session IDs, optionally filtered by agent. Parameters:
NameType
agent_idOption&lt;&str&gt;

emit

async fn emit(&self, event: GatewayEvent) -> Result<()>
Emit an event to registered handlers. Parameters:
NameType
eventGatewayEvent

broadcast

async fn broadcast(&self, event: GatewayEvent, exclude: Option<Vec<String>>) -> Result<()>
Broadcast an event to all connected clients. Parameters:
NameType
eventGatewayEvent
excludeOption&lt;Vec&lt;String&gt;&gt;

health

fn health(&self) -> GatewayHealth
Get gateway health status.

Source

View on GitHub

praisonai/src/gateway/mod.rs at line 0