aether_core/events/
acp.rs1use acp_utils::AETHER_TOOL_NAME_META_KEY;
2
3pub fn aether_tool_name_meta(name: &str) -> serde_json::Map<String, serde_json::Value> {
4 let mut meta = serde_json::Map::new();
5 meta.insert(AETHER_TOOL_NAME_META_KEY.to_string(), name.to_string().into());
6 meta
7}
8
9pub fn parse_tool_call_chunk(chunk: &str) -> serde_json::Value {
10 serde_json::from_str(chunk).unwrap_or_else(|_| serde_json::Value::String(chunk.to_string()))
11}
12
13pub fn humanize_tool_name(name: &str) -> String {
14 let base = name.split("__").last().unwrap_or(name);
15 let mut result = base.replace('_', " ");
16 if let Some(first) = result.get_mut(0..1) {
17 first.make_ascii_uppercase();
18 }
19 result
20}
21
22#[cfg(test)]
23mod tests {
24 use super::*;
25
26 #[test]
27 fn humanizes_tool_names() {
28 assert_eq!(humanize_tool_name("coding__read_file"), "Read file");
29 assert_eq!(humanize_tool_name("read_file"), "Read file");
30 assert_eq!(humanize_tool_name("bash"), "Bash");
31 assert_eq!(humanize_tool_name("plugins__coding__read_file"), "Read file");
32 }
33}