@flrande/browserctl 0.5.0-dev.22.1 → 0.6.0
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/dist/client.d.ts +34 -0
- package/dist/client.js +138 -0
- package/dist/commandRegistry.d.ts +16 -0
- package/dist/commandRegistry.js +21 -0
- package/dist/help.d.ts +4 -0
- package/dist/help.js +24 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -0
- package/dist/runCli.d.ts +5 -0
- package/dist/runCli.js +170 -0
- package/package.json +32 -59
- package/INSTALL-CN.md +0 -92
- package/INSTALL.md +0 -92
- package/LICENSE +0 -21
- package/README-CN.md +0 -69
- package/README.md +0 -69
- package/apps/browserctl/src/commands/a11y-snapshot.ts +0 -20
- package/apps/browserctl/src/commands/act.test.ts +0 -71
- package/apps/browserctl/src/commands/act.ts +0 -64
- package/apps/browserctl/src/commands/command-wrappers.test.ts +0 -688
- package/apps/browserctl/src/commands/common.test.ts +0 -87
- package/apps/browserctl/src/commands/common.ts +0 -191
- package/apps/browserctl/src/commands/console-list.test.ts +0 -102
- package/apps/browserctl/src/commands/console-list.ts +0 -108
- package/apps/browserctl/src/commands/cookie-clear.ts +0 -18
- package/apps/browserctl/src/commands/cookie-get.ts +0 -18
- package/apps/browserctl/src/commands/cookie-set.ts +0 -22
- package/apps/browserctl/src/commands/dialog-arm.ts +0 -20
- package/apps/browserctl/src/commands/dom-query-all.ts +0 -18
- package/apps/browserctl/src/commands/dom-query.ts +0 -18
- package/apps/browserctl/src/commands/download-trigger.ts +0 -22
- package/apps/browserctl/src/commands/download-wait.test.ts +0 -67
- package/apps/browserctl/src/commands/download-wait.ts +0 -27
- package/apps/browserctl/src/commands/element-screenshot.ts +0 -20
- package/apps/browserctl/src/commands/frame-list.ts +0 -16
- package/apps/browserctl/src/commands/frame-snapshot.ts +0 -18
- package/apps/browserctl/src/commands/har-export.test.ts +0 -112
- package/apps/browserctl/src/commands/har-export.ts +0 -120
- package/apps/browserctl/src/commands/memory-delete.ts +0 -20
- package/apps/browserctl/src/commands/memory-inspect.ts +0 -20
- package/apps/browserctl/src/commands/memory-list.ts +0 -90
- package/apps/browserctl/src/commands/memory-mode-set.ts +0 -29
- package/apps/browserctl/src/commands/memory-purge.ts +0 -16
- package/apps/browserctl/src/commands/memory-resolve.ts +0 -56
- package/apps/browserctl/src/commands/memory-status.ts +0 -16
- package/apps/browserctl/src/commands/memory-ttl-set.ts +0 -28
- package/apps/browserctl/src/commands/memory-upsert.ts +0 -142
- package/apps/browserctl/src/commands/network-list.test.ts +0 -110
- package/apps/browserctl/src/commands/network-list.ts +0 -112
- package/apps/browserctl/src/commands/network-wait-for.test.ts +0 -90
- package/apps/browserctl/src/commands/network-wait-for.ts +0 -100
- package/apps/browserctl/src/commands/profile-list.ts +0 -16
- package/apps/browserctl/src/commands/profile-use.ts +0 -18
- package/apps/browserctl/src/commands/response-body.ts +0 -24
- package/apps/browserctl/src/commands/screenshot.ts +0 -16
- package/apps/browserctl/src/commands/session-drop.test.ts +0 -36
- package/apps/browserctl/src/commands/session-drop.ts +0 -16
- package/apps/browserctl/src/commands/session-list.test.ts +0 -81
- package/apps/browserctl/src/commands/session-list.ts +0 -70
- package/apps/browserctl/src/commands/snapshot.ts +0 -16
- package/apps/browserctl/src/commands/status.ts +0 -10
- package/apps/browserctl/src/commands/storage-get.ts +0 -20
- package/apps/browserctl/src/commands/storage-set.ts +0 -22
- package/apps/browserctl/src/commands/tab-close.ts +0 -20
- package/apps/browserctl/src/commands/tab-focus.ts +0 -20
- package/apps/browserctl/src/commands/tab-open.ts +0 -19
- package/apps/browserctl/src/commands/tabs.ts +0 -13
- package/apps/browserctl/src/commands/trace-get.test.ts +0 -61
- package/apps/browserctl/src/commands/trace-get.ts +0 -62
- package/apps/browserctl/src/commands/upload-arm.ts +0 -26
- package/apps/browserctl/src/commands/wait-element.test.ts +0 -80
- package/apps/browserctl/src/commands/wait-element.ts +0 -76
- package/apps/browserctl/src/commands/wait-text.test.ts +0 -110
- package/apps/browserctl/src/commands/wait-text.ts +0 -93
- package/apps/browserctl/src/commands/wait-url.test.ts +0 -80
- package/apps/browserctl/src/commands/wait-url.ts +0 -76
- package/apps/browserctl/src/daemon-client.test.ts +0 -512
- package/apps/browserctl/src/daemon-client.ts +0 -632
- package/apps/browserctl/src/e2e.test.ts +0 -103
- package/apps/browserctl/src/main.dispatch.test.ts +0 -461
- package/apps/browserctl/src/main.test.ts +0 -334
- package/apps/browserctl/src/main.ts +0 -957
- package/apps/browserctl/src/smoke.e2e.test.ts +0 -97
- package/apps/browserctl/src/test-port.ts +0 -26
- package/apps/browserd/src/bootstrap.ts +0 -432
- package/apps/browserd/src/chrome-relay-extension-bridge.test.ts +0 -250
- package/apps/browserd/src/chrome-relay-extension-bridge.ts +0 -506
- package/apps/browserd/src/container.ts +0 -3088
- package/apps/browserd/src/main.test.ts +0 -1522
- package/apps/browserd/src/main.ts +0 -7
- package/apps/browserd/src/test-port.ts +0 -26
- package/apps/browserd/src/tool-matrix.test.ts +0 -887
- package/bin/browserctl.cjs +0 -21
- package/bin/browserd.cjs +0 -21
- package/extensions/chrome-relay/README-CN.md +0 -39
- package/extensions/chrome-relay/README.md +0 -39
- package/extensions/chrome-relay/background.js +0 -1687
- package/extensions/chrome-relay/manifest.json +0 -15
- package/extensions/chrome-relay/popup.html +0 -369
- package/extensions/chrome-relay/popup.js +0 -972
- package/packages/core/src/bootstrap.test.ts +0 -10
- package/packages/core/src/driver-registry.test.ts +0 -45
- package/packages/core/src/driver-registry.ts +0 -22
- package/packages/core/src/driver.ts +0 -47
- package/packages/core/src/index.ts +0 -6
- package/packages/core/src/navigation-memory.test.ts +0 -259
- package/packages/core/src/navigation-memory.ts +0 -360
- package/packages/core/src/ref-cache.test.ts +0 -61
- package/packages/core/src/ref-cache.ts +0 -28
- package/packages/core/src/session-store.test.ts +0 -82
- package/packages/core/src/session-store.ts +0 -138
- package/packages/core/src/types.ts +0 -9
- package/packages/driver-chrome-relay/src/chrome-relay-driver.test.ts +0 -744
- package/packages/driver-chrome-relay/src/chrome-relay-driver.ts +0 -2429
- package/packages/driver-chrome-relay/src/chrome-relay-extension-runtime.test.ts +0 -264
- package/packages/driver-chrome-relay/src/chrome-relay-extension-runtime.ts +0 -521
- package/packages/driver-chrome-relay/src/index.ts +0 -26
- package/packages/driver-managed/src/index.ts +0 -22
- package/packages/driver-managed/src/managed-driver.test.ts +0 -183
- package/packages/driver-managed/src/managed-driver.ts +0 -341
- package/packages/driver-managed/src/managed-local-driver.test.ts +0 -608
- package/packages/driver-managed/src/managed-local-driver.ts +0 -2243
- package/packages/driver-remote-cdp/src/index.ts +0 -19
- package/packages/driver-remote-cdp/src/remote-cdp-driver.test.ts +0 -727
- package/packages/driver-remote-cdp/src/remote-cdp-driver.ts +0 -2264
- package/packages/protocol/src/envelope.test.ts +0 -25
- package/packages/protocol/src/envelope.ts +0 -31
- package/packages/protocol/src/errors.test.ts +0 -17
- package/packages/protocol/src/errors.ts +0 -11
- package/packages/protocol/src/index.ts +0 -3
- package/packages/protocol/src/tools.ts +0 -3
- package/packages/transport-mcp-stdio/src/index.ts +0 -3
- package/packages/transport-mcp-stdio/src/sdk-server.ts +0 -139
- package/packages/transport-mcp-stdio/src/server.test.ts +0 -281
- package/packages/transport-mcp-stdio/src/server.ts +0 -183
- package/packages/transport-mcp-stdio/src/tool-map.ts +0 -84
package/INSTALL.md
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# Install browserctl Skills
|
|
2
|
-
|
|
3
|
-
English | [简体中文](INSTALL-CN.md)
|
|
4
|
-
|
|
5
|
-
This repository publishes one default installable skill:
|
|
6
|
-
|
|
7
|
-
- `skills/browserctl`
|
|
8
|
-
|
|
9
|
-
## Primary Agent Prompt
|
|
10
|
-
|
|
11
|
-
Paste this to your agent:
|
|
12
|
-
|
|
13
|
-
```text
|
|
14
|
-
Fetch and follow instructions from https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/INSTALL.md
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Platform Guides
|
|
18
|
-
|
|
19
|
-
- Codex: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.codex/INSTALL.md`
|
|
20
|
-
- Claude Code: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.claude-plugin/INSTALL.md`
|
|
21
|
-
- Cursor: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.cursor-plugin/INSTALL.md`
|
|
22
|
-
- OpenCode: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.opencode/INSTALL.md`
|
|
23
|
-
|
|
24
|
-
## Update After Install
|
|
25
|
-
|
|
26
|
-
Recommended default: use repository-synced updates so skill, extension, and CLI stay aligned.
|
|
27
|
-
|
|
28
|
-
PowerShell 7:
|
|
29
|
-
|
|
30
|
-
```powershell
|
|
31
|
-
$repoPath = Join-Path $env:USERPROFILE ".codex\\browserctl" # adjust to your local clone path
|
|
32
|
-
|
|
33
|
-
git -C $repoPath pull --ff-only
|
|
34
|
-
npm install --global "$repoPath"
|
|
35
|
-
|
|
36
|
-
browserctl daemon-stop --json
|
|
37
|
-
browserctl daemon-start --json
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Bash:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
repoPath="$HOME/.codex/browserctl" # adjust to your local clone path
|
|
44
|
-
|
|
45
|
-
git -C "$repoPath" pull --ff-only
|
|
46
|
-
npm install --global "$repoPath"
|
|
47
|
-
|
|
48
|
-
browserctl daemon-stop --json
|
|
49
|
-
browserctl daemon-start --json
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Reload the extension in `edge://extensions` or `chrome://extensions` after pulling:
|
|
53
|
-
|
|
54
|
-
1. Open extension management page.
|
|
55
|
-
2. Find `BrowserCtl Relay`.
|
|
56
|
-
3. Click `Reload`.
|
|
57
|
-
|
|
58
|
-
Verify:
|
|
59
|
-
|
|
60
|
-
PowerShell 7:
|
|
61
|
-
|
|
62
|
-
```powershell
|
|
63
|
-
browserctl status --json --session relay --profile chrome-relay
|
|
64
|
-
Invoke-WebRequest -UseBasicParsing -Uri "http://127.0.0.1:9223/browserctl/relay/status" -TimeoutSec 3
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Bash:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
browserctl status --json --session relay --profile chrome-relay
|
|
71
|
-
curl --fail --max-time 3 "http://127.0.0.1:9223/browserctl/relay/status"
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Optional fallback (not the default): update CLI from npm registry only.
|
|
75
|
-
|
|
76
|
-
PowerShell 7:
|
|
77
|
-
|
|
78
|
-
```powershell
|
|
79
|
-
npm install --global @flrande/browserctl@latest
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
Bash:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm install --global @flrande/browserctl@latest
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Fallback Contract
|
|
89
|
-
|
|
90
|
-
If platform-specific install is unavailable, agents should fetch and follow:
|
|
91
|
-
|
|
92
|
-
- `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/skills/browserctl/SKILL.md`
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 browserctl contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README-CN.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# browserctl
|
|
2
|
-
|
|
3
|
-
[English](README.md) | 简体中文
|
|
4
|
-
|
|
5
|
-
面向 coding agent 的扩展优先浏览器控制工具集。
|
|
6
|
-
|
|
7
|
-
## 给 Agent 安装
|
|
8
|
-
|
|
9
|
-
把下面文本贴给 agent:
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
请抓取并遵循 https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/INSTALL.md 中的说明。
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
平台快捷入口:
|
|
16
|
-
|
|
17
|
-
- Codex:`https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.codex/INSTALL.md`
|
|
18
|
-
- Claude Code:`https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.claude-plugin/INSTALL.md`
|
|
19
|
-
- Cursor:`https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.cursor-plugin/INSTALL.md`
|
|
20
|
-
- OpenCode:`https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.opencode/INSTALL.md`
|
|
21
|
-
|
|
22
|
-
默认 skill:
|
|
23
|
-
|
|
24
|
-
- 名称:`browserctl`
|
|
25
|
-
- 路径:`skills/browserctl`
|
|
26
|
-
|
|
27
|
-
## 浏览器快速开始(扩展默认)
|
|
28
|
-
|
|
29
|
-
PowerShell 7:
|
|
30
|
-
|
|
31
|
-
```powershell
|
|
32
|
-
npm install --global @flrande/browserctl
|
|
33
|
-
|
|
34
|
-
$env:BROWSERD_DEFAULT_DRIVER = "chrome-relay"
|
|
35
|
-
$env:BROWSERD_CHROME_RELAY_MODE = "extension"
|
|
36
|
-
$env:BROWSERD_CHROME_RELAY_URL = "http://127.0.0.1:9223"
|
|
37
|
-
$env:BROWSERD_CHROME_RELAY_EXTENSION_TOKEN = "browserctl-relay"
|
|
38
|
-
|
|
39
|
-
browserctl daemon-stop --json
|
|
40
|
-
browserctl daemon-start --json
|
|
41
|
-
browserctl status --json --session relay --profile chrome-relay
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Bash:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm install --global @flrande/browserctl
|
|
48
|
-
|
|
49
|
-
export BROWSERD_DEFAULT_DRIVER="chrome-relay"
|
|
50
|
-
export BROWSERD_CHROME_RELAY_MODE="extension"
|
|
51
|
-
export BROWSERD_CHROME_RELAY_URL="http://127.0.0.1:9223"
|
|
52
|
-
export BROWSERD_CHROME_RELAY_EXTENSION_TOKEN="browserctl-relay"
|
|
53
|
-
|
|
54
|
-
browserctl daemon-stop --json
|
|
55
|
-
browserctl daemon-start --json
|
|
56
|
-
browserctl status --json --session relay --profile chrome-relay
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## 完整文档
|
|
60
|
-
|
|
61
|
-
- [Install Guide (English)](INSTALL.md)
|
|
62
|
-
- [安装指南(中文)](INSTALL-CN.md)
|
|
63
|
-
- [User Guide (English)](docs/user-guide.md)
|
|
64
|
-
- [使用指南(中文)](docs/user-guide-cn.md)
|
|
65
|
-
- 安装后更新(skill + 扩展 + CLI):[使用指南](docs/user-guide-cn.md)、[CLI 参考](docs/cli-reference-cn.md)
|
|
66
|
-
- [CLI Reference (English)](docs/cli-reference.md)
|
|
67
|
-
- [CLI 参考(中文)](docs/cli-reference-cn.md)
|
|
68
|
-
- [Maintainer Onboarding (English)](docs/maintainer-onboarding.md)
|
|
69
|
-
- [维护者上手文档(中文)](docs/maintainer-onboarding-cn.md)
|
package/README.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# browserctl
|
|
2
|
-
|
|
3
|
-
English | [简体中文](README-CN.md)
|
|
4
|
-
|
|
5
|
-
Extension-first browser control toolkit for coding agents.
|
|
6
|
-
|
|
7
|
-
## Install In Agents
|
|
8
|
-
|
|
9
|
-
Paste this to your agent:
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
Fetch and follow instructions from https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/INSTALL.md
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Platform shortcuts:
|
|
16
|
-
|
|
17
|
-
- Codex: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.codex/INSTALL.md`
|
|
18
|
-
- Claude Code: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.claude-plugin/INSTALL.md`
|
|
19
|
-
- Cursor: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.cursor-plugin/INSTALL.md`
|
|
20
|
-
- OpenCode: `https://raw.githubusercontent.com/Flrande/browserctl/refs/heads/master/.opencode/INSTALL.md`
|
|
21
|
-
|
|
22
|
-
Default skill:
|
|
23
|
-
|
|
24
|
-
- Name: `browserctl`
|
|
25
|
-
- Path: `skills/browserctl`
|
|
26
|
-
|
|
27
|
-
## Browser Quick Start (Extension Default)
|
|
28
|
-
|
|
29
|
-
PowerShell 7:
|
|
30
|
-
|
|
31
|
-
```powershell
|
|
32
|
-
npm install --global @flrande/browserctl
|
|
33
|
-
|
|
34
|
-
$env:BROWSERD_DEFAULT_DRIVER = "chrome-relay"
|
|
35
|
-
$env:BROWSERD_CHROME_RELAY_MODE = "extension"
|
|
36
|
-
$env:BROWSERD_CHROME_RELAY_URL = "http://127.0.0.1:9223"
|
|
37
|
-
$env:BROWSERD_CHROME_RELAY_EXTENSION_TOKEN = "browserctl-relay"
|
|
38
|
-
|
|
39
|
-
browserctl daemon-stop --json
|
|
40
|
-
browserctl daemon-start --json
|
|
41
|
-
browserctl status --json --session relay --profile chrome-relay
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Bash:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npm install --global @flrande/browserctl
|
|
48
|
-
|
|
49
|
-
export BROWSERD_DEFAULT_DRIVER="chrome-relay"
|
|
50
|
-
export BROWSERD_CHROME_RELAY_MODE="extension"
|
|
51
|
-
export BROWSERD_CHROME_RELAY_URL="http://127.0.0.1:9223"
|
|
52
|
-
export BROWSERD_CHROME_RELAY_EXTENSION_TOKEN="browserctl-relay"
|
|
53
|
-
|
|
54
|
-
browserctl daemon-stop --json
|
|
55
|
-
browserctl daemon-start --json
|
|
56
|
-
browserctl status --json --session relay --profile chrome-relay
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Full Docs
|
|
60
|
-
|
|
61
|
-
- [Install Guide (English)](INSTALL.md)
|
|
62
|
-
- [安装指南(中文)](INSTALL-CN.md)
|
|
63
|
-
- [User Guide (English)](docs/user-guide.md)
|
|
64
|
-
- [使用指南(中文)](docs/user-guide-cn.md)
|
|
65
|
-
- Update after install (skill + extension + CLI): [User Guide](docs/user-guide.md), [CLI Reference](docs/cli-reference.md)
|
|
66
|
-
- [CLI Reference (English)](docs/cli-reference.md)
|
|
67
|
-
- [CLI 参考(中文)](docs/cli-reference-cn.md)
|
|
68
|
-
- [Maintainer Onboarding (English)](docs/maintainer-onboarding.md)
|
|
69
|
-
- [维护者上手文档(中文)](docs/maintainer-onboarding-cn.md)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { callDaemonTool } from "../daemon-client";
|
|
2
|
-
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
-
|
|
4
|
-
export type A11ySnapshotCommandResult = Record<string, unknown>;
|
|
5
|
-
|
|
6
|
-
export async function runA11ySnapshotCommand(args: string[]): Promise<A11ySnapshotCommandResult> {
|
|
7
|
-
const context = parseCommandContext(args);
|
|
8
|
-
const targetId = requirePositionalArg(context, 0, "targetId");
|
|
9
|
-
const selector = context.positional[1];
|
|
10
|
-
|
|
11
|
-
return await callDaemonTool<A11ySnapshotCommandResult>(
|
|
12
|
-
"browser.a11y.snapshot",
|
|
13
|
-
buildToolArguments(context, {
|
|
14
|
-
targetId,
|
|
15
|
-
...(typeof selector === "string" && selector.trim().length > 0
|
|
16
|
-
? { selector: selector.trim() }
|
|
17
|
-
: {})
|
|
18
|
-
})
|
|
19
|
-
);
|
|
20
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
const { callDaemonToolMock } = vi.hoisted(() => ({
|
|
4
|
-
callDaemonToolMock: vi.fn()
|
|
5
|
-
}));
|
|
6
|
-
|
|
7
|
-
vi.mock("../daemon-client", () => ({
|
|
8
|
-
callDaemonTool: callDaemonToolMock
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
import { runActCommand } from "./act";
|
|
12
|
-
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
callDaemonToolMock.mockReset();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe("runActCommand", () => {
|
|
18
|
-
it("forwards --payload-json into action payload", async () => {
|
|
19
|
-
callDaemonToolMock.mockResolvedValue({
|
|
20
|
-
ok: true
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
await runActCommand([
|
|
24
|
-
"click",
|
|
25
|
-
"target:1",
|
|
26
|
-
"--payload-json",
|
|
27
|
-
"{\"selector\":\"#submit\",\"delayMs\":200}"
|
|
28
|
-
]);
|
|
29
|
-
|
|
30
|
-
expect(callDaemonToolMock).toHaveBeenCalledTimes(1);
|
|
31
|
-
expect(callDaemonToolMock).toHaveBeenCalledWith("browser.act", {
|
|
32
|
-
sessionId: "cli:local",
|
|
33
|
-
targetId: "target:1",
|
|
34
|
-
action: {
|
|
35
|
-
type: "click",
|
|
36
|
-
payload: {
|
|
37
|
-
selector: "#submit",
|
|
38
|
-
delayMs: 200
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("throws when --payload-json value is missing", async () => {
|
|
45
|
-
await expect(runActCommand(["click", "target:1", "--payload-json"])).rejects.toThrow(
|
|
46
|
-
"Missing value for --payload-json."
|
|
47
|
-
);
|
|
48
|
-
expect(callDaemonToolMock).not.toHaveBeenCalled();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("throws when --payload-json is invalid JSON", async () => {
|
|
52
|
-
await expect(
|
|
53
|
-
runActCommand(["click", "target:1", "--payload-json", "{not-json}"])
|
|
54
|
-
).rejects.toThrow("Invalid JSON for --payload-json:");
|
|
55
|
-
expect(callDaemonToolMock).not.toHaveBeenCalled();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("throws when --payload-json is not a JSON object", async () => {
|
|
59
|
-
await expect(runActCommand(["click", "target:1", "--payload-json", "[1,2,3]"])).rejects.toThrow(
|
|
60
|
-
"--payload-json must decode to a JSON object."
|
|
61
|
-
);
|
|
62
|
-
expect(callDaemonToolMock).not.toHaveBeenCalled();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("throws on unknown act options", async () => {
|
|
66
|
-
await expect(runActCommand(["click", "target:1", "--payload", "{}"])).rejects.toThrow(
|
|
67
|
-
"Unknown act option: --payload"
|
|
68
|
-
);
|
|
69
|
-
expect(callDaemonToolMock).not.toHaveBeenCalled();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { callDaemonTool } from "../daemon-client";
|
|
2
|
-
import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
|
|
3
|
-
|
|
4
|
-
export type ActCommandResult = Record<string, unknown>;
|
|
5
|
-
|
|
6
|
-
function isObjectRecord(value: unknown): value is Record<string, unknown> {
|
|
7
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function parseActPayload(tokens: string[]): Record<string, unknown> | undefined {
|
|
11
|
-
let payloadJson: string | undefined;
|
|
12
|
-
|
|
13
|
-
for (let index = 0; index < tokens.length; index += 1) {
|
|
14
|
-
const token = tokens[index];
|
|
15
|
-
if (token === "--payload-json") {
|
|
16
|
-
const value = tokens[index + 1];
|
|
17
|
-
if (value === undefined) {
|
|
18
|
-
throw new Error("Missing value for --payload-json.");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
payloadJson = value;
|
|
22
|
-
index += 1;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
throw new Error(`Unknown act option: ${token}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (payloadJson === undefined) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let parsedPayload: unknown;
|
|
34
|
-
try {
|
|
35
|
-
parsedPayload = JSON.parse(payloadJson);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
38
|
-
throw new Error(`Invalid JSON for --payload-json: ${message}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!isObjectRecord(parsedPayload)) {
|
|
42
|
-
throw new Error("--payload-json must decode to a JSON object.");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return parsedPayload;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export async function runActCommand(args: string[]): Promise<ActCommandResult> {
|
|
49
|
-
const context = parseCommandContext(args);
|
|
50
|
-
const actionType = requirePositionalArg(context, 0, "actionType");
|
|
51
|
-
const targetId = requirePositionalArg(context, 1, "targetId");
|
|
52
|
-
const payload = parseActPayload(context.positional.slice(2));
|
|
53
|
-
|
|
54
|
-
return await callDaemonTool<ActCommandResult>(
|
|
55
|
-
"browser.act",
|
|
56
|
-
buildToolArguments(context, {
|
|
57
|
-
targetId,
|
|
58
|
-
action: {
|
|
59
|
-
type: actionType,
|
|
60
|
-
...(payload !== undefined ? { payload } : {})
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|