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

Adds aspect-rs AOP-style logging to execute_tool_with_enforcer, providing cross-cutting arg/result logging for all tool dispatches. Introduces aspect-core, aspect-macros, and aspect-std dependencies.
This commit is contained in:
Yijun Yu
2026-05-24 19:22:45 -07:00
committed by GitHub
parent 96ddecab81
commit aefa5b0f19
3 changed files with 41 additions and 0 deletions

33
rust/Cargo.lock generated
View File

@@ -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",

View File

@@ -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

View File

@@ -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,