use std::{
sync::{
Arc,
atomic::{AtomicBool, Ordering},
},
time::Duration,
};
use super::{AgentHandle, AgentId};
use crate::{
config::AgentConfig,
error::Error,
types::{ConversationMessage, MessageRole, UsageMetadata},
};
mod runtime_impl;
#[cfg(test)]
mod tests_conversation;
#[cfg(test)]
mod tests_lifecycle;
pub struct ToolAwareMockRuntime {
chat_count: std::sync::Mutex<std::collections::HashMap<AgentId, u32>>,
fail_create: AtomicBool,
fail_quota: AtomicBool,
pub(crate) try_shutdown_called: AtomicBool,
pub(crate) last_create_id: std::sync::Mutex<Option<u64>>,
quota_registry: crate::quota::QuotaRegistry,
}
impl ToolAwareMockRuntime {
pub(crate) fn new() -> Self {
Self {
chat_count: std::sync::Mutex::new(std::collections::HashMap::new()),
fail_create: AtomicBool::new(false),
fail_quota: AtomicBool::new(false),
try_shutdown_called: AtomicBool::new(false),
last_create_id: std::sync::Mutex::new(None),
quota_registry: crate::quota::QuotaRegistry::new(),
}
}
pub(crate) fn with_create_failure() -> Self {
let rt = Self::new();
rt.fail_create.store(true, Ordering::SeqCst);
rt
}
}
#[cfg(test)]
fn test_config() -> AgentConfig {
AgentConfig::default()
}