Exec Tool for Running Commands
Asta can run shell commands on your machine via the exec tool. This enables powerful integrations like:- Reading local files (“What’s in my Apple Notes about banking?”)
- Searching code (“Find all TODOs in this project”)
- Automating tasks (“Commit and push these changes”)
- System queries (“Show me running Docker containers”)
~/workspace/source/backend/app/exec_tool.py
Security Modes
Asta supports three exec security modes:| Mode | Behavior | Use Case |
|---|---|---|
deny | No commands allowed | Maximum security (default on first run) |
allowlist | Only allowlisted binaries run | Recommended for normal use |
full | Any command allowed (runs via shell) | Advanced use (dangerous) |
Setting the Mode
Option 1: Web Settings- Go to Settings → Exec Security
- Select a mode
- Click Save
Allowlist Mode (Recommended)
Inallowlist mode, only binaries you explicitly allow can run. This balances functionality and security.
Adding Binaries to the Allowlist
Environment variable (persistent):rg (ripgrep) to the allowlist immediately.
Settings UI:
- Go to Settings → Exec Security
- Add comma-separated binaries to “Extra Allowed Bins”
- Save
Auto-Allowlist from Skills
Source:~/workspace/source/backend/app/exec_tool.py:267-298
When you enable a workspace skill with requires.bins, those binaries are automatically added to the allowlist:
memo and osascript are allowed.
Viewing the Allowlist
Telegram:Approval Flow (Allowlist Mode)
Source:~/workspace/source/backend/app/channels/telegram_bot.py:737-802
When Asta wants to run a command with a binary not in the allowlist, it requests approval:
Asta proposes a command
User: “What notes do I have about gift cards?”Asta (internal): Wants to run
memo notes -s "gift cards"User approves or denies
- Once: Runs the command this time only
- Always: Adds
memoto the allowlist permanently + runs the command - Deny: Blocks the command
Pending approvals expire after 1 hour. Use
/approvals in Telegram to view and manage them.Full Mode (Advanced)
Infull mode, any command runs via a real shell (bash -lc <command>).
When to Use Full Mode
- Complex scripts: Multiline bash with pipes, loops, variables
- Shell builtins:
cd,export,source(not available in allowlist mode) - Rapid prototyping: Testing workflows before creating a skill
Enabling Full Mode
Process Tool for Long-Running Commands
Source:~/workspace/source/backend/app/process_tool.py
For commands that take longer than a few seconds (e.g., web servers, monitoring, compilation), use the process tool for background execution.
Background vs. Foreground Exec
Foreground (default):session_id immediately.
Starting a Background Process
Asta automatically backgrounds long-running commands. You can also request it explicitly: User:Managing Background Processes
Source:~/workspace/source/backend/app/process_tool.py:490-534
Process tool actions:
| Action | Description |
|---|---|
list | Show all running and finished processes |
poll | Check status and get new output |
log | Read full output (with offset/limit) |
write | Send stdin data (for interactive commands) |
send-keys | Send special keys (Enter, Ctrl-C, Tab) |
submit | Send newline (alias for write + Enter) |
paste | Paste text (with bracketed paste mode) |
kill | Terminate a process |
clear | Remove a finished process from history |
remove | Kill and remove a process |
PTY Mode (Pseudo-Terminal)
Some commands need a TTY (e.g., interactive prompts, colored output). Usepty: true:
- Color codes (ANSI escape sequences)
- Interactive input (prompts, readline)
- Terminal size detection
PTY mode is not supported on Windows in Asta’s current runtime.
Yield Mode (Auto-Background)
Source:~/workspace/source/backend/app/process_tool.py:402-487
If a command runs longer than yield_ms (default: 10 seconds), it automatically backgrounds:
- Waits up to 10 seconds for completion
- If still running, returns
{"status": "running", "session_id": "..."}immediately - Process continues in background
- Use
processtool to poll for results
Configuration
Environment Variables
Injected Environment Variables
Source:~/workspace/source/backend/app/exec_tool.py:403-416
Asta injects API keys from Settings into the command environment:
NOTION_API_KEY(from Settings → Notion Integration)GIPHY_API_KEY(from Settings → Giphy Integration)
Workdir (Working Directory)
Source:~/workspace/source/backend/app/exec_tool.py:301-321
Specify a working directory for commands:
- Your home directory (
~) - The Asta workspace path (
ASTA_WORKSPACE_PATH)
Secret Blocking
Source:~/workspace/source/backend/app/exec_tool.py:58-81
Asta blocks commands that might expose secrets:
Blocked patterns:
Troubleshooting
'Command not allowed'
'Command not allowed'
The binary is not in the allowlist.Fix:
- Add it:
/allow <binary> - Or enable a skill that requires it
- Or switch to
fullmode (not recommended)
'Binary not found'
'Binary not found'
The binary is not in PATH.Check:Install:Restart Asta after installation.
'Command timed out after 30s'
'Command timed out after 30s'
The command took too long.Fix:
- Increase timeout:
{"timeout_sec": 120} - Or use background mode:
{"background": true}
'Invalid workdir'
'Invalid workdir'
The workdir is outside allowed paths.Fix: Use a path under:
- Home directory:
~/project - Workspace:
/home/user/workspace/source
Process output is truncated
Process output is truncated
Asta caps exec output at 200,000 characters (tail).Fix:
- Redirect to file:
command > output.txt - Use
processtool withlogaction (supports offset/limit)
Best Practices
Use Allowlist Mode
Default to
allowlist mode. Only use full for trusted, temporary workflows.Create Skills for Workflows
Package related binaries into skills. Auto-allowlist binaries when the skill is enabled.
Always Approve Commands
Review every approval prompt. Tap “Always” only for binaries you trust.
Background Long Commands
Use
{"background": true} for commands that take >10 seconds. Poll with process tool.Examples
Search Apple Notes
User: “What notes do I have about banking?” Asta (exec):memo must be allowed (via /allow memo or apple-notes skill).
Commit and Push Git Changes
User: “Commit these changes with message ‘fix: typo’ and push” Asta (exec):git must be allowed.
Run Tests in Background
User: “Run the test suite in the background” Asta (exec):npm must be allowed.
Query Notion API
User: “Search my Notion for pages about ‘product roadmap’” Asta (exec):curl must be allowed.
Injected env: NOTION_API_KEY is auto-injected from Settings.
Next Steps
- Creating Skills - Package exec commands into reusable skills
- Subagent Orchestration - Run multi-step exec workflows in the background
- Telegram Bot Setup - Approve exec commands from mobile