codewhale_command_contract/
facets.rs1use std::path::PathBuf;
9
10use codewhale_core::request::{Message, SystemPrompt};
11
12use crate::types::{
13 CommandApprovalMode, CommandCurrency, CommandMode, CommandProviderId, CommandReasoningEffort,
14};
15
16pub trait CommandSessionContext {
18 fn session_id(&self) -> Option<String>;
19 fn api_messages(&self) -> Vec<Message>;
20 fn add_message(&mut self, message: Message);
21 fn queued_message_count(&self) -> usize;
22 fn remove_queued_message(&mut self, index: usize) -> Result<(), String>;
23 fn total_tokens(&self) -> u64;
24}
25
26pub trait CommandModelContext {
28 fn current_model(&self) -> String;
29 fn auto_model(&self) -> bool;
30 fn set_model_selection(&mut self, model: String, provider: Option<CommandProviderId>);
31 fn reasoning_effort(&self) -> CommandReasoningEffort;
32 fn provider_identity(&self) -> Option<CommandProviderId>;
33 fn fallback_chain(&self) -> Vec<CommandProviderId>;
34}
35
36pub trait CommandCostContext {
38 fn display_currency(&self) -> CommandCurrency;
39 fn session_cost_for_currency(&self, currency: CommandCurrency) -> f64;
40 fn subagent_cost_for_currency(&self, currency: CommandCurrency) -> f64;
41 fn accrue_cost_estimate(&mut self, amount: f64, currency: CommandCurrency);
42 fn record_turn_cost(
43 &mut self,
44 amount: f64,
45 currency: CommandCurrency,
46 route_receipt: Option<String>,
47 );
48}
49
50pub trait CommandModePolicyContext {
52 fn mode(&self) -> CommandMode;
53 fn set_mode(&mut self, mode: CommandMode);
54 fn approval_mode(&self) -> CommandApprovalMode;
55 fn allow_shell(&self) -> bool;
56 fn set_shell_access(&mut self, allow: bool);
57 fn policy_locked(&self) -> bool;
58}
59
60pub trait CommandSystemPromptContext {
62 fn system_prompt(&self) -> Option<SystemPrompt>;
63}
64
65pub trait CommandSkillsContext {
67 fn active_skill(&self) -> Option<String>;
68 fn active_skill_provenance(&self) -> Option<String>;
69 fn refresh_skill_cache(&mut self);
70}
71
72pub trait CommandWorkspaceContext {
74 fn workspace(&self) -> PathBuf;
75 fn work_state_snapshot(&self) -> Result<Option<String>, String>;
76}