Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T08:05:47.409Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

settings.rs

51 lines · 1.5 KB · rust
1use anyhow::Result;
2use serde_json::Value;
3
4use crate::migrations::migrate_settings;
5
6const AGENT_KEY: &str = "agent";
7const PROFILES_KEY: &str = "profiles";
8const TOOL_PERMISSIONS_KEY: &str = "tool_permissions";
9const TOOLS_KEY: &str = "tools";
10const OLD_TOOL_NAME: &str = "web_search";
11const NEW_TOOL_NAME: &str = "search_web";
12
13pub fn rename_web_search_to_search_web(value: &mut Value) -> Result<()> {
14    migrate_settings(value, &mut migrate_agent_value)
15}
16
17fn migrate_agent_value(object: &mut serde_json::Map<String, Value>) -> Result<()> {
18    let Some(agent) = object.get_mut(AGENT_KEY).and_then(|v| v.as_object_mut()) else {
19        return Ok(());
20    };
21
22    if let Some(tools) = agent
23        .get_mut(TOOL_PERMISSIONS_KEY)
24        .and_then(|v| v.as_object_mut())
25        .and_then(|tp| tp.get_mut(TOOLS_KEY))
26        .and_then(|v| v.as_object_mut())
27    {
28        rename_key(tools);
29    }
30
31    if let Some(profiles) = agent.get_mut(PROFILES_KEY).and_then(|v| v.as_object_mut()) {
32        for (_profile_name, profile) in profiles.iter_mut() {
33            if let Some(tools) = profile
34                .as_object_mut()
35                .and_then(|p| p.get_mut(TOOLS_KEY))
36                .and_then(|v| v.as_object_mut())
37            {
38                rename_key(tools);
39            }
40        }
41    }
42
43    Ok(())
44}
45
46fn rename_key(tools: &mut serde_json::Map<String, Value>) {
47    if let Some(value) = tools.remove(OLD_TOOL_NAME) {
48        tools.insert(NEW_TOOL_NAME.to_string(), value);
49    }
50}
51
Served at tenant.openagents/omega Member data and write actions are omitted.