#![deny(clippy::await_holding_lock)]
use std::sync::Arc;
pub mod airline;
pub mod retail;
pub mod tools;
pub type ActionTrace = Arc<std::sync::Mutex<Vec<RecordedToolCall>>>;
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
pub struct RecordedToolCall {
pub name: String,
pub arguments: serde_json::Map<String, serde_json::Value>,
}
impl RecordedToolCall {
#[must_use]
pub fn from_tool_call(call: &zeph_tools::executor::ToolCall) -> Self {
Self {
name: call.tool_id.as_str().to_owned(),
arguments: call.params.clone(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn recorded_tool_call_strong_count_invariant() {
let trace: ActionTrace = Arc::new(std::sync::Mutex::new(Vec::new()));
let trace2 = trace.clone();
assert!(Arc::strong_count(&trace) >= 2);
trace2.lock().expect("poisoned").push(RecordedToolCall {
name: "test".into(),
arguments: serde_json::Map::new(),
});
assert_eq!(trace.lock().expect("poisoned").len(), 1);
}
}