Skip to main content

Overview

The terminal commands capability gives your Utari workers the power to execute shell commands, install packages, run scripts, and interact with the command line interface in your workspace. This powerful tool enables workers to perform technical tasks like setting up environments, running builds, executing scripts, and managing processes.

Terminal Command Capabilities

Your workers can execute four types of terminal operations:

Execute Command

Run shell commands in blocking or non-blocking mode with full control over execution

Check Command Output

Monitor the progress and output of non-blocking commands running in background sessions

List Commands

View all running tmux sessions and their current status

Terminate Command

Stop running commands by killing their tmux sessions
Terminal commands execute in your workspace directory and have access to standard shell utilities, package managers, and installed tools.

Execute Command

The core capability for running shell commands with two execution modes:

Blocking Mode (Synchronous)

When to Use:
  • Quick commands that complete in seconds
  • Package installations
  • File operations (copy, move, delete)
  • Build processes
  • Script execution that completes quickly
  • Any command where you need immediate results
How It Works:
Example Commands:

Non-Blocking Mode (Asynchronous)

When to Use:
  • Long-running processes
  • Development servers
  • Watch processes
  • Background jobs
  • Continuous monitoring tasks
  • Any command that runs indefinitely
How It Works:
Example Commands:

Command Execution Examples

Installing Dependencies

Python Package Installation: Always use the --break-system-packages flag when installing Python packages with pip to avoid system package conflicts.

Running Scripts

File and Directory Operations

Check Command Output

Monitor non-blocking commands running in background sessions.
1

Execute Non-Blocking Command

Start a command in non-blocking mode (blocking=false).
2

Get Session Information

Note the tmux session ID returned when the command starts.
3

Check Output

Use check_command_output with the session ID to view progress and output.
4

Monitor Periodically

Call check_command_output multiple times to track ongoing progress.
IMPORTANT: Only use check_command_output for commands executed with blocking=false.Blocking commands return output directly and automatically clean up their sessions—calling check_command_output on them will fail.

Example Workflow

List Commands

View all active tmux sessions to see what’s currently running. Use Cases:
  • Check which background processes are active
  • Identify session IDs for monitoring
  • Verify servers are still running
  • Audit workspace processes
  • Troubleshoot command execution
Example Output:

Terminate Command

Stop running commands by killing their tmux sessions.
1

Identify Session

Use list_commands to find the session ID of the command you want to stop.
2

Terminate Session

Call terminate_command with the session ID.
3

Verify Termination

Optionally use list_commands again to confirm the session is stopped.
Common Scenarios:
Terminating a session immediately kills the process. Ensure you don’t need the output or that important work is saved before terminating.

Choosing Execution Mode

Use Blocking Mode (blocking=true) For:

Quick Operations

Commands that complete in seconds or minutes

Package Installation

npm install, pip install, apt-get install

File Operations

Copy, move, delete, create files and folders

Build Processes

npm run build, make, compilation tasks

Script Execution

Short scripts that complete and exit

System Commands

Configuration, setup, one-time operations

Use Non-Blocking Mode (blocking=false) For:

Servers

Development servers, web servers, API servers

Watch Processes

File watchers, auto-recompiling tools

Long-Running Jobs

Data processing, large file operations

Monitoring

Continuous monitoring scripts

Background Tasks

Tasks that should run while you do other work

Interactive Programs

Programs that require ongoing interaction

Common Workflows

Setting Up a Development Environment

1

Update System

2

Install Dependencies

3

Install Project Packages

4

Start Development Server

5

Verify Server

Running Tests and Builds

1

Install Test Dependencies

2

Run Tests

3

Build Project

4

Verify Build Output

Managing Long-Running Processes

1

Start Background Process

Save the session ID returned
2

Monitor Progress

Repeat periodically to track progress
3

List All Processes

View all active sessions
4

Terminate When Complete

Or let it complete naturally

Best Practices

Choose Right Mode

Use blocking for quick tasks, non-blocking for long-running processes

Monitor Non-Blocking

Always check output of non-blocking commands to verify they’re running correctly

Clean Up Sessions

Terminate completed non-blocking commands to free resources

Handle Errors

Check command exit codes and output for errors

Use Full Paths

Specify complete file paths to avoid ambiguity

Test Commands First

Test complex commands manually before automating

Include Flags

Always use required flags (like —break-system-packages for pip)

Document Sessions

Keep track of what each non-blocking session is doing

Troubleshooting

Try:
  • Using sudo if appropriate (apt-get, system operations)
  • Checking file/directory permissions with ls -la
  • Ensuring you’re in the correct directory
  • Verifying the command syntax is correct
For pip:
  • Always include --break-system-packages flag
  • Try updating pip: pip install --upgrade pip --break-system-packages
  • Check internet connectivity
For npm:
  • Clear cache: npm cache clean --force
  • Delete node_modules and reinstall
  • Check package.json for syntax errors
Remember:
  • Blocking commands return output directly
  • They automatically clean up sessions
  • Don’t use check_command_output for them
  • The output is in the execute_command response
Verify:
  • Use list_commands to see active sessions
  • Check output with check_command_output
  • Look for errors in the command syntax
  • Ensure required dependencies are installed
  • Try running in blocking mode first to debug
Solutions:
  • Check output to see if it’s waiting for input
  • Verify the command is appropriate for non-blocking
  • Terminate and restart if necessary
  • Check for errors in the command output
Check:
  • Environment differences (paths, installed packages)
  • Missing dependencies
  • Different shell or system configuration
  • Required system packages not installed

Security Considerations

Security Best Practices:
  • Never expose sensitive credentials in commands
  • Use environment variables for secrets
  • Be cautious with rm -rf commands
  • Validate user input before executing
  • Limit permissions where possible
  • Avoid running untrusted scripts
  • Monitor command execution for unusual activity

Advanced Usage

Chaining Commands

Environment Variables

Working with Files

Summary

You’ve successfully learned:
How to execute commands in blocking vs non-blocking mode
When to use each execution mode for optimal performance
How to monitor non-blocking commands with check_command_output
How to list and terminate running command sessions
Best practices for package installation and script execution
Common workflows for development environment setup
Troubleshooting techniques for command execution issues
Terminal commands give your Utari workers powerful capabilities to set up environments, run scripts, manage processes, and perform technical operations—all through natural language instructions.

Next Steps

Files and Folder Tool

Manage files created or modified by terminal commands

Worker Configuration

Set up workers optimized for technical tasks

Triggers

Automate terminal commands on a schedule

Integrations

Combine terminal commands with third-party apps