use std::{collections::HashMap, ffi::OsString, path::PathBuf, sync::Arc, time::Duration};
use crate::{
builtin::chat_attach,
delegate::{
adapters::{OutputFormat, Resume, Transport},
background,
conversation::ConversationLimits,
records::DelegationRegistry,
},
};
#[derive(Debug, Clone)]
pub struct ToolsConfig {
pub command_timeout: Duration,
pub agent_timeout: Duration,
pub max_timeout: Duration,
pub output_limit_bytes: usize,
pub max_read_bytes: usize,
pub max_write_bytes: usize,
pub max_delegation_depth: u32,
pub conversations: ConversationLimits,
pub delegation: Option<DelegationContext>,
pub max_background: usize,
pub background: Option<Arc<background::BackgroundJobs>>,
pub chat_attach: Option<chat_attach::ChatAttachConfig>,
}
impl Default for ToolsConfig {
fn default() -> Self {
Self {
command_timeout: Duration::from_secs(600),
agent_timeout: Duration::from_secs(3600),
max_timeout: Duration::from_secs(14400),
output_limit_bytes: 64 * 1024,
max_read_bytes: 256 * 1024,
max_write_bytes: 1024 * 1024,
max_delegation_depth: 2,
conversations: ConversationLimits {
max: 8,
idle: Duration::from_secs(86400),
},
delegation: None,
max_background: 2,
background: None,
chat_attach: None,
}
}
}
#[derive(Debug, Clone)]
pub struct DelegationContext {
pub registry: Arc<DelegationRegistry>,
pub session: String,
pub depth: u32,
}
impl DelegationContext {
pub(crate) fn owner_depth(&self) -> u32 {
self.registry.depth().max(self.depth)
}
}
#[derive(Debug, Clone)]
pub struct AgentAdapterConfig {
pub command: String,
pub args: Vec<String>,
pub prompt_args: Vec<String>,
pub full_permission_args: Option<Vec<String>>,
pub model_args: Vec<String>,
pub effort_args: Vec<String>,
pub model_hint: String,
pub environment: Vec<(OsString, OsString)>,
pub search_dirs: Vec<PathBuf>,
pub output: OutputFormat,
pub resume: Resume,
pub home: Option<PathBuf>,
pub transport: Transport,
pub acp: Option<AcpAgentLaunch>,
pub use_for: Option<String>,
pub model: Option<String>,
pub effort: Option<String>,
}
#[derive(Debug, Clone)]
pub struct AcpAgentLaunch {
pub command: String,
pub args: Vec<String>,
pub full_mode: Option<String>,
pub environment: Vec<(OsString, OsString)>,
pub required: bool,
}
pub type SkillMap = HashMap<String, PathBuf>;