agentmb 0.3.1 → 0.3.2

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.
Files changed (33) hide show
  1. package/README.md +188 -4
  2. package/dist/browser/actions.d.ts +1 -1
  3. package/dist/browser/actions.d.ts.map +1 -1
  4. package/dist/browser/actions.js +4 -3
  5. package/dist/browser/actions.js.map +1 -1
  6. package/dist/browser/manager.d.ts +21 -0
  7. package/dist/browser/manager.d.ts.map +1 -1
  8. package/dist/browser/manager.js +127 -12
  9. package/dist/browser/manager.js.map +1 -1
  10. package/dist/cli/commands/actions.d.ts.map +1 -1
  11. package/dist/cli/commands/actions.js +37 -10
  12. package/dist/cli/commands/actions.js.map +1 -1
  13. package/dist/cli/commands/session.d.ts.map +1 -1
  14. package/dist/cli/commands/session.js +9 -0
  15. package/dist/cli/commands/session.js.map +1 -1
  16. package/dist/cli/index.js +1 -1
  17. package/dist/daemon/routes/actions.d.ts.map +1 -1
  18. package/dist/daemon/routes/actions.js +97 -12
  19. package/dist/daemon/routes/actions.js.map +1 -1
  20. package/dist/daemon/routes/interaction.d.ts.map +1 -1
  21. package/dist/daemon/routes/interaction.js +10 -1
  22. package/dist/daemon/routes/interaction.js.map +1 -1
  23. package/dist/daemon/routes/sessions.d.ts.map +1 -1
  24. package/dist/daemon/routes/sessions.js +107 -1
  25. package/dist/daemon/routes/sessions.js.map +1 -1
  26. package/dist/daemon/server.js +1 -1
  27. package/package.json +4 -2
  28. package/skills/agentmb/SKILL.md +541 -0
  29. package/skills/agentmb/references/authentication.md +180 -0
  30. package/skills/agentmb/references/browser-modes.md +167 -0
  31. package/skills/agentmb/references/commands.md +231 -0
  32. package/skills/agentmb/references/locator-modes.md +254 -0
  33. package/skills/agentmb/references/session-management.md +260 -0
