import { BrowserUse } from "browser-use-sdk/v3";
import * as readline from "readline";
const client = new BrowserUse();
// 1. Create a session
const session = await client.sessions.create();
console.log(`Live view: ${session.liveUrl}`);
// 2. Agent does the first part
const searchResult = await client.run(
"Go to amazon.com and search for noise cancelling headphones",
{ sessionId: session.id },
);
console.log(searchResult.output);
// 3. Human opens liveUrl and picks a product
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
await new Promise((resolve) =>
rl.question("Press Enter after you've selected a product in the live view...", resolve),
);
rl.close();
// 4. Agent continues where the human left off
const result = await client.run(
"Get the details of the selected product — name, price, and rating",
{ sessionId: session.id },
);
console.log(result.output);
// Clean up
await client.sessions.stop(session.id);