Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

feat(tools): add LoggingAspect to unified tool dispatch entry point

Yijun Yuaefa5b0f19ed
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 23622e85..fc73cb34 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -42,6 +42,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 = "atomic-waker"
version = "1.1.2"
@@ -1840,8 +1869,12 @@ name = "tools"
version = "0.1.0"
dependencies = [
"api",
+ "aspect-core",
+ "aspect-macros",
+ "aspect-std",
"commands",
"flate2",
+ "log",
"plugins",
"reqwest",
"runtime",
diff --git a/rust/crates/tools/Cargo.toml b/rust/crates/tools/Cargo.toml
index 86da4e63..8215c9e7 100644
--- a/rust/crates/tools/Cargo.toml
+++ b/rust/crates/tools/Cargo.toml
@@ -15,6 +15,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 e40684ff..c7c2434f 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, model_family_identity_for, resolve_model_alias, ApiError,
ContentBlockDelta, InputContentBlock, InputMessage, MessageRequest, MessageResponse,
@@ -1199,6 +1202,7 @@ pub fn execute_tool(name: &str, input: &Value) -> Result<String, String> {
}
#[allow(clippy::too_many_lines)]
+#[aspect(LoggingAspect::new().log_args().log_result())]
fn execute_tool_with_enforcer(
enforcer: Option<&PermissionEnforcer>,
name: &str,