@@ -0,0 +1,180 @@
1
+ # Authentication — Deep Reference
2
+
3
+ ---
4
+
5
+ ## Human Login Handoff
6
+
7
+ Switch a headless session to headed (visible) mode, log in manually, then return to headless automation with the same cookies and storage intact.
8
+
9
+ ```bash
10
+ # Step 1: Start daemon and create a session (can be existing profile)
11
+ agentmb session new --profile myaccount
12
+
13
+ # Step 2: Open the browser window for manual login
14
+ agentmb login <session-id>
15
+ # → browser window opens
16
+ # → navigate to the site and log in manually
17
+ # → press Enter in terminal when done
18
+ # → session returns to headless mode with cookies preserved
19
+ ```
20
+
21
+ Python SDK:
22
+ ```python
23
+ sess = client.sessions.create(profile="myaccount", headless=False)
24
+ # ... navigate to the site manually via headed browser ...
25
+ # (no SDK equivalent for the interactive login flow — use CLI `agentmb login`)
26
+ ```
27
+
28
+ After login, subsequent sessions created with the same `--profile` name automatically have the saved cookies.
29
+
30
+ ---
31
+
32
+ ## Profile Persistence
33
+
34
+ ### Agent Workspace (Named Profile)
35
+
36
+ Cookies, localStorage, IndexedDB, and browser state are saved to `AGENTMB_DATA_DIR/profiles/<name>/`.
37
+
38
+ ```bash
39
+ agentmb session new --profile gmail-account
40
+ # cookies and state saved to ~/.agentmb/profiles/gmail-account/
41
+ ```
42
+
43
+ Reuse in future runs:
44
+ ```bash
45
+ agentmb session new --profile gmail-account # cookies already there
46
+ agentmb navigate <sid> https://mail.google.com # logged in automatically
47
+ ```
48
+
49
+ ### Pure Sandbox (Ephemeral)
50
+
51
+ No state persisted. Auto-deleted on `close()`.
52
+
53
+ ```bash
54
+ agentmb session new --ephemeral
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Storage Export / Import
60
+
61
+ Export auth state from one session and import into another (e.g., from manual login to automated session).
62
+
63
+ ```bash
64
+ agentmb storage-export <session-id> -o myaccount-state.json
65
+ # → saves Playwright storageState format (cookies + origins)
66
+
67
+ agentmb storage-import <new-session-id> myaccount-state.json
68
+ # → restores cookies; origins_skipped count returned
69
+ ```
70
+
71
+ Python SDK:
72
+ ```python
73
+ # After manual login — export the state
74
+ sess.storage_export("myaccount-state.json")
75
+ sess.close()
76
+
77
+ # New automated session — import the state
78
+ sess2 = client.sessions.create(profile="myaccount")
79
+ result = sess2.storage_import("myaccount-state.json")
80
+ print(result.origins_skipped) # number of origins skipped (cross-origin restrictions)
81
+ ```
82
+
83
+ Use case: login once (headless or manual), export, share across sessions or agents.
84
+
85
+ ---
86
+
87
+ ## Cookie Management
88
+
89
+ ```bash
90
+ agentmb cookie-list <session-id> # list all cookies
91
+ agentmb cookie-clear <session-id> # clear all cookies
92
+ agentmb cookie-delete <session-id> <name> # delete specific cookie
93
+ agentmb cookie-delete <session-id> session_token --domain .example.com
94
+ ```
95
+
96
+ Python SDK:
97
+ ```python
98
+ # List cookies
99
+ cookies = sess.cookie_list()
100
+
101
+ # Clear all
102
+ sess.cookie_clear()
103
+
104
+ # Delete specific cookie (domain filter optional)
105
+ result = sess.delete_cookie("session_token")
106
+ result = sess.delete_cookie("tracker", domain=".example.com")
107
+ print(result.removed, result.remaining)
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Profile Encryption
113
+
114
+ Browser profiles (cookies, storage) can be encrypted at rest using AES-256-GCM.
115
+
116
+ ```bash
117
+ # Generate a 32-byte key
118
+ export AGENTMB_ENCRYPTION_KEY="$(openssl rand -base64 32)"
119
+ # Start daemon with key set
120
+ agentmb start
121
+ ```
122
+
123
+ ```python
124
+ import os
125
+ os.environ["AGENTMB_ENCRYPTION_KEY"] = "your-32-byte-key-base64-or-hex"
126
+ ```
127
+
128
+ **Important**: Profiles written without a key cannot be read with one, and vice versa. Keep the key consistent across daemon restarts.
129
+
130
+ ---
131
+
132
+ ## API Token Authentication
133
+
134
+ When `AGENTMB_API_TOKEN` is set, all endpoints except `/health` require the token.
135
+
136
+ ```bash
137
+ export AGENTMB_API_TOKEN="my-secret-token"
138
+ agentmb start
139
+ ```
140
+
141
+ Send the token in requests:
142
+ ```bash
143
+ # Via header
144
+ curl -H "X-API-Token: my-secret-token" http://127.0.0.1:19315/health
145
+
146
+ # Via Authorization Bearer
147
+ curl -H "Authorization: Bearer my-secret-token" http://127.0.0.1:19315/health
148
+ ```
149
+
150
+ Python SDK:
151
+ ```python
152
+ client = BrowserClient(base_url="http://127.0.0.1:19315", api_token="my-secret-token")
153
+ ```
154
+
155
+ Requests without a valid token return `401 Unauthorized`.
156
+
157
+ ---
158
+
159
+ ## Multi-Site Auth Pattern
160
+
161
+ For workflows that require multiple site logins:
162
+
163
+ ```bash
164
+ # Login to site A
165
+ agentmb session new --profile site-a-account
166
+ agentmb login <sid-a> # manual login
167
+ agentmb storage-export <sid-a> -o site-a-state.json
168
+ agentmb session rm <sid-a>
169
+
170
+ # Login to site B
171
+ agentmb session new --profile site-b-account
172
+ agentmb login <sid-b>
173
+ agentmb storage-export <sid-b> -o site-b-state.json
174
+ agentmb session rm <sid-b>
175
+
176
+ # Automation session with pre-loaded auth
177
+ agentmb session new --profile site-a-account
178
+ agentmb storage-import <sid> site-a-state.json
179
+ agentmb navigate <sid> https://site-a.example.com # already logged in
180
+ ```
@@ -0,0 +1,167 @@
1
+ # Browser Modes — Deep Reference
2
+
3
+ agentmb supports three browser running modes, differing in **which binary is used and how it is connected**.
4
+
5
+ | Mode | Browser | How Connected | Profile Persistence |
6
+ |---|---|---|---|
7
+ | **1. Managed Chromium** | Playwright-bundled Chromium | agentmb spawns & owns | Persistent or ephemeral |
8
+ | **2. Managed Chrome Stable** | System Chrome / Edge | agentmb spawns & owns | Persistent or ephemeral |
9
+ | **3. CDP Attach** | Any running Chrome-compatible | agentmb attaches via CDP | Owned by external process |
10
+
11
+ ---
12
+
13
+ ## Mode 1 — Managed Chromium (default)
14
+
15
+ agentmb spawns the **Playwright-bundled Chromium** binary. No system Chrome required. Works in headless (CI) and headed modes.
16
+
17
+ ```bash
18
+ agentmb session new --profile demo # named profile (persistent)
19
+ agentmb session new --ephemeral # temp profile (auto-deleted)
20
+ agentmb session new --profile demo --headed # visible window
21
+ ```
22
+
23
+ ```python
24
+ sess = client.sessions.create(profile="demo")
25
+ sess = client.sessions.create(ephemeral=True)
26
+ sess = client.sessions.create(profile="demo", headless=False)
27
+ ```
28
+
29
+ **Use when**: default automation, CI pipelines, no system Chrome required, any OS.
30
+
31
+ ---
32
+
33
+ ## Mode 2 — Managed Chrome Stable
34
+
35
+ agentmb spawns **system-installed Chrome or Edge** via Playwright. Chrome Stable or Edge must be installed on the host.
36
+
37
+ ```bash
38
+ agentmb session new --browser-channel chrome # system Chrome Stable
39
+ agentmb session new --browser-channel msedge # system Edge
40
+ agentmb session new --executable-path /path/to/chrome # custom binary
41
+ ```
42
+
43
+ ```python
44
+ sess = client.sessions.create(browser_channel="chrome") # Chrome Stable
45
+ sess = client.sessions.create(browser_channel="msedge") # Edge
46
+ sess = client.sessions.create(executable_path="/usr/bin/chromium") # custom path
47
+ ```
48
+
49
+ Valid `browser_channel` values: `chromium` (default), `chrome`, `msedge`.
50
+ `browser_channel` and `executable_path` are mutually exclusive — using both returns `400 preflight_failed`.
51
+
52
+ **Use when**: you need Chrome-specific behavior, extensions, or site compatibility that differs from bundled Chromium.
53
+
54
+ ---
55
+
56
+ ## Mode 3 — CDP Attach
57
+
58
+ agentmb **attaches to an already-running Chrome** process via the Chrome DevTools Protocol. The external browser is **not terminated** on `close()` — only the Playwright connection is dropped.
59
+
60
+ ### Three Profile Variants
61
+
62
+ | Variant | `--user-data-dir` | State | Typical Use |
63
+ |---|---|---|---|
64
+ | **A. Sandbox** | temp dir (auto) | ephemeral | clean CI, throwaway sessions |
65
+ | **B. Dedicated Profile** | custom persistent dir | persistent, isolated | automation account, persistent login |
66
+ | **C. User Chrome** | your real Chrome profile | inherits cookies & extensions | leverage personal login state |
67
+
68
+ #### Variant A: Sandbox (temp profile, via browser-launch)
69
+
70
+ `agentmb browser-launch` starts Chrome with an auto-created temp profile. Clean slate every time.
71
+
72
+ ```bash
73
+ agentmb browser-launch --port 9222
74
+ # → Chrome launched at ws://127.0.0.1:9222 with temp --user-data-dir
75
+
76
+ agentmb session new --launch-mode attach --cdp-url http://127.0.0.1:9222
77
+ ```
78
+
79
+ ```python
80
+ sess = client.sessions.create(launch_mode="attach", cdp_url="http://127.0.0.1:9222")
81
+ sess.navigate("https://example.com")
82
+ sess.close() # only disconnects — Chrome stays alive
83
+ ```
84
+
85
+ #### Variant B: Dedicated Profile (persistent, isolated)
86
+
87
+ Pass a fixed `--user-data-dir` to Chrome at startup. State persists across restarts. Completely isolated from personal Chrome.
88
+
89
+ ```bash
90
+ # macOS / Linux
91
+ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
92
+ --remote-debugging-port=9222 \
93
+ --user-data-dir="$HOME/.agentmb-profiles/my-automation-profile" \
94
+ --no-first-run --no-default-browser-check
95
+
96
+ # Windows
97
+ "C:\Program Files\Google\Chrome\Application\chrome.exe" ^
98
+ --remote-debugging-port=9222 ^
99
+ --user-data-dir="%APPDATA%\agentmb-profiles\my-automation-profile"
100
+ ```
101
+
102
+ ```python
103
+ sess = client.sessions.create(launch_mode="attach", cdp_url="http://127.0.0.1:9222")
104
+ ```
105
+
106
+ #### Variant C: User Chrome (reuse personal profile)
107
+
108
+ Point Chrome at your existing user profile to inherit all logged-in sessions, saved passwords, and installed extensions. **Chrome must not be running** with that profile when you launch it with remote debugging.
109
+
110
+ ```bash
111
+ # macOS — close Chrome first, then:
112
+ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
113
+ --remote-debugging-port=9222 \
114
+ --user-data-dir="$HOME/Library/Application Support/Google/Chrome"
115
+
116
+ # Linux
117
+ google-chrome --remote-debugging-port=9222 \
118
+ --user-data-dir="$HOME/.config/google-chrome"
119
+
120
+ # Windows
121
+ "C:\Program Files\Google\Chrome\Application\chrome.exe" ^
122
+ --remote-debugging-port=9222 ^
123
+ --user-data-dir="%LOCALAPPDATA%\Google\Chrome\User Data"
124
+ ```
125
+
126
+ ```python
127
+ sess = client.sessions.create(launch_mode="attach", cdp_url="http://127.0.0.1:9222")
128
+ # → all cookies, extensions, and login state from personal Chrome are available
129
+ ```
130
+
131
+ **Warning**: actions will affect your real Chrome profile. Use Variant B when in doubt.
132
+
133
+ ### CDP Attach Notes
134
+
135
+ - `close()` only drops the Playwright connection. Chrome process stays alive.
136
+ - CDP attach gives agentmb control over **all tabs** in the connected browser.
137
+ - `launch_mode=attach` is incompatible with `browser_channel` and `executable_path` (preflight returns `400`).
138
+ - Lower `navigator.webdriver` fingerprint than managed modes.
139
+ - Supports real browser extensions.
140
+
141
+ Attach command (all variants):
142
+ ```bash
143
+ agentmb session new --launch-mode attach --cdp-url http://127.0.0.1:9222
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Preflight Validation
149
+
150
+ The session creation endpoint validates parameters before launching. Returns `400 preflight_failed` for:
151
+ - `browser_channel` + `executable_path` used together
152
+ - `browser_channel` not in `['chromium', 'chrome', 'msedge']`
153
+ - `launch_mode=attach` without `cdp_url`
154
+ - `cdp_url` with invalid URL format
155
+ - `launch_mode=attach` combined with `browser_channel` or `executable_path`
156
+
157
+ ---
158
+
159
+ ## Mode Selection Summary
160
+
161
+ | Need | Mode |
162
+ |---|---|
163
+ | Default CI automation, no system Chrome | Mode 1 (Managed Chromium) |
164
+ | Chrome-specific rendering or extensions | Mode 2 (Managed Chrome Stable) |
165
+ | Clean-slate session, real Chrome binary | Mode 3 Variant A (CDP Attach + browser-launch) |
166
+ | Persistent automation account (isolated) | Mode 3 Variant B (CDP Attach + dedicated profile) |
167
+ | Reuse personal login state | Mode 3 Variant C (CDP Attach + user profile) |
@@ -0,0 +1,231 @@
1
+ # CLI Commands — Full Reference
2
+
3
+ All commands follow the pattern: `agentmb <command> <session-id> [args] [flags]`
4
+
5
+ Use `agentmb --help` and `agentmb <command> --help` for full flag lists.
6
+
7
+ ---
8
+
9
+ ## Daemon
10
+
11
+ | Command | Notes |
12
+ |---|---|
13
+ | `agentmb start` | Start daemon; `-p <port>` (default 19315), `-d <data-dir>` |
14
+ | `agentmb stop` | Stop daemon |
15
+ | `agentmb status` | Show daemon status (sessions, uptime) |
16
+ | `agentmb browser-launch` | Launch Chrome with CDP remote debugging (for CDP Attach mode) |
17
+
18
+ `browser-launch` flags: `--port <n>` (CDP port, default 9222), `--user-data-dir <dir>`, `--channel chrome|msedge`.
19
+
20
+ ---
21
+
22
+ ## Session
23
+
24
+ | Command | Notes |
25
+ |---|---|
26
+ | `agentmb session new` | Create session; returns `<session-id>` |
27
+ | `agentmb session list` | List all active sessions |
28
+ | `agentmb session get <sid>` | Show session details |
29
+ | `agentmb session rm <sid>` | Close and delete session |
30
+ | `agentmb session seal <sid>` | Seal session (prevent deletion; 423 on rm) |
31
+ | `agentmb settings <sid>` | Show session settings (viewport, headless, url, profile) |
32
+
33
+ `session new` flags:
34
+
35
+ | Flag | Default | Notes |
36
+ |---|---|---|
37
+ | `--profile <name>` | — | Named persistent profile |
38
+ | `--ephemeral` | false | Temp profile (auto-deleted on close) |
39
+ | `--headless` | true | Run headless |
40
+ | `--headed` | — | Run headed (visible window) |
41
+ | `--browser-channel <ch>` | `chromium` | `chromium` / `chrome` / `msedge` |
42
+ | `--executable-path <path>` | — | Custom browser binary |
43
+ | `--launch-mode attach` | — | CDP Attach mode |
44
+ | `--cdp-url <url>` | — | Required with `--launch-mode attach` |
45
+ | `--accept-downloads` | false | Enable file downloads |
46
+ | `--policy <profile>` | `safe` | `safe` / `permissive` / `disabled` |
47
+
48
+ ---
49
+
50
+ ## Navigation
51
+
52
+ | Command | Notes |
53
+ |---|---|
54
+ | `agentmb navigate <sid> <url>` | Navigate; `--wait-until load\|networkidle\|commit` |
55
+ | `agentmb back <sid>` | Browser back |
56
+ | `agentmb forward <sid>` | Browser forward |
57
+ | `agentmb reload <sid>` | Reload page |
58
+ | `agentmb wait-url <sid> <pattern>` | Wait for URL match (glob pattern) |
59
+ | `agentmb wait-load-state <sid>` | Wait for load state |
60
+ | `agentmb wait-function <sid> <expr>` | Wait for JS expression to return truthy |
61
+ | `agentmb wait-text <sid> <text>` | Wait for text to appear in DOM |
62
+ | `agentmb wait-stable <sid>` | Network idle + DOM quiet + optional overlay clear |
63
+
64
+ ---
65
+
66
+ ## Locator / Scan
67
+
68
+ | Command | Notes |
69
+ |---|---|
70
+ | `agentmb element-map <sid>` | Inject element_ids; return labeled element list |
71
+ | `agentmb element-map <sid> --include-unlabeled` | Include icon-only elements (fallback label: `[tag @ x,y]`) |
72
+ | `agentmb snapshot-map <sid>` | Server-side snapshot; returns ref_id per element |
73
+ | `agentmb snapshot-map <sid> --include-unlabeled` | Include unlabeled in snapshot |
74
+ | `agentmb find <sid> <type> <query>` | Semantic find: `type` = `text\|role\|label\|placeholder\|alt_text` |
75
+
76
+ ---
77
+
78
+ ## Read / Assert
79
+
80
+ | Command | Notes |
81
+ |---|---|
82
+ | `agentmb get <sid> <prop> <sel-or-eid>` | Read: `text\|html\|value\|attr\|count\|box` |
83
+ | `agentmb assert <sid> <prop> <sel-or-eid>` | Assert: `visible\|enabled\|checked` |
84
+ | `agentmb extract <sid> <selector>` | Extract all matching elements as list; `--attribute <attr>` |
85
+ | `agentmb eval <sid> <expr>` | Evaluate JavaScript; returns raw result |
86
+
87
+ ---
88
+
89
+ ## Element Interaction
90
+
91
+ | Command | Notes |
92
+ |---|---|
93
+ | `agentmb click <sid> <sel-or-eid>` | Click; `--element-id` or `--ref-id`; `422` with `recovery_hint` on failure |
94
+ | `agentmb dblclick <sid> <sel-or-eid>` | Double-click |
95
+ | `agentmb fill <sid> <sel-or-eid> <value>` | Fast fill (replace); `--fill-strategy normal\|type`, `--char-delay-ms <ms>` |
96
+ | `agentmb type <sid> <sel-or-eid> <text>` | Type char by char; `--delay-ms <ms>` |
97
+ | `agentmb press <sid> <sel-or-eid> <key>` | Key / combo: `Enter`, `Tab`, `Control+a` |
98
+ | `agentmb select <sid> <sel> <value...>` | Select `<option>` by value/label |
99
+ | `agentmb hover <sid> <sel-or-eid>` | Hover |
100
+ | `agentmb focus <sid> <sel-or-eid>` | Focus element |
101
+ | `agentmb check <sid> <sel-or-eid>` | Check checkbox / radio |
102
+ | `agentmb uncheck <sid> <sel-or-eid>` | Uncheck |
103
+ | `agentmb drag <sid> <source> <target>` | Drag-and-drop; `--source-ref-id` / `--target-ref-id` |
104
+
105
+ ---
106
+
107
+ ## Scroll
108
+
109
+ | Command | Notes |
110
+ |---|---|
111
+ | `agentmb scroll <sid> <sel-or-eid>` | Scroll element; direction `up\|down\|left\|right`; `--amount <px>` |
112
+ | `agentmb scroll-into-view <sid> <sel-or-eid>` | Scroll element into viewport |
113
+ | `agentmb scroll-until <sid>` | Scroll until condition; `--stop-selector`, `--stop-text`, `--max-scrolls`, `--step-delay-ms` |
114
+ | `agentmb load-more-until <sid> <btn-sel> <item-sel>` | Click load-more repeatedly |
115
+
116
+ `scroll` response: `{ "scrolled": bool, "warning": "...", "scrollable_hint": [...] }`
117
+ If `scrolled=false`, use selectors from `scrollable_hint` for the next scroll call.
118
+
119
+ ---
120
+
121
+ ## Coordinate / Low-Level
122
+
123
+ | Command | Notes |
124
+ |---|---|
125
+ | `agentmb click-at <sid> <x> <y>` | Click at absolute page coordinates |
126
+ | `agentmb bbox <sid> <sel-or-eid>` | Bounding box + center_x/center_y; accepts `--element-id` / `--ref-id` |
127
+ | `agentmb mouse-move <sid> [x] [y]` | Move mouse; or `--selector`/`--element-id`/`--ref-id`; `--steps <n>` |
128
+ | `agentmb mouse-down <sid>` / `mouse-up <sid>` | Mouse button press/release |
129
+ | `agentmb key-down <sid> <key>` / `key-up <sid> <key>` | Raw key press/release |
130
+ | `agentmb wheel <sid> --dx <n> --dy <n>` | Low-level wheel event |
131
+ | `agentmb insert-text <sid> <text>` | Insert text into focused element (no keyboard simulation) |
132
+
133
+ ---
134
+
135
+ ## File Transfer
136
+
137
+ | Command | Notes |
138
+ |---|---|
139
+ | `agentmb upload <sid> <selector> <file>` | Upload from disk; `--mime-type` to override auto-detection |
140
+ | `agentmb download <sid> <sel-or-eid> -o <file>` | Download triggered by element; session must have `--accept-downloads` |
141
+
142
+ `download` also accepts `--element-id` / `--ref-id`. Without `accept_downloads=True`, returns `422 download_not_enabled`.
143
+
144
+ ---
145
+
146
+ ## Cookies / Storage
147
+
148
+ | Command | Notes |
149
+ |---|---|
150
+ | `agentmb cookie-list <sid>` | List all cookies |
151
+ | `agentmb cookie-clear <sid>` | Clear all cookies |
152
+ | `agentmb cookie-delete <sid> <name>` | Delete cookie by name; `--domain`, `--path`, `--url` filters |
153
+ | `agentmb storage-export <sid> -o state.json` | Export Playwright storageState (cookies + origins) |
154
+ | `agentmb storage-import <sid> state.json` | Restore cookies from storageState |
155
+
156
+ ---
157
+
158
+ ## Observability
159
+
160
+ | Command | Notes |
161
+ |---|---|
162
+ | `agentmb screenshot <sid> -o out.png` | Screenshot; `--full-page`, `--format png\|jpeg` |
163
+ | `agentmb annotated-screenshot <sid>` | Screenshot with element overlays; `--highlight <sel>` |
164
+ | `agentmb logs <sid>` | Session audit log; `--tail <n>` |
165
+ | `agentmb console-log <sid>` | Browser console entries; `--tail <n>` |
166
+ | `agentmb page-errors <sid>` | Uncaught JS errors |
167
+ | `agentmb dialogs <sid>` | Auto-dismissed dialog history (alert/confirm/prompt) |
168
+ | `agentmb trace start <sid>` | Start Playwright trace recording |
169
+ | `agentmb trace stop <sid> -o trace.zip` | Stop trace and save; view with `npx playwright show-trace trace.zip` |
170
+
171
+ ---
172
+
173
+ ## Browser Controls
174
+
175
+ | Command | Notes |
176
+ |---|---|
177
+ | `agentmb set-viewport <sid> <w> <h>` | Resize viewport |
178
+ | `agentmb clipboard-write <sid> <text>` | Write to clipboard |
179
+ | `agentmb clipboard-read <sid>` | Read from clipboard |
180
+ | `agentmb policy <sid>` | Get current policy profile |
181
+ | `agentmb policy <sid> <profile>` | Set policy: `safe\|permissive\|disabled` |
182
+ | `agentmb policy <sid> safe --allow-sensitive` | Safe + allow sensitive actions |
183
+ | `agentmb cdp-ws <sid>` | Print browser-level CDP WebSocket URL |
184
+ | `agentmb set-network <sid>` | Network throttling; `--latency-ms`, `--download-kbps`, `--upload-kbps`, `--offline` |
185
+ | `agentmb reset-network <sid>` | Restore normal network conditions |
186
+
187
+ ---
188
+
189
+ ## Multi-Page (Tabs)
190
+
191
+ | Command | Notes |
192
+ |---|---|
193
+ | `agentmb pages list <sid>` | List all open tabs |
194
+ | `agentmb pages new <sid>` | Open a new blank tab; returns `<page-id>` |
195
+ | `agentmb pages switch <sid> <page-id>` | Make tab the active target |
196
+ | `agentmb pages close <sid> <page-id>` | Close tab (last tab protected — 409) |
197
+
198
+ ---
199
+
200
+ ## Routes (Network Mocks)
201
+
202
+ | Command | Notes |
203
+ |---|---|
204
+ | `agentmb route list <sid>` | List active route mocks |
205
+ | `agentmb route add <sid> <pattern>` | Add mock; `--status`, `--body`, `--content-type` |
206
+ | `agentmb route rm <sid> <pattern>` | Remove mock |
207
+
208
+ Mocks persist across page navigations within the session.
209
+
210
+ ---
211
+
212
+ ## CDP
213
+
214
+ | Command | Notes |
215
+ |---|---|
216
+ | `agentmb cdp-ws <sid>` | Print `ws://` browser-level CDP endpoint |
217
+
218
+ REST:
219
+ ```
220
+ GET /api/v1/sessions/:id/cdp → session CDP info
221
+ POST /api/v1/sessions/:id/cdp → send CDP method: {"method": "...", "params": {...}}
222
+ ```
223
+
224
+ ---
225
+
226
+ ## Health
227
+
228
+ ```
229
+ GET /health
230
+ → { "status": "ok", "version": "0.3.1", "uptime_s": N, "sessions_active": N }
231
+ ```