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(&mut self, amount: f64, currency: CommandCurrency, route_receipt: bool);
43}
44
45pub trait CommandModePolicyContext {
47 fn mode(&self) -> CommandMode;
48 fn set_mode(&mut self, mode: CommandMode);
49 fn approval_mode(&self) -> CommandApprovalMode;
50 fn allow_shell(&self) -> bool;
51 fn set_shell_access(&mut self, allow: bool);
52 fn policy_locked(&self) -> bool;
53}
54
55pub trait CommandSystemPromptContext {
57 fn system_prompt(&self) -> Option<SystemPrompt>;
58}
59
60pub trait CommandSkillsContext {
62 fn active_skill(&self) -> Option<String>;
63 fn active_skill_provenance(&self) -> Option<String>;
64 fn refresh_skill_cache(&mut self);
65}
66
67pub trait CommandWorkspaceContext {
69 fn workspace(&self) -> PathBuf;
70 fn work_state_snapshot(&self) -> Result<Option<String>, String>;
71}