diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d94c57b..73ac481 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -28,6 +28,35 @@ dependencies = [ "tokio", ] +[[package]] +name = "aspect-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70188b9bf884266a6c7117e30af44f38229bc5ac56916bd16512b3e49f90fe20" + +[[package]] +name = "aspect-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e7db9b6a7bb4f117b8d97054d2d5a7bdc43b95c19c15c751fb8dcb9bc8a5c" +dependencies = [ + "aspect-core", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "aspect-std" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7d130884fda30ec0acabcadc8f4711267d1cc21edc8f85283e91a011d699fa" +dependencies = [ + "aspect-core", + "log", + "parking_lot", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -1753,6 +1782,10 @@ name = "tools" version = "0.1.0" dependencies = [ "api", + "aspect-core", + "aspect-macros", + "aspect-std", + "log", "plugins", "reqwest", "runtime", diff --git a/rust/crates/tools/Cargo.toml b/rust/crates/tools/Cargo.toml index 04d738b..6461553 100644 --- a/rust/crates/tools/Cargo.toml +++ b/rust/crates/tools/Cargo.toml @@ -13,6 +13,10 @@ reqwest = { version = "0.12", default-features = false, features = ["blocking", serde = { version = "1", features = ["derive"] } serde_json.workspace = true tokio = { version = "1", features = ["rt-multi-thread"] } +aspect-core = "0.1" +aspect-macros = "0.1" +aspect-std = "0.1" +log = "0.4" [lints] workspace = true diff --git a/rust/crates/tools/src/lib.rs b/rust/crates/tools/src/lib.rs index 4b42572..9fe509d 100644 --- a/rust/crates/tools/src/lib.rs +++ b/rust/crates/tools/src/lib.rs @@ -3,6 +3,9 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::time::{Duration, Instant}; +use aspect_macros::aspect; +use aspect_std::LoggingAspect; + use api::{ max_tokens_for_model, resolve_model_alias, ContentBlockDelta, InputContentBlock, InputMessage, MessageRequest, MessageResponse, OutputContentBlock, ProviderClient, @@ -536,6 +539,7 @@ pub fn mvp_tool_specs() -> Vec { ] } +#[aspect(LoggingAspect::new().log_args().log_result())] pub fn execute_tool(name: &str, input: &Value) -> Result { match name { "bash" => from_value::(input).and_then(run_bash),