Skip to main content

agentkernel_sdk/
types.rs

1use serde::{Deserialize, Serialize};
2
3/// Security profile for sandbox execution.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5#[serde(rename_all = "lowercase")]
6pub enum SecurityProfile {
7    Permissive,
8    Moderate,
9    Restrictive,
10}
11
12/// Options for running a command.
13#[derive(Debug, Default, Serialize)]
14pub struct RunOptions {
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub image: Option<String>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub profile: Option<SecurityProfile>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub fast: Option<bool>,
21}
22
23/// Output from a command execution.
24#[derive(Debug, Deserialize)]
25pub struct RunOutput {
26    pub output: String,
27}
28
29/// Information about a sandbox.
30#[derive(Debug, Deserialize)]
31pub struct SandboxInfo {
32    pub name: String,
33    pub status: String,
34    pub backend: String,
35    pub image: Option<String>,
36    pub vcpus: Option<u32>,
37    pub memory_mb: Option<u64>,
38    pub created_at: Option<String>,
39}
40
41/// SSE stream event.
42#[derive(Debug)]
43pub struct StreamEvent {
44    pub event_type: String,
45    pub data: serde_json::Value,
46}
47
48/// API response wrapper (internal).
49#[derive(Debug, Deserialize)]
50pub(crate) struct ApiResponse<T> {
51    pub success: bool,
52    pub data: Option<T>,
53    pub error: Option<String>,
54}
55
56/// Run request body (internal).
57#[derive(Serialize)]
58pub(crate) struct RunRequest {
59    pub command: Vec<String>,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub image: Option<String>,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub profile: Option<SecurityProfile>,
64    pub fast: bool,
65}
66
67/// Create sandbox request body (internal).
68#[derive(Serialize)]
69pub(crate) struct CreateRequest {
70    pub name: String,
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub image: Option<String>,
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub vcpus: Option<u32>,
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub memory_mb: Option<u64>,
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub profile: Option<SecurityProfile>,
79}
80
81/// Exec request body (internal).
82#[derive(Serialize)]
83pub(crate) struct ExecRequest {
84    pub command: Vec<String>,
85}
86
87/// File write request body (internal).
88#[derive(Serialize)]
89pub(crate) struct FileWriteRequest {
90    pub content: String,
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub encoding: Option<String>,
93}
94
95/// Response from reading a file.
96#[derive(Debug, Deserialize)]
97pub struct FileReadResponse {
98    pub content: String,
99    pub encoding: String,
100    pub size: usize,
101}
102
103/// Batch run request body (internal).
104#[derive(Serialize)]
105pub(crate) struct BatchRunRequest {
106    pub commands: Vec<BatchCommand>,
107}
108
109/// A command for batch execution.
110#[derive(Debug, Serialize)]
111pub struct BatchCommand {
112    pub command: Vec<String>,
113}
114
115/// Result of a single batch command.
116#[derive(Debug, Deserialize)]
117pub struct BatchResult {
118    pub output: Option<String>,
119    pub error: Option<String>,
120}
121
122/// Response from batch execution.
123#[derive(Debug, Deserialize)]
124pub struct BatchRunResponse {
125    pub results: Vec<BatchResult>,
126}