8000 [Computer/Agent] Add Sandboxed Python Execution API, Stability Fixes by ddupont808 · Pull Request #281 · trycua/cua · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Computer/Agent] Add Sandboxed Python Execution API, Stability Fixes #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ async def main():
loop="uitars",
model=LLM(provider="mlxvlm", name="mlx-community/UI-TARS-1.5-7B-6bit")
)
await agent.run("Find the trycua/cua repository on GitHub and follow the quick start guide")
async for result in agent.run("Find the trycua/cua repository on GitHub and follow the quick start guide"):
print(result)

main()
if __name__ == "__main__":
asyncio.run(main())
```

For ready-to-use examples, check out our [Notebooks](./notebooks/) collection.
Expand Down Expand Up @@ -273,6 +275,25 @@ await computer.interface.run_command(cmd) # Run shell command

# Accessibility
await computer.interface.get_accessibility_tree() # Get accessibility tree

# Python Virtual Environment Operations
await computer.venv_install("demo_venv", ["requests", "macos-pyxa"]) # Install packages in a virtual environment
await computer.venv_cmd("demo_venv", "python -c 'import requests; print(requests.get(`https://httpbin.org/ip`).json())'") # Run a shell command in a virtual environment
await computer.venv_exec("demo_venv", python_function_or_code, *args, **kwargs) # Run a Python function in a virtual environment and return the result / raise an exception

# Example: Use sandboxed functions to execute code in a C/ua Container
from computer.helpers import sandboxed
@sandboxed("demo_venv")
def greet_and_print(name, html_snippet_length=200):
# get .html of the current Safari tab
import PyXA
safari = PyXA.Application("Safari")
html = safari.current_document.source()
print(f"Hello from inside the container, {name}!")
print("Safari HTML length:", len(html))
return {"greeted": name, "safari_html_length": len(html), "safari_html_snippet": html[:html_snippet_length]}
result = await greet_and_print("C/ua", html_snippet_length=100) # Executes in the container
print("Result from sandboxed function:", result)
```

## ComputerAgent Reference
Expand Down
Loading
Loading
0