@mearl/client 2.19.0 → 2.19.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
@@ -18,7 +18,7 @@ pnpm add @mearl/client
18
18
  import * as client from '@mearl/client';
19
19
 
20
20
  // 具名方法(类型安全)
21
- const requests = await client.getRequests({ count: 5 });
21
+ const requests = await client.getRequests({ tabId: 12345, count: 5 });
22
22
  const result = await client.sendRequest({
23
23
  url: 'https://api.example.com',
24
24
  method: 'GET',
@@ -30,7 +30,7 @@ const data = await client.invoke('send_request', { url: '...' });
30
30
 
31
31
  // browser_list 默认聚合本机和所有远端 connector
32
32
  const browsers = await client.browserList();
33
- await client.getLogs({}, { browser: browsers.browsers[0].browserId });
33
+ await client.getLogs({ tabId: 12345 }, { browser: browsers.browsers[0].browserId });
34
34
  ```
35
35
 
36
36
  ## CLI 使用
@@ -39,7 +39,7 @@ await client.getLogs({}, { browser: browsers.browsers[0].browserId });
39
39
 
40
40
  ```bash
41
41
  # 获取最近 5 个请求
42
- mearl get_requests --payload '{"count":5}'
42
+ mearl get_requests --payload '{"tabId":12345,"count":5}'
43
43
 
44
44
  # 代理一个 HTTP 请求
45
45
  mearl send_request --payload '{"url":"https://api.example.com","method":"GET"}'
@@ -50,7 +50,7 @@ mearl send_request --payload '{"url":"https://api.example.com/upload","method":"
50
50
  # 截图并保存(tabId 来自 tab_open 或 tab_list)
51
51
  mearl page_screenshot --payload '{"tabId":12345}' --output ./screenshot.png
52
52
 
53
- # 从文件读取大体积参数(如 mock 数据)
53
+ # 从文件读取大体积参数(mock-data.json 需包含 tabId)
54
54
  mearl set_mock --payload-file ./mock-data.json
55
55
 
56
56
  # 环境自检
@@ -158,6 +158,7 @@ client、native-host、cloud-server 和 MCP server 的已安装版本。发现
158
158
  ```bash
159
159
  npx @mearl/setup plugin install trip/mearl --skill yuque-doc-fetch --yes
160
160
  npx @mearl/setup plugin install trip/mearl --skill buc-request --yes
161
+ npx @mearl/setup plugin install trip/mearl --skill authx-request --yes
161
162
  npx @mearl/setup plugin /absolute/path/to/yuque-doc-fetch
162
163
  npx @mearl/setup plugin uninstall yuque
163
164
  mearl yuque read "https://aliyuque.antfin.com/group/book/doc"
@@ -198,7 +199,7 @@ const result = await invokePlugin(
198
199
  );
199
200
  ```
200
201
 
201
- MCP Server 通过固定工具 `plugin_invoke` 接受同样的 `plugin`、`command` 和 `input`,不会把插件子命令动态扩展成 MCP 工具。SDK 与 MCP 不接受任意入口路径;调用尚未注册的 `buc` 或 `tdbank` 时,会通过匹配当前 client 版本的 setup 自动安装并重试一次。其他未注册名称返回 `PLUGIN_NOT_REGISTERED`。
202
+ MCP Server 通过固定工具 `plugin_invoke` 接受同样的 `plugin`、`command` 和 `input`,不会把插件子命令动态扩展成 MCP 工具。SDK 与 MCP 不接受任意入口路径;调用尚未注册的 `buc`、`authx` 或 `tdbank` 时,会通过匹配当前 client 版本的 setup 自动安装并重试一次。其他未注册名称返回 `PLUGIN_NOT_REGISTERED`。
202
203
 
203
204
  注册记录在 `~/.mearl/plugins/<name>.json`,保存入口路径和可选的简短描述;skill 业务代码原地更新直接生效,换路径或更新描述后重新注册。
204
205
  `plugin uninstall <name>` 会对 `~/.agents/skills` 中的全局 Skill 调用 `ali-skills remove --global --yes`,
package/dist/cli.js CHANGED
@@ -21,7 +21,7 @@ const CATEGORIES = [
21
21
  title: '网络请求',
22
22
  names: ['send_request', 'send_mtop_request', 'request_domain_permission'],
23
23
  },
24
- { title: '标签页', names: ['tab_open', 'tab_list', 'tab_close'] },
24
+ { title: '标签页', names: ['tab_open', 'tab_list', 'tab_group', 'tab_close'] },
25
25
  {
26
26
  title: '页面感知',
27
27
  names: ['page_snapshot', 'page_inspect', 'page_screenshot', 'page_frames'],
@@ -70,6 +70,7 @@ const SUGGESTABLE_COMMANDS = [
70
70
  ];
71
71
  const ADVANCED_BUILTIN_COMMANDS = new Set(['connector_list']);
72
72
  const PLUGIN_HOST_OPTIONS = new Set([
73
+ '--all',
73
74
  '--browser',
74
75
  '--cdp',
75
76
  '--compact',
@@ -417,6 +418,7 @@ export function parseClientArgs(args, plugin = false) {
417
418
  if (plugin)
418
419
  program
419
420
  .argument('[pluginArgs...]')
421
+ .option('--all')
420
422
  .option('-h, --help')
421
423
  .option('-v, --version')
422
424
  .option('--verbose');
@@ -436,9 +438,12 @@ export function parseClientArgs(args, plugin = false) {
436
438
  if (plugin && options.payloadFile !== undefined) {
437
439
  throw new Error('插件使用 --payload 传入 command 和 input;正文文件可由业务字段引用');
438
440
  }
439
- const pluginInput = Object.fromEntries(pluginInputOptionNames
440
- .filter(name => Object.hasOwn(options, name))
441
- .map(name => [name, options[name]]));
441
+ const pluginInput = {
442
+ ...Object.fromEntries(pluginInputOptionNames
443
+ .filter(name => Object.hasOwn(options, name))
444
+ .map(name => [name, options[name]])),
445
+ ...(plugin && options.all === true ? { all: true } : {}),
446
+ };
442
447
  if (plugin && options.payload !== undefined && Object.keys(pluginInput).length > 0) {
443
448
  throw new Error('插件业务选项不能与 --payload 同时使用');
444
449
  }
@@ -24,6 +24,7 @@ export declare const COMMANDS: readonly [{
24
24
  readonly params: [{
25
25
  readonly name: "tabId";
26
26
  readonly type: "number";
27
+ readonly required: true;
27
28
  readonly description: "目标标签页 ID,从 tab_open 获取";
28
29
  }];
29
30
  readonly examples: ["tab_checkpoint --payload '{\"tabId\":12345}'"];
@@ -33,6 +34,7 @@ export declare const COMMANDS: readonly [{
33
34
  readonly params: [{
34
35
  readonly name: "tabId";
35
36
  readonly type: "number";
37
+ readonly required: true;
36
38
  readonly description: "目标标签页 ID,从 tab_list 获取";
37
39
  }, {
38
40
  readonly name: "count";
@@ -75,13 +77,14 @@ export declare const COMMANDS: readonly [{
75
77
  readonly type: "boolean";
76
78
  readonly description: "只返回数据结构,不返回叶子值";
77
79
  }];
78
- readonly examples: ["get_requests --payload '{\"count\":5}'", "get_requests --payload '{\"source\":\"mtop\",\"filter\":\"cart\"}'"];
80
+ readonly examples: ["get_requests --payload '{\"tabId\":12345,\"count\":5}'", "get_requests --payload '{\"tabId\":12345,\"source\":\"mtop\",\"filter\":\"cart\"}'"];
79
81
  }, {
80
82
  readonly name: "get_logs";
81
83
  readonly description: "获取浏览器控制台日志";
82
84
  readonly params: [{
83
85
  readonly name: "tabId";
84
86
  readonly type: "number";
87
+ readonly required: true;
85
88
  readonly description: "目标标签页 ID,从 tab_list 获取";
86
89
  }, {
87
90
  readonly name: "limit";
@@ -104,13 +107,14 @@ export declare const COMMANDS: readonly [{
104
107
  readonly type: "string";
105
108
  readonly description: "只返回指定 tab checkpoint 或同类查询 cursor 之后的日志";
106
109
  }];
107
- readonly examples: ["get_logs --payload '{\"limit\":10,\"level\":\"error\"}'"];
110
+ readonly examples: ["get_logs --payload '{\"tabId\":12345,\"limit\":10,\"level\":\"error\"}'"];
108
111
  }, {
109
112
  readonly name: "get_events";
110
113
  readonly description: "获取 RUM/aplus/ARMS 埋点事件";
111
114
  readonly params: [{
112
115
  readonly name: "tabId";
113
116
  readonly type: "number";
117
+ readonly required: true;
114
118
  readonly description: "目标标签页 ID,从 tab_list 获取";
115
119
  }, {
116
120
  readonly name: "source";
@@ -141,13 +145,14 @@ export declare const COMMANDS: readonly [{
141
145
  readonly type: "boolean";
142
146
  readonly description: "返回完整 URL、_raw 和 _context;默认 false";
143
147
  }];
144
- readonly examples: ["get_events --payload '{\"source\":\"aplus\",\"event_type\":\"CLK\",\"limit\":10}'", "get_events --payload '{\"filter\":\"order\",\"includeRaw\":true,\"limit\":1}'", "get_events --payload '{\"tabId\":12345,\"source\":\"all\",\"limit\":20}'"];
148
+ readonly examples: ["get_events --payload '{\"tabId\":12345,\"source\":\"aplus\",\"event_type\":\"CLK\",\"limit\":10}'", "get_events --payload '{\"tabId\":12345,\"filter\":\"order\",\"includeRaw\":true,\"limit\":1}'", "get_events --payload '{\"tabId\":12345,\"source\":\"all\",\"limit\":20}'"];
145
149
  }, {
146
150
  readonly name: "set_mock";
147
151
  readonly description: "设置 API mock 数据";
148
152
  readonly params: [{
149
153
  readonly name: "tabId";
150
154
  readonly type: "number";
155
+ readonly required: true;
151
156
  readonly description: "目标标签页 ID,从 tab_list 获取";
152
157
  }, {
153
158
  readonly name: "apiName";
@@ -175,33 +180,40 @@ export declare const COMMANDS: readonly [{
175
180
  readonly type: "object";
176
181
  readonly description: "请求 query/body 字段子集匹配;$index 从 0 开始指定调用顺序";
177
182
  }];
178
- readonly examples: ["set_mock --payload '{\"apiName\":\"mtop.cart.query\",\"mockData\":{\"ret\":[\"SUCCESS::调用成功\"]}}'", "set_mock --payload-file ./mock-data.json"];
183
+ readonly examples: ["set_mock --payload '{\"tabId\":12345,\"apiName\":\"mtop.cart.query\",\"mockData\":{\"ret\":[\"SUCCESS::调用成功\"]}}'", "set_mock --payload-file ./mock-data.json"];
179
184
  }, {
180
185
  readonly name: "get_mocks";
181
186
  readonly description: "查看当前生效的 mock 列表";
182
187
  readonly params: [{
183
188
  readonly name: "tabId";
184
189
  readonly type: "number";
190
+ readonly required: true;
185
191
  readonly description: "目标标签页 ID,从 tab_list 获取";
186
192
  }, {
187
193
  readonly name: "apiName";
188
194
  readonly type: "string";
189
195
  readonly description: "按 API 名称或正则表达式过滤";
190
196
  }];
191
- readonly examples: ["get_mocks"];
197
+ readonly examples: ["get_mocks --payload '{\"tabId\":12345}'"];
192
198
  }, {
193
199
  readonly name: "set_rule";
194
- readonly description: "添加 Chrome declarativeNetRequest 规则(重定向/修改请求头/拦截请求)";
200
+ readonly description: "添加浏览器请求规则;enabled=false 且传 ruleId 时彻底删除规则";
195
201
  readonly params: [{
202
+ readonly name: "ruleId";
203
+ readonly type: "number";
204
+ readonly description: "删除时必填,从 get_rules 获取";
205
+ }, {
206
+ readonly name: "enabled";
207
+ readonly type: "boolean";
208
+ readonly description: "省略时添加;false 时按 ruleId 删除";
209
+ }, {
196
210
  readonly name: "actionType";
197
211
  readonly type: "\"redirect\" | \"block\" | \"allow\" | \"upgradeScheme\" | \"modifyHeaders\"";
198
- readonly required: true;
199
- readonly description: "规则动作";
212
+ readonly description: "添加时必填,规则动作";
200
213
  }, {
201
214
  readonly name: "filter";
202
215
  readonly type: "string";
203
- readonly required: true;
204
- readonly description: "URL 过滤表达式";
216
+ readonly description: "添加时必填,URL 过滤表达式";
205
217
  }, {
206
218
  readonly name: "redirectUrl";
207
219
  readonly type: "string";
@@ -231,10 +243,10 @@ export declare const COMMANDS: readonly [{
231
243
  readonly type: "string";
232
244
  readonly description: "规则说明";
233
245
  }];
234
- readonly examples: ["set_rule --payload '{\"actionType\":\"block\",\"filter\":\"^https://example\\\\.com/ads/.*\"}'"];
246
+ readonly examples: ["set_rule --payload '{\"actionType\":\"block\",\"filter\":\"^https://example\\\\.com/ads/.*\"}'", "set_rule --payload '{\"ruleId\":42,\"enabled\":false}'"];
235
247
  }, {
236
248
  readonly name: "get_rules";
237
- readonly description: "查看当前存储的全部请求规则(含 Options 面板配置的)";
249
+ readonly description: "查看当前模式的请求规则;扩展模式包含 Options 面板配置的规则";
238
250
  readonly examples: ["get_rules"];
239
251
  }, {
240
252
  readonly name: "send_request";
@@ -452,6 +464,26 @@ export declare const COMMANDS: readonly [{
452
464
  readonly description: "列出目标浏览器所有窗口中的标签页";
453
465
  readonly aliases: readonly ["tabs", "list_tabs", "show_tabs"];
454
466
  readonly examples: ["tab_list"];
467
+ }, {
468
+ readonly name: "tab_group";
469
+ readonly description: "把同一窗口中的标签页加入分组,或通过 ungroup 取消分组并保留标签页;仅扩展模式支持";
470
+ readonly params: [{
471
+ readonly name: "tabIds";
472
+ readonly type: "number[]";
473
+ readonly required: true;
474
+ readonly description: "标签页 ID,分组最多 100 个,取消分组最多 1000 个";
475
+ }, {
476
+ readonly name: "title";
477
+ readonly type: "string";
478
+ readonly required: false;
479
+ readonly description: "分组标题;取消分组时省略";
480
+ }, {
481
+ readonly name: "ungroup";
482
+ readonly type: "boolean";
483
+ readonly required: false;
484
+ readonly description: "为 true 时取消分组并保留标签页";
485
+ }];
486
+ readonly examples: ["tab_group --payload '{\"tabIds\":[123,124],\"title\":\"项目文档\"}'", "tab_group --payload '{\"tabIds\":[123,124],\"ungroup\":true}'"];
455
487
  }, {
456
488
  readonly name: "page_click";
457
489
  readonly description: "点击页面元素,支持 CSS/@ref、可见文本或视口坐标定位";
package/dist/commands.js CHANGED
@@ -17,14 +17,26 @@ export const COMMANDS = [
17
17
  {
18
18
  name: 'tab_checkpoint',
19
19
  description: '为目标标签页建立日志、请求和埋点增量边界',
20
- params: [{ name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_open 获取' }],
20
+ params: [
21
+ {
22
+ name: 'tabId',
23
+ type: 'number',
24
+ required: true,
25
+ description: '目标标签页 ID,从 tab_open 获取',
26
+ },
27
+ ],
21
28
  examples: [`tab_checkpoint --payload '{"tabId":12345}'`],
22
29
  },
23
30
  {
24
31
  name: 'get_requests',
25
32
  description: '获取最近的网络请求(mtop 或普通 xhr/fetch)',
26
33
  params: [
27
- { name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_list 获取' },
34
+ {
35
+ name: 'tabId',
36
+ type: 'number',
37
+ required: true,
38
+ description: '目标标签页 ID,从 tab_list 获取',
39
+ },
28
40
  { name: 'count', type: 'number', description: '返回条数,默认 10' },
29
41
  {
30
42
  name: 'source',
@@ -45,15 +57,20 @@ export const COMMANDS = [
45
57
  { name: 'keysOnly', type: 'boolean', description: '只返回数据结构,不返回叶子值' },
46
58
  ],
47
59
  examples: [
48
- `get_requests --payload '{"count":5}'`,
49
- `get_requests --payload '{"source":"mtop","filter":"cart"}'`,
60
+ `get_requests --payload '{"tabId":12345,"count":5}'`,
61
+ `get_requests --payload '{"tabId":12345,"source":"mtop","filter":"cart"}'`,
50
62
  ],
51
63
  },
52
64
  {
53
65
  name: 'get_logs',
54
66
  description: '获取浏览器控制台日志',
55
67
  params: [
56
- { name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_list 获取' },
68
+ {
69
+ name: 'tabId',
70
+ type: 'number',
71
+ required: true,
72
+ description: '目标标签页 ID,从 tab_list 获取',
73
+ },
57
74
  { name: 'limit', type: 'number', description: '返回最新 N 条,默认 100' },
58
75
  { name: 'level', type: 'string', description: '按日志级别过滤:log/info/warn/error/all' },
59
76
  { name: 'filter', type: 'string', description: '按内容过滤,支持正则' },
@@ -64,13 +81,18 @@ export const COMMANDS = [
64
81
  description: '只返回指定 tab checkpoint 或同类查询 cursor 之后的日志',
65
82
  },
66
83
  ],
67
- examples: [`get_logs --payload '{"limit":10,"level":"error"}'`],
84
+ examples: [`get_logs --payload '{"tabId":12345,"limit":10,"level":"error"}'`],
68
85
  },
69
86
  {
70
87
  name: 'get_events',
71
88
  description: '获取 RUM/aplus/ARMS 埋点事件',
72
89
  params: [
73
- { name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_list 获取' },
90
+ {
91
+ name: 'tabId',
92
+ type: 'number',
93
+ required: true,
94
+ description: '目标标签页 ID,从 tab_list 获取',
95
+ },
74
96
  {
75
97
  name: 'source',
76
98
  type: '"rum" | "aplus" | "arms" | "all"',
@@ -88,8 +110,8 @@ export const COMMANDS = [
88
110
  },
89
111
  ],
90
112
  examples: [
91
- `get_events --payload '{"source":"aplus","event_type":"CLK","limit":10}'`,
92
- `get_events --payload '{"filter":"order","includeRaw":true,"limit":1}'`,
113
+ `get_events --payload '{"tabId":12345,"source":"aplus","event_type":"CLK","limit":10}'`,
114
+ `get_events --payload '{"tabId":12345,"filter":"order","includeRaw":true,"limit":1}'`,
93
115
  `get_events --payload '{"tabId":12345,"source":"all","limit":20}'`,
94
116
  ],
95
117
  },
@@ -98,7 +120,12 @@ export const COMMANDS = [
98
120
  name: 'set_mock',
99
121
  description: '设置 API mock 数据',
100
122
  params: [
101
- { name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_list 获取' },
123
+ {
124
+ name: 'tabId',
125
+ type: 'number',
126
+ required: true,
127
+ description: '目标标签页 ID,从 tab_list 获取',
128
+ },
102
129
  { name: 'apiName', type: 'string', required: true, description: 'API 名称或正则表达式' },
103
130
  { name: 'mockData', type: 'object', description: '完整 mock 响应数据(与 fields 二选一)' },
104
131
  {
@@ -123,7 +150,7 @@ export const COMMANDS = [
123
150
  },
124
151
  ],
125
152
  examples: [
126
- `set_mock --payload '{"apiName":"mtop.cart.query","mockData":{"ret":["SUCCESS::调用成功"]}}'`,
153
+ `set_mock --payload '{"tabId":12345,"apiName":"mtop.cart.query","mockData":{"ret":["SUCCESS::调用成功"]}}'`,
127
154
  `set_mock --payload-file ./mock-data.json`,
128
155
  ],
129
156
  },
@@ -131,22 +158,28 @@ export const COMMANDS = [
131
158
  name: 'get_mocks',
132
159
  description: '查看当前生效的 mock 列表',
133
160
  params: [
134
- { name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_list 获取' },
161
+ {
162
+ name: 'tabId',
163
+ type: 'number',
164
+ required: true,
165
+ description: '目标标签页 ID,从 tab_list 获取',
166
+ },
135
167
  { name: 'apiName', type: 'string', description: '按 API 名称或正则表达式过滤' },
136
168
  ],
137
- examples: ['get_mocks'],
169
+ examples: [`get_mocks --payload '{"tabId":12345}'`],
138
170
  },
139
171
  {
140
172
  name: 'set_rule',
141
- description: '添加 Chrome declarativeNetRequest 规则(重定向/修改请求头/拦截请求)',
173
+ description: '添加浏览器请求规则;enabled=false 且传 ruleId 时彻底删除规则',
142
174
  params: [
175
+ { name: 'ruleId', type: 'number', description: '删除时必填,从 get_rules 获取' },
176
+ { name: 'enabled', type: 'boolean', description: '省略时添加;false 时按 ruleId 删除' },
143
177
  {
144
178
  name: 'actionType',
145
179
  type: '"redirect" | "block" | "allow" | "upgradeScheme" | "modifyHeaders"',
146
- required: true,
147
- description: '规则动作',
180
+ description: '添加时必填,规则动作',
148
181
  },
149
- { name: 'filter', type: 'string', required: true, description: 'URL 过滤表达式' },
182
+ { name: 'filter', type: 'string', description: '添加时必填,URL 过滤表达式' },
150
183
  { name: 'redirectUrl', type: 'string', description: 'redirect 动作的目标 URL' },
151
184
  {
152
185
  name: 'requestHeaders',
@@ -165,11 +198,12 @@ export const COMMANDS = [
165
198
  ],
166
199
  examples: [
167
200
  `set_rule --payload '{"actionType":"block","filter":"^https://example\\\\.com/ads/.*"}'`,
201
+ `set_rule --payload '{"ruleId":42,"enabled":false}'`,
168
202
  ],
169
203
  },
170
204
  {
171
205
  name: 'get_rules',
172
- description: '查看当前存储的全部请求规则(含 Options 面板配置的)',
206
+ description: '查看当前模式的请求规则;扩展模式包含 Options 面板配置的规则',
173
207
  examples: ['get_rules'],
174
208
  },
175
209
  // ── 网络代理 ──────────────────────────────────────────────────────────────
@@ -389,6 +423,29 @@ export const COMMANDS = [
389
423
  aliases: ['tabs', 'list_tabs', 'show_tabs'],
390
424
  examples: ['tab_list'],
391
425
  },
426
+ {
427
+ name: 'tab_group',
428
+ description: '把同一窗口中的标签页加入分组,或通过 ungroup 取消分组并保留标签页;仅扩展模式支持',
429
+ params: [
430
+ {
431
+ name: 'tabIds',
432
+ type: 'number[]',
433
+ required: true,
434
+ description: '标签页 ID,分组最多 100 个,取消分组最多 1000 个',
435
+ },
436
+ { name: 'title', type: 'string', required: false, description: '分组标题;取消分组时省略' },
437
+ {
438
+ name: 'ungroup',
439
+ type: 'boolean',
440
+ required: false,
441
+ description: '为 true 时取消分组并保留标签页',
442
+ },
443
+ ],
444
+ examples: [
445
+ `tab_group --payload '{"tabIds":[123,124],"title":"项目文档"}'`,
446
+ `tab_group --payload '{"tabIds":[123,124],"ungroup":true}'`,
447
+ ],
448
+ },
392
449
  // ── 页面操作 ──────────────────────────────────────────────────────────────
393
450
  {
394
451
  name: 'page_click',
@@ -1,5 +1,5 @@
1
1
  export interface GetRequestsParams {
2
- tabId?: number;
2
+ tabId: number;
3
3
  count?: number;
4
4
  filter?: string;
5
5
  /** Relative time window in seconds. */
@@ -15,7 +15,7 @@ export interface GetRequestsParams {
15
15
  source?: 'mtop' | 'requests' | 'all';
16
16
  }
17
17
  export interface GetLogsParams {
18
- tabId?: number;
18
+ tabId: number;
19
19
  level?: 'log' | 'warn' | 'error' | 'info' | 'all';
20
20
  /** Relative time window in seconds. */
21
21
  since?: number;
@@ -25,7 +25,7 @@ export interface GetLogsParams {
25
25
  filter?: string;
26
26
  }
27
27
  export interface CaptureCheckpointParams {
28
- tabId?: number;
28
+ tabId: number;
29
29
  }
30
30
  export interface CaptureCheckpointResult {
31
31
  tabId: number;
@@ -34,7 +34,7 @@ export interface CaptureCheckpointResult {
34
34
  captureStatus: 'armed' | 'active';
35
35
  }
36
36
  export interface GetEventsParams {
37
- tabId?: number;
37
+ tabId: number;
38
38
  source?: 'rum' | 'aplus' | 'arms' | 'all';
39
39
  event_type?: string;
40
40
  filter?: string;
@@ -45,7 +45,7 @@ export interface GetEventsParams {
45
45
  includeRaw?: boolean;
46
46
  }
47
47
  export interface SetMockParams {
48
- tabId?: number;
48
+ tabId: number;
49
49
  apiName: string;
50
50
  mockData?: unknown;
51
51
  fields?: Array<{
@@ -57,7 +57,7 @@ export interface SetMockParams {
57
57
  conditions?: Record<string, unknown>;
58
58
  }
59
59
  export interface GetMocksParams {
60
- tabId?: number;
60
+ tabId: number;
61
61
  apiName?: string;
62
62
  }
63
63
  export declare const SEND_REQUEST_MAX_FILES = 20;
@@ -319,7 +319,8 @@ export interface BrowserAccessResult {
319
319
  sensitive: true;
320
320
  };
321
321
  }
322
- export interface SetRuleParams {
322
+ export interface AddRuleParams {
323
+ enabled?: true;
323
324
  actionType: 'redirect' | 'block' | 'allow' | 'upgradeScheme' | 'modifyHeaders';
324
325
  filter: string;
325
326
  redirectUrl?: string;
@@ -338,6 +339,11 @@ export interface SetRuleParams {
338
339
  priority?: number;
339
340
  description?: string;
340
341
  }
342
+ export interface DeleteRuleParams {
343
+ enabled: false;
344
+ ruleId: number;
345
+ }
346
+ export type SetRuleParams = AddRuleParams | DeleteRuleParams;
341
347
  export interface RulesResult {
342
348
  enabled: boolean;
343
349
  rules: Array<Record<string, unknown>>;
@@ -403,6 +409,15 @@ export interface TabOpenParams {
403
409
  /** 与 appProfile 配合使用;按方法覆盖档案内置桥配置 */
404
410
  bridgeConfig?: AppBridgeConfig;
405
411
  }
412
+ export type TabGroupParams = {
413
+ tabIds: number[];
414
+ title: string;
415
+ ungroup?: false;
416
+ } | {
417
+ tabIds: number[];
418
+ ungroup: true;
419
+ title?: never;
420
+ };
406
421
  /**
407
422
  * 客户端容器模拟可用档案名。
408
423
  *
@@ -727,6 +742,10 @@ export interface BrowserActionMap {
727
742
  request: undefined;
728
743
  response: unknown;
729
744
  };
745
+ tab_group: {
746
+ request: TabGroupParams;
747
+ response: unknown;
748
+ };
730
749
  page_click: {
731
750
  request: PageClickParams;
732
751
  response: unknown;
@@ -813,7 +832,7 @@ export type BrowserActionRequest<A extends BrowserAction> = BrowserActionMap[A][
813
832
  export type BrowserActionResponse<A extends BrowserAction> = BrowserActionMap[A]['response'];
814
833
  export type BrowserCommandAction = Exclude<BrowserAction, 'browser_select_browser'>;
815
834
  export type ExtensionBrowserAction = Exclude<BrowserCommandAction, 'browser_list' | 'browser_launch' | 'browser_close'>;
816
- export declare const TAB_ID_REQUIRED_ACTIONS: readonly ["page_screenshot", "tab_close", "page_click", "page_drag", "page_type", "page_scroll", "page_hover", "page_eval", "page_inspect", "page_snapshot", "page_press", "page_wait", "page_navigate", "page_upload", "page_frames", "set_device_emulation", "set_app_profile", "set_timezone", "get_cookie", "set_cookie", "run_actions"];
835
+ export declare const TAB_ID_REQUIRED_ACTIONS: readonly ["tab_checkpoint", "capture_checkpoint", "get_requests", "get_logs", "get_events", "set_mock", "get_mocks", "page_screenshot", "tab_close", "page_click", "page_drag", "page_type", "page_scroll", "page_hover", "page_eval", "page_inspect", "page_snapshot", "page_press", "page_wait", "page_navigate", "page_upload", "page_frames", "set_device_emulation", "set_app_profile", "set_timezone", "get_cookie", "set_cookie", "run_actions"];
817
836
  export type TabIdRequiredAction = (typeof TAB_ID_REQUIRED_ACTIONS)[number];
818
837
  export declare function actionRequiresTabId(action: unknown): action is TabIdRequiredAction;
819
838
  export declare function validateRequiredActionTabId(action: string, data: unknown): void;
@@ -840,6 +859,7 @@ export declare const BROWSER_ACTIONS: {
840
859
  readonly tab_open: true;
841
860
  readonly tab_close: true;
842
861
  readonly tab_list: true;
862
+ readonly tab_group: true;
843
863
  readonly page_click: true;
844
864
  readonly page_drag: true;
845
865
  readonly page_type: true;
@@ -881,6 +901,7 @@ export declare const BROWSER_COMMAND_ACTIONS: {
881
901
  readonly tab_open: true;
882
902
  readonly tab_close: true;
883
903
  readonly tab_list: true;
904
+ readonly tab_group: true;
884
905
  readonly page_click: true;
885
906
  readonly page_drag: true;
886
907
  readonly page_type: true;
@@ -919,6 +940,7 @@ export declare const EXTENSION_BROWSER_ACTIONS: {
919
940
  readonly tab_open: true;
920
941
  readonly tab_close: true;
921
942
  readonly tab_list: true;
943
+ readonly tab_group: true;
922
944
  readonly page_click: true;
923
945
  readonly page_drag: true;
924
946
  readonly page_type: true;
@@ -51,6 +51,13 @@ export const APP_PROFILE_NAMES = [
51
51
  'easybike',
52
52
  ];
53
53
  export const TAB_ID_REQUIRED_ACTIONS = [
54
+ 'tab_checkpoint',
55
+ 'capture_checkpoint',
56
+ 'get_requests',
57
+ 'get_logs',
58
+ 'get_events',
59
+ 'set_mock',
60
+ 'get_mocks',
54
61
  'page_screenshot',
55
62
  'tab_close',
56
63
  'page_click',
@@ -118,6 +125,7 @@ export const BROWSER_ACTIONS = {
118
125
  tab_open: true,
119
126
  tab_close: true,
120
127
  tab_list: true,
128
+ tab_group: true,
121
129
  page_click: true,
122
130
  page_drag: true,
123
131
  page_type: true,
@@ -159,6 +167,7 @@ export const BROWSER_COMMAND_ACTIONS = {
159
167
  tab_open: true,
160
168
  tab_close: true,
161
169
  tab_list: true,
170
+ tab_group: true,
162
171
  page_click: true,
163
172
  page_drag: true,
164
173
  page_type: true,
@@ -197,6 +206,7 @@ export const EXTENSION_BROWSER_ACTIONS = {
197
206
  tab_open: true,
198
207
  tab_close: true,
199
208
  tab_list: true,
209
+ tab_group: true,
200
210
  page_click: true,
201
211
  page_drag: true,
202
212
  page_type: true,
package/dist/index.d.ts CHANGED
@@ -11,14 +11,14 @@ export { APP_PROFILE_NAMES, BROWSER_DEVICE_PRESET_NAMES, BROWSER_ACTIONS, BROWSE
11
11
  export type { ActionStep, AppProfileName, BrowserAction, BrowserActionMap, BrowserActionRequest, BrowserActionResponse, BrowserCapabilities, BrowserCapabilityAction, BrowserCloseParams, BrowserCommandAction, BrowserInfo, BrowserInfoBase, BrowserJsonValue, BrowserLaunchParams, BrowserProviderOperation, BrowserListResult, BrowserPairingInfo, BrowserReleaseFailure, BrowserReleaseResult, BrowserProviderDefinition, BrowserProviderIdentity, BrowserProviderInputSchema, BrowserProviderListResult, BrowserReference, BrowserDetails, BrowserSource, BrowserStatus, BrowserScreenshotKind, BrowserTransport, CaptureCheckpointParams, CaptureCheckpointResult, BrowserDevicePresetName, BrowserEmulationOptions, ExtensionBrowserAction, GetCookieParams, GetCookieResult, GetEventsParams, GetLogsParams, GetMocksParams, GetRequestsParams, ManagedBrowserInfo, PageClickParams, PageDragEndpoint, PageDragParams, PageDragPoint, PageActAction, PageDiagnosticsOptions, PageDiagnosticsSetting, PageEvalParams, PageFramesParams, PageHoverParams, PageInspectFilter, PageInspectParams, PageNavigateParams, PageObservationWaitOptions, PagePressParams, PageScreenshotParams, PageScrollParams, PageSnapshotParams, PageSnapshotQuery, PageTypeParams, PageUploadParams, PageWaitParams, RegularBrowserInfo, RequestDomainPermissionParams, RulesResult, RunActionName, RunActionsParams, SelectBrowserParams, SelectBrowserResult, SendRequestFile, SendRequestFormValue, SendMtopRequestParams, SendRequestParams, SetAppProfileParams, SetCookieParams, SetCookieResult, SetDeviceEmulationParams, SetMockParams, SetRuleParams, SetTimezoneParams, SetTimezoneResult, TabCloseParams, TabOpenParams, } from './generated-browser-action-protocol.js';
12
12
  import { type UnifiedInvokeOptions } from './unified.js';
13
13
  import type * as Protocol from './generated-browser-action-protocol.js';
14
- export declare function tabCheckpoint(params?: Protocol.CaptureCheckpointParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_checkpoint'>>;
14
+ export declare function tabCheckpoint(params: Protocol.CaptureCheckpointParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_checkpoint'>>;
15
15
  /** Compatibility wrapper for tabCheckpoint. */
16
- export declare function captureCheckpoint(params?: Protocol.CaptureCheckpointParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_checkpoint'>>;
17
- export declare function getRequests(params?: Protocol.GetRequestsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_requests'>>;
18
- export declare function getLogs(params?: Protocol.GetLogsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_logs'>>;
19
- export declare function getEvents(params?: Protocol.GetEventsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_events'>>;
16
+ export declare function captureCheckpoint(params: Protocol.CaptureCheckpointParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_checkpoint'>>;
17
+ export declare function getRequests(params: Protocol.GetRequestsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_requests'>>;
18
+ export declare function getLogs(params: Protocol.GetLogsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_logs'>>;
19
+ export declare function getEvents(params: Protocol.GetEventsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_events'>>;
20
20
  export declare function setMock(params: Protocol.SetMockParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_mock'>>;
21
- export declare function getMocks(params?: Protocol.GetMocksParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_mocks'>>;
21
+ export declare function getMocks(params: Protocol.GetMocksParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_mocks'>>;
22
22
  export declare function sendRequest(params: Protocol.SendRequestParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'send_request'>>;
23
23
  export declare function sendMtopRequest(params: Protocol.SendMtopRequestParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'send_mtop_request'>>;
24
24
  export declare function browserList(options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'browser_list'>>;
@@ -32,6 +32,7 @@ export declare function pageScreenshot(params: Protocol.PageScreenshotParams, op
32
32
  export declare function tabOpen(params: Protocol.TabOpenParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_open'>>;
33
33
  export declare function tabClose(params: Protocol.TabCloseParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_close'>>;
34
34
  export declare function tabList(options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_list'>>;
35
+ export declare function tabGroup(params: Protocol.TabGroupParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_group'>>;
35
36
  export declare function pageClick(params: Protocol.PageClickParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'page_click'>>;
36
37
  export declare function pageDrag(params: Protocol.PageDragParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'page_drag'>>;
37
38
  export declare function pageType(params: Protocol.PageTypeParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'page_type'>>;
package/dist/index.js CHANGED
@@ -7,26 +7,26 @@
7
7
  export { UnifiedClient, UnifiedClient as MearlClient, decodeBrowserTarget, invoke, invokePlugin, listCloudConnectors, } from './unified.js';
8
8
  export { APP_PROFILE_NAMES, BROWSER_DEVICE_PRESET_NAMES, BROWSER_ACTIONS, BROWSER_COMMAND_ACTIONS, EXTENSION_BROWSER_ACTIONS, PAGE_ACT_ACTIONS, SEND_REQUEST_MAX_FILES, SEND_REQUEST_MAX_TOTAL_BASE64_FILE_BYTES, SEND_REQUEST_MAX_TOTAL_FILE_BYTES, isBrowserAction, isBrowserCapabilityAction, isBrowserCommandAction, isExtensionBrowserAction, } from './generated-browser-action-protocol.js';
9
9
  import { invoke } from './unified.js';
10
- export function tabCheckpoint(params = {}, options) {
10
+ export function tabCheckpoint(params, options) {
11
11
  return invoke('tab_checkpoint', params, options);
12
12
  }
13
13
  /** Compatibility wrapper for tabCheckpoint. */
14
- export function captureCheckpoint(params = {}, options) {
14
+ export function captureCheckpoint(params, options) {
15
15
  return tabCheckpoint(params, options);
16
16
  }
17
- export function getRequests(params = {}, options) {
17
+ export function getRequests(params, options) {
18
18
  return invoke('get_requests', params, options);
19
19
  }
20
- export function getLogs(params = {}, options) {
20
+ export function getLogs(params, options) {
21
21
  return invoke('get_logs', params, options);
22
22
  }
23
- export function getEvents(params = {}, options) {
23
+ export function getEvents(params, options) {
24
24
  return invoke('get_events', params, options);
25
25
  }
26
26
  export function setMock(params, options) {
27
27
  return invoke('set_mock', params, options);
28
28
  }
29
- export function getMocks(params = {}, options) {
29
+ export function getMocks(params, options) {
30
30
  return invoke('get_mocks', params, options);
31
31
  }
32
32
  export function sendRequest(params, options) {
@@ -68,6 +68,9 @@ export function tabClose(params, options) {
68
68
  export function tabList(options) {
69
69
  return invoke('tab_list', {}, options);
70
70
  }
71
+ export function tabGroup(params, options) {
72
+ return invoke('tab_group', params, options);
73
+ }
71
74
  export function pageClick(params, options) {
72
75
  return invoke('page_click', params, options);
73
76
  }
@@ -9,9 +9,13 @@ export declare const OFFICIAL_PLUGINS: {
9
9
  readonly buc: {
10
10
  readonly description: "使用 BUC 身份请求内部服务";
11
11
  readonly installArgs: readonly ["trip/mearl", "--skill", "buc-request", "--yes"];
12
- readonly setup: "alibaba";
13
12
  readonly skill: "buc-request";
14
13
  };
14
+ readonly authx: {
15
+ readonly description: "使用 AuthX 身份请求内部服务";
16
+ readonly installArgs: readonly ["trip/mearl", "--skill", "authx-request", "--yes"];
17
+ readonly skill: "authx-request";
18
+ };
15
19
  readonly tdbank: {
16
20
  readonly description: "查询、借用和切换 TDBank 测试账号";
17
21
  readonly installArgs: readonly ["trip/mearl", "--skill", "tdbank-account", "--yes"];
@@ -3,9 +3,13 @@ export const OFFICIAL_PLUGINS = {
3
3
  buc: {
4
4
  description: '使用 BUC 身份请求内部服务',
5
5
  installArgs: ['trip/mearl', '--skill', 'buc-request', '--yes'],
6
- setup: 'alibaba',
7
6
  skill: 'buc-request',
8
7
  },
8
+ authx: {
9
+ description: '使用 AuthX 身份请求内部服务',
10
+ installArgs: ['trip/mearl', '--skill', 'authx-request', '--yes'],
11
+ skill: 'authx-request',
12
+ },
9
13
  tdbank: {
10
14
  description: '查询、借用和切换 TDBank 测试账号',
11
15
  installArgs: ['trip/mearl', '--skill', 'tdbank-account', '--yes'],
package/dist/plugin.js CHANGED
@@ -187,7 +187,7 @@ export async function loadPlugin(entry, context, pluginName) {
187
187
  '',
188
188
  '常用选项: --browser --timeout --compact --output',
189
189
  '连接或传输排障运行 mearl check --help。',
190
- '插件选项: --name=value 传入字符串业务字段;--verbose; -h, --help; -v, --version',
190
+ '插件选项: --name=value 传入字符串业务字段;--all 传入 all=true;--verbose; -h, --help; -v, --version',
191
191
  '同名宿主选项及非字符串字段使用 --payload;业务字段与校验规则见对应 skill。',
192
192
  ].join('\n');
193
193
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/client",
3
- "version": "2.19.0",
3
+ "version": "2.19.2",
4
4
  "description": "Unified Mearl SDK & CLI for local and remote browsers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -59,8 +59,8 @@
59
59
  "commander": "^15.0.0",
60
60
  "fastest-levenshtein": "^1.0.16",
61
61
  "ws": "^8.18.0",
62
- "@mearl/provider": "2.19.0",
63
- "@mearl/cloud-types": "2.19.0"
62
+ "@mearl/cloud-types": "2.19.2",
63
+ "@mearl/provider": "2.19.2"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/node": "^24.9.1",