|
| 1 | +use alloc::string::String; |
| 2 | +use alloc::vec::Vec; |
| 3 | +use serde::{Deserialize, Serialize}; |
| 4 | + |
| 5 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 6 | +pub struct CommandRequest { |
| 7 | + pub command: String, |
| 8 | + pub args: Vec<String>, |
| 9 | + pub env_vars: Vec<(String, String)>, |
| 10 | + pub working_dir: Option<String>, |
| 11 | + pub timeout_ms: u64, |
| 12 | +} |
| 13 | + |
| 14 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 15 | +pub struct CommandResult { |
| 16 | + pub exit_code: i32, |
| 17 | + pub stdout: Vec<u8>, |
| 18 | + pub stderr: Vec<u8>, |
| 19 | + pub execution_time_ms: u64, |
| 20 | +} |
| 21 | + |
| 22 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 23 | +pub struct FileReadRequest { |
| 24 | + pub path: String, |
| 25 | +} |
| 26 | + |
| 27 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 28 | +pub struct FileReadResponse { |
| 29 | + pub data: Vec<u8>, |
| 30 | + pub success: bool, |
| 31 | + pub error: Option<String>, |
| 32 | +} |
| 33 | + |
| 34 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 35 | +pub struct FileWriteRequest { |
| 36 | + pub path: String, |
| 37 | + pub data: Vec<u8>, |
| 38 | +} |
| 39 | + |
| 40 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 41 | +pub struct FileWriteResponse { |
| 42 | + pub success: bool, |
| 43 | + pub bytes_written: u64, |
| 44 | + pub error: Option<String>, |
| 45 | +} |
| 46 | + |
| 47 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 48 | +pub struct FileListRequest { |
| 49 | + pub path: String, |
| 50 | +} |
| 51 | + |
| 52 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 53 | +pub struct FileListResponse { |
| 54 | + pub entries: Vec<FileEntry>, |
| 55 | + pub success: bool, |
| 56 | + pub error: Option<String>, |
| 57 | +} |
| 58 | + |
| 59 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 60 | +pub struct FileEntry { |
| 61 | + pub name: String, |
| 62 | + pub is_dir: bool, |
| 63 | + pub size: u64, |
| 64 | +} |
| 65 | + |
| 66 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 67 | +pub struct TaskDefinition { |
| 68 | + pub task_id: String, |
| 69 | + pub description: String, |
| 70 | + pub expected_output_hash: Option<Vec<u8>>, |
| 71 | + pub environment_config: Vec<u8>, |
| 72 | + pub scoring_params: Vec<u8>, |
| 73 | +} |
| 74 | + |
| 75 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 76 | +pub struct TermEvaluationMetrics { |
| 77 | + pub execution_time_ms: u64, |
| 78 | + pub correctness_score: f64, |
| 79 | + pub partial_credit: f64, |
| 80 | + pub cost: f64, |
| 81 | +} |
| 82 | + |
| 83 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 84 | +pub struct TermEvaluationInput { |
| 85 | + pub agent_data: Vec<u8>, |
| 86 | + pub challenge_id: String, |
| 87 | + pub params: Vec<u8>, |
| 88 | + pub task_definition: Option<Vec<u8>>, |
| 89 | + pub environment_config: Option<Vec<u8>>, |
| 90 | +} |
| 91 | + |
| 92 | +#[derive(Clone, Debug, Serialize, Deserialize)] |
| 93 | +pub struct TermEvaluationOutput { |
| 94 | + pub score: i64, |
| 95 | + pub valid: bool, |
| 96 | + pub message: String, |
| 97 | + pub metrics: Option<Vec<u8>>, |
| 98 | +} |
| 99 | + |
| 100 | +impl TermEvaluationOutput { |
| 101 | + pub fn success(score: i64, message: &str) -> Self { |
| 102 | + Self { |
| 103 | + score, |
| 104 | + valid: true, |
| 105 | + message: String::from(message), |
| 106 | + metrics: None, |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | + pub fn failure(message: &str) -> Self { |
| 111 | + Self { |
| 112 | + score: 0, |
| 113 | + valid: false, |
| 114 | + message: String::from(message), |
| 115 | + metrics: None, |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + pub fn with_metrics(mut self, metrics: Vec<u8>) -> Self { |
| 120 | + self.metrics = Some(metrics); |
| 121 | + self |
| 122 | + } |
| 123 | +} |
0 commit comments