use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use uuid::Uuid;
use crate::types::ids::AgentId;
use crate::types::logs::LogOption;
use crate::types::message::Message;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum LocalCommandResult {
#[serde(rename = "text")]
Text { value: String },
#[serde(rename = "compact")]
Compact {
#[serde(rename = "compactionResult")]
compaction_result: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "displayText")]
display_text: Option<String>,
},
#[serde(rename = "skip")]
Skip,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum SettingSource {
UserSettings,
ProjectSettings,
LocalSettings,
PolicySettings,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PromptCommand {
#[serde(rename = "type")]
pub command_type: String, #[serde(rename = "progressMessage")]
pub progress_message: String,
#[serde(rename = "contentLength")]
pub content_length: usize,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "argNames")]
pub arg_names: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "allowedTools")]
pub allowed_tools: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option<String>,
pub source: CommandSource,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "pluginInfo")]
pub plugin_info: Option<PluginInfo>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "disableNonInteractive")]
pub disable_non_interactive: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub hooks: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "skillRoot")]
pub skill_root: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<ExecutionContext>,
#[serde(skip_serializing_if = "Option::is_none")]
pub agent: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub effort: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub paths: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum CommandSource {
UserSettings,
ProjectSettings,
LocalSettings,
PolicySettings,
Builtin,
Mcp,
Plugin,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginInfo {
#[serde(rename = "pluginManifest")]
pub plugin_manifest: serde_json::Value,
pub repository: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum ExecutionContext {
Inline,
Fork,
}
pub type LocalCommandModule = serde_json::Value;
pub struct LocalCommand {
pub command_type: String, pub supports_non_interactive: bool,
pub load: Box<
dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = LocalCommandModule> + Send>>
+ Send
+ Sync,
>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ResumeEntrypoint {
CliFlag,
SlashCommandPicker,
SlashCommandSessionId,
SlashCommandTitle,
Fork,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum CommandResultDisplay {
Skip,
System,
User,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommandCompleteOptions {
#[serde(skip_serializing_if = "Option::is_none")]
pub display: Option<CommandResultDisplay>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "shouldQuery")]
pub should_query: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "metaMessages")]
pub meta_messages: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "nextInput")]
pub next_input: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "submitNextInput")]
pub submit_next_input: Option<bool>,
}
pub type LocalJsxCommandOnDone =
Box<dyn Fn(Option<String>, Option<CommandCompleteOptions>) + Send + Sync>;
pub type LocalJsxCommandModule = serde_json::Value;
pub struct LocalJsxCommand {
pub command_type: String, pub load: Box<
dyn Fn()
-> std::pin::Pin<Box<dyn std::future::Future<Output = LocalJsxCommandModule> + Send>>
+ Send
+ Sync,
>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum CommandAvailability {
ClaudeAi,
Console,
}
pub struct CommandBase {
pub availability: Option<Vec<CommandAvailability>>,
pub description: String,
pub has_user_specified_description: Option<bool>,
pub is_enabled: Option<Box<dyn Fn() -> bool + Send + Sync>>,
pub is_hidden: Option<bool>,
pub name: String,
pub aliases: Option<Vec<String>>,
pub is_mcp: Option<bool>,
pub argument_hint: Option<String>,
pub when_to_use: Option<String>,
pub version: Option<String>,
pub disable_model_invocation: Option<bool>,
pub user_invocable: Option<bool>,
pub loaded_from: Option<CommandLoadSource>,
pub kind: Option<CommandKind>,
pub immediate: Option<bool>,
pub is_sensitive: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum CommandLoadSource {
CommandsDeprecated,
Skills,
Plugin,
Managed,
Bundled,
Mcp,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum CommandKind {
Workflow,
}
pub fn get_command_name(cmd: &CommandBase) -> &str {
&cmd.name
}
pub fn is_command_enabled(is_enabled: Option<&Box<dyn Fn() -> bool + Send + Sync>>) -> bool {
match is_enabled {
Some(f) => f(),
None => true,
}
}
pub enum Command {
Prompt {
base: CommandBase,
prompt: PromptCommand,
},
Local {
base: CommandBase,
local: LocalCommand,
},
LocalJsx {
base: CommandBase,
local_jsx: LocalJsxCommand,
},
}