pub const SCOPE_AI: &str = "ai";
pub const SCOPE_SKILLS: &str = "skills";
pub const SCOPE_ACCOUNT: &str = "account";
pub const SCOPE_REMOTE_CONTROL: &str = "remote_control";
pub const SCOPE_REMOTE_CONTROL_AGENT_RUN: &str = "remote_control:agent-run";
pub const SCOPE_REMOTE_CONTROL_SESSION_CONTROL: &str = "remote_control:session-control";
pub const SCOPE_REMOTE_CONTROL_PERMISSION_RESPONSE: &str = "remote_control:permission-response";
pub const SCOPE_CHAT_BRIDGE: &str = "chat_bridge";
pub const SCOPE_CHAT_BRIDGE_READ: &str = "chat_bridge:read";
pub const SCOPE_CHAT_BRIDGE_WRITE: &str = "chat_bridge:write";
pub const SCOPE_CHAT_BRIDGE_ROTATE: &str = "chat_bridge:rotate";
pub const SCOPE_AGENT_ACCESS_MANAGE: &str = "agent_access:manage";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_AI")]
pub const SCOPE_MODELS: &str = "models";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_AI")]
pub const SCOPE_MODELS_CHAT: &str = "models:chat";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_AI")]
pub const SCOPE_ENTITLEMENTS: &str = "entitlements";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_AI")]
pub const SCOPE_TOKEN_PACKAGES: &str = "token-packages";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_SKILLS")]
pub const SCOPE_SKILL_STORE: &str = "skill_store";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_SKILLS")]
pub const SCOPE_TOOLS: &str = "tools";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_SKILLS")]
pub const SCOPE_TOOLS_EXECUTE: &str = "tools:execute";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_ACCOUNT")]
pub const SCOPE_WALLET: &str = "wallet";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_ACCOUNT")]
pub const SCOPE_WALLET_READONLY: &str = "wallet:readonly";
#[deprecated(note = "旧细粒度 scope,新代码请用分组 SCOPE_ACCOUNT")]
pub const SCOPE_PROFILE: &str = "profile";
pub fn all_scopes() -> Vec<String> {
vec![
SCOPE_AI.to_string(),
SCOPE_SKILLS.to_string(),
SCOPE_ACCOUNT.to_string(),
]
}
pub fn model_scopes() -> Vec<String> {
vec![SCOPE_AI.to_string()]
}
pub fn commerce_scopes() -> Vec<String> {
vec![SCOPE_AI.to_string(), SCOPE_ACCOUNT.to_string()]
}
pub fn skill_scopes() -> Vec<String> {
vec![SCOPE_SKILLS.to_string()]
}
pub fn remote_control_scopes() -> Vec<String> {
vec![SCOPE_REMOTE_CONTROL.to_string()]
}
pub fn chat_bridge_scopes() -> Vec<String> {
vec![SCOPE_CHAT_BRIDGE.to_string()]
}
pub fn agent_access_scopes() -> Vec<String> {
vec![SCOPE_AGENT_ACCESS_MANAGE.to_string()]
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn all_scopes_is_three_grouped() {
let s = all_scopes();
assert_eq!(s, vec!["ai", "skills", "account"]);
}
#[test]
fn high_risk_scopes_excluded_from_all() {
let s = all_scopes();
assert!(!s.contains(&SCOPE_REMOTE_CONTROL.to_string()));
assert!(!s.contains(&SCOPE_CHAT_BRIDGE.to_string()));
}
#[test]
fn commerce_scopes_combine_ai_and_account() {
assert_eq!(commerce_scopes(), vec!["ai", "account"]);
}
#[test]
fn grouped_scope_literals_match_backend() {
assert_eq!(SCOPE_AI, "ai");
assert_eq!(SCOPE_SKILLS, "skills");
assert_eq!(SCOPE_ACCOUNT, "account");
assert_eq!(SCOPE_REMOTE_CONTROL, "remote_control");
assert_eq!(SCOPE_CHAT_BRIDGE, "chat_bridge");
}
}