import { mkdir } from 'node:fs/promises'; import path from 'node:path'; import { BrowserService, ChatService, workflow } from '@athree/runner'; import { dep } from 'mesh-ioc'; /** * Simple Screenshot Workflow * * A minimal workflow that demonstrates basic browser automation: * 1. Navigates to a URL * 2. Waits for page load * 3. Takes a full-page screenshot * * This is useful as a starting point or for testing browser connectivity. */ @workflow({ title: 'Simple Screenshot', }) export class SimpleScreenshotWorkflow { @dep() private chat!: ChatService; @dep() private browserService!: BrowserService; async run() { const projectDir = process.cwd(); const storageDir = path.join(projectDir, 'services', 'simple-screenshot'); await mkdir(storageDir, { recursive: true }); const url = 'https://example.com'; this.chat.addMessage({ content: 'Starting simple screenshot workflow', }); const page = await this.browserService.getPage(); this.chat.addMessage({ content: `Navigating to ${url}`, }); await page.goto(url); await page.waitForLoadState('networkidle'); const screenshotPath = path.join(storageDir, 'screenshot.png'); await page.screenshot({ path: screenshotPath, fullPage: true }); this.chat.addMessage({ content: `Screenshot saved to ${screenshotPath}`, }); const title = await page.title(); const pageUrl = page.url(); this.chat.addMessage({ content: 'Workflow complete', data: { title, url: pageUrl, screenshotPath, }, }); } }