Skip to content

Commit 8aa987e

Browse files
authored
Accept 3GiB and 6GiB for --video-memory (#311)
## Summary The API now names the GPU tiers by their actual video memory: `3GiB` (default; 4 vCPU, 6GiB memory) and `6GiB` (8 vCPU, 12GiB memory). `2GiB` and `4GiB` are still accepted as deprecated aliases. The CLI validates `--video-memory` before it sends the request, so it currently rejects the new values. - Bump `kernel-go-sdk` from v0.138.0 to v0.141.0, which adds `BrowserVideoMemory3GiB` and `BrowserVideoMemory6GiB`. - `--video-memory` accepts `3GiB` and `6GiB`. The help text and validation error list only those two values. - `2GiB` and `4GiB` are still accepted and sent as typed, so existing scripts keep working and the API can still see how often the old aliases are used. ## Testing `go vet` and `go test ./...` pass. The `TestBrowsersCreate_WithVideoMemory` test covers the new values and the alias passthrough. I didn't create a GPU browser against the API. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > CLI flag validation and SDK bump for GPU VRAM sizing; backward-compatible aliases preserve existing scripts. > > **Overview** > Aligns GPU **`--video-memory`** with the API’s new tier names **`3GiB`** (default) and **`6GiB`**, and bumps **`kernel-go-sdk`** to **v0.141.0** for the matching types. > > Validation now advertises only **`3GiB`** / **`6GiB`** in help and error text, while still accepting **`2GiB`** and **`4GiB`** as deprecated aliases that are forwarded unchanged on create requests. **`TestBrowsersCreate_WithVideoMemory`** covers the new canonical values and alias passthrough. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 292b131. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: yummybomb <19238148+yummybomb@users.noreply.github.com>
1 parent 09d8206 commit 8aa987e

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎cmd/browsers.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,22 @@ func parseMemoryFlag(memory string) (kernel.BrowserMemoryRequest, error) {
205205
// availableVideoMemorySizes returns the video memory (VRAM) sizes the API
206206
// accepts for a GPU browser session.
207207
func availableVideoMemorySizes() []string {
208+
return []string{"3GiB", "6GiB"}
209+
}
210+
211+
// deprecatedVideoMemorySizes are aliases the API still accepts for 3GiB and
212+
// 6GiB. They are sent unchanged so the API can track remaining usage.
213+
func deprecatedVideoMemorySizes() []string {
208214
return []string{"2GiB", "4GiB"}
209215
}
210216

211217
// parseVideoMemoryFlag validates a --video-memory value. An empty value means the
212-
// flag was not set, which lets the API apply its default (2GiB).
218+
// flag was not set, which lets the API apply its default (3GiB).
213219
func parseVideoMemoryFlag(videoMemory string) (kernel.BrowserVideoMemory, error) {
214220
if videoMemory == "" {
215221
return "", nil
216222
}
217-
for _, m := range availableVideoMemorySizes() {
223+
for _, m := range append(availableVideoMemorySizes(), deprecatedVideoMemorySizes()...) {
218224
if strings.EqualFold(videoMemory, m) {
219225
return kernel.BrowserVideoMemory(m), nil
220226
}
@@ -3560,7 +3566,7 @@ unrestricted code execution inside the browser VM and is not sandboxed.`,
35603566
browsersCreateCmd.Flags().BoolP("headless", "H", false, "Launch browser without GUI access")
35613567
browsersCreateCmd.Flags().Bool("gpu", false, "Launch browser with hardware-accelerated GPU rendering")
35623568
browsersCreateCmd.Flags().String("memory", "", "Memory for a non-GPU browser session. Headless: '1GiB' (default), '2GiB' or '4GiB'. Headful: '8GiB' (default) or '16GiB'")
3563-
browsersCreateCmd.Flags().String("video-memory", "", "Video memory (VRAM) for a GPU browser session (requires --gpu): '2GiB' (default, 4 vCPU/6GiB memory) or '4GiB' (8 vCPU/12GiB memory)")
3569+
browsersCreateCmd.Flags().String("video-memory", "", "Video memory (VRAM) for a GPU browser session (requires --gpu): '3GiB' (default, 4 vCPU/6GiB memory) or '6GiB' (8 vCPU/12GiB memory)")
35643570
browsersCreateCmd.Flags().String("fingerprint-os", "", "Closed beta browser fingerprint OS override: macos. Contact Kernel to enable; requires --stealth=true, --headless=false, --gpu=false, and default memory")
35653571
browsersCreateCmd.Flags().String("invocation-id", "", "Associate the browser session with an invocation")
35663572
browsersCreateCmd.Flags().Bool("kiosk", false, "Launch browser in kiosk mode")

‎cmd/browsers_test.go‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,15 +1048,20 @@ func TestBrowsersCreate_WithVideoMemory(t *testing.T) {
10481048
}
10491049
b := BrowsersCmd{browsers: fake}
10501050

1051-
err := b.Create(context.Background(), BrowsersCreateInput{GPU: BoolFlag{Set: true, Value: true}, VideoMemory: "4gib"})
1051+
err := b.Create(context.Background(), BrowsersCreateInput{GPU: BoolFlag{Set: true, Value: true}, VideoMemory: "6gib"})
10521052
require.NoError(t, err)
1053-
assert.Equal(t, kernel.BrowserVideoMemory4GiB, captured.VideoMemory)
1053+
assert.Equal(t, kernel.BrowserVideoMemory6GiB, captured.VideoMemory)
10541054

10551055
raw, err := captured.MarshalJSON()
10561056
require.NoError(t, err)
1057-
assert.Contains(t, string(raw), `"video_memory":"4GiB"`)
1057+
assert.Contains(t, string(raw), `"video_memory":"6GiB"`)
1058+
1059+
// Deprecated aliases are sent as given; the API maps them to 3GiB and 6GiB.
1060+
err = b.Create(context.Background(), BrowsersCreateInput{GPU: BoolFlag{Set: true, Value: true}, VideoMemory: "4GiB"})
1061+
require.NoError(t, err)
1062+
assert.Equal(t, kernel.BrowserVideoMemory4GiB, captured.VideoMemory)
10581063

1059-
// Omitting the flag sends nothing; the server defaults to 2GiB.
1064+
// Omitting the flag sends nothing; the server defaults to 3GiB.
10601065
err = b.Create(context.Background(), BrowsersCreateInput{GPU: BoolFlag{Set: true, Value: true}})
10611066
require.NoError(t, err)
10621067
assert.Empty(t, captured.VideoMemory)

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.1
1010
github.com/golang-jwt/jwt/v5 v5.2.2
1111
github.com/joho/godotenv v1.5.1
12-
github.com/kernel/kernel-go-sdk v0.138.0
12+
github.com/kernel/kernel-go-sdk v0.141.0
1313
github.com/klauspost/compress v1.18.5
1414
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
1515
github.com/pterm/pterm v0.12.80

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
6868
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
6969
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
7070
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
71-
github.com/kernel/kernel-go-sdk v0.138.0 h1:jZg4WIDEV47annt1tc/ywwFfZRMd6yhLyMFG4+j20cs=
72-
github.com/kernel/kernel-go-sdk v0.138.0/go.mod h1:IoxXdj7vgL3LwtAASaRDhs4qgp9AXwBuB3+3EiRBB+U=
71+
github.com/kernel/kernel-go-sdk v0.141.0 h1:uM2bmguFJLoxgBg2eKHAUY10WUn7WhGrsrpZ//cJbAA=
72+
github.com/kernel/kernel-go-sdk v0.141.0/go.mod h1:IoxXdj7vgL3LwtAASaRDhs4qgp9AXwBuB3+3EiRBB+U=
7373
github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE=
7474
github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
7575
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=

0 commit comments

Comments
 (0)