mirror of
https://github.com/trycua/computer.git
synced 2026-02-21 13:59:34 -06:00
Fix computer examples
This commit is contained in:
@@ -34,7 +34,7 @@ async def main():
|
||||
display="1024x768", # Higher resolution
|
||||
memory="8GB", # More memory
|
||||
cpu="4", # More CPU cores
|
||||
os="macos",
|
||||
os_type="macos",
|
||||
verbosity=LogLevel.NORMAL, # Use QUIET to suppress most logs
|
||||
use_host_computer_server=False,
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"source": [
|
||||
"## Lume daemon\n",
|
||||
"\n",
|
||||
"While a `lume` binary is included with Computer, we recommend installing the standalone version with brew, and starting the lume daemon service before running Computer. Refer to [../libs/lume/README.md](../libs/lume/README.md) for more details on lume cli."
|
||||
"Refer to [../libs/lume/README.md](../libs/lume/README.md) for more details on the lume cli."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -71,17 +71,6 @@
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Start the lume daemon service (from another terminal):\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"lume serve\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -102,8 +91,6 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Initial download requires 80GB storage, but reduces to ~30GB after first run due to macOS's sparse file system.\n",
|
||||
"\n",
|
||||
"VMs are stored in `~/.lume`, and locally cached images are stored in `~/.lume/cache`."
|
||||
]
|
||||
},
|
||||
@@ -116,15 +103,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"name os cpu memory disk display status ip vnc \n",
|
||||
"macos-sequoia-cua_latest macOS 12 16.00G 64.5GB/80.0GB 1024x768 running 192.168.64.78 vnc://:kind-forest-zulu-island@127.0.0.1:56085 \n"
|
||||
"name os cpu memory disk display status storage shared_dirs ip vnc \n",
|
||||
"macos-sequoia-cua_latest macOS 4 8.00G 25.9GB/80.0GB 1024x768 stopped default - - - \n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -200,7 +187,7 @@
|
||||
" display=\"1024x768\",\n",
|
||||
" memory=\"8GB\",\n",
|
||||
" cpu=\"4\",\n",
|
||||
" os=\"macos\"\n",
|
||||
" os_type=\"macos\"\n",
|
||||
") as computer:\n",
|
||||
" await computer.run()\n",
|
||||
" # ... do something with the computer interface"
|
||||
@@ -215,50 +202,20 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"Equivalent curl command:\n",
|
||||
"curl -X POST \\\n",
|
||||
" 'http://localhost:3000/lume/vms/macos-sequoia-cua_latest/run' \\\n",
|
||||
" -H 'Content-Type: application/json' \\\n",
|
||||
" -d '{\"noDisplay\": false, \"sharedDirectories\": []}'\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"computer = Computer(\n",
|
||||
" display=\"1024x768\",\n",
|
||||
" memory=\"8GB\",\n",
|
||||
" cpu=\"4\",\n",
|
||||
" os=\"macos\"\n",
|
||||
" os_type=\"macos\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"await computer.run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The Computer instance requires a Lume server for communication. Here's how it works:\n",
|
||||
"\n",
|
||||
"1. First, it attempts to connect to any existing Lume server running on port 3000\n",
|
||||
"2. If no Lume server is available, it automatically starts a new one via [lume serve](https://github.com/trycua/lume/?tab=readme-ov-file#local-api-server)\n",
|
||||
"\n",
|
||||
"The sandbox's lifecycle is tied to the Lume server:\n",
|
||||
"- If Computer started the Lume server itself, the server will be terminated when Computer stops\n",
|
||||
"- If Computer connected to a pre-existing server, that server remains running after Computer stops\n",
|
||||
"\n",
|
||||
"If you have scenarios where you need to run multiple sandboxes in parallel, we recommend first starting the Lume server separately with `lume serve` (refer to [Lume](https://github.com/trycua/lume/?tab=readme-ov-file#install) on how to install) and then having each Computer instance connect to it."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -421,7 +378,7 @@
|
||||
" display=\"1024x768\",\n",
|
||||
" memory=\"4GB\",\n",
|
||||
" cpu=\"2\",\n",
|
||||
" os=\"macos\",\n",
|
||||
" os_type=\"macos\",\n",
|
||||
" shared_directories=[\"/absolute/path/to/directory\"]\n",
|
||||
")"
|
||||
]
|
||||
@@ -445,7 +402,7 @@
|
||||
" display=\"1024x768\",\n",
|
||||
" memory=\"4GB\",\n",
|
||||
" cpu=\"2\",\n",
|
||||
" os=\"macos\",\n",
|
||||
" os_type=\"macos\",\n",
|
||||
" use_host_computer_server=True\n",
|
||||
")"
|
||||
]
|
||||
@@ -476,7 +433,7 @@
|
||||
" display=\"1024x768\",\n",
|
||||
" memory=\"4GB\",\n",
|
||||
" cpu=\"2\",\n",
|
||||
" os=\"macos\"\n",
|
||||
" os_type=\"macos\"\n",
|
||||
") as computer:\n",
|
||||
" await computer.run()\n",
|
||||
" res = await computer.interface.run_command(\"ls -a\")\n",
|
||||
@@ -503,7 +460,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "cua",
|
||||
"display_name": "cua313",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -517,7 +474,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.11"
|
||||
"version": "3.13.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user