Skip to content

Commit dccd8a8

Browse files
committed
add demos
1 parent e8c63c3 commit dccd8a8

14 files changed

+295
-26
lines changed

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,20 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
106106
### App Management
107107

108108
- `kernel deploy <file>` - Deploy an app to Kernel
109+
109110
- `--version <version>` - Specify app version (default: latest)
110111
- `--force` - Allow overwriting existing version
111112
- `--env <KEY=VALUE>`, `-e` - Set environment variables (can be used multiple times)
112113
- `--env-file <file>` - Load environment variables from file (can be used multiple times)
113114

114115
- `kernel invoke <app> <action>` - Run an app action
116+
115117
- `--version <version>`, `-v` - Specify app version (default: latest)
116118
- `--payload <json>`, `-p` - JSON payload for the action
117119
- `--sync`, `-s` - Invoke synchronously (timeout after 60s)
118120

119121
- `kernel app list` - List deployed apps
122+
120123
- `--name <app_name>` - Filter by app name
121124
- `--version <version>` - Filter by version
122125

@@ -141,6 +144,86 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
141144
- `-y, --yes` - Skip confirmation prompt
142145
- `kernel browsers view <id or persistent id>` - Get live view URL for a browser
143146

147+
### Browser Logs
148+
149+
- `kernel browsers logs stream <id or persistent id>` - Stream browser logs
150+
- `--source <source>` - Log source: "path" or "supervisor" (required)
151+
- `--follow` - Follow the log stream (default: true)
152+
- `--path <path>` - File path when source=path
153+
- `--supervisor-process <name>` - Supervisor process name when source=supervisor. Most useful value is "chromium"
154+
155+
### Browser Replays
156+
157+
- `kernel browsers replays list <id or persistent id>` - List replays for a browser
158+
- `kernel browsers replays start <id or persistent id>` - Start a replay recording
159+
- `--framerate <fps>` - Recording framerate (fps)
160+
- `--max-duration <seconds>` - Maximum duration in seconds
161+
- `kernel browsers replays stop <id or persistent id> <replay-id>` - Stop a replay recording
162+
- `kernel browsers replays download <id or persistent id> <replay-id>` - Download a replay video
163+
- `-o, --output <path>` - Output file path for the replay video
164+
165+
### Browser Process Control
166+
167+
- `kernel browsers process exec <id or persistent id> [--] [command...]` - Execute a command synchronously
168+
- `--command <cmd>` - Command to execute (optional; if omitted, trailing args are executed via /bin/bash -c)
169+
- `--args <args>` - Command arguments
170+
- `--cwd <path>` - Working directory
171+
- `--timeout <seconds>` - Timeout in seconds
172+
- `--as-user <user>` - Run as user
173+
- `--as-root` - Run as root
174+
- `kernel browsers process spawn <id or persistent id> [--] [command...]` - Execute a command asynchronously
175+
- `--command <cmd>` - Command to execute (optional; if omitted, trailing args are executed via /bin/bash -c)
176+
- `--args <args>` - Command arguments
177+
- `--cwd <path>` - Working directory
178+
- `--timeout <seconds>` - Timeout in seconds
179+
- `--as-user <user>` - Run as user
180+
- `--as-root` - Run as root
181+
- `kernel browsers process kill <id or persistent id> <process-id>` - Send a signal to a process
182+
- `--signal <signal>` - Signal to send: TERM, KILL, INT, HUP (default: TERM)
183+
- `kernel browsers process status <id or persistent id> <process-id>` - Get process status
184+
- `kernel browsers process stdin <id or persistent id> <process-id>` - Write to process stdin (base64)
185+
- `--data-b64 <data>` - Base64-encoded data to write to stdin (required)
186+
- `kernel browsers process stdout-stream <id or persistent id> <process-id>` - Stream process stdout/stderr
187+
188+
### Browser Filesystem
189+
190+
- `kernel browsers fs new-directory <id or persistent id>` - Create a new directory
191+
- `--path <path>` - Absolute directory path to create (required)
192+
- `--mode <mode>` - Directory mode (octal string)
193+
- `kernel browsers fs delete-directory <id or persistent id>` - Delete a directory
194+
- `--path <path>` - Absolute directory path to delete (required)
195+
- `kernel browsers fs delete-file <id or persistent id>` - Delete a file
196+
- `--path <path>` - Absolute file path to delete (required)
197+
- `kernel browsers fs download-dir-zip <id or persistent id>` - Download a directory as zip
198+
- `--path <path>` - Absolute directory path to download (required)
199+
- `-o, --output <path>` - Output zip file path
200+
- `kernel browsers fs file-info <id or persistent id>` - Get file or directory info
201+
- `--path <path>` - Absolute file or directory path (required)
202+
- `kernel browsers fs list-files <id or persistent id>` - List files in a directory
203+
- `--path <path>` - Absolute directory path (required)
204+
- `kernel browsers fs move <id or persistent id>` - Move or rename a file or directory
205+
- `--src <path>` - Absolute source path (required)
206+
- `--dest <path>` - Absolute destination path (required)
207+
- `kernel browsers fs read-file <id or persistent id>` - Read a file
208+
- `--path <path>` - Absolute file path (required)
209+
- `-o, --output <path>` - Output file path (optional)
210+
- `kernel browsers fs set-permissions <id or persistent id>` - Set file permissions or ownership
211+
- `--path <path>` - Absolute path (required)
212+
- `--mode <mode>` - File mode bits (octal string) (required)
213+
- `--owner <user>` - New owner username or UID
214+
- `--group <group>` - New group name or GID
215+
- `kernel browsers fs upload <id or persistent id>` - Upload one or more files
216+
- `--file <local:remote>` - Mapping local:remote (repeatable)
217+
- `--dest-dir <path>` - Destination directory for uploads
218+
- `--paths <paths>` - Local file paths to upload
219+
- `kernel browsers fs upload-zip <id or persistent id>` - Upload a zip and extract it
220+
- `--zip <path>` - Local zip file path (required)
221+
- `--dest-dir <path>` - Destination directory to extract to (required)
222+
- `kernel browsers fs write-file <id or persistent id>` - Write a file from local data
223+
- `--path <path>` - Destination absolute file path (required)
224+
- `--mode <mode>` - File mode (octal string)
225+
- `--source <path>` - Local source file path (required)
226+
144227
## Examples
145228

