import { CopilotClient } from "@github/copilot-sdk"; import { accessibilityRuleLookup, createSnapshotReader, permissionForTarget, reportPrompt, streamResponse } from "./workshop.js"; const input = process.argv[2]; if (!input) throw new Error("Usage: npm start -- "); const target = new URL(input.includes("://") ? input : `https://${input}`); if (!["http:", "https:"].includes(target.protocol)) throw new Error("Enter an absolute HTTP or HTTPS URL."); const client = new CopilotClient(); await client.start(); try { const session = await client.createSession({ streaming: true, onPermissionRequest: permissionForTarget(target), tools: [accessibilityRuleLookup, createSnapshotReader(process.cwd())], availableTools: ["accessibility_rule_lookup", "read_latest_accessibility_snapshot", "playwright-browser_navigate"], mcpServers: { playwright: { command: "npx", args: ["-y", "@playwright/mcp@0.0.78", "--browser=msedge", "--output-dir", ".playwright-mcp", "--output-mode", "file"], workingDirectory: process.cwd(), tools: ["browser_navigate"] } }, }); try { await streamResponse(session, reportPrompt(target)); } finally { await session.disconnect(); } } finally { await client.stop(); }