API reference

BrowserAgent

Core Playwright wrapper with LLM-driven navigation.

import { BrowserAgent } from "slapify";

const agent = new BrowserAgent({ model: "gpt-4o" });
await agent.launch();

const result = await agent.task("Click the login button and submit the form");
console.log(result);

await agent.close();

Constructor options

OptionTypeDefaultDescription
modelstring"gpt-4o"LLM model identifier
headlessbooleantrueRun without visible browser window
maxStepsnumber30Maximum agent steps per task

Methods

MethodReturnsDescription
launch()Promise<void>Start the browser
task(goal)Promise<TaskResult>Execute an autonomous task
navigate(url)Promise<void>Navigate to a URL
screenshot()Promise<Buffer>Capture current page screenshot
close()Promise<void>Close the browser

runPerfAudit

Run a Lighthouse-style performance audit against a URL.

import { runPerfAudit, BrowserAgent } from "slapify";

const agent = new BrowserAgent();
await agent.launch();

const result = await runPerfAudit("https://example.com", agent);
console.log(result.scores);
// { performance: 92, accessibility: 87, bestPractices: 100, seo: 83 }

await agent.close();

AuditResult

PropertyTypeDescription
scoresobjectPerformance, accessibility, best practices, and SEO scores (0–100)
metricsobjectLCP, FID, CLS, TTFB, and other Core Web Vitals
reportstringFull HTML report string

TaskResult

Returned by agent.task():

PropertyTypeDescription
successbooleanWhether the goal was achieved
stepsStepRecord[]Array of steps taken with screenshots
elapsedMsnumberTotal wall-clock time