bootstrap.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #[derive(Debug, Clone, Copy, PartialEq, Eq)]
  2. pub enum BootstrapPhase {
  3. CliEntry,
  4. FastPathVersion,
  5. StartupProfiler,
  6. SystemPromptFastPath,
  7. ChromeMcpFastPath,
  8. DaemonWorkerFastPath,
  9. BridgeFastPath,
  10. DaemonFastPath,
  11. BackgroundSessionFastPath,
  12. TemplateFastPath,
  13. EnvironmentRunnerFastPath,
  14. MainRuntime,
  15. }
  16. #[derive(Debug, Clone, PartialEq, Eq)]
  17. pub struct BootstrapPlan {
  18. phases: Vec<BootstrapPhase>,
  19. }
  20. impl BootstrapPlan {
  21. #[must_use]
  22. pub fn default_bootstrap() -> Self {
  23. Self::from_phases(vec![
  24. BootstrapPhase::CliEntry,
  25. BootstrapPhase::FastPathVersion,
  26. BootstrapPhase::StartupProfiler,
  27. BootstrapPhase::SystemPromptFastPath,
  28. BootstrapPhase::ChromeMcpFastPath,
  29. BootstrapPhase::DaemonWorkerFastPath,
  30. BootstrapPhase::BridgeFastPath,
  31. BootstrapPhase::DaemonFastPath,
  32. BootstrapPhase::BackgroundSessionFastPath,
  33. BootstrapPhase::TemplateFastPath,
  34. BootstrapPhase::EnvironmentRunnerFastPath,
  35. BootstrapPhase::MainRuntime,
  36. ])
  37. }
  38. #[must_use]
  39. pub fn from_phases(phases: Vec<BootstrapPhase>) -> Self {
  40. let mut deduped = Vec::new();
  41. for phase in phases {
  42. if !deduped.contains(&phase) {
  43. deduped.push(phase);
  44. }
  45. }
  46. Self { phases: deduped }
  47. }
  48. #[must_use]
  49. pub fn phases(&self) -> &[BootstrapPhase] {
  50. &self.phases
  51. }
  52. }