BBR Scenario JSON Documentation
Complete reference for authoring BBR automation scenarios.
Scenario Structure
A scenario is a JSON array of step objects. Each step has an action field and action-specific parameters.
[
{"action": "msg", "text": "Hello!", "duration": 2.0},
{"action": "run_command_silent", "name": "user", "command": "whoami"},
{"action": "msg", "text": "User: {user_output}", "duration": 3.0}
]
Actions Reference
1. msg â Display Message
Shows a toast notification to the user.
| Parameter | Type | Required | Description |
|---|
text | string | â | Message content (supports {variables}) |
duration | number | â | Display time in seconds |
{
"action": "msg",
"text": "Hello, {user_output}! đĻĢ",
"duration": 3.0
}
2. sleep â Pause Execution
Waits for a specified duration before proceeding.
| Parameter | Type | Required | Description |
|---|
seconds | number | â | Time to wait in seconds |
{
"action": "sleep",
"seconds": 1.5
}
3. set_context â Set Variable
Stores a value in RunContext for later use.
| Parameter | Type | Required | Description |
|---|
key | string | â | Variable name (alphanumeric, underscores) |
value | string | â | Value to store |
{
"action": "set_context",
"key": "project_name",
"value": "MyAwesomeProject"
}
Use later: {project_name}
4. run_command_silent â Execute Shell Command
Runs a shell command in the background, capturing output.
| Parameter | Type | Required | Description |
|---|
name | string | â | Identifier for output variable |
command | string | â | Shell command to execute |
{
"action": "run_command_silent",
"name": "current_dir",
"command": "pwd"
}
Output stored in: {current_dir_output}
5. run_terminal_command â Execute in Visible Terminal
Opens Terminal.app and runs a command visibly.
| Parameter | Type | Required | Description |
|---|
command | string | â | Command to type and execute |
{
"action": "run_terminal_command",
"command": "npm run dev"
}
6. extract_regex â Extract Text via Regex
Extracts matching text from a variable using regular expressions.
| Parameter | Type | Required | Description |
|---|
source | string | â | Source variable name |
pattern | string | â | Regex pattern (escaped for JSON) |
target | string | â | Variable name to store result |
mode | string | â | "first" (default) or "all" |
group | number | â | Capture group index (default: 0) |
{
"action": "extract_regex",
"source": "ip_raw_output",
"pattern": "inet\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)",
"target": "local_ip",
"mode": "first",
"group": 1
}
7. open_or_focus_app â Activate Application
Opens an application or brings it to foreground.
| Parameter | Type | Required | Description |
|---|
app | string | â | Application name (e.g., "Safari", "Visual Studio Code") |
pause | number | â | Wait time after opening (seconds) |
{
"action": "open_or_focus_app",
"app": "Safari",
"pause": 1.0
}
8. open_url â Navigate to URL
Opens a URL in the default browser.
| Parameter | Type | Required | Description |
|---|
url | string | â | Full URL (must include https://) |
pause | number | â | Wait time after loading (seconds) |
{
"action": "open_url",
"url": "https://github.com",
"pause": 3.0
}
9. type_text â Human-Like Typing
Types text with realistic keystroke timing.
| Parameter | Type | Required | Description |
|---|
text | string | â | Text to type (supports {variables}, \n for newlines) |
interval | number | â | Delay between keystrokes (seconds, default: 0.05) |
{
"action": "type_text",
"text": "Hello, {user_output}!\n\nThis is typed by Bober.",
"interval": 0.03
}
Interval guide:
0.02 â Fast (experienced typer)0.05 â Normal0.08 â Slow/deliberate
10. hotkey â Keyboard Shortcut
Presses a keyboard shortcut.
| Parameter | Type | Required | Description |
|---|
mod | string | â | Modifier key: "command", "option", "control", "shift", or "" |
key | string | â | Key to press (lowercase letter or special key name) |
{
"action": "hotkey",
"mod": "command",
"key": "s"
}
Common shortcuts:
- Save:
{"mod": "command", "key": "s"} - New:
{"mod": "command", "key": "n"} - Close:
{"mod": "command", "key": "w"} - Enter:
{"mod": "", "key": "return"}
11. capture_screen â Screenshot
Captures the current screen and saves to run directory.
| Parameter | Type | Required | Description |
|---|
| (none) | â | â | No parameters required |
{
"action": "capture_screen"
}
Image saved to: {runDir}/screenshot-001.png
12. run_subscenario â Execute Another Scenario
Runs another scenario file as part of the current execution.
| Parameter | Type | Required | Description |
|---|
file | string | â | Path to scenario file (relative or absolute) |
{
"action": "run_subscenario",
"file": "./setup-environment.json"
}
13. run_batch â Iterate with Parameters
Runs a scenario multiple times with different parameter sets.
| Parameter | Type | Required | Description |
|---|
file | string | â | Path to scenario file |
prefix | string | â | Prefix for output variables |
params | array | â | Array of parameter arrays [[p1, p2], [p1, p2], ...] |
{
"action": "run_batch",
"file": "./run-command.json",
"prefix": "sys",
"params": [
["hostname", "hostname"],
["os_version", "sw_vers -productVersion"],
["cpu_arch", "uname -m"]
]
}
In the sub-scenario, use {param1}, {param2}. Outputs: {hostname_output}, {os_version_output}, etc.
Conditionals
Add "if" clause to any step to conditionally execute.
| Operator | Example |
|---|
== | "if": "status == 'ready'" |
!= | "if": "error != 'none'" |
contains | "if": "output contains 'success'" |
startsWith | "if": "path startsWith '/Users'" |
endsWith | "if": "file endsWith '.json'" |
{
"if": "git_check_output == 'installed'",
"action": "msg",
"text": "â Git is ready!",
"duration": 2.5
}
Built-in Variables
| Variable | Description |
|---|
{runDir} | Current run's output directory |
{name_output} | Output from command with name |
{param1}, {param2} | Batch iteration parameters |
Complete Example
[
{"action": "msg", "text": "đĻĢ Starting automation", "duration": 2.0},
{"action": "set_context", "key": "project", "value": "MyApp"},
{"action": "run_command_silent", "name": "user", "command": "whoami"},
{"action": "msg", "text": "User: {user_output}", "duration": 3.0},
{"action": "open_or_focus_app", "app": "Safari", "pause": 1.0},
{"action": "open_url", "url": "https://example.com", "pause": 2.0},
{"action": "capture_screen"},
{"action": "msg", "text": "â
Complete!", "duration": 2.0}
]