clawd/skills/browser/SKILL.md

110 lines
3.0 KiB
Markdown

---
name: browser
description: Web browsing via Chrome relay or headless Chromium
default_model: K2.5
---
# Skill: Browser Automation
**Route all browsing tasks to the `k2-browser` agent** (uses K2.5 model).
## Spawning Browser Tasks
From main agent, delegate browsing to K2.5:
```
clawdbot agent --agent k2-browser --message "Browse to X and summarize Y"
```
Or use sessions_spawn tool:
```json
{"agent": "k2-browser", "message": "Browse to https://example.com and extract..."}
```
## Quick Reference
### Available Actions
| Action | Required Params | Description |
|--------|-----------------|-------------|
| `tabs` | — | List open tabs |
| `open` | `targetUrl` | Open new tab with URL |
| `navigate` | `targetUrl`, `targetId` | Navigate existing tab |
| `snapshot` | `targetId` | Get page content (aria tree) |
| `screenshot` | `targetId` | Get page screenshot |
| `act` | `targetId`, `request` | Click/type/interact |
### Profiles
- `profile="chrome"` — Chrome relay (authenticated sites like X.com)
- `profile="fast"` — Headless Chromium (general automation)
## Examples
### 1. List tabs
```json
{"action": "tabs", "profile": "chrome"}
```
### 2. Open a new tab
```json
{"action": "open", "profile": "chrome", "targetUrl": "https://example.com"}
```
### 3. Navigate existing tab
```json
{"action": "navigate", "profile": "chrome", "targetId": "ABC123", "targetUrl": "https://example.com"}
```
### 4. Get page content
```json
{"action": "snapshot", "profile": "chrome", "targetId": "ABC123"}
```
### 5. Click an element (use ref from snapshot)
```json
{"action": "act", "profile": "chrome", "targetId": "ABC123", "request": {"kind": "click", "ref": "e42"}}
```
### 6. Type text
```json
{"action": "act", "profile": "chrome", "targetId": "ABC123", "request": {"kind": "type", "ref": "e15", "text": "hello world"}}
```
## Common Mistakes (AVOID THESE)
**Wrong:** `{"action": "navigate", "url": "https://..."}`
**Right:** `{"action": "navigate", "targetUrl": "https://...", "targetId": "..."}`
**Wrong:** `{"action": "open"}` (missing targetUrl)
**Right:** `{"action": "open", "targetUrl": "https://..."}`
**Wrong:** `{"action": "snapshot"}` (missing targetId)
**Right:** `{"action": "snapshot", "targetId": "ABC123"}`
## Workflow
1. **Get tabs:** `browser(action="tabs", profile="chrome")`
2. **Open/navigate:** Use `targetUrl` for the URL
3. **Read content:** `browser(action="snapshot", targetId="...")`
4. **Interact:** `browser(action="act", targetId="...", request={...})`
## K2.5 Tips (IMPORTANT)
K2.5 chokes on large snapshots. **Always use `maxChars`**:
```json
{"action": "snapshot", "profile": "chrome", "targetId": "ABC123", "maxChars": 10000}
```
Without this, K2.5 will timeout on content-heavy pages.
## Alternative: web_fetch
For simple page reading without interaction, use `web_fetch` instead:
```json
{"url": "https://example.com"}
```
This is simpler and doesn't require browser profiles or targetIds. Note: Some sites (nu.nl) block web_fetch with 403 — use browser tool instead.