Skip to content

Commit 84e8951

Browse files
committed
docs: Final spec for the agent-browser-profiles convention
1 parent 7a103aa commit 84e8951

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

docs/agent-browsers/spec.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
## Agent Browser Profiles — Minimal Convention (v0)
2+
3+
### Scope
4+
5+
Defines a shared, cross‑platform convention for storing named browser profiles used by automated agents that require authenticated access to particular websites. A profile represents a persistent browser user data directory plus lightweight metadata that describes login expectations and provenance. This spec’s primary purpose is to make such profiles discoverable by applications while allowing users to transparently know which profile and authentication will be used by the application. The same profile name can be referenced by multiple applications. A default profile is used when none is specified.
6+
7+
#### Motivating example
8+
9+
Multiple agentic applications (e.g., a research assistant, an issue triager, and an expense reporter) need to act on behalf of the user across several websites (e.g., `chatgpt.com`, `jira.example.com`, `expense.example.com`). Instead of each app asking the user to log in separately, they discover existing agent browser profiles by matching `loginExpectations` (site `id`/`origins`) and reuse the corresponding user data directories. Typically these apps run headless using a browser automation framework such as Playwright. When an expected login is not actually present, the app restarts the automation engine in a visible state so the user can complete the login, then resumes and finishes the task.
10+
11+
If the app discovers multiple candidate profiles for the same website (for example, different `username` values), our guidance is to ask the user which profile to use for the current task. Applications should communicate profile names clearly and expose options to create new profiles or rename existing ones. Users are expected to become familiar with these profile names, which are reused across applications.
12+
13+
### Base Directory (per‑user)
14+
15+
Profiles live under a single per‑user base directory. It can be overridden by an environment variable; otherwise, standard OS conventions are used.
16+
17+
- Linux: `$XDG_DATA_HOME/agent-browser-profiles` or `$HOME/.local/share/agent-browser-profiles` when `XDG_DATA_HOME` is unset
18+
- macOS: `$HOME/Library/Application Support/agent-browser-profiles`
19+
- Windows: `%APPDATA%\agent-browser-profiles`
20+
21+
Override (highest precedence): `AGENT_BROWSER_PROFILES_DIR`
22+
23+
### Profile Naming and Resolution
24+
25+
- Profile names must be lowercase slugs: `[a-z0-9][a-z0-9-_]{0,62}` (no spaces).
26+
- Reserved name: `default` — used when the caller does not specify a profile.
27+
- Applications should fail fast on invalid names and print the resolved absolute path.
28+
29+
### Directory Layout
30+
31+
```
32+
<AGENT_BROWSER_PROFILES_DIR>/
33+
<profile-name>/
34+
metadata.json # Required metadata (schema v1)
35+
browsers/ # Playwright persistent context userDataDir
36+
chromium/
37+
firefox/
38+
safari/
39+
webkit/
40+
notes.md # Optional, user-maintained
41+
```
42+
43+
Notes:
44+
- Only `metadata.json` is required by this spec. Subdirectories under `browsers/` are optional and created on demand.
45+
- Data in these directories may contain secrets (cookies, tokens). Store them in user scope; do not commit to VCS.
46+
47+
### Metadata File: `metadata.json` (Schema v1)
48+
49+
Format: JSON, UTF‑8. Unknown fields must be ignored for forward compatibility.
50+
51+
```json
52+
{
53+
"schemaVersion": 1,
54+
"profileName": "default",
55+
"description": "Primary automation profile",
56+
"createdAt": "2025-01-01T12:00:00Z",
57+
"updatedAt": "2025-01-01T12:00:00Z",
58+
"createdBy": ["my-app", "v1.2.3"],
59+
"loginExpectations": [
60+
{
61+
"id": "chatgpt-com",
62+
"origins": ["https://chatgpt.com"],
63+
"username": "[email protected]"
64+
}
65+
]
66+
}
67+
```
68+
69+
Field definitions:
70+
- `schemaVersion` (number): Always `1` for this spec.
71+
- `profileName` (string): Redundant safety for human inspection. Not authoritative for path resolution.
72+
- `description` (string, optional).
73+
- `createdAt` / `updatedAt` (RFC3339 strings): For auditing.
74+
- `createdBy` (array<string>): Application and version that created this profile, e.g., `["app-name", "v1.2.3"]`.
75+
- `loginExpectations` (array): Zero or more per‑site discovery hints. Each entry:
76+
- `id` (string): Stable identifier for the site (e.g., `chatgpt-com`).
77+
- `origins` (array<string>): Allowed origins for the site (schemes required).
78+
- `username` (string): Account identifier expected to be logged in (email, handle, or user ID).
79+
Applications MAY include additional, application‑specific keys inside `loginExpectations` entries to support their own check mechanisms; such keys are not standardized by this spec.
80+
81+
Semantics:
82+
- Applications MAY add engine‑specific data under `browsers/*` and MUST NOT modify fields they do not own.
83+
- This spec does not define a login‑check format. Applications and libraries are expected to implement authentication checks in an application‑specific way and may publish reusable packages for popular sites.
84+
- Recommended (non‑normative) UX guidance: start headless; if a check indicates login is required, relaunch the same user data directory headful to allow the user to complete login, then continue the task.
85+
- Discoverability intent: when an application needs to act on a site (e.g., `chatgpt.com`), it can search for profiles with matching `loginExpectations.id`/`origins`. If multiple profiles exist with different `username` values, the application may select automatically per policy or prompt the user to choose which account to use for the task.
86+
87+
### Environment Variables
88+
89+
- `AGENT_BROWSER_PROFILES_DIR`: Absolute path override for the base directory.
90+
- `AGENT_BROWSER_PROFILE`: Default profile name to use when the application does not specify one.
91+
92+
### Security and Portability Notes
93+
94+
- Profile contents may include cookies and tokens protected by OS keychains. Profiles generally do not port across different machines/OSes. Treat them as per‑user, per‑machine.
95+
- Never commit profile directories to source control.
96+
- Prefer role/aria selectors in `selector-present` checks to minimize locale‑specific fragility.
97+
98+

0 commit comments

Comments
 (0)