@opentiny/webmcp-cli 0.0.1-alpha.5 → 0.0.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.
package/README.md CHANGED
@@ -32,7 +32,9 @@ npm install -g .
32
32
 
33
33
  ### 1. `state` 命令
34
34
 
35
- 获取浏览器当前活跃页签(或指定页签)的详细状态,包括当前页面的标题、URL、页面中包含的可操作 DOM 树,以及当前页面所有可调用的 MCP 工具列表(包含自动注入的 `page-agent-tool`)。
35
+ 获取浏览器当前活跃页签(或指定页签)的**导航元数据**,包括当前页面的标题、URL、浏览器所有已打开的页签列表,以及当前页面已注入的 MCP 工具列表(`webmcpTools`)。
36
+
37
+ > **注意**:`state` 不再返回页面 DOM 内容(`content`)。若需要读取页面可交互元素,请在 `state` 之后显式调用 `page-agent-tool` 的 `browserState` action。
36
38
 
37
39
  **用法:**
38
40
  ```bash
@@ -43,7 +45,6 @@ webmcp-cli state -t <tabid>
43
45
  **返回格式(JSON):**
44
46
  ```json
45
47
  {
46
- "content": "浏览器状态:包含 [index]<type>text</type> 格式的页面树...",
47
48
  "url": "https://example.com",
48
49
  "title": "Example Domain",
49
50
  "webmcpTools": [
@@ -55,7 +56,7 @@ webmcp-cli state -t <tabid>
55
56
  ],
56
57
  "tabs": [
57
58
  {
58
- "tabid": 1234,
59
+ "tabid": "2EA73ED323E46E5E108D4E46DA4E4AA7",
59
60
  "title": "Example Domain",
60
61
  "url": "https://example.com"
61
62
  }
@@ -83,17 +84,29 @@ webmcp-cli run change-color '{"color": "#ff0000"}'
83
84
  **示例二:使用内置的 `page-agent-tool` 操控浏览器**
84
85
  CLI 自动注入的 `page-agent-tool` 支持丰富的动作(action):`browserState`, `click`, `fill`, `select`, `scroll`, `executeJavascript`。
85
86
 
86
- 获取状态(执行前必须调用一次):
87
+ 此外,该工具接收配置参数 **`responseMode`**,用于控制返回的页面状态形式:
88
+ - **`diff`**(默认):仅返回自上一次状态以来的增量 DOM 差异。
89
+ - **`full`**:返回当前视口中完整的语义化 ARIA YAML 树。
90
+ - **`both`**:同时返回全量树和增量差异。
91
+
92
+ 在执行 `click`, `fill`, `select`, `scroll` 等操作后,工具默认会自动以指定的 `responseMode`(默认 `diff`)返回最新的页面状态,使你可以立即检测操作效果,无须再次手动调用 `browserState`。
93
+
94
+ 获取状态(全量模式):
95
+ ```bash
96
+ webmcp-cli run page-agent-tool '{"action": "browserState", "responseMode": "full"}'
97
+ ```
98
+
99
+ 获取状态(仅增量差异模式,默认):
87
100
  ```bash
88
- webmcp-cli run page-agent-tool '{"action": "browserState"}'
101
+ webmcp-cli run page-agent-tool '{"action": "browserState", "responseMode": "diff"}'
89
102
  ```
90
103
 
91
- 点击索引为 35 的元素:
104
+ 点击索引为 35 的元素(动作执行完自动返回增量):
92
105
  ```bash
93
106
  webmcp-cli run page-agent-tool '{"action": "click", "index": 35}'
94
107
  ```
95
108
 
96
- 向索引为 40 的输入框填入文本:
109
+ 向索引为 40 的输入框填入文本(动作执行完自动返回增量):
97
110
  ```bash
98
111
  webmcp-cli run page-agent-tool '{"action": "fill", "index": 40, "text": "OpenTiny"}'
99
112
  ```