Download crates/notebook-kernel/src/cell_agent.rs from Snapkitty/rowm-polymorphic-notebook: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/Snapkitty/rowm-polymorphic-notebook/resolve/main/crates/notebook-kernel/src/cell_agent.rs
- Command line
-
hf download hf://Snapkitty/rowm-polymorphic-notebook/crates/notebook-kernel/src/cell_agent.rs
-
curl -L -o cell_agent.rs https://huggingface.co/Snapkitty/rowm-polymorphic-notebook/resolve/main/crates/notebook-kernel/src/cell_agent.rs
2.22 kB
| //! Cell Agent — autonomous executable unit | |
| use serde::{Deserialize, Serialize}; | |
| use std::sync::Arc; | |
| /// Cell execution configuration | |
| 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, | |
| } | |
| /// Cell output | |
| 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>, | |
| } | |
| /// Autonomous cell execution agent | |
| pub struct CellAgent { | |
| config: CellConfig, | |
| } | |
| impl CellAgent { | |
| pub fn new(config: CellConfig) -> Self { | |
| Self { config } | |
| } | |
| /// Execute this cell | |
| 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 | |
| } | |
| } | |
| mod tests { | |
| use super::*; | |
| 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"); | |
| } | |
| 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"); | |
| } | |
| } | |