Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "steel-cli"
version = "0.5.0-preview.2"
version = "0.5.0-preview.3"
edition = "2024"
description = "Steel CLI - Browser automation for AI agents"
license = "MIT"
Expand Down
3 changes: 1 addition & 2 deletions docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1572,11 +1572,10 @@ steel computer create

### Parameters

- `--template` (string, required): Template name
- `--template` (string, optional): Template name (defaults to the only one the API offers)
- `--region` (string, optional): Region, for example us-east
- `--vcpu` (string, optional): Number of vCPUs
- `--memory` (string, optional): Memory in MiB
- `--disk` (string, optional): Disk in MiB
- `--timeout` (string, optional): Stop the computer after this many seconds of running time
- `--auto-pause` (boolean, optional): Pause instead of stopping when the timeout is reached
- `--wait` (boolean, optional): Wait until the computer is running
Expand Down
23 changes: 11 additions & 12 deletions src/api/computers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ pub fn computer_path(id: &str) -> String {

#[derive(Debug, Default, Clone)]
pub struct CreateComputer {
pub template: String,
pub template: Option<String>,
pub region: Option<String>,
pub vcpu: Option<u32>,
pub memory_mib: Option<u32>,
pub disk_mib: Option<u32>,
pub timeout_seconds: Option<u32>,
pub auto_pause: Option<bool>,
}

impl CreateComputer {
pub fn body(&self) -> Value {
let mut body = json!({ "template": self.template });
let mut body = json!({});
if let Some(template) = &self.template {
body["template"] = json!(template);
}
if let Some(region) = &self.region {
body["region"] = json!(region);
}
Expand All @@ -31,9 +33,6 @@ impl CreateComputer {
if let Some(memory) = self.memory_mib {
body["memoryMib"] = json!(memory);
}
if let Some(disk) = self.disk_mib {
body["diskMib"] = json!(disk);
}
if let Some(timeout) = self.timeout_seconds {
body["timeoutSeconds"] = json!(timeout);
}
Expand Down Expand Up @@ -195,18 +194,19 @@ mod tests {

#[test]
fn create_body_only_carries_given_fields() {
let minimal = CreateComputer {
template: "steel".into(),
assert_eq!(CreateComputer::default().body(), json!({}));

let named = CreateComputer {
template: Some("steel".into()),
..Default::default()
};
assert_eq!(minimal.body(), json!({ "template": "steel" }));
assert_eq!(named.body(), json!({ "template": "steel" }));

let full = CreateComputer {
template: "steel".into(),
template: Some("steel".into()),
region: Some("us-east".into()),
vcpu: Some(4),
memory_mib: Some(4096),
disk_mib: Some(10240),
timeout_seconds: Some(600),
auto_pause: Some(true),
};
Expand All @@ -217,7 +217,6 @@ mod tests {
"region": "us-east",
"vcpu": 4,
"memoryMib": 4096,
"diskMib": 10240,
"timeoutSeconds": 600,
"autoPause": true,
})
Expand Down
9 changes: 2 additions & 7 deletions src/commands/computer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl Command {

#[derive(Parser)]
pub struct CreateArgs {
/// Template name
/// Template name (defaults to the only one the API offers)
#[arg(long)]
pub template: String,
pub template: Option<String>,

/// Region, for example us-east
#[arg(long)]
Expand All @@ -90,10 +90,6 @@ pub struct CreateArgs {
#[arg(long = "memory", value_name = "MIB")]
pub memory_mib: Option<u32>,

/// Disk in MiB
#[arg(long = "disk", value_name = "MIB")]
pub disk_mib: Option<u32>,

/// Stop the computer after this many seconds of running time
#[arg(long = "timeout", value_name = "SECONDS")]
pub timeout_seconds: Option<u32>,
Expand Down Expand Up @@ -215,7 +211,6 @@ async fn run_create(args: CreateArgs) -> Result<()> {
region: args.region,
vcpu: args.vcpu,
memory_mib: args.memory_mib,
disk_mib: args.disk_mib,
timeout_seconds: args.timeout_seconds,
auto_pause: args.auto_pause.then_some(true),
};
Expand Down
Loading