aither_core/llm/tool/
identity.rs1use alloc::boxed::Box;
8use alloc::string::String;
9use core::fmt::{self, Display};
10
11#[derive(Debug, Clone, PartialEq, Eq, Hash)]
13pub struct ToolCallId(String);
14
15impl ToolCallId {
16 #[must_use]
18 pub fn new(id: impl Into<String>) -> Self {
19 Self(id.into())
20 }
21
22 #[must_use]
24 pub fn as_str(&self) -> &str {
25 &self.0
26 }
27}
28
29impl Display for ToolCallId {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 f.write_str(&self.0)
32 }
33}
34
35#[derive(Debug, Clone, PartialEq, Eq, Hash)]
40pub struct SubagentIdentity {
41 name: String,
42 started_by: Option<Box<CallIdentity>>,
43}
44
45impl SubagentIdentity {
46 #[must_use]
49 pub fn new(name: impl Into<String>, started_by: Option<CallIdentity>) -> Self {
50 Self {
51 name: name.into(),
52 started_by: started_by.map(Box::new),
53 }
54 }
55
56 #[must_use]
58 pub fn name(&self) -> &str {
59 &self.name
60 }
61
62 #[must_use]
64 pub fn started_by(&self) -> Option<&CallIdentity> {
65 self.started_by.as_deref()
66 }
67}
68
69#[derive(Debug, Clone, PartialEq, Eq, Hash)]
71pub enum AgentIdentity {
72 Main,
74 Subagent(SubagentIdentity),
76}
77
78#[derive(Debug, Clone, PartialEq, Eq, Hash)]
80pub struct CallIdentity {
81 call: ToolCallId,
82 agent: AgentIdentity,
83}
84
85impl CallIdentity {
86 #[must_use]
88 pub const fn new(call: ToolCallId, agent: AgentIdentity) -> Self {
89 Self { call, agent }
90 }
91
92 #[must_use]
94 pub const fn call(&self) -> &ToolCallId {
95 &self.call
96 }
97
98 #[must_use]
100 pub const fn agent(&self) -> &AgentIdentity {
101 &self.agent
102 }
103}