Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
Remove lume from typescript sdk, rename CloudComputer -> Computer
Morgan Dean7f3b9884f663
diff --git a/libs/computer/typescript/README.md b/libs/computer/typescript/README.mdindex 77e2c47cb1..98311be68c 100644--- a/libs/computer/typescript/README.md+++ b/libs/computer/typescript/README.md@@ -1,6 +1,6 @@-# C/UA Computer TypeScript Library+# C/ua Computer TypeScript Library-The TypeScript library for C/UA Computer - a powerful computer control and automation library.+The TypeScript library for C/cua Computer - a powerful computer control and automation library.## Overview@@ -20,7 +20,7 @@ pnpm add @cua/computerimport { Computer } from '@cua/computer';// Create a new computer instance-const computer = new CloudComputer({+const computer = new Computer({osType: OSType.LINUX,name: 's-linux-vm_id'apiKey: 'your-api-key'@@ -57,13 +57,7 @@ The library is organized into the following structure:### Provider Implementations-- **LumeComputer**: Implementation for Lume API-based VMs (Unmaintained)-- **CloudComputer**: Implementation for cloud-based VMs--### Utility Functions--- **Lume API Utilities**: Functions for interacting with the Lume API (lumeApiGet, lumeApiRun, lumeApiStop, etc.) (Unmaintained)-- **Helper Functions**: Parsing utilities for display and memory strings+- **Computer**: Implementation for cloud-based VMs## Development@@ -91,10 +85,6 @@ pnpm buildpnpm typecheck```-## Disclaimer--**WARNING:** Some parts of this library, particularly the provider implementations (like Lume), were created as test/example implementations and are not maintained or expected to work in production environments. They serve as references for how providers might be implemented but should not be used in production.-## License[MIT](./LICENSE) License 2025 [C/UA](https://github.com/trycua)diff --git a/libs/computer/typescript/package.json b/libs/computer/typescript/package.jsonindex 71141f22cc..cd9177720c 100644--- a/libs/computer/typescript/package.json+++ b/libs/computer/typescript/package.json@@ -39,7 +39,6 @@},"dependencies": {"pino": "^9.7.0",- "sharp": "^0.33.0","ws": "^8.18.0"},"devDependencies": {diff --git a/libs/computer/typescript/pnpm-lock.yaml b/libs/computer/typescript/pnpm-lock.yamlindex 9104a636bb..e1b1e8f529 100644--- a/libs/computer/typescript/pnpm-lock.yaml+++ b/libs/computer/typescript/pnpm-lock.yaml@@ -11,9 +11,6 @@ importers:pino:specifier: ^9.7.0version: 9.7.0- sharp:- specifier: ^0.33.0- version: 0.33.5ws:specifier: ^8.18.0version: 8.18.2@@ -290,111 +287,6 @@ packages:cpu: [x64]os: [win32]- '@img/[email protected]':- resolution: {integrity: sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [arm64]- os: [darwin]-- '@img/[email protected]':- resolution: {integrity: sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [x64]- os: [darwin]-- '@img/[email protected]':- resolution: {integrity: sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==}- cpu: [arm64]- os: [darwin]-- '@img/[email protected]':- resolution: {integrity: sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==}- cpu: [x64]- os: [darwin]-- '@img/[email protected]':- resolution: {integrity: sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==}- cpu: [arm64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==}- cpu: [arm]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==}- cpu: [s390x]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==}- cpu: [x64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==}- cpu: [arm64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==}- cpu: [x64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [arm64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [arm]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [s390x]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [x64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [arm64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [x64]- os: [linux]-- '@img/[email protected]':- resolution: {integrity: sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [wasm32]-- '@img/[email protected]':- resolution: {integrity: sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [ia32]- os: [win32]-- '@img/[email protected]':- resolution: {integrity: sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}- cpu: [x64]- os: [win32]-'@inquirer/[email protected]':resolution: {integrity: sha512-dpq+ielV9/bqgXRUbNH//KsY6WEw9DrGPmipkpmgC1Y46cwuBTNx7PXFWTjc3MQ+urcc0QxoVHcMI0FW4Ok0hg==}engines: {node: '>=18'}@@ -776,13 +668,6 @@ packages:resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}- resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==}-- resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}- engines: {node: '>=12.5.0'}-resolution: {integrity: sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==}@@ -813,10 +698,6 @@ packages:resolution: {integrity: sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==}- resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}- engines: {node: '>=8'}-resolution: {integrity: sha512-sSuxWU5j5SR9QQji/o2qMvqRNYRDOcBTgsJ/DeCf4iSN4gW+gNMXM7wFIP+fdXZxoNiAnHUTGjCr+TSWXdRDKg==}engines: {node: '>=0.3.1'}@@ -905,9 +786,6 @@ packages:resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}- resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==}-resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}engines: {node: '>=8'}@@ -1095,10 +973,6 @@ packages:engines: {node: '>=10'}hasBin: true- resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==}- engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}-resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}@@ -1106,9 +980,6 @@ packages:resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}engines: {node: '>=14'}- resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}-resolution: {integrity: sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==}@@ -1521,81 +1392,6 @@ snapshots:'@esbuild/[email protected]':optional: true- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-darwin-arm64': 1.0.4- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-darwin-x64': 1.0.4- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-linux-arm64': 1.0.4- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-linux-arm': 1.0.5- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-linux-s390x': 1.0.4- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-linux-x64': 1.0.4- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-linuxmusl-arm64': 1.0.4- optional: true-- '@img/[email protected]':- optionalDependencies:- '@img/sharp-libvips-linuxmusl-x64': 1.0.4- optional: true-- '@img/[email protected]':- dependencies:- '@emnapi/runtime': 1.4.3- optional: true-- '@img/[email protected]':- optional: true-- '@img/[email protected]':- optional: true-'@inquirer/[email protected](@types/[email protected])':dependencies:'@inquirer/core': 10.1.13(@types/[email protected])@@ -1953,18 +1749,10 @@ snapshots:dependencies:color-name: 1.1.4+ optional: true- [email protected]: {}-- dependencies:- color-name: 1.1.4- simple-swizzle: 0.2.2-- dependencies:- color-convert: 2.0.1- color-string: 1.9.1+ optional: true@@ -1983,8 +1771,6 @@ snapshots:- [email protected]: {}-@@ -2074,8 +1860,6 @@ snapshots:- [email protected]: {}-optional: true@@ -2293,41 +2077,11 @@ snapshots:- dependencies:- color: 4.2.3- detect-libc: 2.0.4- semver: 7.7.2- optionalDependencies:- '@img/sharp-darwin-arm64': 0.33.5- '@img/sharp-darwin-x64': 0.33.5- '@img/sharp-libvips-darwin-arm64': 1.0.4- '@img/sharp-libvips-darwin-x64': 1.0.4- '@img/sharp-libvips-linux-arm': 1.0.5- '@img/sharp-libvips-linux-arm64': 1.0.4- '@img/sharp-libvips-linux-s390x': 1.0.4- '@img/sharp-libvips-linux-x64': 1.0.4- '@img/sharp-libvips-linuxmusl-arm64': 1.0.4- '@img/sharp-libvips-linuxmusl-x64': 1.0.4- '@img/sharp-linux-arm': 0.33.5- '@img/sharp-linux-arm64': 0.33.5- '@img/sharp-linux-s390x': 0.33.5- '@img/sharp-linux-x64': 0.33.5- '@img/sharp-linuxmusl-arm64': 0.33.5- '@img/sharp-linuxmusl-x64': 0.33.5- '@img/sharp-wasm32': 0.33.5- '@img/sharp-win32-ia32': 0.33.5- '@img/sharp-win32-x64': 0.33.5-optional: true- dependencies:- is-arrayish: 0.3.2-dependencies:atomic-sleep: 1.0.0diff --git a/libs/computer/typescript/src/computer/index.ts b/libs/computer/typescript/src/computer/index.tsindex 365dd47816..4a1a7007ef 100644--- a/libs/computer/typescript/src/computer/index.ts+++ b/libs/computer/typescript/src/computer/index.ts@@ -1 +1 @@-export { BaseComputer, CloudComputer, LumeComputer } from "./providers";+export { BaseComputer, CloudComputer } from "./providers";diff --git a/libs/computer/typescript/src/computer/providers/index.ts b/libs/computer/typescript/src/computer/providers/index.tsindex 70ff7ae8ab..d4fd5391cc 100644--- a/libs/computer/typescript/src/computer/providers/index.ts+++ b/libs/computer/typescript/src/computer/providers/index.ts@@ -1,3 +1,2 @@export * from "./base";-export * from "./cloud";-export * from "./lume";+export * from "./cloud";\ No newline at end of filediff --git a/libs/computer/typescript/src/computer/providers/lume.ts b/libs/computer/typescript/src/computer/providers/lume.tsdeleted file mode 100644index e96f922109..0000000000--- a/libs/computer/typescript/src/computer/providers/lume.ts+++ /dev/null@@ -1,278 +0,0 @@-/**- * WARNING: This file was created as a test/example implementation and is not maintained or expected to work.- * It serves as a reference for how a provider might be implemented but should not be used in production.- */--import type { Display, LumeComputerConfig } from "../types.ts";-import { BaseComputer } from "./base.ts";-import {- lumeApiGet,- lumeApiRun,- lumeApiPull,- lumeApiStop,- lumeApiDelete,- lumeApiUpdate,- type VMInfo,-} from "../../util/lume.ts";-import pino from "pino";--const logger = pino({ name: "computer-lume" });--/**- * Lume-specific computer implementation- */-export class LumeComputer extends BaseComputer {- private display: string | Display;- private memory: string;- private cpu: number;- private image: string;- private port: number;- private host: string;- private ephemeral: boolean;-- constructor(config: LumeComputerConfig) {- super(config);-- this.display = config.display ?? "1024x768";- this.memory = config.memory ?? "8GB";- this.cpu = config.cpu ?? 2;- this.image = config.image ?? "macos-sequoia-cua:latest";- this.port = config.port ?? 7777;- this.host = config.host ?? "localhost";- this.ephemeral = config.ephemeral ?? false;- }-- /**- * Lume-specific method to get a VM- */-- async getVm(name: string, storage?: string): Promise<VMInfo> {- try {- const vmInfo = (await lumeApiGet(name, this.host, this.port, storage))[0];- if (!vmInfo) throw new Error("VM Not Found.");- if (vmInfo.status === "stopped") {- logger.info(- `VM ${name} is in '${vmInfo.status}' state - not waiting for IP address`- );- return {- ...vmInfo,- name,- status: vmInfo.status,- };- }- if (!vmInfo.ipAddress) {- logger.info(- `VM ${name} is in '${vmInfo.status}' state but no IP address found - reporting as still starting`- );- }- return vmInfo;- } catch (e) {- logger.error(`Failed to get VM status: ${e}`);- throw e;- }- }-- /**- * Lume-specific method to list availalbe VMs- */-- async listVm() {- const vms = await lumeApiGet("", this.host, this.port);- return vms;- }-- /**- * Lume-specific method to run the VM- */- async runVm(- image: string,- name: string,- runOpts: { [key: string]: unknown } = {},- storage?: string- ): Promise<VMInfo> {- logger.info(- `Running Lume computer ${this.name} with ${this.memory} memory and ${this.cpu} CPUs`- );- logger.info(- `Using image ${this.image} with display ${- typeof this.display === "string"- ? this.display- : `${this.display.width}x${this.display.height}`- }`- );- // Lume-specific implementation- try {- await this.getVm(name, storage);- } catch {- logger.info(- `VM ${name} not found, attempting to pull image ${image} from registry...`- );- // Call pull_vm with the image parameter- try {- const pullRes = await this.pullVm(name, image, storage);- logger.info(pullRes);- } catch (e) {- logger.info(`Failed to pull VM image: ${e}`);- throw e;- }- }- logger.info(`Running VM ${name} with options: ${runOpts}`);- return await lumeApiRun(name, this.host, this.port, runOpts, storage);- }-- /**- * Lume-specific method to stop a VM- */- async stopVm(name: string, storage?: string): Promise<VMInfo> {- // Stop the VM first- const stopResult = await lumeApiStop(name, this.host, this.port, storage);-- // If ephemeral mode is enabled, delete the VM after stopping- if (this.ephemeral && (!stopResult || !("error" in stopResult))) {- logger.info(- `Ephemeral mode enabled - deleting VM ${name} after stopping`- );- try {- const deleteResult = await this.deleteVm(name, storage);-- // Return combined result- return {- ...stopResult,- deleted: true,- deleteResult: deleteResult,- } as VMInfo;- } catch (e) {- logger.error(`Failed to delete ephemeral VM ${name}: ${e}`);- throw new Error(`Failed to delete ephemeral VM ${name}: ${e}`);- }- }-- // Just return the stop result if not ephemeral- return stopResult;- }-- /**- * Lume-specific method to pull a VM image from the registry- */- async pullVm(- name: string,- image: string,- storage?: string,- registry = "ghcr.io",- organization = "trycua"- ): Promise<VMInfo> {- // Validate image parameter- if (!image) {- throw new Error("Image parameter is required for pullVm");- }-- logger.info(`Pulling VM image '${image}' as '${name}'`);- logger.info("You can check the pull progress using: lume logs -f");- logger.debug(`Pull storage location: ${storage || "default"}`);-- try {- const result = await lumeApiPull(- image,- name,- this.host,- this.port,- storage,- registry,- organization- );-- logger.info(`Successfully pulled VM image '${image}' as '${name}'`);- return result;- } catch (e) {- logger.error(`Failed to pull VM image '${image}': ${e}`);- throw new Error(`Failed to pull VM: ${e}`);- }- }-- /**- * Lume-specific method to delete a VM permanently- */- async deleteVm(name: string, storage?: string): Promise<VMInfo | null> {- logger.info(`Deleting VM ${name}...`);-- try {- const result = await lumeApiDelete(- name,- this.host,- this.port,- storage,- false,- false- );-- logger.info(`Successfully deleted VM '${name}'`);- return result;- } catch (e) {- logger.error(`Failed to delete VM '${name}': ${e}`);- throw new Error(`Failed to delete VM: ${e}`);- }- }-- /**- * Lume-specific method to update VM configuration- */- async updateVm(- name: string,- updateOpts: { [key: string]: unknown },- storage?: string- ): Promise<VMInfo> {- return await lumeApiUpdate(- name,- this.host,- this.port,- updateOpts,- storage,- false,- false- );- }-- /**- * Lume-specific method to get the IP address of a VM, waiting indefinitely until it's available- */- async getIp(name: string, storage?: string, retryDelay = 2): Promise<string> {- // Track total attempts for logging purposes- let attempts = 0;-- while (true) {- attempts++;-- try {- const vmInfo = await this.getVm(name, storage);-- // Check if VM has an IP address- if (vmInfo.ipAddress) {- logger.info(- `Got IP address for VM ${name} after ${attempts} attempts: ${vmInfo.ipAddress}`- );- return vmInfo.ipAddress;- }-- // Check if VM is in a state where it won't get an IP- if (vmInfo.status === "stopped" || vmInfo.status === "error") {- throw new Error(- `VM ${name} is in '${vmInfo.status}' state and will not get an IP address`- );- }-- // Log progress every 10 attempts- if (attempts % 10 === 0) {- logger.info(- `Still waiting for IP address for VM ${name} (${attempts} attempts)...`- );- }-- // Wait before retrying- await new Promise((resolve) => setTimeout(resolve, retryDelay * 1000));- } catch (e) {- logger.error(`Error getting IP for VM ${name}: ${e}`);- throw e;- }- }- }-}diff --git a/libs/computer/typescript/src/computer/types.ts b/libs/computer/typescript/src/computer/types.tsindex dbf8c734bc..296302f3f7 100644--- a/libs/computer/typescript/src/computer/types.ts+++ b/libs/computer/typescript/src/computer/types.ts@@ -31,87 +31,6 @@ export interface CloudComputerConfig extends BaseComputerConfig {apiKey: string;}-export interface LumeComputerConfig extends BaseComputerConfig {- /**- * The display configuration. Can be:- * - A Display object- * - A dict with 'width' and 'height'- * - A string in format "WIDTHxHEIGHT" (e.g. "1920x1080")- * @default "1024x768"- */- display?: Display | string;-- /**- * The VM memory allocation. (e.g. "8GB", "4GB", "1024MB")- * @default "8GB"- */- memory?: string;-- /**- * The VM CPU allocation.- * @default 4- */- cpu?: number;-- /**- * The VM image name- * @default "macos-sequoia-cua:latest"- */- image?: string;-- /**- * Optional list of directory paths to share with the VM- */- sharedDirectories?: string[];-- /**- * If True, target localhost instead of starting a VM- * @default false- */- useHostComputerServer?: boolean;-- /**- * Whether to enable telemetry tracking.- * @default true- */- telemetryEnabled?: boolean;-- /**- * Optional port to use for the VM provider server- * @default 7777- */- port?: number;-- /**- * Optional port for the noVNC web interface- * @default 8006- */- noVNCPort?: number;-- /**- * Host to use for VM provider connections (e.g. "localhost", "host.docker.internal")- * @default "localhost"- */- host?: string;-- /**- * Optional path for persistent VM storage- */- storage?: string;-- /**- * Whether to use ephemeral storage- * @default false- */- ephemeral?: boolean;-- /**- * Optional list of experimental features to enable (e.g. ["app-use"])- */- experiments?: string[];-}-export enum VMProviderType {CLOUD = "cloud",- LUME = "lume",}diff --git a/libs/computer/typescript/src/index.ts b/libs/computer/typescript/src/index.tsindex ef312139c2..9917d55935 100644--- a/libs/computer/typescript/src/index.ts+++ b/libs/computer/typescript/src/index.ts@@ -1,5 +1,5 @@// Export classes-export * from "./computer";+export { CloudComputer as Computer } from "./computer";//todo: figure out what types to export and how to do that//diff --git a/libs/computer/typescript/src/util/lume.ts b/libs/computer/typescript/src/util/lume.tsdeleted file mode 100644index cdbd8ce56f..0000000000--- a/libs/computer/typescript/src/util/lume.ts+++ /dev/null@@ -1,592 +0,0 @@-/**- * Shared API utilities for Lume providers.- *- * This module contains shared functions for interacting with the Lume API,- * used by LumeProvider.- *- * WARNING: This file was created as a test/example implementation and is not maintained or expected to work.- * It serves as a reference for how a provider might be implemented but should not be used in production.- */--import pino from "pino";--// Setup logging-const logger = pino({ name: "lume_api" });--// Types for API responses and options-// These are lume-specific-export interface SharedDirectory {- hostPath: string;- tag: string;- readOnly: boolean;-}--export interface VMInfo {- status?: string;- name: string;- diskSize: {- allocated: number;- total: number;- };- memorySize: number;- os: string;- display: string;- locationName: string;- cpuCount?: number;- // started state results- vncUrl?: string;- ipAddress?: string;- sharedDirectories?: SharedDirectory[];-}--export interface RunOptions {- [key: string]: unknown;-}--export interface UpdateOptions {- [key: string]: unknown;-}--/**- * Use fetch to get VM information from Lume API.- *- * @param vmName - Name of the VM to get info for- * @param host - API host- * @param port - API port- * @param storage - Storage path for the VM- * @param debug - Whether to show debug output- * @param verbose - Enable verbose logging- * @returns Dictionary with VM status information parsed from JSON response- */-export async function lumeApiGet(- vmName: string,- host: string,- port: number,- storage?: string,- debug = false,- verbose = false-): Promise<VMInfo[]> {- // URL encode the storage parameter for the query- let storageParam = "";-- if (storage) {- // First encode the storage path properly- const encodedStorage = encodeURIComponent(storage);- storageParam = `?storage=${encodedStorage}`;- }-- // Construct API URL with encoded storage parameter if needed- const apiUrl = `http://${host}:${port}/lume/vms${- vmName ? `/${vmName}` : ""- }${storageParam}`;-- // Only print the fetch URL when debug is enabled- logger.info(`Executing API request: ${apiUrl}`);-- try {- // Execute the request with timeouts- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 20000); // 20 second timeout-- const response = await fetch(apiUrl, {- method: "GET",- signal: controller.signal,- });-- clearTimeout(timeoutId);-- if (!response.ok) {- // Handle HTTP errors- const errorMsg = `HTTP error returned from API server (status: ${response.status})`;- throw new Error(`API request failed: ${errorMsg}`);- }-- // Parse JSON response- // If vmName is provided, API returns a single object; otherwise it returns an array- const data = await response.json();- const result = vmName ? [data as VMInfo] : (data as VMInfo[]);-- if (debug || verbose) {- console.log(`DEBUG: API response: ${JSON.stringify(result, null, 2)}`);- }-- return result;- } catch (err) {- const error = err as Error;- let errorMsg = "Unknown error";-- if (error.name === "AbortError") {- errorMsg =- "Operation timeout - the API server is taking too long to respond";- } else if (error.message.includes("ECONNREFUSED")) {- errorMsg =- "Failed to connect to the API server - it might still be starting up";- } else if (error.message.includes("ENOTFOUND")) {- errorMsg = "Failed to resolve host - check the API server address";- } else if (error.message) {- errorMsg = error.message;- }-- logger.error(`API request failed: ${errorMsg}`);- throw new Error(`API request failed: ${errorMsg}`);- }-}--/**- * Run a VM using fetch.- *- * @param vmName - Name of the VM to run- * @param host - API host- * @param port - API port- * @param runOpts - Dictionary of run options- * @param storage - Storage path for the VM- * @param debug - Whether to show debug output- * @param verbose - Enable verbose logging- * @returns Dictionary with API response- */-export async function lumeApiRun(- vmName: string,- host: string,- port: number,- runOpts: RunOptions,- storage?: string,- debug = false,- verbose = false-): Promise<VMInfo> {- // URL encode the storage parameter for the query- let storageParam = "";-- if (storage) {- const encodedStorage = encodeURIComponent(storage);- storageParam = `?storage=${encodedStorage}`;- }-- // Construct API URL- const apiUrl = `http://${host}:${port}/lume/vms/${vmName}/run${storageParam}`;-- // Convert run options to JSON- const jsonData = JSON.stringify(runOpts);-- if (debug || verbose) {- console.log(`Executing fetch API call: POST ${apiUrl}`);- console.log(`Request body: ${jsonData}`);- }- logger.info(`Executing API request: POST ${apiUrl}`);-- try {- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 20000);-- const response = await fetch(apiUrl, {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: jsonData,- signal: controller.signal,- });-- clearTimeout(timeoutId);-- if (!response.ok) {- const errorMsg = `HTTP error returned from API server (status: ${response.status})`;- throw new Error(`API request failed: ${errorMsg}`);- }-- const data = (await response.json()) as VMInfo;-- if (debug || verbose) {- console.log(`DEBUG: API response: ${JSON.stringify(data, null, 2)}`);- }-- return data;- } catch (err) {- const error = err as Error;- let errorMsg = "Unknown error";-- if (error.name === "AbortError") {- errorMsg =- "Operation timeout - the API server is taking too long to respond";- } else if (error.message.includes("ECONNREFUSED")) {- errorMsg =- "Failed to connect to the API server - it might still be starting up";- } else if (error.message.includes("ENOTFOUND")) {- errorMsg = "Failed to resolve host - check the API server address";- } else if (error.message) {- errorMsg = error.message;- }-- logger.error(`API request failed: ${errorMsg}`);- throw new Error(`API request failed: ${errorMsg}`);- }-}--/**- * Stop a VM using fetch.- *- * @param vmName - Name of the VM to stop- * @param host - API host- * @param port - API port- * @param storage - Storage path for the VM- * @param debug - Whether to show debug output- * @param verbose - Enable verbose logging- * @returns Dictionary with API response- */-export async function lumeApiStop(- vmName: string,- host: string,- port: number,- storage?: string,- debug = false,- verbose = false-): Promise<VMInfo> {- // URL encode the storage parameter for the query- let storageParam = "";-- if (storage) {- const encodedStorage = encodeURIComponent(storage);- storageParam = `?storage=${encodedStorage}`;- }-- // Construct API URL- const apiUrl = `http://${host}:${port}/lume/vms/${vmName}/stop${storageParam}`;-- if (debug || verbose) {- console.log(`DEBUG: Executing fetch API call: POST ${apiUrl}`);- }- logger.debug(`Executing API request: POST ${apiUrl}`);-- try {- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 20000);-- const response = await fetch(apiUrl, {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: "{}",- signal: controller.signal,- });-- clearTimeout(timeoutId);-- if (!response.ok) {- const errorMsg = `HTTP error returned from API server (status: ${response.status})`;- throw new Error(`API request failed: ${errorMsg}`);- }-- const data = (await response.json()) as VMInfo;-- if (debug || verbose) {- console.log(`DEBUG: API response: ${JSON.stringify(data, null, 2)}`);- }-- return data;- } catch (err) {- const error = err as Error;- let errorMsg = "Unknown error";-- if (error.name === "AbortError") {- errorMsg =- "Operation timeout - the API server is taking too long to respond";- } else if (error.message.includes("ECONNREFUSED")) {- errorMsg =- "Failed to connect to the API server - it might still be starting up";- } else if (error.message.includes("ENOTFOUND")) {- errorMsg = "Failed to resolve host - check the API server address";- } else if (error.message) {- errorMsg = error.message;- }-- logger.error(`API request failed: ${errorMsg}`);- throw new Error(`API request failed: ${errorMsg}`);- }-}--/**- * Update VM settings using fetch.- *- * @param vmName - Name of the VM to update- * @param host - API host- * @param port - API port- * @param updateOpts - Dictionary of update options- * @param storage - Storage path for the VM- * @param debug - Whether to show debug output- * @param verbose - Enable verbose logging- * @returns Dictionary with API response- */-export async function lumeApiUpdate(- vmName: string,- host: string,- port: number,- updateOpts: UpdateOptions,- storage?: string,- debug = false,- verbose = false-): Promise<VMInfo> {- // URL encode the storage parameter for the query- let storageParam = "";-- if (storage) {- const encodedStorage = encodeURIComponent(storage);- storageParam = `?storage=${encodedStorage}`;- }-- // Construct API URL- const apiUrl = `http://${host}:${port}/lume/vms/${vmName}/update${storageParam}`;-- // Convert update options to JSON- const jsonData = JSON.stringify(updateOpts);-- if (debug || verbose) {- console.log(`DEBUG: Executing fetch API call: POST ${apiUrl}`);- console.log(`DEBUG: Request body: ${jsonData}`);- }- logger.debug(`Executing API request: POST ${apiUrl}`);-- try {- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 20000);-- const response = await fetch(apiUrl, {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: jsonData,- signal: controller.signal,- });-- clearTimeout(timeoutId);-- if (!response.ok) {- const errorMsg = `HTTP error returned from API server (status: ${response.status})`;- throw new Error(`API request failed: ${errorMsg}`);- }-- const data = (await response.json()) as VMInfo;-- if (debug || verbose) {- console.log(`DEBUG: API response: ${JSON.stringify(data, null, 2)}`);- }-- return data;- } catch (err) {- const error = err as Error;- let errorMsg = "Unknown error";-- if (error.name === "AbortError") {- errorMsg =- "Operation timeout - the API server is taking too long to respond";- } else if (error.message.includes("ECONNREFUSED")) {- errorMsg =- "Failed to connect to the API server - it might still be starting up";- } else if (error.message.includes("ENOTFOUND")) {- errorMsg = "Failed to resolve host - check the API server address";- } else if (error.message) {- errorMsg = error.message;- }-- logger.error(`API request failed: ${errorMsg}`);- throw new Error(`API request failed: ${errorMsg}`);- }-}--/**- * Pull a VM image from a registry using fetch.- *- * @param image - Name/tag of the image to pull- * @param name - Name to give the VM after pulling- * @param host - API host- * @param port - API port- * @param storage - Storage path for the VM- * @param registry - Registry to pull from (default: ghcr.io)- * @param organization - Organization in registry (default: trycua)- * @param debug - Whether to show debug output- * @param verbose - Enable verbose logging- * @returns Dictionary with pull status and information- */-export async function lumeApiPull(- image: string,- name: string,- host: string,- port: number,- storage?: string,- registry = "ghcr.io",- organization = "trycua",- debug = false,- verbose = false-): Promise<VMInfo> {- // URL encode the storage parameter for the query- let storageParam = "";-- if (storage) {- const encodedStorage = encodeURIComponent(storage);- storageParam = `?storage=${encodedStorage}`;- }-- // Construct API URL- const apiUrl = `http://${host}:${port}/lume/pull${storageParam}`;-- // Construct pull options- const pullOpts = {- image,- name,- registry,- organization,- };-- const jsonData = JSON.stringify(pullOpts);-- if (debug || verbose) {- console.log(`DEBUG: Executing fetch API call: POST ${apiUrl}`);- console.log(`DEBUG: Request body: ${jsonData}`);- }- logger.debug(`Executing API request: POST ${apiUrl}`);-- try {- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 60000); // 60 second timeout for pulls-- const response = await fetch(apiUrl, {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: jsonData,- signal: controller.signal,- });-- clearTimeout(timeoutId);-- if (!response.ok) {- const errorMsg = `HTTP error returned from API server (status: ${response.status})`;- throw new Error(`API request failed: ${errorMsg}`);- }-- const data = (await response.json()) as VMInfo;-- if (debug || verbose) {- console.log(`DEBUG: API response: ${JSON.stringify(data, null, 2)}`);- }-- return data;- } catch (err) {- const error = err as Error;- let errorMsg = "Unknown error";-- if (error.name === "AbortError") {- errorMsg =- "Operation timeout - the API server is taking too long to respond";- } else if (error.message.includes("ECONNREFUSED")) {- errorMsg =- "Failed to connect to the API server - it might still be starting up";- } else if (error.message.includes("ENOTFOUND")) {- errorMsg = "Failed to resolve host - check the API server address";- } else if (error.message) {- errorMsg = error.message;- }-- logger.error(`API request failed: ${errorMsg}`);- throw new Error(`API request failed: ${errorMsg}`);- }-}--/**- * Delete a VM using fetch.- *- * @param vmName - Name of the VM to delete- * @param host - API host- * @param port - API port- * @param storage - Storage path for the VM- * @param debug - Whether to show debug output- * @param verbose - Enable verbose logging- * @returns Dictionary with API response- */-export async function lumeApiDelete(- vmName: string,- host: string,- port: number,- storage?: string,- debug = false,- verbose = false-): Promise<VMInfo | null> {- // URL encode the storage parameter for the query- let storageParam = "";-- if (storage) {- const encodedStorage = encodeURIComponent(storage);- storageParam = `?storage=${encodedStorage}`;- }-- // Construct API URL- const apiUrl = `http://${host}:${port}/lume/vms/${vmName}${storageParam}`;-- if (debug || verbose) {- console.log(`DEBUG: Executing fetch API call: DELETE ${apiUrl}`);- }- logger.debug(`Executing API request: DELETE ${apiUrl}`);-- try {- const controller = new AbortController();- const timeoutId = setTimeout(() => controller.abort(), 20000);-- const response = await fetch(apiUrl, {- method: "DELETE",- signal: controller.signal,- });-- clearTimeout(timeoutId);-- if (!response.ok && response.status !== 404) {- const errorMsg = `HTTP error returned from API server (status: ${response.status})`;- throw new Error(`API request failed: ${errorMsg}`);- }-- // For 404, return null (VM already deleted)- if (response.status === 404) {- if (debug || verbose) {- console.log("DEBUG: VM not found (404) - treating as already deleted");- }- return null;- }-- // Try to parse JSON response, but handle empty responses- let data: VMInfo | null = null;- const contentType = response.headers.get("content-type");- if (contentType?.includes("application/json")) {- try {- data = (await response.json()) as VMInfo;- } catch {- // Empty response is OK for DELETE- }- } else {- // No JSON response expected- }-- if (debug || verbose) {- console.log(`DEBUG: API response: ${JSON.stringify(data, null, 2)}`);- }-- return data;- } catch (err) {- const error = err as Error;- let errorMsg = "Unknown error";-- if (error.name === "AbortError") {- errorMsg =- "Operation timeout - the API server is taking too long to respond";- } else if (error.message.includes("ECONNREFUSED")) {- errorMsg =- "Failed to connect to the API server - it might still be starting up";- } else if (error.message.includes("ENOTFOUND")) {- errorMsg = "Failed to resolve host - check the API server address";- } else if (error.message) {- errorMsg = error.message;- }-- logger.error(`API request failed: ${errorMsg}`);- throw new Error(`API request failed: ${errorMsg}`);- }-}diff --git a/libs/computer/typescript/tests/computer/cloud.test.ts b/libs/computer/typescript/tests/computer/cloud.test.tsindex 78653c098e..f1f7a1b66a 100644--- a/libs/computer/typescript/tests/computer/cloud.test.ts+++ b/libs/computer/typescript/tests/computer/cloud.test.ts@@ -1,14 +1,14 @@import { describe, expect, it } from "vitest";import { OSType } from "../../src/types";-import { CloudComputer } from "../../src/computer/providers/cloud";+import { Computer } from "../../src";describe("Computer Cloud", () => {it("Should create computer instance", () => {- const cloud = new CloudComputer({+ const cloud = new Computer({apiKey: "asdf",name: "s-linux-1234",osType: OSType.LINUX,});- expect(cloud).toBeInstanceOf(CloudComputer);+ expect(cloud).toBeInstanceOf(Computer);});});