146229
### Deploy with environment variables
@@ -199,6 +282,21 @@ kernel browsers delete --by-persistent-id my-browser-session --yes
199282

200283
# Get live view URL
201284
kernel browsers view --by-id browser123
285+
286+
# Stream browser logs
287+
kernel browsers logs stream my-browser --source supervisor --follow --supervisor-process chromium
288+
289+
# Start a replay recording
290+
kernel browsers replays start my-browser --framerate 30 --max-duration 300
291+
292+
# Execute a command in the browser VM
293+
kernel browsers process exec my-browser -- ls -alh /tmp
294+
295+
# Upload files to the browser VM
296+
kernel browsers fs upload my-browser --file "local.txt:remote.txt" --dest-dir "/tmp"
297+
298+
# List files in a directory
299+
kernel browsers fs list-files my-browser --path "/tmp"
202300
```
203301

204302
## Getting Help
@@ -223,3 +321,7 @@ For complete documentation, visit:
223321
---
224322

225323
For development and contribution information, see [DEVELOPMENT.md](./DEVELOPMENT.md).
324+
325+
```
326+
327+
```

cmd/browsers.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,30 @@ func (b BrowsersCmd) ProcessExec(ctx context.Context, in BrowsersProcessExecInpu
577577
}
578578
rows := pterm.TableData{{"Property", "Value"}, {"Exit Code", fmt.Sprintf("%d", res.ExitCode)}, {"Duration (ms)", fmt.Sprintf("%d", res.DurationMs)}}
579579
printTableNoPad(rows, true)
580+
if res.StdoutB64 != "" {
581+
data, err := base64.StdEncoding.DecodeString(res.StdoutB64)
582+
if err != nil {
583+
pterm.Error.Printf("stdout decode error: %v\n", err)
584+
} else if len(data) > 0 {
585+
pterm.Info.Println("stdout:")
586+
os.Stdout.Write(data)
587+
if data[len(data)-1] != '\n' {
588+
fmt.Println()
589+
}
590+
}
591+
}
592+
if res.StderrB64 != "" {
593+
data, err := base64.StdEncoding.DecodeString(res.StderrB64)
594+
if err != nil {
595+
pterm.Error.Printf("stderr decode error: %v\n", err)
596+
} else if len(data) > 0 {
597+
pterm.Info.Println("stderr:")
598+
os.Stderr.Write(data)
599+
if data[len(data)-1] != '\n' {
600+
fmt.Fprintln(os.Stderr)
601+
}
602+
}
603+
}
580604
return nil
581605
}
582606

tapes/demo.gif

25.8 KB
Loading

tapes/demo.tape

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# VHS documentation
2+
#
3+
# Output:
4+
# Output <path>.gif Create a GIF output at the given <path>
5+
# Output <path>.mp4 Create an MP4 output at the given <path>
6+
# Output <path>.webm Create a WebM output at the given <path>
7+
#
8+
# Require:
9+
# Require <string> Ensure a program is on the $PATH to proceed
10+
#
11+
# Settings:
12+
# Set FontSize <number> Set the font size of the terminal
13+
# Set FontFamily <string> Set the font family of the terminal
14+
# Set Height <number> Set the height of the terminal
15+
# Set Width <number> Set the width of the terminal
16+
# Set LetterSpacing <float> Set the font letter spacing (tracking)
17+
# Set LineHeight <float> Set the font line height
18+
# Set LoopOffset <float>% Set the starting frame offset for the GIF loop
19+
# Set Theme <json|string> Set the theme of the terminal
20+
# Set Padding <number> Set the padding of the terminal
21+
# Set Framerate <number> Set the framerate of the recording
22+
# Set PlaybackSpeed <float> Set the playback speed of the recording
23+
# Set MarginFill <file|#000000> Set the file or color the margin will be filled with.
24+
# Set Margin <number> Set the size of the margin. Has no effect if MarginFill isn't set.
25+
# Set BorderRadius <number> Set terminal border radius, in pixels.
26+
# Set WindowBar <string> Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight)
27+
# Set WindowBarSize <number> Set window bar size, in pixels. Default is 40.
28+
# Set TypingSpeed <time> Set the typing speed of the terminal. Default is 50ms.
29+
#
30+
# Sleep:
31+
# Sleep <time> Sleep for a set amount of <time> in seconds
32+
#
33+
# Type:
34+
# Type[@<time>] "<characters>" Type <characters> into the terminal with a
35+
# <time> delay between each character
36+
#
37+
# Keys:
38+
# Escape[@<time>] [number] Press the Escape key
39+
# Backspace[@<time>] [number] Press the Backspace key
40+
# Delete[@<time>] [number] Press the Delete key
41+
# Insert[@<time>] [number] Press the Insert key
42+
# Down[@<time>] [number] Press the Down key
43+
# Enter[@<time>] [number] Press the Enter key
44+
# Space[@<time>] [number] Press the Space key
45+
# Tab[@<time>] [number] Press the Tab key
46+
# Left[@<time>] [number] Press the Left Arrow key
47+
# Right[@<time>] [number] Press the Right Arrow key
48+
# Up[@<time>] [number] Press the Up Arrow key
49+
# Down[@<time>] [number] Press the Down Arrow key
50+
# PageUp[@<time>] [number] Press the Page Up key
51+
# PageDown[@<time>] [number] Press the Page Down key
52+
# Ctrl+<key> Press the Control key + <key> (e.g. Ctrl+C)
53+
#
54+
# Display:
55+
# Hide Hide the subsequent commands from the output
56+
# Show Show the subsequent commands in the output
57+
58+
Output tapes/demo.gif
59+
60+
Require echo
61+
62+
Set Shell "bash"
63+
Set FontSize 32
64+
Set Width 1200
65+
Set Height 600
66+
67+
Type "echo 'Welcome to VHS!'" Sleep 500ms Enter
68+
69+
Sleep 5s

tapes/fs-demo.gif

3.16 MB
Loading

tapes/fs-demo.mp4

1.79 MB
Binary file not shown.

tapes/fs-demo.tape

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ Set Shell "bash"
77
Set FontSize 32
88
Set Width 2400
99
Set Height 1200
10-
Set TypingSpeed 20ms
10+
Set TypingSpeed 100ms
1111

12-
Type "kernel browsers create -H -p demo > /dev/null" Enter
12+
Type "kernel browsers create -H -p fs-demo" Enter
1313
Sleep 2s
14-
Type "kernel browsers fs new-directory demo --path /tmp/test" Enter
14+
Type "kernel browsers fs new-directory fs-demo --path /tmp/test" Enter
1515
Sleep 2s
1616
Type "echo 'hello world' > /tmp/hello_world.txt" Enter
1717
Sleep 2s
18-
Type "kernel browsers fs write-file demo --source /tmp/hello_world.txt --path /tmp/test/hello_world" Enter
18+
Type "kernel browsers fs write-file fs-demo --source /tmp/hello_world.txt --path /tmp/test/hello_world" Enter
1919
Sleep 2s
20-
Type "kernel browsers fs list-files demo --path /tmp/test" Enter
20+
Type "kernel browsers fs list-files fs-demo --path /tmp/test" Enter
2121
Sleep 2s
22-
Type "kernel browsers fs file-info demo --path /tmp/test/hello_world" Enter
22+
Type "kernel browsers fs file-info fs-demo --path /tmp/test/hello_world" Enter
2323
Sleep 2s
24-
Type "kernel browsers fs read-file demo --path /tmp/test/hello_world" Enter
24+
Type "kernel browsers fs read-file fs-demo --path /tmp/test/hello_world" Enter
2525
Sleep 2s
26-
Type "kernel browsers fs download-dir-zip demo --path /tmp/test --output /tmp/test.zip" Enter
26+
Type "kernel browsers fs download-dir-zip fs-demo --path /tmp/test --output /tmp/test.zip" Enter
2727
Sleep 2s
2828
Type "unzip -l /tmp/test.zip" Enter
2929
Sleep 2s
30-
Type "kernel browsers delete -y demo" Enter
30+
Type "kernel browsers delete -y fs-demo" Enter
3131
Sleep 5s

tapes/process-exec-demo.gif

619 KB
Loading

tapes/process-exec-demo.mp4

392 KB
Binary file not shown.

tapes/process-exec-demo.tape

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Output tapes/process-exec-demo.gif
2+
Output tapes/process-exec-demo.mp4
3+
4+
Require kernel
5+
6+
Set Shell "bash"
7+
Set FontSize 32
8+
Set Width 2400
9+
Set Height 1200
10+
Set TypingSpeed 100ms
11+
12+
Type "kernel browsers create -H -p process-exec-demo" Enter
13+
Sleep 2s
14+
Type "kernel browsers process exec process-exec-demo -- echo hello world!" Enter
15+
Sleep 2s
16+
Type "kernel browsers delete -y process-exec-demo" Enter
17+
Sleep 5s

0 commit comments

Comments
 (0)