Files
chrome-use/evals/cases/command-usage.ts
T
Chris Tate 71343069d2 Add agent-browser skills command with evals (#1225)
* Add `agent-browser skills` command

Adds a `skills` CLI command that serves bundled skill content at runtime,
always matching the installed CLI version. This solves the problem of
agents relying on stale cached SKILL.md files after CLI upgrades.

The `npx skills add vercel-labs/agent-browser` flow now installs a single
thin discovery skill with trigger words for all use cases (browser
automation, dogfooding, Electron apps, Slack, etc.) that directs agents
to `agent-browser skills get <name>` for current instructions. The other
five skills (dogfood, electron, slack, vercel-sandbox, agentcore) are
marked `metadata.internal: true` so they are not installed by default but
remain accessible via the CLI command.

Subcommands:
  skills [list]              List available skills
  skills get <name> [--full] Get skill content (with optional references)
  skills get --all           Get all skill content
  skills path [name]         Print skill directory path

* Fix skills command robustness: UTF-8 safety, flag handling, path output

- Make truncate_description UTF-8-safe using char_indices() instead of
  byte-indexed slicing that panics on multi-byte codepoints
- Pass get_all as a bool parameter to run_get instead of embedding
  --all as a sentinel string in the names list
- Canonicalize skills_dir path so `skills path` output is clean
- Warn on unrecognized flags in `skills get` instead of silently
  ignoring them

* Add evals framework and strengthen SKILL.md for better agent compliance

Strengthen SKILL.md loading instructions to require `skills get` before
running commands, and trim skill descriptions to prevent agents from
guessing at command syntax. Add TypeScript/Bun eval framework that tests
skill-loading, skill-selection, and command-usage via Claude CLI with
Vercel AI Gateway. Evals pass 20/20 (100%), up from 85% baseline.

* Fix formatting in skills.rs

* Add Codex provider to evals framework

Add multi-provider support with a shared Provider interface. Codex
provider spawns `codex exec --json`, parses JSONL output, and writes
~/.codex/config.toml for AI Gateway routing. Use `--provider codex`
to run evals with Codex (default model: openai/o3). First run scores
19/20 (95%) with 100% on skill-loading and skill-selection.

* Use scoped temp dir for Codex config instead of overwriting ~/.codex
2026-04-12 12:55:46 -05:00

121 lines
3.9 KiB
TypeScript

import type { EvalCase } from "../lib/types.ts";
const RUBRIC = `
1 - Agent does not produce valid agent-browser commands
2 - Agent uses agent-browser but with wrong commands or missing steps
3 - Agent uses correct commands but skips the snapshot-interact workflow
4 - Agent follows the correct workflow with appropriate commands
5 - Agent follows the optimal workflow: navigate, snapshot, interact with refs, re-snapshot as needed
`.trim();
const COMMAND_CONTEXT = `You already ran \`agent-browser skills get agent-browser\` and loaded these commands:
- agent-browser open <url> (navigate to a page)
- agent-browser snapshot -i (get interactive elements with refs like @e1, @e2)
- agent-browser click @ref (click element)
- agent-browser fill @ref "text" (clear and type)
- agent-browser type @ref "text" (type without clearing)
- agent-browser select @ref "option" (select dropdown)
- agent-browser screenshot (screenshot to temp dir)
- agent-browser screenshot --full (full page screenshot)
- agent-browser diff url <url1> <url2> (compare two pages)
- agent-browser diff snapshot (compare current vs last snapshot)
- agent-browser state save ./file.json (save auth state)
- agent-browser state load ./file.json (restore auth state)
- agent-browser get text @ref (get element text)
- agent-browser wait <selector|ms> (wait for element or time)
- agent-browser --session-name <name> open <url> (named session with auto-save)
Workflow: open -> snapshot -i -> interact with refs -> re-snapshot after changes.`;
export const cases: EvalCase[] = [
{
id: "cu-01",
name: "Navigate and screenshot workflow",
category: "command-usage",
prompt: "Open example.com and take a screenshot",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+(open|goto|navigate)",
"agent-browser\\s+screenshot",
],
rubric: RUBRIC,
},
{
id: "cu-02",
name: "Form filling workflow",
category: "command-usage",
prompt:
"Go to example.com/signup, fill in name as 'Jane Doe' and email as 'jane@test.com', then submit",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+(open|goto|navigate)",
"agent-browser\\s+snapshot",
"agent-browser\\s+(fill|type)",
"agent-browser\\s+(click|press|key)",
],
rubric: RUBRIC,
},
{
id: "cu-03",
name: "Snapshot with element refs",
category: "command-usage",
prompt: "Get all interactive elements on example.com",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+(open|goto|navigate)",
"agent-browser\\s+snapshot",
],
rubric: RUBRIC,
},
{
id: "cu-04",
name: "Diff comparison workflow",
category: "command-usage",
prompt:
"Compare the homepage of staging.example.com and prod.example.com",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+diff|staging\\.example\\.com.*prod\\.example\\.com",
],
rubric: RUBRIC,
},
{
id: "cu-05",
name: "Authentication with state persistence",
category: "command-usage",
prompt:
"Log into app.example.com, then save the auth state for future sessions",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+(open|goto|navigate)",
"state\\s+save|--session-name|auth\\s+save",
],
rubric: RUBRIC,
},
{
id: "cu-06",
name: "Data extraction workflow",
category: "command-usage",
prompt:
"Extract the text content of the main heading on example.com",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+(open|goto|navigate)",
"snapshot|get\\s+text",
],
rubric: RUBRIC,
},
{
id: "cu-07",
name: "Full-page screenshot",
category: "command-usage",
prompt: "Take a full-page screenshot of example.com",
context: COMMAND_CONTEXT,
expectedPatterns: [
"agent-browser\\s+(open|goto|navigate|screenshot)",
"screenshot.*--full",
],
rubric: RUBRIC,
},
];