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
fn is_running(&self) -> boolWhether the gateway is currently running.
port
fn port(&self) -> u16Port the gateway is listening on.
host
fn host(&self) -> &strHost 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>) -> StringRegister an agent with the gateway.
Parameters:
| Name | Type |
|---|---|
agent | Arc<Agent> |
agent_id | Option<String> |
unregister_agent
fn unregister_agent(&mut self, agent_id: &str) -> boolUnregister an agent from the gateway.
Parameters:
| Name | Type |
|---|---|
agent_id | &str |
get_agent
fn get_agent(&self, agent_id: &str) -> Option<Arc<Agent>>Get a registered agent by ID.
Parameters:
| Name | Type |
|---|---|
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:
| Name | Type |
|---|---|
agent_id | &str |
client_id | Option<String> |
session_id | Option<String> |
get_session
fn get_session(&self, session_id: &str) -> Option<&dyn GatewaySessionProtocol>Get a session by ID.
Parameters:
| Name | Type |
|---|---|
session_id | &str |
close_session
fn close_session(&mut self, session_id: &str) -> boolClose a session.
Parameters:
| Name | Type |
|---|---|
session_id | &str |
list_sessions
fn list_sessions(&self, agent_id: Option<&str>) -> Vec<String>List session IDs, optionally filtered by agent.
Parameters:
| Name | Type |
|---|---|
agent_id | Option<&str> |
emit
async fn emit(&self, event: GatewayEvent) -> Result<()>Emit an event to registered handlers.
Parameters:
| Name | Type |
|---|---|
event | GatewayEvent |
broadcast
async fn broadcast(&self, event: GatewayEvent, exclude: Option<Vec<String>>) -> Result<()>Broadcast an event to all connected clients.
Parameters:
| Name | Type |
|---|---|
event | GatewayEvent |
exclude | Option<Vec<String>> |
health
fn health(&self) -> GatewayHealthGet gateway health status.
Source
View on GitHubpraisonai/src/gateway/mod.rs at line 0