import { playwright } from '@bctrl/sdk';
async function main() {
// Create a remote browser session
const session = await playwright.connect({
apiKey: process.env.BCTRL_API_KEY
});
// Get the default page
const page = session.page;
// Navigate and interact
await page.goto('https://news.ycombinator.com');
// Get page title
const title = await page.title();
console.log('Page title:', title);
// Take a screenshot
await page.screenshot({ path: 'screenshot.png' });
// Clean up
await session.close();
}
main();
Run it:You should see “Page title: Hacker News” and a screenshot.png file in your directory.
import { bctrl } from '@bctrl/sdk';
async function main() {
// Connect to a cloud desktop (Windows or Linux)
const desktop = await bctrl.desktop.connect({
apiKey: process.env.BCTRL_API_KEY,
os: 'windows' // or 'linux'
});
// Use AI to control the desktop
await desktop.cua.run('Open Notepad');
// Or use direct control
await desktop.keyboard.type('Hello from BCTRL!');
await desktop.screenshot({ path: 'desktop.png' });
await desktop.close();
}
main();
Run it:You should see Notepad open with “Hello from BCTRL!” typed in, and a desktop.png file in your directory.