Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions desktop/src-tauri/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ pub struct AppState {
/// restore. `apply_workspace` consumes it after installing the workspace
/// relay and identity, so agents never start against the fallback relay.
pub managed_agent_restore_pending: AtomicBool,
/// Whether desktop may repair managed-agent kind:0 profiles from its local
/// records. Disabled by the agent-managed profiles experiment so an agent's
/// own profile updates are not overwritten on start or restore.
/// Disabled by agent-managed profiles so agent profile updates survive start/restore.
pub managed_agent_profile_reconcile_enabled: AtomicBool,
/// Shared shutdown signal checked by launch-time agent restoration.
pub shutdown_started: AtomicBool,
Expand All @@ -52,6 +50,7 @@ pub struct AppState {
pub managed_agents_store_lock: Mutex<()>,
pub channel_templates_store_lock: Mutex<()>,
pub managed_agent_processes: Mutex<HashMap<ManagedAgentRuntimeKey, ManagedAgentPairRuntime>>,
pub provider_deploy_locks: Mutex<HashMap<String, Arc<tokio::sync::Mutex<()>>>>,
pub huddle_state: Mutex<HuddleState>,
pub huddle_audio: crate::huddle::tts_settings::HuddleAudioSettingsState,
/// Tauri app handle — stored after setup so huddle commands can emit
Expand Down Expand Up @@ -215,6 +214,7 @@ pub fn build_app_state() -> AppState {
managed_agents_store_lock: Mutex::new(()),
channel_templates_store_lock: Mutex::new(()),
managed_agent_processes: Mutex::new(HashMap::new()),
provider_deploy_locks: Mutex::new(HashMap::new()),
session_config_cache: Mutex::new(HashMap::new()),
huddle_state: Mutex::new(HuddleState::default()),
huddle_audio: Default::default(),
Expand Down
13 changes: 13 additions & 0 deletions desktop/src-tauri/src/commands/agent_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ pub fn agent_access_owner_only() -> bool {
crate::managed_agents::owner_only_access_build()
}

/// Tiny executable-facing probe for release packaging smoke tests. Keeping the
/// probe in the product crate makes it impossible for buzz-releases to validate
/// a copied flag interpretation that has drifted from Desktop's command.
#[doc(hidden)]
pub fn print_agent_access_owner_only_probe_if_requested() -> bool {
if std::env::args().any(|arg| arg == "--print-agent-access-owner-only") {
println!("{}", agent_access_owner_only());
true
} else {
false
}
}

#[cfg(test)]
mod tests {
#[test]
Expand Down
1 change: 1 addition & 0 deletions desktop/src-tauri/src/commands/agent_config_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn agent_record() -> ManagedAgentRecord {
runtime_pid: None,
backend: BackendKind::Local,
backend_agent_id: None,
provider_policy_pending: false,
provider_binary_path: None,
team_id: None,
persona_team_dir: None,
Expand Down
55 changes: 24 additions & 31 deletions desktop/src-tauri/src/commands/agent_discovery.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
use tauri::State;

use crate::{
app_state::AppState,
managed_agents::{
command_availability, is_npm_global_install, AcpRuntimeCatalogEntry,
DiscoverManagedAgentPrereqsRequest, InstallRuntimeResult, ManagedAgentPrereqsInfo,
RelayAgentInfo, DEFAULT_ACP_COMMAND,
},
nostr_convert,
relay::query_relay,
use crate::managed_agents::{
command_availability, is_npm_global_install, AcpRuntimeCatalogEntry,
DiscoverManagedAgentPrereqsRequest, InstallRuntimeResult, ManagedAgentPrereqsInfo,
DEFAULT_ACP_COMMAND,
};

mod post_install_verification;
Expand Down Expand Up @@ -1037,31 +1030,31 @@ pub async fn discover_managed_agent_prereqs(
.map_err(|e| format!("spawn_blocking failed: {e}"))
}

#[tauri::command]
pub async fn list_relay_agents(state: State<'_, AppState>) -> Result<Vec<RelayAgentInfo>, String> {
// Query kind:10100 agent profile events from the relay.
let events = query_relay(
&state,
&[serde_json::json!({
"kinds": [10100],
})],
)
.await?;

// The convert helper returns `{"agents": [...]}`. Extract and re-deserialize
// into the strongly-typed `Vec<RelayAgentInfo>` the frontend expects.
let value = nostr_convert::agents_from_events(&events);
let agents = value
.get("agents")
.cloned()
.unwrap_or_else(|| serde_json::json!([]));
serde_json::from_value(agents).map_err(|e| format!("agent parse failed: {e}"))
}
mod relay_directory;
#[cfg(test)]
use relay_directory::advance_relay_cursor;
pub use relay_directory::list_relay_agents;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn relay_directory_cursor_uses_timestamp_and_event_id() {
use nostr::{EventBuilder, Keys, Kind, Timestamp};

let event = EventBuilder::new(Kind::Custom(30177), "{}")
.custom_created_at(Timestamp::from(42))
.sign_with_keys(&Keys::generate())
.expect("sign cursor event");
let mut filter = serde_json::json!({"kinds": [30177]});

advance_relay_cursor(&mut filter, std::slice::from_ref(&event));

assert_eq!(filter["until"], 42);
assert_eq!(filter["before_id"], event.id.to_hex());
}

// ── is_npm_global_install ─────────────────────────────────────────────────

#[test]
Expand Down
Loading