Skip to main content

ai_agent/utils/
plan_mode_v2.rs

1//! Plan mode v2 utilities.
2
3use crate::constants::env::ai;
4use serde::{Deserialize, Serialize};
5
6/// Plan mode v2 configuration
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct PlanModeV2Config {
9    pub enabled: bool,
10    pub use_interview: bool,
11    pub agent_count: usize,
12    pub explore_agent_count: usize,
13}
14
15impl Default for PlanModeV2Config {
16    fn default() -> Self {
17        Self {
18            enabled: false,
19            use_interview: false,
20            agent_count: 1,
21            explore_agent_count: 1,
22        }
23    }
24}
25
26/// Check if plan mode v2 is enabled
27pub fn is_plan_mode_v2_enabled() -> bool {
28    std::env::var(ai::CODE_PLAN_MODE_V2)
29        .map(|v| v == "true")
30        .unwrap_or(false)
31}
32
33/// Get the agent count for plan mode v2
34pub fn get_plan_mode_v2_agent_count() -> usize {
35    std::env::var(ai::CODE_PLAN_MODE_AGENT_COUNT)
36        .ok()
37        .and_then(|v| v.parse().ok())
38        .unwrap_or(1)
39}
40
41/// Get the explore agent count for plan mode v2
42pub fn get_plan_mode_v2_explore_agent_count() -> usize {
43    std::env::var(ai::CODE_PLAN_MODE_EXPLORE_AGENT_COUNT)
44        .ok()
45        .and_then(|v| v.parse().ok())
46        .unwrap_or(1)
47}
48
49/// Check if interview phase is enabled in plan mode v2
50pub fn is_plan_mode_interview_phase_enabled() -> bool {
51    std::env::var(ai::CODE_PLAN_MODE_INTERVIEW)
52        .map(|v| v == "true")
53        .unwrap_or(false)
54}
55
56/// Get the Pewter ledger variant
57pub fn get_pewter_ledger_variant() -> Option<String> {
58    std::env::var(ai::CODE_PEWTER_LEDGER_VARIANT).ok()
59}