|
1 | 1 | <p align="center"> |
2 | 2 | <h1 align="center">kbr (ko-browser)</h1> |
3 | | - <p align="center">A simple, fast, token-efficient browser for AI agents — CLI + Go Library</p> |
| 3 | + <p align="center">A simple, fast, token-efficient browser for AI agents — CLI + Go Library.</p> |
4 | 4 | </p> |
5 | 5 |
|
6 | 6 | <p align="center"> |
| 7 | + <a href="README-CN.md">中文文档</a> • |
7 | 8 | <a href="#-quick-start">Quick Start</a> • |
| 9 | + <a href="#agent-notes">Agent Notes</a> • |
8 | 10 | <a href="#-commands">Commands</a> • |
9 | | - <a href="#-library-usage">Library</a> • |
10 | | - <a href="docs/snapshot-format-en.md">Snapshot Format Spec</a> • |
11 | | - <a href="#-中文文档">中文文档</a> |
| 11 | + <a href="#-library-api">Library</a> • |
| 12 | + <a href="docs/snapshot-format-en.md">Snapshot Format Spec</a> |
12 | 13 | </p> |
13 | 14 |
|
14 | 15 | <p align="center"> |
|
20 | 21 |
|
21 | 22 | --- |
22 | 23 |
|
23 | | -**ko-browser** is a browser automation tool built in Go, designed for AI agents. It provides both a **CLI tool** and a **Go library** with a custom accessibility tree snapshot format that saves **46%+ tokens** compared to alternatives. |
| 24 | +**ko-browser** is a browser automation tool built in Go for AI agents. It exposes the same core model in two forms: |
| 25 | + |
| 26 | +- a **CLI** for shell-driven agent workflows |
| 27 | +- a **Go library** for embedding browser control into agent runtimes and tools |
| 28 | + |
| 29 | +Its custom accessibility-tree snapshot format reduces prompt footprint by **46%+** compared with more verbose alternatives. |
24 | 30 |
|
25 | 31 | ### ✨ Key Features |
26 | 32 |
|
|
30 | 36 | - ⚡ **Fast startup** — ~50ms (Go binary) vs ~500ms (Node.js-based tools) |
31 | 37 | - 🔢 **Simple element references** — `click 5` |
32 | 38 | - 🔍 **Optional OCR** — Tesseract integration via `-tags=ocr` build flag for image-heavy pages |
33 | | -- 🌐 **~86 commands** — full parity with agent-browser v0.19.0 |
| 39 | +- 🌐 **~86 commands** — broad coverage for browser automation workflows |
34 | 40 |
|
35 | 41 | ### Snapshot Format Comparison |
36 | 42 |
|
37 | 43 | ``` |
38 | | -┌─ kbr (46% fewer tokens) ──────────┐ ┌─ agent-browser ────────────────────┐ |
| 44 | +┌─ kbr (46% fewer tokens) ──────────┐ ┌─ verbose snapshot output ──────────┐ |
39 | 45 | │ Page: "Example" │ │ - document "Example" │ |
40 | 46 | │ │ │ - navigation "main": │ |
41 | 47 | │ 1: link "Home" │ │ - link "Home" [ref=@e1] │ |
|
50 | 56 |
|
51 | 57 | ## 📦 Installation |
52 | 58 |
|
| 59 | +### Choose an install path |
| 60 | + |
| 61 | +| Use case | Recommended path | Notes | |
| 62 | +|---------|------------------|-------| |
| 63 | +| macOS local usage | Homebrew | Installs an OCR-enabled build and pulls in `tesseract` | |
| 64 | +| Linux/macOS manual deployment | GitHub Releases | Download the prebuilt archive and make sure Tesseract runtime libraries are present | |
| 65 | +| Go-based integration or custom builds | From source | Best when embedding `kbr` into your own toolchain | |
| 66 | + |
53 | 67 | ### Homebrew |
54 | 68 |
|
55 | 69 | ```bash |
@@ -101,10 +115,32 @@ kbr install # check & download Chromium |
101 | 115 | kbr install --with-deps # also install system dependencies (Linux) |
102 | 116 | ``` |
103 | 117 |
|
| 118 | +### Runtime requirements |
| 119 | + |
| 120 | +- Chrome or Chromium is required. Run `kbr install` if you do not already have a compatible browser. |
| 121 | +- OCR-enabled builds expect Tesseract runtime libraries on the host. |
| 122 | +- On Linux CI or sandboxed environments, Chrome may require `--no-sandbox`-style fallbacks depending on the runner configuration. |
| 123 | + |
104 | 124 | --- |
105 | 125 |
|
106 | 126 | ## 🚀 Quick Start |
107 | 127 |
|
| 128 | +### Agent loop |
| 129 | + |
| 130 | +This is the most common shell-driven agent workflow: |
| 131 | + |
| 132 | +```bash |
| 133 | +kbr open https://example.com |
| 134 | +kbr snapshot |
| 135 | +kbr click 5 |
| 136 | +kbr type 8 "hello world" |
| 137 | +kbr press Enter |
| 138 | +kbr wait load |
| 139 | +kbr get text 12 |
| 140 | +``` |
| 141 | + |
| 142 | +Use `snapshot` to get the current page structure, act on numeric refs, then re-snapshot after the page changes. |
| 143 | + |
108 | 144 | ### CLI |
109 | 145 |
|
110 | 146 | ```bash |
@@ -171,6 +207,16 @@ func main() { |
171 | 207 |
|
172 | 208 | ## 📖 Commands |
173 | 209 |
|
| 210 | +### Common flows |
| 211 | + |
| 212 | +| Goal | Commands | |
| 213 | +|------|----------| |
| 214 | +| Navigate and inspect | `open`, `snapshot`, `get title`, `get url` | |
| 215 | +| Interact with forms | `click`, `type`, `fill`, `select`, `check`, `press` | |
| 216 | +| Wait for state changes | `wait load`, `wait selector`, `wait text`, `wait url` | |
| 217 | +| Debug and verify | `screenshot`, `console messages`, `errors list`, `highlight` | |
| 218 | +| Work with sessions | `tab *`, `cookies *`, `storage *`, `state *` | |
| 219 | + |
174 | 220 | ### Core Interaction |
175 | 221 |
|
176 | 222 | | Command | CLI Usage | Library API | |
@@ -733,6 +779,45 @@ The `browser/`, `axtree/`, `selector/`, and `ocr/` packages are all public and i |
733 | 779 |
|
734 | 780 | --- |
735 | 781 |
|
| 782 | +<a name="agent-notes"></a> |
| 783 | + |
| 784 | +## Agent Notes |
| 785 | + |
| 786 | +If you are an agent reading this README, use `kbr` as an interactive browser with a compact text interface. |
| 787 | + |
| 788 | +- Prefer `kbr snapshot` as the primary page representation. It is the most token-efficient output and gives stable numeric refs. |
| 789 | +- Use numeric refs like `kbr click 5`, `kbr type 8 "hello"`, and `kbr get text 12` after taking a fresh snapshot. |
| 790 | +- Re-snapshot after navigation or DOM mutations. Element IDs are snapshot-local, not permanent selectors. |
| 791 | +- Use `kbr get`, `kbr find`, and `kbr wait` for targeted reads instead of repeatedly taking full screenshots. |
| 792 | +- Use OCR only when the page content is image-heavy or inaccessible through the DOM/accessibility tree. |
| 793 | +- Prefer CSS/XPath selectors only when you already know the target precisely or when numeric refs are unavailable. |
| 794 | +- The published Homebrew package and release binaries are built with OCR enabled, so Tesseract runtime libraries are expected on the host. |
| 795 | + |
| 796 | +### Install as an agent skill |
| 797 | + |
| 798 | +If your agent framework supports local skills, install `kbr` first, then copy the repository skill directory into your agent's skills directory as `ko-browser/`. |
| 799 | + |
| 800 | +```yaml |
| 801 | +<agent-skills-dir>/ |
| 802 | + ko-browser/ |
| 803 | + SKILL.md |
| 804 | +``` |
| 805 | + |
| 806 | +The source skill lives here: |
| 807 | + |
| 808 | +- [`skills/ko-browser/SKILL.md`](https://github.com/libi/ko-browser/blob/main/skills/ko-browser/SKILL.md) |
| 809 | + |
| 810 | +Example: |
| 811 | + |
| 812 | +```bash |
| 813 | +mkdir -p <agent-skills-dir>/ko-browser |
| 814 | +cp skills/ko-browser/SKILL.md <agent-skills-dir>/ko-browser/SKILL.md |
| 815 | +``` |
| 816 | + |
| 817 | +After that, make sure the `kbr` binary is available in the agent runtime `PATH`. For agent hosts that also support executable-tool registration, you can expose `kbr` directly in addition to the skill file. |
| 818 | + |
| 819 | +--- |
| 820 | + |
736 | 821 | ## 🤝 Contributing |
737 | 822 |
|
738 | 823 | Contributions are welcome! Please feel free to submit a Pull Request. |
|
0 commit comments