// built-in skill: capture all screens in light/dark mode import { launchReapedChrome } from '../../../../../scripts/lib/reap-browser' import type { RNXSkill } from '../types' export const skill: RNXSkill = { name: 'screenshot-all', description: 'Capture screenshots of all screens in the app', type: 'screenshot', version: '1.0.0', triggers: ['screenshot', 'capture screens', 'capture all', 'take screenshots'], tools: [ { name: 'capture_screenshot', description: 'Capture a screenshot of the current screen', parameters: { name: { type: 'string', description: 'Screenshot name', required: true }, theme: { type: 'string', description: 'Color scheme: light or dark' }, }, async execute(params, context) { const { chromium } = await import('playwright') const path = await import('path') const fs = await import('fs') // sootsim renders CanvasKit — require GPU-backed Chrome (Metal). the // bundled swiftshader shell software-renders the canvas and pegs every // core; never use it for sootsim. const browser = await launchReapedChrome((options) => chromium.launch(options), { headless: true, }) const page = await browser.newPage({ viewport: { width: 500, height: 900 } }) try { await page.goto(context.url, { waitUntil: 'networkidle' }) await page.waitForTimeout(2000) const outputPath = path.join(context.outputDir, `${params.name}.png`) fs.mkdirSync(path.dirname(outputPath), { recursive: true }) await page.screenshot({ path: outputPath }) return { success: true, message: `Screenshot saved: ${params.name}`, artifacts: [{ type: 'screenshot', name: params.name, path: outputPath }], } } finally { await browser.close() } }, }, ], }