#[cfg(feature = "http-api")]
use async_trait::async_trait;
#[cfg(feature = "http-api")]
use crate::types::{AgentId, AgentState, RuntimeError};
#[cfg(feature = "http-api")]
use super::types::{
AddIdentityMappingRequest, AgentStatusResponse, AgentSummary, ChannelActionResponse,
ChannelAuditResponse, ChannelDetail, ChannelHealthResponse, ChannelSummary, CreateAgentRequest,
CreateAgentResponse, CreateScheduleRequest, CreateScheduleResponse, DeleteAgentResponse,
DeleteChannelResponse, DeleteScheduleResponse, ExecuteAgentRequest, ExecuteAgentResponse,
GetAgentHistoryResponse, HeartbeatRequest, IdentityMappingEntry, NextRunsResponse,
PushEventRequest, RegisterChannelRequest, RegisterChannelResponse, ScheduleActionResponse,
ScheduleDetail, ScheduleHistoryResponse, ScheduleSummary, SchedulerHealthResponse,
UpdateAgentRequest, UpdateAgentResponse, UpdateChannelRequest, UpdateScheduleRequest,
WorkflowExecutionRequest,
};
#[cfg(feature = "http-api")]
#[async_trait]
pub trait RuntimeApiProvider: Send + Sync {
async fn execute_workflow(
&self,
request: WorkflowExecutionRequest,
) -> Result<serde_json::Value, RuntimeError>;
async fn get_agent_status(
&self,
agent_id: AgentId,
) -> Result<AgentStatusResponse, RuntimeError>;
async fn get_system_health(&self) -> Result<serde_json::Value, RuntimeError>;
async fn list_agents(&self) -> Result<Vec<AgentId>, RuntimeError>;
async fn list_agents_detailed(&self) -> Result<Vec<AgentSummary>, RuntimeError> {
let ids = self.list_agents().await?;
Ok(ids
.into_iter()
.map(|id| AgentSummary {
id,
name: String::new(),
state: AgentState::Created,
})
.collect())
}
async fn shutdown_agent(&self, agent_id: AgentId) -> Result<(), RuntimeError>;
async fn get_metrics(&self) -> Result<serde_json::Value, RuntimeError>;
async fn create_agent(
&self,
request: CreateAgentRequest,
) -> Result<CreateAgentResponse, RuntimeError>;
async fn update_agent(
&self,
agent_id: AgentId,
request: UpdateAgentRequest,
) -> Result<UpdateAgentResponse, RuntimeError>;
async fn delete_agent(&self, agent_id: AgentId) -> Result<DeleteAgentResponse, RuntimeError>;
async fn execute_agent(
&self,
agent_id: AgentId,
request: ExecuteAgentRequest,
) -> Result<ExecuteAgentResponse, RuntimeError>;
async fn get_agent_history(
&self,
agent_id: AgentId,
) -> Result<GetAgentHistoryResponse, RuntimeError>;
async fn list_schedules(&self) -> Result<Vec<ScheduleSummary>, RuntimeError>;
async fn create_schedule(
&self,
request: CreateScheduleRequest,
) -> Result<CreateScheduleResponse, RuntimeError>;
async fn get_schedule(&self, job_id: &str) -> Result<ScheduleDetail, RuntimeError>;
async fn update_schedule(
&self,
job_id: &str,
request: UpdateScheduleRequest,
) -> Result<ScheduleDetail, RuntimeError>;
async fn delete_schedule(&self, job_id: &str) -> Result<DeleteScheduleResponse, RuntimeError>;
async fn pause_schedule(&self, job_id: &str) -> Result<ScheduleActionResponse, RuntimeError>;
async fn resume_schedule(&self, job_id: &str) -> Result<ScheduleActionResponse, RuntimeError>;
async fn trigger_schedule(&self, job_id: &str) -> Result<ScheduleActionResponse, RuntimeError>;
async fn get_schedule_history(
&self,
job_id: &str,
limit: usize,
) -> Result<ScheduleHistoryResponse, RuntimeError>;
async fn get_schedule_next_runs(
&self,
job_id: &str,
count: usize,
) -> Result<NextRunsResponse, RuntimeError>;
async fn get_scheduler_health(&self) -> Result<SchedulerHealthResponse, RuntimeError>;
async fn list_channels(&self) -> Result<Vec<ChannelSummary>, RuntimeError>;
async fn register_channel(
&self,
request: RegisterChannelRequest,
) -> Result<RegisterChannelResponse, RuntimeError>;
async fn get_channel(&self, id: &str) -> Result<ChannelDetail, RuntimeError>;
async fn update_channel(
&self,
id: &str,
request: UpdateChannelRequest,
) -> Result<ChannelDetail, RuntimeError>;
async fn delete_channel(&self, id: &str) -> Result<DeleteChannelResponse, RuntimeError>;
async fn start_channel(&self, id: &str) -> Result<ChannelActionResponse, RuntimeError>;
async fn stop_channel(&self, id: &str) -> Result<ChannelActionResponse, RuntimeError>;
async fn get_channel_health(&self, id: &str) -> Result<ChannelHealthResponse, RuntimeError>;
async fn list_channel_mappings(
&self,
id: &str,
) -> Result<Vec<IdentityMappingEntry>, RuntimeError>;
async fn add_channel_mapping(
&self,
id: &str,
request: AddIdentityMappingRequest,
) -> Result<IdentityMappingEntry, RuntimeError>;
async fn remove_channel_mapping(&self, id: &str, user_id: &str) -> Result<(), RuntimeError>;
async fn get_channel_audit(
&self,
id: &str,
limit: usize,
) -> Result<ChannelAuditResponse, RuntimeError>;
async fn update_agent_heartbeat(
&self,
agent_id: AgentId,
heartbeat: HeartbeatRequest,
) -> Result<(), RuntimeError>;
async fn push_agent_event(
&self,
agent_id: AgentId,
event: PushEventRequest,
) -> Result<(), RuntimeError>;
async fn check_unreachable_agents(&self) {}
}