Files
MyAiDesk/nomifun-tauri/crates/backend/nomifun-ai-agent/src/shared_kernel/approval.rs
T
freedak f7a720204a Update: 将子项目从 submodule 转为完整内容
- 移除 GovAI, nomifun-tauri, 算力盒子 的 submodule 引用
- 添加所有子项目的完整源代码
- 保留原始 .git 为 .git.bak 备份
2026-07-04 19:20:46 +08:00

27 lines
901 B
Rust

//! Approval-memory key construction shared across agent managers.
//!
//! Keeps the `always_allow` memory key format identical between agents
//! so the session-level approval cache stays source-of-truth-unique.
/// Build the approval memory key from action and optional command_type.
pub fn approval_key(action: Option<&str>, command_type: Option<&str>) -> String {
match (action, command_type) {
(Some(a), Some(ct)) => format!("{a}:{ct}"),
(Some(a), None) => a.to_owned(),
_ => String::new(),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn approval_key_formats_matches_previous_contract() {
assert_eq!(approval_key(Some("exec"), Some("curl")), "exec:curl");
assert_eq!(approval_key(Some("exec"), None), "exec");
assert_eq!(approval_key(None, Some("curl")), "");
assert_eq!(approval_key(None, None), "");
}
}