vtcode_core/core/interfaces/
session.rs1use anyhow::Result;
2use async_trait::async_trait;
3
4use crate::config::loader::VTCodeConfig;
5use crate::config::types::AgentConfig as CoreAgentConfig;
6use crate::core::agent::steering::SteeringMessage;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
10pub enum PlanningEntrySource {
11 #[default]
12 None,
13 CliFlag,
14 ConfigDefault,
15 UserRequest,
16 AgentSelection,
18 AgentSuggestion,
20}
21
22impl PlanningEntrySource {
23 pub const fn should_auto_enter(self) -> bool {
24 matches!(self, Self::CliFlag)
25 }
26
27 pub const fn requires_startup_prompt(self) -> bool {
28 matches!(self, Self::ConfigDefault)
29 }
30}
31
32#[derive(Debug)]
34pub struct SessionRuntimeParams<'a, Resume> {
35 pub agent_config: &'a CoreAgentConfig,
36 pub vt_config: Option<VTCodeConfig>,
37 pub skip_confirmations: bool,
38 pub full_auto: bool,
39 pub primary_agent_explicitly_configured: bool,
40 pub planning_entry_source: PlanningEntrySource,
41 pub resume: Option<Resume>,
42 pub steering_receiver: &'a mut Option<tokio::sync::mpsc::UnboundedReceiver<SteeringMessage>>,
43}
44
45impl<'a, Resume> SessionRuntimeParams<'a, Resume> {
46 pub fn new(
47 agent_config: &'a CoreAgentConfig,
48 vt_config: Option<VTCodeConfig>,
49 skip_confirmations: bool,
50 full_auto: bool,
51 primary_agent_explicitly_configured: bool,
52 planning_entry_source: PlanningEntrySource,
53 resume: Option<Resume>,
54 steering_receiver: &'a mut Option<tokio::sync::mpsc::UnboundedReceiver<SteeringMessage>>,
55 ) -> Self {
56 Self {
57 agent_config,
58 vt_config,
59 skip_confirmations,
60 full_auto,
61 primary_agent_explicitly_configured,
62 planning_entry_source,
63 resume,
64 steering_receiver,
65 }
66 }
67}
68
69#[async_trait]
71pub trait SessionRuntime<Resume>: Send + Sync {
72 async fn run_session(&self, params: SessionRuntimeParams<'_, Resume>) -> Result<()>;
73}