const sources = [
'https://news.ycombinator.com',
'https://techcrunch.com',
'https://arstechnica.com'
];
// Create a batch of tasks, one per source
const tasks = await agent.runBatch(
sources.map(url => ({
objective: 'Extract top 5 article titles and URLs',
startUrl: url
}))
);
// Wait for all tasks to complete
await agent.waitForAllComplete(tasks);
// Process results
tasks.forEach((task, index) => {
console.log(`News from ${sources[index]}:`);
// Filter ChatMessageEvents to extract content
task.events
.filter(event => event.type === 'ChatMessageEvent')
.forEach(event => {
console.log('-', event.data.content);
});
});