Gateway Protocol • Rust AI Agent SDK

GatewayProtocol: Protocol for gateway/control plane implementations. The gateway coordinates communication between clients and agents, manages sessions, and provides…

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

rust
fn is_running(&self) -> bool

Whether the gateway is currently running.

port

rust
fn port(&self) -> u16

Port the gateway is listening on.

host

rust
fn host(&self) -> &str

Host the gateway is bound to.

start

rust
async fn start(&mut self) -> Result<()>

Start the gateway server.

stop

rust
async fn stop(&mut self) -> Result<()>

Stop the gateway server.

register_agent

rust
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

rust
fn unregister_agent(&mut self, agent_id: &str) -> bool

Unregister an agent from the gateway.

Parameters:

NameType
agent_id&str

get_agent

rust
fn get_agent(&self, agent_id: &str) -> Option<Arc<Agent>>

Get a registered agent by ID.

Parameters:

NameType
agent_id&str

list_agents

rust
fn list_agents(&self) -> Vec<String>

List all registered agent IDs.

create_session

rust
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

rust
fn get_session(&self, session_id: &str) -> Option<&dyn GatewaySessionProtocol>

Get a session by ID.

Parameters:

NameType
session_id&str

close_session

rust
fn close_session(&mut self, session_id: &str) -> bool

Close a session.

Parameters:

NameType
session_id&str

list_sessions

rust
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

rust
async fn emit(&self, event: GatewayEvent) -> Result<()>

Emit an event to registered handlers.

Parameters:

NameType
eventGatewayEvent

broadcast

rust
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

rust
fn health(&self) -> GatewayHealth

Get gateway health status.

Source

View on GitHub

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


Related Documentation