ab2c708ca7
Major Features: - Runtime API for external integrations and turn management - Task manager with persistence and recovery - Shell output streaming and improved tool execution - Error taxonomy and audit logging - Command palette and UI enhancements Documentation: - Runtime API documentation - Operations runbook - Architecture updates Fixes: - Auto-compaction threshold and triggering logic - Doctor command API key validation - Clippy and formatting compliance
85 lines
2.0 KiB
Rust
85 lines
2.0 KiB
Rust
//! Operations submitted by the UI to the core engine.
|
|
//!
|
|
//! These operations flow from the TUI to the engine via a channel,
|
|
//! allowing the UI to remain responsive while the engine processes requests.
|
|
|
|
use crate::compaction::CompactionConfig;
|
|
use crate::models::{Message, SystemPrompt};
|
|
use crate::tui::app::AppMode;
|
|
use std::path::PathBuf;
|
|
|
|
/// Operations that can be submitted to the engine.
|
|
#[derive(Debug, Clone)]
|
|
pub enum Op {
|
|
/// Send a message to the AI
|
|
SendMessage {
|
|
content: String,
|
|
mode: AppMode,
|
|
model: String,
|
|
allow_shell: bool,
|
|
trust_mode: bool,
|
|
},
|
|
|
|
/// Cancel the current request
|
|
CancelRequest,
|
|
|
|
/// Approve a tool call that requires permission
|
|
ApproveToolCall { id: String },
|
|
|
|
/// Deny a tool call that requires permission
|
|
DenyToolCall { id: String },
|
|
|
|
/// Spawn a sub-agent
|
|
SpawnSubAgent { prompt: String },
|
|
|
|
/// List current sub-agents and their status
|
|
ListSubAgents,
|
|
|
|
/// Change the operating mode
|
|
ChangeMode { mode: AppMode },
|
|
|
|
/// Update the model being used
|
|
SetModel { model: String },
|
|
|
|
/// Update auto-compaction settings
|
|
SetCompaction { config: CompactionConfig },
|
|
|
|
/// Sync engine session state (used for resume/load)
|
|
SyncSession {
|
|
messages: Vec<Message>,
|
|
system_prompt: Option<SystemPrompt>,
|
|
model: String,
|
|
workspace: PathBuf,
|
|
},
|
|
|
|
/// Run context compaction immediately.
|
|
CompactContext,
|
|
|
|
/// Shutdown the engine
|
|
Shutdown,
|
|
}
|
|
|
|
impl Op {
|
|
/// Create a send message operation
|
|
pub fn send(
|
|
content: impl Into<String>,
|
|
mode: AppMode,
|
|
model: impl Into<String>,
|
|
allow_shell: bool,
|
|
trust_mode: bool,
|
|
) -> Self {
|
|
Op::SendMessage {
|
|
content: content.into(),
|
|
mode,
|
|
model: model.into(),
|
|
allow_shell,
|
|
trust_mode,
|
|
}
|
|
}
|
|
|
|
/// Create a cancel operation
|
|
pub fn cancel() -> Self {
|
|
Op::CancelRequest
|
|
}
|
|
}
|