use crate::facets::SessionSyncPayload;
#[derive(Debug, Clone, PartialEq)]
pub struct CommandResult<A> {
pub message: Option<String>,
pub action: Option<A>,
pub is_error: bool,
}
impl<A> CommandResult<A> {
pub fn ok() -> Self {
Self {
message: None,
action: None,
is_error: false,
}
}
pub fn message(msg: impl Into<String>) -> Self {
Self {
message: Some(msg.into()),
action: None,
is_error: false,
}
}
pub fn action(action: A) -> Self {
Self {
message: None,
action: Some(action),
is_error: false,
}
}
pub fn with_message_and_action(msg: impl Into<String>, action: A) -> Self {
Self {
message: Some(msg.into()),
action: Some(action),
is_error: false,
}
}
pub fn error(msg: impl Into<String>) -> Self {
Self {
message: Some(format!("Error: {}", msg.into())),
action: None,
is_error: true,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum DebugAction {
FetchBalance,
CacheWarmup,
PreviewOutboundRequest {
json: bool,
base_prompt_only: bool,
hypothetical_prompt: Option<String>,
},
OpenTextPager {
title: String,
content: String,
},
OpenContextInspector,
SendMessage(String),
SyncSession(SessionSyncPayload),
ConversationUndo {
sync: SessionSyncPayload,
retry_input: Option<String>,
},
}
pub type DebugCommandResult = CommandResult<DebugAction>;
pub type StructcopyCommandResult = CommandResult<std::convert::Infallible>;
#[derive(Debug, Clone, PartialEq)]
pub enum SessionAction {
CompactContext { focus: Option<String> },
PurgeContext,
LoadSession(std::path::PathBuf),
SyncSession(SessionSyncPayload),
SendMessage(String),
RemoteControl(SessionRemoteControlAction),
OpenExternalUrl { url: String, label: String },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SessionRemoteControlAction {
Start,
Stop,
}
pub type SessionCommandResult = CommandResult<SessionAction>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConfigPolicyAction {
PermissionRulesChanged,
}
pub type ConfigPolicyCommandResult = CommandResult<ConfigPolicyAction>;
pub type ConfigStatusCommandResult = CommandResult<std::convert::Infallible>;