use std::sync::Arc;

use crate::context::RunCancellation;
use crate::engine::Engine;
use crate::error::Result;
use crate::request::RunRequest;
use crate::result::{AgentMetadata, RunResult};

#[derive(Clone)]
pub struct AgentService {
    engine: Arc<Engine>,
    metadata: AgentMetadata,
}

impl AgentService {
    pub fn new(engine: Arc<Engine>, metadata: AgentMetadata) -> Self {
        Self { engine, metadata }
    }

    pub fn describe(&self) -> &AgentMetadata {
        &self.metadata
    }

    pub fn run_once(&self, request: &RunRequest) -> Result<RunResult> {
        self.engine.run_once(request)
    }

    pub fn run_once_with_cancellation(
        &self,
        request: &RunRequest,
        cancellation: RunCancellation,
    ) -> Result<RunResult> {
        self.engine
            .run_once_with_cancellation(request, cancellation)
    }
}
