import asyncio
import os
from plato import Plato, PlatoTask
async def run_task(client: Plato, task: PlatoTask):
# Create and initialize environment
env = await client.make_environment(task.env_id, open_page_on_start=False)
await env.wait_for_ready()
await env.reset(task)
# Get CDP URL for browser connection
cdp_url = await env.get_cdp_url()
# Get live view URL for monitoring
live_view_url = await env.get_live_view_url()
print(f"Live view URL: {live_view_url}")
try:
# Connect agent and execute task
await YourAgent.run(cdp_url, prompt)
result = await env.evaluate()
print(f"Evaluation result: {result}")
except Exception as e:
print(f"Error: {e}")
finally:
await env.close()
async def main():
client = Plato(api_key=os.environ.get("PLATO_API_KEY"))
tasks = await client.load_tasks("doordash")
for task in tasks:
await run_task(client, task)
if __name__ == "__main__":
asyncio.run(main())