feat: enhance device normalization and classification

- Introduced a new mechanism in EventNormalizer to suppress duplicate events from child nodes of the same physical device.
- Removed the device classification logic from the normalizer and replaced it with a rule-based system using Lua scripts.
- Added support for user-defined device rules in Lua, allowing for flexible device naming based on various conditions.
- Updated the state engine to handle device rules and resolve device names before dispatching events.
- Modified the installation script to set up default configuration files for the daemon and Lua modules.
- Improved the handling of systemd user services to dynamically set the ExecStart path based on the installation directory.
This commit is contained in:
Breadway 2026-05-12 21:27:07 +08:00
parent 22f591e0e6
commit 434fe1721c
12 changed files with 719 additions and 476 deletions

View file

@ -42,8 +42,8 @@ enum Commands {
},
/// Stream live normalized events
Events {
#[arg(long)]
filter: Option<String>,
/// Optional glob pattern to filter events (e.g. bread.device.*, bread.**)
pattern: Option<String>,
/// Output raw JSON
#[arg(long)]
json: bool,
@ -169,12 +169,12 @@ async fn main() -> Result<()> {
}
}
Commands::Events {
filter,
pattern,
json,
fields,
since,
} => {
stream_events(&socket, filter, json, fields, since).await?;
stream_events(&socket, pattern, json, fields, since).await?;
}
Commands::Modules { subcommand } => {
handle_modules_cmd(subcommand, &socket).await?;
@ -769,8 +769,7 @@ fn run_package_installs(packages_dir: &Path, managers: &[String]) -> Result<()>
}
"pip" => {
let mut cmd = std::process::Command::new("pip");
cmd.args(["install", "--user", "-r"])
.arg(file.to_str().unwrap_or(""));
cmd.args(["install", "--user", "-r"]).arg(&file);
let _ = cmd.status();
}
"npm" => {