codewhale_command_contract/
outcome.rs1use crate::facets::SessionSyncPayload;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct CommandResult<A> {
8 pub message: Option<String>,
9 pub action: Option<A>,
10 pub is_error: bool,
11}
12
13impl<A> CommandResult<A> {
14 pub fn ok() -> Self {
15 Self {
16 message: None,
17 action: None,
18 is_error: false,
19 }
20 }
21 pub fn message(msg: impl Into<String>) -> Self {
22 Self {
23 message: Some(msg.into()),
24 action: None,
25 is_error: false,
26 }
27 }
28 pub fn action(action: A) -> Self {
29 Self {
30 message: None,
31 action: Some(action),
32 is_error: false,
33 }
34 }
35 pub fn with_message_and_action(msg: impl Into<String>, action: A) -> Self {
36 Self {
37 message: Some(msg.into()),
38 action: Some(action),
39 is_error: false,
40 }
41 }
42 pub fn error(msg: impl Into<String>) -> Self {
43 Self {
44 message: Some(format!("Error: {}", msg.into())),
45 action: None,
46 is_error: true,
47 }
48 }
49}
50
51#[derive(Debug, Clone, PartialEq)]
54pub enum DebugAction {
55 FetchBalance,
56 CacheWarmup,
57 PreviewOutboundRequest {
58 json: bool,
59 base_prompt_only: bool,
60 hypothetical_prompt: Option<String>,
61 },
62 OpenTextPager {
63 title: String,
64 content: String,
65 },
66 OpenDiffPager {
69 title: String,
70 diff: String,
71 },
72 OpenContextInspector,
73 SendMessage(String),
74 SyncSession(SessionSyncPayload),
75 ConversationUndo {
78 sync: SessionSyncPayload,
79 retry_input: Option<String>,
80 },
81}
82
83pub type DebugCommandResult = CommandResult<DebugAction>;
84
85pub type StructcopyCommandResult = CommandResult<std::convert::Infallible>;
87
88#[derive(Debug, Clone, PartialEq)]
90pub enum SessionAction {
91 CompactContext { focus: Option<String> },
92 PurgeContext,
93 LoadSession(std::path::PathBuf),
94 SyncSession(SessionSyncPayload),
95 SendMessage(String),
96 RemoteControl(SessionRemoteControlAction),
97 OpenExternalUrl { url: String, label: String },
98}
99
100#[derive(Debug, Clone, Copy, PartialEq, Eq)]
101pub enum SessionRemoteControlAction {
102 Start,
103 Stop,
104}
105
106pub type SessionCommandResult = CommandResult<SessionAction>;
107
108#[derive(Debug, Clone, PartialEq, Eq)]
114pub enum ConfigAction {
115 PermissionRulesChanged,
117 StartXaiDeviceLogin,
119 StartClaudeLogin,
120 StartClaudeRevoke,
121 StartChatgptPkceLogin,
122 StartChatgptRevoke,
123 StartOrcarouterPkceLogin,
124 StartOrcarouterRevoke,
125 OpenConfigView,
127 OpenModePicker,
128 OpenThemePicker,
129 OpenStatusPicker,
130 OpenProviderPicker,
131 StartPluginLogin {
132 provider: String,
133 },
134 StartPluginLogout {
135 provider: String,
136 },
137 SetScreenMode(crate::types::CommandScreenMode),
138 SetWorkspaceTrust {
139 trusted: bool,
140 save: bool,
141 },
142 ModeChanged(crate::types::CommandMode),
144 ApprovalPolicyChanged {
145 policy: Option<String>,
146 },
147 SwitchProvider {
148 provider: crate::types::CommandProviderId,
149 model: Option<String>,
150 },
151 CompactionChanged(crate::config::CommandCompactionConfig),
152 StreamChunkTimeoutChanged(u64),
153 SubagentRuntimeChanged(crate::config::CommandSubagentRuntimeConfig),
154 SearchProviderChanged(crate::config::CommandSearchProvider),
155 PromptSuggestionChanged {
156 enabled: bool,
157 },
158 NotificationChanged(crate::config::CommandNotificationUpdate),
159}
160pub type ConfigCommandResult = CommandResult<ConfigAction>;
161pub type ConfigPolicyAction = ConfigAction;
163pub type ConfigPolicyCommandResult = ConfigCommandResult;
164pub type ConfigStatusCommandResult = CommandResult<std::convert::Infallible>;
165
166#[derive(Debug, Clone, PartialEq, Eq)]
167pub enum CoreNavigationAction {
168 OpenHotbarSetup,
169 DisableHotbar,
170 RestoreHotbarDefaults,
171 OpenLiveTranscript,
172 OpenTurnInspector,
173 OpenWorktreeManager,
174 SwitchWorkspace { workspace: std::path::PathBuf },
175 VoiceCapture,
176}
177
178pub type CoreNavigationCommandResult = CommandResult<CoreNavigationAction>;