sync: Multi-project updates - SolverBot, GuruRMM, Dataforth
SolverBot: - Inject active project path into agent system prompts so agents know which directory to scope file operations to GuruRMM: - Bump agent version to 0.6.0 - Add serde aliases for PowerShell/ClaudeTask command types - Add typed CommandType enum on server for proper serialization - Support claude_task command type in send_command API Dataforth: - Fix SCP space-escaping in Sync-FromNAS.ps1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -193,10 +193,74 @@ pub struct NetworkStatePayload {
|
||||
pub state_hash: String,
|
||||
}
|
||||
|
||||
/// Types of commands that can be sent to agents.
|
||||
/// Must match the agent's CommandType enum serialization format.
|
||||
/// Uses snake_case to match the agent's #[serde(rename_all = "snake_case")].
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommandType {
|
||||
/// Shell command (cmd on Windows, sh on Unix)
|
||||
Shell,
|
||||
/// PowerShell command (Windows)
|
||||
PowerShell,
|
||||
/// Python script
|
||||
Python,
|
||||
/// Raw script execution
|
||||
Script,
|
||||
/// Claude Code task execution
|
||||
ClaudeTask {
|
||||
/// Task description for Claude Code
|
||||
task: String,
|
||||
/// Optional working directory
|
||||
working_directory: Option<String>,
|
||||
/// Optional context files
|
||||
context_files: Option<Vec<String>>,
|
||||
},
|
||||
}
|
||||
|
||||
impl CommandType {
|
||||
/// Parse a command type string from the API into the enum.
|
||||
/// Accepts both snake_case ("power_shell") and common formats ("powershell").
|
||||
/// Note: ClaudeTask requires additional fields - use `new_claude_task()` instead.
|
||||
pub fn from_api_string(s: &str) -> Result<Self, String> {
|
||||
match s.to_lowercase().as_str() {
|
||||
"shell" => Ok(Self::Shell),
|
||||
"powershell" | "power_shell" => Ok(Self::PowerShell),
|
||||
"python" => Ok(Self::Python),
|
||||
"script" => Ok(Self::Script),
|
||||
"claude_task" | "claudetask" => Err(
|
||||
"claude_task type requires task field - use the claude_task-specific API fields".to_string()
|
||||
),
|
||||
_ => Err(format!("Unknown command type: '{}'. Valid types: shell, powershell, python, script, claude_task", s)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a command type string represents a claude_task.
|
||||
pub fn is_claude_task(s: &str) -> bool {
|
||||
matches!(s.to_lowercase().as_str(), "claude_task" | "claudetask")
|
||||
}
|
||||
|
||||
/// Create a ClaudeTask command type with the required fields.
|
||||
pub fn new_claude_task(task: String, working_directory: Option<String>, context_files: Option<Vec<String>>) -> Self {
|
||||
Self::ClaudeTask { task, working_directory, context_files }
|
||||
}
|
||||
|
||||
/// Convert back to the string format stored in the database.
|
||||
pub fn as_db_string(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Shell => "shell",
|
||||
Self::PowerShell => "powershell",
|
||||
Self::Python => "python",
|
||||
Self::Script => "script",
|
||||
Self::ClaudeTask { .. } => "claude_task",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct CommandPayload {
|
||||
pub id: Uuid,
|
||||
pub command_type: String,
|
||||
pub command_type: CommandType,
|
||||
pub command: String,
|
||||
pub timeout_seconds: Option<u64>,
|
||||
pub elevated: bool,
|
||||
|
||||
Reference in New Issue
Block a user