~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/asyncai

0
0
main
54 lines · 1.3 KB Raw History
use std::collections::HashMap;

use crate::ids::{AgentId, FileId, RunId, ThreadId};
use crate::message::RunStatus;

#[derive(Clone, Debug)]
pub struct AgentRecord {
    pub agent_id: AgentId,
    pub agent_name: String,
    pub file_ids: Vec<FileId>,
    pub thread_ids: Vec<ThreadId>,
}

impl AgentRecord {
    pub fn new(agent_id: AgentId, agent_name: String) -> Self {
        Self {
            agent_id,
            agent_name,
            file_ids: Vec::new(),
            thread_ids: Vec::new(),
        }
    }
}

#[derive(Clone, Debug)]
pub struct ThreadRecord {
    pub agent_id: AgentId,
    pub thread_id: ThreadId,
    pub most_recent_run_id: Option<RunId>,
    pub most_recent_run_status: Option<RunStatus>,
}

#[derive(Clone, Debug, Default)]
pub struct OrchestratorState {
    pub agents: HashMap<AgentId, AgentRecord>,
    pub threads: HashMap<ThreadId, ThreadRecord>,
    pub active_agent: Option<AgentId>,
    pub active_thread: Option<ThreadId>,
}

impl OrchestratorState {
    pub fn dispatch_state(&self) -> DispatchState {
        DispatchState {
            active_agent: self.active_agent.clone(),
            active_thread: self.active_thread.clone(),
        }
    }
}

#[derive(Clone, Debug, Default)]
pub struct DispatchState {
    pub active_agent: Option<AgentId>,
    pub active_thread: Option<ThreadId>,
}