const stream = agent.stream({
startUrl: "https://www.sec.gov/edgar/search/",
goal: "Find Apple's latest 10-Q filings and return filing metadata.",
});
for await (const event of stream) {
if (event.type === "browser.created") {
console.log("Browser", event.browserId);
}
if (event.type === "tool.completed") {
console.log("Step", event.step, event.page?.title ?? event.page?.url);
}
if (event.type === "confirmation.requested") {
console.log("Needs confirmation", event.request.message);
}
if (event.type === "run.completed") {
console.log(event.result.status);
console.log(event.result.text);
}
}