Package Exports
- terminator.js
- terminator.js/wrapper.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (terminator.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
terminator.js
Node.js/TypeScript bindings for the Terminator Rust library - AI-native GUI automation for Windows, macOS, and Linux.
Installation
npm install terminator.js
# or
bun install terminator.js
# or
yarn add terminator.jsQuick Start
const { Desktop } = require('terminator.js');
async function main() {
const desktop = new Desktop();
// Get root element
const root = desktop.root();
console.log('Root element:', root.role(), root.name());
// Find and click a button
const locator = desktop.locator('role:button');
try {
const button = await locator.first();
console.log('Found button:', button.name());
await button.click();
} catch (error) {
console.log('Button not found:', error.message);
}
// Take a screenshot
const screenshot = await desktop.captureScreen();
console.log(`Screenshot: ${screenshot.width}x${screenshot.height}`);
// Run a command
const result = await desktop.runCommand('echo hello', 'echo hello');
console.log('Command output:', result.stdout);
}
main().catch(console.error);TypeScript Support
This package includes TypeScript definitions out of the box:
import { Desktop, ElementNotFoundError } from 'terminator.js';
const desktop = new Desktop();
const root = desktop.root();Error Handling
The library provides specific error types for better error handling:
const {
Desktop,
ElementNotFoundError,
TimeoutError,
PermissionDeniedError
} = require('terminator.js');
try {
const button = await desktop.locator('role:button').first();
await button.click();
} catch (error) {
if (error instanceof ElementNotFoundError) {
console.log('Element not found');
} else if (error instanceof TimeoutError) {
console.log('Operation timed out');
} else if (error instanceof PermissionDeniedError) {
console.log('Permission denied');
}
}Platform Support
- ✅ Windows (x64)
API Reference
Desktop
new Desktop()- Create a new desktop automation instanceroot()- Get the root elementapplications()- List all applicationslocator(selector)- Create a locator for finding elementscaptureScreen()- Take a screenshotrunCommand(windowsCmd, unixCmd)- Run a system command
Element
click()- Click the elementtype(text)- Type text into the elementrole()- Get element rolename()- Get element namechildren()- Get child elements
Locator
first()- Get the first matching elementall()- Get all matching elementscount()- Count matching elements
Examples
See the examples directory for more usage examples.