Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Correct typescript doc

Morgan Dean2b5757e59931
diff --git a/docs/content/docs/home/libraries/computer/typescript.mdx b/docs/content/docs/home/libraries/computer/typescript.mdx
index 10a6b7cb4d..bf9d79d3b6 100644
--- a/docs/content/docs/home/libraries/computer/typescript.mdx
+++ b/docs/content/docs/home/libraries/computer/typescript.mdx
@@ -40,43 +40,6 @@ title: Computer (TypeScript)
## TypeScript API
-```typescript
-import { Computer } from '@cua/computer';
-
-const main = async () => {
- const computer = new Computer({
- osType: "macos",
- display: "1024x768",
- memory: "8GB",
- cpu: "4"
- });
-
- try {
- await computer.run();
-
- const screenshot = await computer.interface.screenshot();
- // Save screenshot using fs or other method
- require('fs').writeFileSync('screenshot.png', screenshot);
-
- await computer.interface.moveCursor(100, 100);
- await computer.interface.leftClick();
- await computer.interface.rightClick(300, 300);
- await computer.interface.doubleClick(400, 400);
-
- await computer.interface.type("Hello, World!");
- await computer.interface.pressKey("enter");
-
- await computer.interface.setClipboard("Test clipboard");
- const content = await computer.interface.copyToClipboard();
- console.log(`Clipboard content: ${content}`);
- } finally {
- await computer.stop();
- }
-};
-
-main().catch(console.error);
-```
-
## Install
To install the Computer-Use Interface (CUI) for TypeScript:
@@ -87,102 +50,49 @@ npm install @cua/computer
yarn add @cua/computer
```
-The TypeScript package automatically handles the necessary dependencies for working with Lume.
-
-## Provider System
-
-The TypeScript implementation includes a flexible provider system:
-
-- **Lume Provider**: For local macOS and Linux sandboxes
-- **Lumier Provider**: For Docker-based containers
-- **Cloud Provider**: For remote cloud-based VMs
-
-```typescript
-// Using specific provider options
-import { Computer } from '@cua/computer';
-
-const computer = new Computer({
- osType: "macos",
- provider: "lume",
- providerOptions: {
- ephemeral: true,
- sharedDirectories: [
- { hostPath: "/path/to/share", tag: "shared", readOnly: true }
- ]
- }
-});
-```
-
-## Interface System
-
-The TypeScript implementation provides a comprehensive interface system for interacting with virtual machines:
-
```typescript
-// Example of using the interface
-import { Computer } from '@cua/computer';
+import { CloudComputer, OSType } from '@cua/computer';
const main = async () => {
- const computer = new Computer({ osType: "macos" });
- await computer.run();
-
- // Screenshot and image operations
- const screenshot = await computer.interface.screenshot();
-
- // Mouse operations
- await computer.interface.moveCursor(100, 100);
- await computer.interface.leftClick();
-
- // Keyboard operations
- await computer.interface.type("Hello from TypeScript!");
- await computer.interface.hotkey(["command", "a"]);
-
- // Clipboard operations
- await computer.interface.setClipboard("Clipboard content");
- const content = await computer.interface.copyToClipboard();
-
- await computer.stop();
-};
-```
+ // Create a cloud-based computer
+ const computer = new CloudComputer({
+ name: 'cloud-vm',
+ osType: OSType.Linux,
+ apiKey: 'your-api-key',
+ });
-## Advanced Usage
+ // Access the interface
+ const interface = computer.interface;
-### Cloud Provider
+ // Screenshot operations
+ const screenshot = await interface.screenshot();
-For using the cloud provider with WebSocket communication:
+ // Mouse operations
+ await interface.moveCursor(100, 100);
+ await interface.leftClick();
+ await interface.rightClick(300, 300);
+ await interface.doubleClick(400, 400);
+ await interface.dragTo(500, 500, 'left', 1000); // Drag with left button for 1 second
-```typescript
-import { Computer } from '@cua/computer';
-
-const computer = new Computer({
- osType: "macos",
- provider: "cloud",
- providerOptions: {
- apiKey: "your-api-key",
- endpoint: "wss://your-cloud-endpoint.com"
- }
-});
-
-await computer.run();
-// Use computer.interface methods as usual
-await computer.stop();
-```
+ // Keyboard operations
+ await interface.typeText('Hello from TypeScript!');
+ await interface.pressKey('enter');
+ await interface.hotkey('command', 'a'); // Select all
-### Telemetry
+ // Clipboard operations
+ await interface.setClipboard('Clipboard content');
+ const content = await interface.copyToClipboard();
-The TypeScript implementation includes built-in telemetry tracking:
+ // File operations
+ await interface.writeText('/tmp/test.txt', 'Hello world');
+ const fileContent = await interface.readText('/tmp/test.txt');
-```typescript
-import { TelemetryManager } from '@cua/computer';
+ // Run a command in the VM
+ const [stdout, stderr] = await interface.runCommand('ls -la');
-// Disable telemetry if needed
-TelemetryManager.getInstance().disable();
+ // Disconnect from the cloud VM
+ await computer.disconnect();
+};
-// Or track custom events
-TelemetryManager.getInstance().trackEvent('custom_event', {
- property: 'value'
-});
+main().catch(console.error);
```
-
-## Examples
-
-For more examples and detailed usage, refer to the [TypeScript examples](https://github.com/trycua/cua/tree/main/examples/typescript) in the repository.
\ No newline at end of file