Streaming
To stream command output as it is being executed, pass the on_stdout and on_stderr callbacks to the commands.run() method in Python.
The on_stdout and on_stderr callbacks are called with a bytes object as the first argument.
from agentbox import Sandbox
sandbox = Sandbox(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxx",
template="wemmodr8mb2uk3kn7exw",
timeout=120
)
result = sandbox.commands.run(
'echo hello; sleep 1; echo world',
on_stdout=lambda data: print(data),
on_stderr=lambda data: print(data)
)
print(result)