diff --git a/crates/vida-core/src/agent_loop.rs b/crates/vida-core/src/agent_loop.rs index 912b0a6..0b0c545 100644 --- a/crates/vida-core/src/agent_loop.rs +++ b/crates/vida-core/src/agent_loop.rs @@ -12,6 +12,7 @@ use crate::mcp::{McpManager, McpTool, McpToolResult, McpToolResultContent}; use crate::tool_validator::validate_tool_call; const MAX_TOOL_ITERATIONS: usize = 8; +#[allow(dead_code)] const TOOL_CALL_TIMEOUT_SECS: u64 = 30; const TOOL_CALL_START: &str = ""; const TOOL_CALL_END: &str = ""; diff --git a/crates/vida-core/src/engine.rs b/crates/vida-core/src/engine.rs index 75e4b69..cfe960c 100644 --- a/crates/vida-core/src/engine.rs +++ b/crates/vida-core/src/engine.rs @@ -1,7 +1,6 @@ use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; -use std::time::Instant; use tokio::sync::mpsc; use uuid::Uuid; @@ -643,13 +642,13 @@ impl VidaEngine { "Too many login attempts. Try again later.".to_string(), )); } else { - self.login_blocked_until.remove(&username.to_string()); + self.login_blocked_until.remove(username); } } match self.authenticate_user(username, password).await { Ok(session) => { - self.login_attempts.remove(&username.to_string()); + self.login_attempts.remove(username); self.current_actor = Some(session.clone()); Ok(session) } @@ -665,7 +664,7 @@ impl VidaEngine { username.to_string(), now + std::time::Duration::from_secs(LOGIN_BLOCK_SECS), ); - self.login_attempts.remove(&username.to_string()); + self.login_attempts.remove(username); } } Err(err) @@ -1249,8 +1248,7 @@ impl VidaEngine { name: &str, ) -> Result { let workspace_path = std::path::Path::new(path); - let mut config = WorkspaceConfig::default(); - config.name = name.to_string(); + let config = WorkspaceConfig { name: name.to_string(), ..Default::default() }; save_workspace_config(workspace_path, &config)?; diff --git a/crates/vida-core/src/permissions.rs b/crates/vida-core/src/permissions.rs index 3f25a6d..1f19564 100644 --- a/crates/vida-core/src/permissions.rs +++ b/crates/vida-core/src/permissions.rs @@ -1,19 +1,14 @@ use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] #[serde(rename_all = "lowercase")] pub enum PermissionMode { Yolo, + #[default] Ask, Sandbox, } -impl Default for PermissionMode { - fn default() -> Self { - Self::Ask - } -} - #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(rename_all = "snake_case")] pub enum PermissionType { diff --git a/crates/vida-core/src/remote.rs b/crates/vida-core/src/remote.rs index 941b29f..aa172a6 100644 --- a/crates/vida-core/src/remote.rs +++ b/crates/vida-core/src/remote.rs @@ -971,8 +971,7 @@ mod server { let _ = socket .send(ws::Message::Text( serde_json::json!({"error": e.to_string()}) - .to_string() - .into(), + .to_string(), )) .await; return; @@ -1007,7 +1006,7 @@ mod server { }; let is_done = matches!(event, StreamEvent::Done); if socket - .send(ws::Message::Text(json.to_string().into())) + .send(ws::Message::Text(json.to_string())) .await .is_err() { diff --git a/crates/vida-core/src/tool_validator.rs b/crates/vida-core/src/tool_validator.rs index a00dcd7..378d629 100644 --- a/crates/vida-core/src/tool_validator.rs +++ b/crates/vida-core/src/tool_validator.rs @@ -35,7 +35,7 @@ fn validate_against_schema(value: &Value, schema: &Value) -> Result<(), String> "array" => validate_array(value, schema)?, "string" if !value.is_string() => return Err("expected string".to_string()), "number" if !value.is_number() => return Err("expected number".to_string()), - "integer" if !value.as_i64().is_some() && !value.as_u64().is_some() => { + "integer" if value.as_i64().is_none() && value.as_u64().is_none() => { return Err("expected integer".to_string()) } "boolean" if !value.is_boolean() => return Err("expected boolean".to_string()),