@53able/pi-agent-browser 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +50 -65
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# pi-agent-browser
|
|
2
2
|
|
|
3
|
-
Pi
|
|
3
|
+
Typed browser automation tools for Pi, powered by [`agent-browser`](https://github.com/vercel-labs/agent-browser).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use this package when Pi needs to operate real web pages, extract rendered context, keep login sessions, or capture visual evidence without falling back to ad-hoc shell commands.
|
|
6
|
+
|
|
7
|
+
## What you get
|
|
8
|
+
|
|
9
|
+
- **Rendered-page context extraction** — read text from public pages or the active authenticated browser tab.
|
|
10
|
+
- **Reliable interaction handles** — use accessibility snapshots with stable `@ref` targets for clicks and form fills.
|
|
11
|
+
- **Evidence capture** — save screenshots and extracted text to predictable artifact paths.
|
|
12
|
+
- **Session persistence** — reuse login state with named `agent-browser` sessions and restore support.
|
|
13
|
+
- **Safer browsing controls** — constrain work with `allowedDomains`, `maxOutput`, and explicit state management.
|
|
14
|
+
- **Typed Pi tools** — each browser action has its own schema instead of one free-form command string.
|
|
6
15
|
|
|
7
16
|
## Requirements
|
|
8
17
|
|
|
@@ -10,13 +19,13 @@ This package exposes `agent-browser` CLI capabilities as typed Pi tools, so Pi c
|
|
|
10
19
|
- [`agent-browser`](https://github.com/vercel-labs/agent-browser) installed and available on `PATH`
|
|
11
20
|
- Chrome for Testing installed through `agent-browser install`
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
Check your local setup:
|
|
14
23
|
|
|
15
24
|
```bash
|
|
16
25
|
agent-browser doctor
|
|
17
26
|
```
|
|
18
27
|
|
|
19
|
-
If `agent-browser` is
|
|
28
|
+
If `agent-browser` is installed outside `PATH`, set:
|
|
20
29
|
|
|
21
30
|
```bash
|
|
22
31
|
export AGENT_BROWSER_BIN=/absolute/path/to/agent-browser
|
|
@@ -24,39 +33,29 @@ export AGENT_BROWSER_BIN=/absolute/path/to/agent-browser
|
|
|
24
33
|
|
|
25
34
|
## Installation
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
Install from npm:
|
|
28
37
|
|
|
29
38
|
```bash
|
|
30
|
-
pi install
|
|
39
|
+
pi install npm:@53able/pi-agent-browser
|
|
31
40
|
```
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
Install from GitHub:
|
|
34
43
|
|
|
35
44
|
```bash
|
|
36
|
-
pi install
|
|
45
|
+
pi install https://github.com/53able/pi-agent-browser
|
|
37
46
|
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
Install from a local checkout:
|
|
40
49
|
|
|
41
50
|
```bash
|
|
42
51
|
git clone https://github.com/53able/pi-agent-browser.git
|
|
43
52
|
pi install ./pi-agent-browser
|
|
44
53
|
```
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
{
|
|
50
|
-
"packages": ["npm:@53able/pi-agent-browser"]
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Tools
|
|
55
|
-
|
|
56
|
-
The extension registers these Pi tools:
|
|
55
|
+
## Registered tools
|
|
57
56
|
|
|
58
57
|
- `agent_browser_open` — open a URL or launch `about:blank`
|
|
59
|
-
- `agent_browser_read` — extract
|
|
58
|
+
- `agent_browser_read` — extract text or JSON from a URL or active rendered tab
|
|
60
59
|
- `agent_browser_snapshot` — get accessibility tree refs for interaction
|
|
61
60
|
- `agent_browser_click` — click by `@ref` or CSS selector
|
|
62
61
|
- `agent_browser_fill` — fill an input by `@ref` or CSS selector
|
|
@@ -66,15 +65,17 @@ The extension registers these Pi tools:
|
|
|
66
65
|
- `agent_browser_close` — close a browser session
|
|
67
66
|
- `agent_browser_doctor` — run `agent-browser doctor`
|
|
68
67
|
|
|
69
|
-
##
|
|
68
|
+
## Common workflows
|
|
69
|
+
|
|
70
|
+
### Read a page and save the extracted source
|
|
70
71
|
|
|
71
|
-
Ask Pi
|
|
72
|
+
Ask Pi:
|
|
72
73
|
|
|
73
74
|
```text
|
|
74
|
-
https://example.com
|
|
75
|
+
https://example.com をブラウザ経由で読み、outputs/browser/example.md に保存して
|
|
75
76
|
```
|
|
76
77
|
|
|
77
|
-
Equivalent
|
|
78
|
+
Equivalent `agent_browser_read` arguments:
|
|
78
79
|
|
|
79
80
|
```json
|
|
80
81
|
{
|
|
@@ -84,9 +85,9 @@ Equivalent tool arguments for `agent_browser_read`:
|
|
|
84
85
|
}
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
### Interact with a rendered page
|
|
88
89
|
|
|
89
|
-
1. Open
|
|
90
|
+
1. Open the page.
|
|
90
91
|
|
|
91
92
|
```json
|
|
92
93
|
{
|
|
@@ -98,12 +99,12 @@ Equivalent tool arguments for `agent_browser_read`:
|
|
|
98
99
|
|
|
99
100
|
2. Call `agent_browser_snapshot` to get fresh `@ref` values.
|
|
100
101
|
3. Use `agent_browser_click` or `agent_browser_fill` with those refs.
|
|
101
|
-
4.
|
|
102
|
+
4. Call `agent_browser_read` for text or `agent_browser_screenshot` for visual evidence.
|
|
102
103
|
5. Close the session with `agent_browser_close` when finished.
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
### Keep login state across runs
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
Use a stable session name and `restore: true`:
|
|
107
108
|
|
|
108
109
|
```json
|
|
109
110
|
{
|
|
@@ -114,6 +115,10 @@ To keep login state automatically, use a stable `session` and `restore: true` on
|
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
118
|
+
After logging in once, future opens with the same `session` and `restore` can reuse saved browser state.
|
|
119
|
+
|
|
120
|
+
### Inspect or clear saved state
|
|
121
|
+
|
|
117
122
|
List saved states:
|
|
118
123
|
|
|
119
124
|
```json
|
|
@@ -131,7 +136,7 @@ Clear one saved session state:
|
|
|
131
136
|
}
|
|
132
137
|
```
|
|
133
138
|
|
|
134
|
-
Clear all saved states only when
|
|
139
|
+
Clear all saved states only when intentionally resetting everything:
|
|
135
140
|
|
|
136
141
|
```json
|
|
137
142
|
{
|
|
@@ -140,52 +145,32 @@ Clear all saved states only when explicitly intended:
|
|
|
140
145
|
}
|
|
141
146
|
```
|
|
142
147
|
|
|
143
|
-
## Safety
|
|
148
|
+
## Safety guidance
|
|
144
149
|
|
|
145
|
-
-
|
|
146
|
-
- Use `outputPath`
|
|
147
|
-
- Take a fresh snapshot after navigation, form submission, modal dismissal, or failed
|
|
150
|
+
- Pass `allowedDomains` whenever the browsing scope is known.
|
|
151
|
+
- Use `outputPath` when extracted content supports a report, audit, or later verification.
|
|
152
|
+
- Take a fresh snapshot after navigation, form submission, modal dismissal, or a failed click.
|
|
148
153
|
- Prefer `agent_browser_read` for textual evidence and `agent_browser_screenshot` for visual evidence.
|
|
149
|
-
- Use `agent_browser_eval` only when `read
|
|
154
|
+
- Use `agent_browser_eval` only when `read` or `snapshot` cannot expose the required state.
|
|
155
|
+
- Review saved browser state before clearing broadly.
|
|
150
156
|
|
|
151
|
-
##
|
|
157
|
+
## Troubleshooting
|
|
152
158
|
|
|
153
|
-
|
|
159
|
+
Run:
|
|
154
160
|
|
|
155
161
|
```bash
|
|
156
|
-
|
|
162
|
+
agent-browser doctor
|
|
157
163
|
```
|
|
158
164
|
|
|
159
|
-
|
|
165
|
+
Or ask Pi to run `agent_browser_doctor`.
|
|
166
|
+
|
|
167
|
+
Common fixes:
|
|
160
168
|
|
|
161
169
|
```bash
|
|
162
|
-
|
|
170
|
+
npm install -g agent-browser
|
|
171
|
+
agent-browser install
|
|
163
172
|
```
|
|
164
173
|
|
|
165
174
|
## License
|
|
166
175
|
|
|
167
176
|
MIT
|
|
168
|
-
|
|
169
|
-
## Publishing
|
|
170
|
-
|
|
171
|
-
This repository is intended to publish through npm Trusted Publishing from GitHub Actions, not through long-lived npm tokens.
|
|
172
|
-
|
|
173
|
-
### npm Trusted Publisher setup
|
|
174
|
-
|
|
175
|
-
In npm, configure a trusted publisher for the package:
|
|
176
|
-
|
|
177
|
-
- Package: `@53able/pi-agent-browser`
|
|
178
|
-
- Publisher type: GitHub Actions
|
|
179
|
-
- GitHub owner: `53able`
|
|
180
|
-
- Repository: `pi-agent-browser`
|
|
181
|
-
- Workflow filename: `publish.yml`
|
|
182
|
-
- Allowed action: `npm publish`
|
|
183
|
-
|
|
184
|
-
Then publish a release by pushing a semver tag:
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
git tag v0.1.0
|
|
188
|
-
git push origin v0.1.0
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
The workflow uses GitHub OIDC with `id-token: write`, so no `NPM_TOKEN` secret is required.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@53able/pi-agent-browser",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Pi
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Typed Pi tools for browser automation, rendered-page context extraction, screenshots, and saved session state via agent-browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|