28 lines
600 B
Python
28 lines
600 B
Python
import asyncio
|
|
|
|
|
|
async def bash(command: str, sandbox=None) -> str:
|
|
"""
|
|
Execute a bash command in the sandbox.
|
|
|
|
Args:
|
|
command: Shell command to run
|
|
sandbox: PodmanSandbox instance
|
|
|
|
Returns:
|
|
Command output (stdout + stderr)
|
|
"""
|
|
|
|
if sandbox is None:
|
|
return "Error: Sandbox not available"
|
|
|
|
try:
|
|
result = await asyncio.to_thread(sandbox.run, command)
|
|
return result
|
|
|
|
except RuntimeError as e:
|
|
return f"Error: sandbox execution failed: {e}"
|
|
|
|
except Exception as e:
|
|
return f"Error: Unexpected failure: {e}"
|