#![warn(missing_debug_implementations)]
pub mod audit;
pub mod config;
pub mod event;
pub mod executor;
pub mod factory;
pub mod real_factory;
pub mod registry;
pub mod routing;
pub mod session;
#[cfg(any(test, feature = "testing"))]
pub mod testing;
pub mod worktree;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum OrchestratorError {
#[error("config error: {0}")]
Config(String),
#[error("worktree error: {0}")]
Worktree(String),
#[error("driver error: {0}")]
Driver(#[from] cap_rs::driver::DriverError),
}
use crate::config::FleetSpec;
use crate::event::OrchestratorEvent;
use crate::executor::{Executor, ExecutorHandle};
use crate::real_factory::RealDriverFactory;
use crate::routing::RoutingStrategy;
use crate::worktree::GitWorktreeManager;
pub async fn run(
spec: FleetSpec,
repo: impl AsRef<std::path::Path>,
task: &str,
) -> Result<
(
ExecutorHandle,
tokio::sync::mpsc::Receiver<OrchestratorEvent>,
),
OrchestratorError,
> {
let worktree = GitWorktreeManager::new(repo);
Executor::start(spec, RealDriverFactory, worktree, task).await
}
pub async fn chat(
spec: FleetSpec,
repo: impl AsRef<std::path::Path>,
task: &str,
) -> Result<
(
ExecutorHandle,
tokio::sync::mpsc::Receiver<OrchestratorEvent>,
),
OrchestratorError,
> {
let worktree = GitWorktreeManager::new(repo);
Executor::start_chat(spec, RealDriverFactory, worktree, task).await
}
pub async fn run_with_strategy<S>(
spec: FleetSpec,
repo: impl AsRef<std::path::Path>,
task: &str,
strategy: S,
) -> Result<
(
ExecutorHandle,
tokio::sync::mpsc::Receiver<OrchestratorEvent>,
),
OrchestratorError,
>
where
S: RoutingStrategy,
{
let worktree = GitWorktreeManager::new(repo);
Executor::start_with_strategy(spec, RealDriverFactory, worktree, task, strategy).await
}