reasonkit/m2/
mod.rs

1//! # MiniMax M2 Integration Module
2//!
3//! NOTE: The full M2 integration is currently experimental.
4//!
5//! This module intentionally provides a small, compiling API surface so that
6//! `cargo test --all-features` remains green while the full implementation is
7//! iterated on.
8
9pub mod types;
10
11pub use types::*;
12
13// The full implementation files still exist in `src/m2/`, but are intentionally
14// not compiled until stabilized.
15//
16pub mod benchmarks;
17pub mod connector;
18pub mod engine;
19pub mod protocol_generator;
20
21use crate::error::Error;
22
23/// Primary M2 integration service.
24///
25/// The full interleaved-thinking engine is not yet wired in.
26#[derive(Debug, Clone)]
27pub struct M2IntegrationService {
28    config: M2Config,
29    integration_config: M2IntegrationConfig,
30}
31
32impl M2IntegrationService {
33    /// Create a new service.
34    pub async fn new(
35        config: M2Config,
36        integration_config: M2IntegrationConfig,
37    ) -> Result<Self, Error> {
38        Ok(Self {
39            config,
40            integration_config,
41        })
42    }
43
44    /// Execute an M2 run for a `UseCase`.
45    ///
46    /// Currently returns `Error::M2ExecutionError` because the integration is a stub.
47    pub async fn execute_for_use_case(
48        &self,
49        _use_case: UseCase,
50        _input: ProtocolInput,
51        _framework: Option<AgentFramework>,
52    ) -> Result<InterleavedResult, Error> {
53        let _ = (&self.config, &self.integration_config);
54        Err(Error::M2ExecutionError(
55            "M2 integration is not implemented in this build".to_string(),
56        ))
57    }
58
59    /// Map a high-level `UseCase` to a `TaskClassification`.
60    pub fn classify_use_case(
61        &self,
62        use_case: UseCase,
63        _input: &ProtocolInput,
64    ) -> Result<TaskClassification, Error> {
65        Ok(TaskClassification::from(use_case))
66    }
67}
68
69/// Builder for `M2IntegrationService`.
70#[derive(Debug, Clone)]
71pub struct M2ServiceBuilder {
72    config: Option<M2Config>,
73    integration_config: Option<M2IntegrationConfig>,
74}
75
76impl M2ServiceBuilder {
77    pub fn new() -> Self {
78        Self {
79            config: None,
80            integration_config: None,
81        }
82    }
83
84    pub fn with_config(mut self, config: M2Config) -> Self {
85        self.config = Some(config);
86        self
87    }
88
89    pub fn with_integration_config(mut self, integration_config: M2IntegrationConfig) -> Self {
90        self.integration_config = Some(integration_config);
91        self
92    }
93
94    pub async fn build(self) -> Result<M2IntegrationService, Error> {
95        let config = self.config.unwrap_or_default();
96        let integration_config = self.integration_config.unwrap_or_default();
97        M2IntegrationService::new(config, integration_config).await
98    }
99}
100
101impl Default for M2ServiceBuilder {
102    fn default() -> Self {
103        Self::new()
104    }
105}