|
|
|
|
| use serde::{Deserialize, Serialize};
|
| use std::sync::Arc;
|
|
|
|
|
| #[derive(Debug, Clone, Serialize, Deserialize)]
|
| pub struct CellConfig {
|
| pub cell_id: String,
|
| pub source: String,
|
| pub language: String,
|
| pub enable_m4: bool,
|
| pub enable_proof: bool,
|
| pub enable_telemetry: bool,
|
| }
|
|
|
|
|
| #[derive(Debug, Clone, Serialize, Deserialize)]
|
| pub struct CellOutput {
|
| pub status: String,
|
| pub execution_count: usize,
|
| pub stdout: Vec<String>,
|
| pub stderr: Vec<String>,
|
| pub mutation_visualization: Option<serde_json::Value>,
|
| pub proof_status: Option<serde_json::Value>,
|
| }
|
|
|
|
|
| pub struct CellAgent {
|
| config: CellConfig,
|
| }
|
|
|
| impl CellAgent {
|
| pub fn new(config: CellConfig) -> Self {
|
| Self { config }
|
| }
|
|
|
|
|
| pub fn execute(&self) -> CellOutput {
|
| CellOutput {
|
| status: "ok".into(),
|
| execution_count: 0,
|
| stdout: vec![],
|
| stderr: vec![],
|
| mutation_visualization: None,
|
| proof_status: None,
|
| }
|
| }
|
|
|
| pub fn config(&self) -> &CellConfig {
|
| &self.config
|
| }
|
| }
|
|
|
| #[cfg(test)]
|
| mod tests {
|
| use super::*;
|
|
|
| #[test]
|
| fn test_cell_agent_creation() {
|
| let config = CellConfig {
|
| cell_id: "cell-1".into(),
|
| source: "print('hello')".into(),
|
| language: "python".into(),
|
| enable_m4: false,
|
| enable_proof: true,
|
| enable_telemetry: true,
|
| };
|
|
|
| let agent = CellAgent::new(config);
|
| assert_eq!(agent.config().cell_id, "cell-1");
|
| }
|
|
|
| #[test]
|
| fn test_cell_execution() {
|
| let config = CellConfig {
|
| cell_id: "cell-1".into(),
|
| source: "".into(),
|
| language: "python".into(),
|
| enable_m4: false,
|
| enable_proof: false,
|
| enable_telemetry: false,
|
| };
|
|
|
| let agent = CellAgent::new(config);
|
| let output = agent.execute();
|
| assert_eq!(output.status, "ok");
|
| }
|
| }
|
|
|