| 1 | //! Operations submitted by the UI to the core engine. |
| 2 | //! |
| 3 | //! These operations flow from the TUI to the engine via a channel, |
| 4 | //! allowing the UI to remain responsive while the engine processes requests. |
| 5 | |
| 6 | use crate::compaction::CompactionConfig; |
| 7 | use crate::models::{Message, SystemPrompt}; |
| 8 | use crate::tui::app::AppMode; |
| 9 | use crate::tui::approval::ApprovalMode; |
| 10 | use std::path::PathBuf; |
| 11 | |
| 12 | /// Operations that can be submitted to the engine. |
| 13 | #[derive(Debug, Clone)] |
| 14 | pub enum Op { |
| 15 | /// Send a message to the AI |
| 16 | SendMessage { |
| 17 | content: String, |
| 18 | mode: AppMode, |
| 19 | model: String, |
| 20 | goal_objective: Option<String>, |
| 21 | /// Reasoning-effort tier: `"off" | "low" | "medium" | "high" | "max"`. |
| 22 | /// `None` lets the provider apply its default. |
| 23 | reasoning_effort: Option<String>, |
| 24 | /// True when the user selected auto thinking, even though the UI sends |
| 25 | /// a concrete per-turn value to the model API. |
| 26 | reasoning_effort_auto: bool, |
| 27 | /// True when the user selected auto model routing. |
| 28 | auto_model: bool, |
| 29 | allow_shell: bool, |
| 30 | trust_mode: bool, |
| 31 | auto_approve: bool, |
| 32 | approval_mode: ApprovalMode, |
| 33 | }, |
| 34 | |
| 35 | /// Cancel the current request |
| 36 | #[allow(dead_code)] |
| 37 | CancelRequest, |
| 38 | |
| 39 | /// Approve a tool call that requires permission |
| 40 | #[allow(dead_code)] |
| 41 | ApproveToolCall { id: String }, |
| 42 | |
| 43 | /// Deny a tool call that requires permission |
| 44 | #[allow(dead_code)] |
| 45 | DenyToolCall { id: String }, |
| 46 | |
| 47 | /// Spawn a sub-agent |
| 48 | #[allow(dead_code)] |
| 49 | SpawnSubAgent { prompt: String }, |
| 50 | |
| 51 | /// List current sub-agents and their status |
| 52 | ListSubAgents, |
| 53 | |
| 54 | /// Change the operating mode |
| 55 | #[allow(dead_code)] |
| 56 | ChangeMode { mode: AppMode }, |
| 57 | |
| 58 | /// Update the model being used |
| 59 | #[allow(dead_code)] |
| 60 | SetModel { model: String }, |
| 61 | |
| 62 | /// Update auto-compaction settings |
| 63 | SetCompaction { config: CompactionConfig }, |
| 64 | |
| 65 | /// Sync engine session state (used for resume/load) |
| 66 | SyncSession { |
| 67 | messages: Vec<Message>, |
| 68 | system_prompt: Option<SystemPrompt>, |
| 69 | model: String, |
| 70 | workspace: PathBuf, |
| 71 | }, |
| 72 | |
| 73 | /// Run context compaction immediately. |
| 74 | CompactContext, |
| 75 | |
| 76 | /// Run a Recursive Language Model (RLM) turn per Algorithm 1 of |
| 77 | /// Zhang et al. (arXiv:2512.24601). The prompt is stored in the REPL |
| 78 | /// as `context`; the root LLM only sees metadata. |
| 79 | Rlm { |
| 80 | /// The user's prompt — stored in REPL, NOT in the LLM context. |
| 81 | content: String, |
| 82 | /// The model to use for root LLM calls. |
| 83 | model: String, |
| 84 | /// The model to use for sub-LLM (llm_query) calls. |
| 85 | child_model: String, |
| 86 | /// Recursion budget for `sub_rlm()` calls. Paper experiments use |
| 87 | /// depth=1; defaults set by the `/rlm` command. |
| 88 | max_depth: u32, |
| 89 | }, |
| 90 | |
| 91 | /// Edit the last user message: remove the last user+assistant exchange |
| 92 | /// from the session, then re-send with the new content. |
| 93 | #[allow(dead_code)] |
| 94 | EditLastTurn { new_message: String }, |
| 95 | |
| 96 | /// Shutdown the engine |
| 97 | Shutdown, |
| 98 | } |
| 99 |