use alloc::boxed::Box;
use alloc::string::String;
use core::fmt::{self, Display};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ToolCallId(String);
impl ToolCallId {
#[must_use]
pub fn new(id: impl Into<String>) -> Self {
Self(id.into())
}
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
}
impl Display for ToolCallId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SubagentIdentity {
name: String,
started_by: Option<Box<CallIdentity>>,
}
impl SubagentIdentity {
#[must_use]
pub fn new(name: impl Into<String>, started_by: Option<CallIdentity>) -> Self {
Self {
name: name.into(),
started_by: started_by.map(Box::new),
}
}
#[must_use]
pub fn name(&self) -> &str {
&self.name
}
#[must_use]
pub fn started_by(&self) -> Option<&CallIdentity> {
self.started_by.as_deref()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AgentIdentity {
Main,
Subagent(SubagentIdentity),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CallIdentity {
call: ToolCallId,
agent: AgentIdentity,
}
impl CallIdentity {
#[must_use]
pub const fn new(call: ToolCallId, agent: AgentIdentity) -> Self {
Self { call, agent }
}
#[must_use]
pub const fn call(&self) -> &ToolCallId {
&self.call
}
#[must_use]
pub const fn agent(&self) -> &AgentIdentity {
&self.agent
}
}