# CrawlDex Playwright Pack

Canonical: https://crawldex.com/agents/playwright
Markdown: https://crawldex.com/agents/playwright.md
Harness id: playwright
Channel: adapter-playwright

## Why this exists

This adds a cheap public route-risk check before scripted browser work and gives the script a consistent reporting closeout.

## When to call CrawlDex

Before a script visits a task route, especially checkout, support, account, cancellation, or form flows.

## Install or paste

```typescript
import { test } from "@playwright/test";

const CRAWLDEX_CHANNEL = process.env.CRAWLDEX_CHANNEL ?? "adapter-playwright";

async function preflight(site: string, task: string) {
  const res = await fetch("https://crawldex.com/api/v1/preflight", {
    method: "POST",
    headers: {
      "content-type": "application/json",
      "x-crawldex-channel": CRAWLDEX_CHANNEL
    },
    body: JSON.stringify({
      site,
      task,
      agent_profile: { stack: "playwright", browser_runtime: "chromium" }
    })
  });
  return res.json();
}

test("public route stays agent-readable", async ({ page }) => {
  const gate = await preflight("netflix.com", "subscriptions.cancel");
  test.skip(!gate.decision.should_attempt_autonomously, gate.agent_instruction);
  await page.goto("https://www.netflix.com/");
});
```

## Preflight call

```bash
curl -sS -X POST https://crawldex.com/api/v1/preflight \
  -H "content-type: application/json" \
  -H "x-crawldex-channel: adapter-playwright" \
  -d '{"site":"netflix.com","task":"subscriptions.cancel","agent_profile":{"stack":"browser-agent","browser_runtime":"chromium"}}'
```

## Report redacted outcome after eligible public work

Do not report private account data, payment data, messages, screenshots with sensitive content, tokens, cookies, raw traces, local files, or logged-in-only pages.

```bash
curl -sS -X POST https://crawldex.com/api/v1/runs \
  -H "content-type: application/json" \
  -H "x-crawldex-agent-key: $CRAWLDEX_AGENT_KEY" \
  -H "x-crawldex-channel: adapter-playwright" \
  -d '{"site":"netflix.com","task":"subscriptions.cancel","outcome":"success_with_handoff","friction":["login_required"],"source_tier":"anonymous_report","evidence":{"artifact_types":["redacted_agent_report"]}}'
```
