@mearl/client 2.7.3 → 2.8.1

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/cli.js CHANGED
@@ -13,12 +13,16 @@ const CATEGORIES = [
13
13
  names: ['tab_checkpoint', 'get_requests', 'get_logs', 'get_events', 'get_api_schema'],
14
14
  },
15
15
  { title: 'Mock & 规则', names: ['set_mock', 'get_mocks', 'set_rule', 'get_rules'] },
16
- { title: '网络代理', names: ['send_request', 'send_mtop_request'] },
16
+ {
17
+ title: '网络代理',
18
+ names: ['send_request', 'send_mtop_request', 'request_domain_permission'],
19
+ },
17
20
  { title: '标签页', names: ['tab_open', 'tab_close', 'tab_list'] },
18
21
  {
19
22
  title: '页面操作',
20
23
  names: [
21
24
  'page_click',
25
+ 'page_drag',
22
26
  'page_type',
23
27
  'page_hover',
24
28
  'page_scroll',
@@ -36,7 +40,7 @@ const CATEGORIES = [
36
40
  },
37
41
  {
38
42
  title: '环境与 Cookie',
39
- names: ['set_device_emulation', 'set_timezone', 'get_cookie', 'set_cookie'],
43
+ names: ['set_device_emulation', 'set_app_profile', 'set_timezone', 'get_cookie', 'set_cookie'],
40
44
  },
41
45
  { title: '用户信息', names: ['get_user_info'] },
42
46
  { title: '录制', names: ['record_start', 'record_stop'] },
@@ -289,8 +293,10 @@ export async function runMearlCli(args, options = {}) {
289
293
  return 0;
290
294
  }
291
295
  if (args[0] !== 'check' && args[0] !== 'connector_list' && !COMMAND_MAP.has(args[0])) {
292
- printUnknownCommand(commandName, args);
293
- return 2;
296
+ if (!args[0].startsWith('__')) {
297
+ printUnknownCommand(commandName, args);
298
+ return 2;
299
+ }
294
300
  }
295
301
  let parsed;
296
302
  try {
@@ -1,4 +1,4 @@
1
- import type { BrowserCommandAction } from './generated-browser-action-protocol.js';
1
+ import { type BrowserCommandAction } from './generated-browser-action-protocol.js';
2
2
  export interface ParamDef {
3
3
  name: string;
4
4
  type: string;
@@ -56,6 +56,22 @@ export declare const COMMANDS: readonly [{
56
56
  readonly name: "includeBody";
57
57
  readonly type: "boolean";
58
58
  readonly description: "是否包含请求/响应体,默认 true";
59
+ }, {
60
+ readonly name: "includeHeaders";
61
+ readonly type: "boolean";
62
+ readonly description: "是否包含请求/响应头,默认 false";
63
+ }, {
64
+ readonly name: "maxBodySize";
65
+ readonly type: "number";
66
+ readonly description: "单个请求/响应体最大字符数,默认 50000";
67
+ }, {
68
+ readonly name: "fields";
69
+ readonly type: "string[]";
70
+ readonly description: "从响应体提取指定字段路径,最多 100 个";
71
+ }, {
72
+ readonly name: "keysOnly";
73
+ readonly type: "boolean";
74
+ readonly description: "只返回数据结构,不返回叶子值";
59
75
  }];
60
76
  readonly examples: ["get_requests --payload '{\"count\":5}'", "get_requests --payload '{\"source\":\"mtop\",\"filter\":\"cart\"}'"];
61
77
  }, {
@@ -72,7 +88,7 @@ export declare const COMMANDS: readonly [{
72
88
  }, {
73
89
  readonly name: "level";
74
90
  readonly type: "string";
75
- readonly description: "按日志级别过滤:log/info/warn/error";
91
+ readonly description: "按日志级别过滤:log/info/warn/error/all";
76
92
  }, {
77
93
  readonly name: "filter";
78
94
  readonly type: "string";
@@ -132,6 +148,10 @@ export declare const COMMANDS: readonly [{
132
148
  readonly type: "string";
133
149
  readonly required: true;
134
150
  readonly description: "API 名称";
151
+ }, {
152
+ readonly name: "version";
153
+ readonly type: "string";
154
+ readonly description: "API 版本,用于精确匹配接口定义";
135
155
  }, {
136
156
  readonly name: "fields";
137
157
  readonly type: "(\"schema\" | \"hsf\")[]";
@@ -188,7 +208,46 @@ export declare const COMMANDS: readonly [{
188
208
  }, {
189
209
  readonly name: "set_rule";
190
210
  readonly description: "添加 Chrome declarativeNetRequest 规则(重定向/修改请求头/拦截请求)";
191
- readonly examples: ["set_rule --payload '{\"rule\":{...}}'"];
211
+ readonly params: [{
212
+ readonly name: "actionType";
213
+ readonly type: "\"redirect\" | \"block\" | \"allow\" | \"upgradeScheme\" | \"modifyHeaders\"";
214
+ readonly required: true;
215
+ readonly description: "规则动作";
216
+ }, {
217
+ readonly name: "filter";
218
+ readonly type: "string";
219
+ readonly required: true;
220
+ readonly description: "URL 过滤表达式";
221
+ }, {
222
+ readonly name: "redirectUrl";
223
+ readonly type: "string";
224
+ readonly description: "redirect 动作的目标 URL";
225
+ }, {
226
+ readonly name: "requestHeaders";
227
+ readonly type: "array";
228
+ readonly description: "modifyHeaders 动作的请求头修改列表";
229
+ }, {
230
+ readonly name: "responseHeaders";
231
+ readonly type: "array";
232
+ readonly description: "modifyHeaders 动作的响应头修改列表";
233
+ }, {
234
+ readonly name: "initiatorDomains";
235
+ readonly type: "string";
236
+ readonly description: "发起方域名过滤";
237
+ }, {
238
+ readonly name: "resourceTypes";
239
+ readonly type: "string[]";
240
+ readonly description: "资源类型过滤";
241
+ }, {
242
+ readonly name: "priority";
243
+ readonly type: "number";
244
+ readonly description: "规则优先级";
245
+ }, {
246
+ readonly name: "description";
247
+ readonly type: "string";
248
+ readonly description: "规则说明";
249
+ }];
250
+ readonly examples: ["set_rule --payload '{\"actionType\":\"block\",\"filter\":\"^https://example\\\\.com/ads/.*\"}'"];
192
251
  }, {
193
252
  readonly name: "get_rules";
194
253
  readonly description: "查看当前存储的全部请求规则(含 Options 面板配置的)";
@@ -229,6 +288,10 @@ export declare const COMMANDS: readonly [{
229
288
  readonly name: "withCookies";
230
289
  readonly type: "boolean";
231
290
  readonly description: "是否附加浏览器 Cookie,默认 true";
291
+ }, {
292
+ readonly name: "responseType";
293
+ readonly type: "\"json\" | \"text\" | \"auto\"";
294
+ readonly description: "响应解析方式,默认 auto";
232
295
  }, {
233
296
  readonly name: "timeout";
234
297
  readonly type: "number";
@@ -237,7 +300,7 @@ export declare const COMMANDS: readonly [{
237
300
  readonly examples: ["send_request --payload '{\"url\":\"https://api.example.com/data\",\"method\":\"GET\"}'", "send_request --payload '{\"url\":\"https://api.example.com/upload\",\"method\":\"POST\",\"formData\":{\"folder\":\"assets\"},\"files\":[{\"fieldName\":\"file\",\"filePath\":\"/absolute/path/image.png\"}]}'"];
238
301
  }, {
239
302
  readonly name: "send_mtop_request";
240
- readonly description: "在页面上下文中发起 mtop 请求,自动处理签名和 token";
303
+ readonly description: "使用目标浏览器 Cookie 发起 mtop 请求,自动处理签名和 token";
241
304
  readonly params: [{
242
305
  readonly name: "api";
243
306
  readonly type: "string";
@@ -255,6 +318,10 @@ export declare const COMMANDS: readonly [{
255
318
  readonly name: "method";
256
319
  readonly type: "string";
257
320
  readonly description: "HTTP 方法,默认 GET";
321
+ }, {
322
+ readonly name: "appKey";
323
+ readonly type: "string";
324
+ readonly description: "签名使用的 appKey,默认 12574478";
258
325
  }, {
259
326
  readonly name: "env";
260
327
  readonly type: "\"online\" | \"pre\"";
@@ -280,6 +347,10 @@ export declare const COMMANDS: readonly [{
280
347
  readonly name: "refresh";
281
348
  readonly type: "boolean";
282
349
  readonly description: "list 时是否强制刷新账号列表";
350
+ }, {
351
+ readonly name: "pageIndex";
352
+ readonly type: "number";
353
+ readonly description: "list 时的页码,默认 1";
283
354
  }, {
284
355
  readonly name: "accountId";
285
356
  readonly type: "string | number";
@@ -300,7 +371,7 @@ export declare const COMMANDS: readonly [{
300
371
  readonly examples: ["tdbank_account --payload '{\"operation\":\"current\"}'", "tdbank_account --payload '{\"operation\":\"list\",\"refresh\":true}'", "tdbank_account --payload '{\"operation\":\"switch\",\"accountId\":12345}'", "tdbank_account --payload '{\"operation\":\"borrow\",\"query\":\"test_account\"}'"];
301
372
  }, {
302
373
  readonly name: "browser_list";
303
- readonly description: "列出所有浏览器及其连接状态、类型和托管实例信息;AgentBay 可包含镜像、持久化 Context 和串流地址";
374
+ readonly description: "列出所有浏览器及其连接状态、类型和托管实例信息;AgentBay 可包含镜像与持久化 Context";
304
375
  readonly examples: ["browser_list"];
305
376
  }, {
306
377
  readonly name: "browser_release";
@@ -427,8 +498,12 @@ export declare const COMMANDS: readonly [{
427
498
  readonly name: "emulation";
428
499
  readonly type: "object";
429
500
  readonly description: "开 tab 即进入移动端模拟态(首屏即移动态、无需 reload)。字段同 set_device_emulation 去掉 enabled,如 {\"preset\":\"iphone-15-pro\"}";
501
+ }, {
502
+ readonly name: "appProfile";
503
+ readonly type: "string";
504
+ readonly description: "开 tab 即进入 App 容器模拟态(客户端 UA + JSBridge 托管 + iframe 容器栈 + 自适应系统标题栏,首屏即容器态)。系统栏由 iframe 外层统一渲染,并根据页面协议与桥调用切换普通、沉浸或隐藏状态;档案名同 set_app_profile,如 \"fliggy\"";
430
505
  }];
431
- readonly examples: ["tab_open --payload '{\"url\":\"https://example.com\"}'", "tab_open --payload '{\"url\":\"https://example.com/page\",\"reuse\":\"prefer\",\"match\":{\"ignoreSearch\":true}}'", "tab_open --payload '{\"url\":\"https://m.example.com\",\"emulation\":{\"preset\":\"iphone-15-pro\"}}'", "tab_open --payload '{\"url\":\"https://example.com\",\"group\":\"验证任务\"}'"];
506
+ readonly examples: ["tab_open --payload '{\"url\":\"https://example.com\"}'", "tab_open --payload '{\"url\":\"https://example.com/page\",\"reuse\":\"prefer\",\"match\":{\"ignoreSearch\":true}}'", "tab_open --payload '{\"url\":\"https://m.example.com\",\"emulation\":{\"preset\":\"iphone-15-pro\"}}'", "tab_open --payload '{\"url\":\"https://market.m.taobao.com/app/trip/rx-home/pages/home\",\"appProfile\":\"fliggy\"}'", "tab_open --payload '{\"url\":\"https://example.com\",\"group\":\"验证任务\"}'"];
432
507
  }, {
433
508
  readonly name: "tab_close";
434
509
  readonly description: "关闭指定标签页";
@@ -853,6 +928,45 @@ export declare const COMMANDS: readonly [{
853
928
  readonly description: "目标标签页 ID";
854
929
  }];
855
930
  readonly examples: ["set_device_emulation --payload '{\"enabled\":true,\"preset\":\"iphone-15-pro\"}'", "set_device_emulation --payload '{\"enabled\":true,\"preset\":\"pixel-8\",\"orientation\":\"landscape\"}'", "set_device_emulation --payload '{\"enabled\":false}'"];
931
+ }, {
932
+ readonly name: "set_app_profile";
933
+ readonly description: "把目标 tab 切换为 App 容器模拟态(客户端 UA + JSBridge 托管 + 页面跳转 iframe 容器栈 + scheme 唤端映射 + 自适应系统标题栏),系统栏由 iframe 外层统一渲染,并根据页面协议与桥调用切换普通、沉浸或隐藏状态;用于桌面浏览器近似实机验证 App 内 H5,需保持调试控制才持续生效";
934
+ readonly params: [{
935
+ readonly name: "enabled";
936
+ readonly type: "boolean";
937
+ readonly required: true;
938
+ readonly description: "true=启用,false=清除";
939
+ }, {
940
+ readonly name: "profile";
941
+ readonly type: "string";
942
+ readonly description: `\u5BB9\u5668\u6863\u6848\u540D\uFF08enabled=true \u65F6\u5FC5\u586B\uFF09\uFF1A${string}`;
943
+ }, {
944
+ readonly name: "os";
945
+ readonly type: "\"ios\" | \"android\"";
946
+ readonly description: "容器系统,默认 ios";
947
+ }, {
948
+ readonly name: "appVersion";
949
+ readonly type: "string";
950
+ readonly description: "覆盖档案默认 App 版本号";
951
+ }, {
952
+ readonly name: "deviceModel";
953
+ readonly type: "string";
954
+ readonly description: "Android 机型名(拼入 UA 与 __DEVICE_MODEL__)";
955
+ }, {
956
+ readonly name: "emulation";
957
+ readonly type: "object";
958
+ readonly description: "覆盖档案推荐的设备模拟参数,字段同 set_device_emulation 去掉 enabled";
959
+ }, {
960
+ readonly name: "reload";
961
+ readonly type: "boolean";
962
+ readonly description: "应用/清除后是否重载页面,默认 true";
963
+ }, {
964
+ readonly name: "tabId";
965
+ readonly type: "number";
966
+ readonly required: true;
967
+ readonly description: "目标标签页 ID";
968
+ }];
969
+ readonly examples: ["set_app_profile --payload '{\"enabled\":true,\"profile\":\"fliggy\"}'", "set_app_profile --payload '{\"enabled\":true,\"profile\":\"alipay\",\"os\":\"android\",\"deviceModel\":\"Pixel 8 Pro\"}'", "set_app_profile --payload '{\"enabled\":false}'"];
856
970
  }, {
857
971
  readonly name: "set_timezone";
858
972
  readonly description: "覆盖目标 tab 的时区,传空字符串恢复浏览器默认时区";
@@ -957,6 +1071,6 @@ export declare const COMMANDS: readonly [{
957
1071
  readonly required: true;
958
1072
  readonly description: "所有步骤共享的 tabId,步骤自身指定的优先";
959
1073
  }];
960
- readonly examples: ["run_actions --payload '{\"actions\":[{\"action\":\"page_scroll\",\"data\":{\"direction\":\"down\"}},{\"action\":\"page_wait\",\"data\":{\"time\":500}},{\"action\":\"page_screenshot\"}]}'"];
1074
+ readonly examples: ["run_actions --payload '{\"tabId\":12345,\"actions\":[{\"action\":\"page_scroll\",\"data\":{\"direction\":\"down\"}},{\"action\":\"page_wait\",\"data\":{\"time\":500}},{\"action\":\"page_screenshot\"}]}'"];
961
1075
  }];
962
1076
  export declare const COMMAND_MAP: ReadonlyMap<string, CommandDef>;
package/dist/commands.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { APP_PROFILE_NAMES, } from './generated-browser-action-protocol.js';
2
+ /** 容器档案名列表(拼进参数说明,新增档案无需改本文件) */
3
+ const APP_PROFILE_NAME_LIST = APP_PROFILE_NAMES.join('/');
1
4
  const PAGE_DIAGNOSTICS_PARAM = {
2
5
  name: 'diagnostics',
3
6
  type: 'object | boolean',
@@ -35,6 +38,10 @@ export const COMMANDS = [
35
38
  description: '只返回指定 tab checkpoint 或同类查询 cursor 之后的请求',
36
39
  },
37
40
  { name: 'includeBody', type: 'boolean', description: '是否包含请求/响应体,默认 true' },
41
+ { name: 'includeHeaders', type: 'boolean', description: '是否包含请求/响应头,默认 false' },
42
+ { name: 'maxBodySize', type: 'number', description: '单个请求/响应体最大字符数,默认 50000' },
43
+ { name: 'fields', type: 'string[]', description: '从响应体提取指定字段路径,最多 100 个' },
44
+ { name: 'keysOnly', type: 'boolean', description: '只返回数据结构,不返回叶子值' },
38
45
  ],
39
46
  examples: [
40
47
  `get_requests --payload '{"count":5}'`,
@@ -47,7 +54,7 @@ export const COMMANDS = [
47
54
  params: [
48
55
  { name: 'tabId', type: 'number', description: '目标标签页 ID,从 tab_list 获取' },
49
56
  { name: 'limit', type: 'number', description: '返回最新 N 条,默认 100' },
50
- { name: 'level', type: 'string', description: '按日志级别过滤:log/info/warn/error' },
57
+ { name: 'level', type: 'string', description: '按日志级别过滤:log/info/warn/error/all' },
51
58
  { name: 'filter', type: 'string', description: '按内容过滤,支持正则' },
52
59
  { name: 'since', type: 'number', description: '只返回最近 N 秒内的日志' },
53
60
  {
@@ -90,6 +97,7 @@ export const COMMANDS = [
90
97
  description: '获取 API 接口 schema(出入参定义)',
91
98
  params: [
92
99
  { name: 'api', type: 'string', required: true, description: 'API 名称' },
100
+ { name: 'version', type: 'string', description: 'API 版本,用于精确匹配接口定义' },
93
101
  {
94
102
  name: 'fields',
95
103
  type: '("schema" | "hsf")[]',
@@ -144,7 +152,33 @@ export const COMMANDS = [
144
152
  {
145
153
  name: 'set_rule',
146
154
  description: '添加 Chrome declarativeNetRequest 规则(重定向/修改请求头/拦截请求)',
147
- examples: [`set_rule --payload '{"rule":{...}}'`],
155
+ params: [
156
+ {
157
+ name: 'actionType',
158
+ type: '"redirect" | "block" | "allow" | "upgradeScheme" | "modifyHeaders"',
159
+ required: true,
160
+ description: '规则动作',
161
+ },
162
+ { name: 'filter', type: 'string', required: true, description: 'URL 过滤表达式' },
163
+ { name: 'redirectUrl', type: 'string', description: 'redirect 动作的目标 URL' },
164
+ {
165
+ name: 'requestHeaders',
166
+ type: 'array',
167
+ description: 'modifyHeaders 动作的请求头修改列表',
168
+ },
169
+ {
170
+ name: 'responseHeaders',
171
+ type: 'array',
172
+ description: 'modifyHeaders 动作的响应头修改列表',
173
+ },
174
+ { name: 'initiatorDomains', type: 'string', description: '发起方域名过滤' },
175
+ { name: 'resourceTypes', type: 'string[]', description: '资源类型过滤' },
176
+ { name: 'priority', type: 'number', description: '规则优先级' },
177
+ { name: 'description', type: 'string', description: '规则说明' },
178
+ ],
179
+ examples: [
180
+ `set_rule --payload '{"actionType":"block","filter":"^https://example\\\\.com/ads/.*"}'`,
181
+ ],
148
182
  },
149
183
  {
150
184
  name: 'get_rules',
@@ -172,6 +206,11 @@ export const COMMANDS = [
172
206
  description: 'multipart 文件,最多 20 个、总计不超过 40 MiB;Base64 文件总计不超过 7 MiB。每项传 fieldName 和绝对 filePath,或传 base64 + filename',
173
207
  },
174
208
  { name: 'withCookies', type: 'boolean', description: '是否附加浏览器 Cookie,默认 true' },
209
+ {
210
+ name: 'responseType',
211
+ type: '"json" | "text" | "auto"',
212
+ description: '响应解析方式,默认 auto',
213
+ },
175
214
  { name: 'timeout', type: 'number', description: '超时毫秒数,默认 30000' },
176
215
  ],
177
216
  examples: [
@@ -181,12 +220,13 @@ export const COMMANDS = [
181
220
  },
182
221
  {
183
222
  name: 'send_mtop_request',
184
- description: '在页面上下文中发起 mtop 请求,自动处理签名和 token',
223
+ description: '使用目标浏览器 Cookie 发起 mtop 请求,自动处理签名和 token',
185
224
  params: [
186
225
  { name: 'api', type: 'string', required: true, description: 'mtop API 名称' },
187
226
  { name: 'data', type: 'object', description: '请求数据' },
188
227
  { name: 'version', type: 'string', description: 'API 版本,默认 1.0' },
189
228
  { name: 'method', type: 'string', description: 'HTTP 方法,默认 GET' },
229
+ { name: 'appKey', type: 'string', description: '签名使用的 appKey,默认 12574478' },
190
230
  { name: 'env', type: '"online" | "pre"', description: '请求环境,默认 online' },
191
231
  { name: 'timeout', type: 'number', description: '超时毫秒数,默认 10000' },
192
232
  ],
@@ -209,6 +249,7 @@ export const COMMANDS = [
209
249
  description: '操作类型,默认 list',
210
250
  },
211
251
  { name: 'refresh', type: 'boolean', description: 'list 时是否强制刷新账号列表' },
252
+ { name: 'pageIndex', type: 'number', description: 'list 时的页码,默认 1' },
212
253
  { name: 'accountId', type: 'string | number', description: 'switch 时使用账号列表中的 id' },
213
254
  { name: 'havanaId', type: 'string | number', description: 'switch 时也可直接指定 havanaId' },
214
255
  { name: 'site', type: 'string | number', description: '直接指定 havanaId 时必填' },
@@ -224,7 +265,7 @@ export const COMMANDS = [
224
265
  // ── 浏览器 ────────────────────────────────────────────────────────────────
225
266
  {
226
267
  name: 'browser_list',
227
- description: '列出所有浏览器及其连接状态、类型和托管实例信息;AgentBay 可包含镜像、持久化 Context 和串流地址',
268
+ description: '列出所有浏览器及其连接状态、类型和托管实例信息;AgentBay 可包含镜像与持久化 Context',
228
269
  examples: ['browser_list'],
229
270
  },
230
271
  {
@@ -364,11 +405,17 @@ export const COMMANDS = [
364
405
  type: 'object',
365
406
  description: '开 tab 即进入移动端模拟态(首屏即移动态、无需 reload)。字段同 set_device_emulation 去掉 enabled,如 {"preset":"iphone-15-pro"}',
366
407
  },
408
+ {
409
+ name: 'appProfile',
410
+ type: 'string',
411
+ description: '开 tab 即进入 App 容器模拟态(客户端 UA + JSBridge 托管 + iframe 容器栈 + 自适应系统标题栏,首屏即容器态)。系统栏由 iframe 外层统一渲染,并根据页面协议与桥调用切换普通、沉浸或隐藏状态;档案名同 set_app_profile,如 "fliggy"',
412
+ },
367
413
  ],
368
414
  examples: [
369
415
  `tab_open --payload '{"url":"https://example.com"}'`,
370
416
  `tab_open --payload '{"url":"https://example.com/page","reuse":"prefer","match":{"ignoreSearch":true}}'`,
371
417
  `tab_open --payload '{"url":"https://m.example.com","emulation":{"preset":"iphone-15-pro"}}'`,
418
+ `tab_open --payload '{"url":"https://market.m.taobao.com/app/trip/rx-home/pages/home","appProfile":"fliggy"}'`,
372
419
  `tab_open --payload '{"url":"https://example.com","group":"验证任务"}'`,
373
420
  ],
374
421
  },
@@ -785,6 +832,37 @@ export const COMMANDS = [
785
832
  `set_device_emulation --payload '{"enabled":false}'`,
786
833
  ],
787
834
  },
835
+ {
836
+ name: 'set_app_profile',
837
+ description: '把目标 tab 切换为 App 容器模拟态(客户端 UA + JSBridge 托管 + 页面跳转 iframe 容器栈 + scheme 唤端映射 + 自适应系统标题栏),系统栏由 iframe 外层统一渲染,并根据页面协议与桥调用切换普通、沉浸或隐藏状态;用于桌面浏览器近似实机验证 App 内 H5,需保持调试控制才持续生效',
838
+ params: [
839
+ { name: 'enabled', type: 'boolean', required: true, description: 'true=启用,false=清除' },
840
+ {
841
+ name: 'profile',
842
+ type: 'string',
843
+ description: `容器档案名(enabled=true 时必填):${APP_PROFILE_NAME_LIST}`,
844
+ },
845
+ { name: 'os', type: '"ios" | "android"', description: '容器系统,默认 ios' },
846
+ { name: 'appVersion', type: 'string', description: '覆盖档案默认 App 版本号' },
847
+ {
848
+ name: 'deviceModel',
849
+ type: 'string',
850
+ description: 'Android 机型名(拼入 UA 与 __DEVICE_MODEL__)',
851
+ },
852
+ {
853
+ name: 'emulation',
854
+ type: 'object',
855
+ description: '覆盖档案推荐的设备模拟参数,字段同 set_device_emulation 去掉 enabled',
856
+ },
857
+ { name: 'reload', type: 'boolean', description: '应用/清除后是否重载页面,默认 true' },
858
+ { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
859
+ ],
860
+ examples: [
861
+ `set_app_profile --payload '{"enabled":true,"profile":"fliggy"}'`,
862
+ `set_app_profile --payload '{"enabled":true,"profile":"alipay","os":"android","deviceModel":"Pixel 8 Pro"}'`,
863
+ `set_app_profile --payload '{"enabled":false}'`,
864
+ ],
865
+ },
788
866
  {
789
867
  name: 'set_timezone',
790
868
  description: '覆盖目标 tab 的时区,传空字符串恢复浏览器默认时区',
@@ -894,7 +972,7 @@ export const COMMANDS = [
894
972
  },
895
973
  ],
896
974
  examples: [
897
- `run_actions --payload '{"actions":[{"action":"page_scroll","data":{"direction":"down"}},{"action":"page_wait","data":{"time":500}},{"action":"page_screenshot"}]}'`,
975
+ `run_actions --payload '{"tabId":12345,"actions":[{"action":"page_scroll","data":{"direction":"down"}},{"action":"page_wait","data":{"time":500}},{"action":"page_screenshot"}]}'`,
898
976
  ],
899
977
  },
900
978
  ];
@@ -108,6 +108,8 @@ export interface SendMtopRequestParams {
108
108
  appKey?: string;
109
109
  env?: string;
110
110
  timeout?: number;
111
+ headers?: Record<string, string>;
112
+ ttid?: string;
111
113
  }
112
114
  export interface TdbankAccountParams {
113
115
  operation?: 'current' | 'list' | 'switch' | 'borrow';
@@ -285,6 +287,36 @@ export interface TabOpenParams {
285
287
  restoreFocusOnClose?: boolean;
286
288
  emulation?: BrowserEmulationOptions;
287
289
  group?: string;
290
+ /**
291
+ * 客户端容器模拟档案名(如 'fliggy')。打开后即按该 App 的 WebView 环境渲染:
292
+ * 移动视口 + 容器 UA + JSBridge 托管 + 自适应系统标题栏。系统栏由 iframe 外层统一渲染,
293
+ * 并根据页面协议与桥调用切换普通、沉浸或隐藏状态。可用档案见 APP_PROFILE_NAMES。
294
+ */
295
+ appProfile?: AppProfileName;
296
+ }
297
+ /**
298
+ * 客户端容器模拟可用档案名。
299
+ *
300
+ * 档案数据(UA / 桥对象 / 方法映射)在 @mearl/app-profiles 维护,但名单属于协议:
301
+ * 它是 set_app_profile.profile 与 tab_open.appProfile 的取值域,CLI 帮助与 MCP 工具
302
+ * schema 的 enum 也由它生成。app-profiles 反向引用本清单约束自己的档案表,
303
+ * 因此新增档案时只需改两处(名单 + 档案数据),且漏改会在类型检查时暴露。
304
+ */
305
+ export declare const APP_PROFILE_NAMES: readonly ["fliggy", "taobao", "wechat", "tmall", "alipay", "koubei", "taobao-tj", "taobao-live", "xianyu", "etao", "eleme", "damai", "btrip", "amap", "qianwen", "lingyou", "didi", "easybike"];
306
+ export type AppProfileName = (typeof APP_PROFILE_NAMES)[number];
307
+ export interface SetAppProfileParams {
308
+ tabId?: number;
309
+ /** false 时清除该 tab 的容器模拟并刷新 */
310
+ enabled: boolean;
311
+ /** 容器档案名(enabled=true 时必填) */
312
+ profile?: AppProfileName;
313
+ os?: 'ios' | 'android';
314
+ appVersion?: string;
315
+ deviceModel?: string;
316
+ /** 覆盖档案推荐的设备模拟参数(视口/UA 默认取档案值) */
317
+ emulation?: BrowserEmulationOptions;
318
+ /** 默认 true:应用/清除后刷新页面使注入生效 */
319
+ reload?: boolean;
288
320
  }
289
321
  export interface TabCloseParams {
290
322
  tabId: number;
@@ -619,6 +651,10 @@ export interface BrowserActionMap {
619
651
  request: SetDeviceEmulationParams;
620
652
  response: unknown;
621
653
  };
654
+ set_app_profile: {
655
+ request: SetAppProfileParams;
656
+ response: unknown;
657
+ };
622
658
  set_timezone: {
623
659
  request: SetTimezoneParams;
624
660
  response: SetTimezoneResult;
@@ -696,6 +732,7 @@ export declare const BROWSER_ACTIONS: {
696
732
  readonly page_upload: true;
697
733
  readonly page_frames: true;
698
734
  readonly set_device_emulation: true;
735
+ readonly set_app_profile: true;
699
736
  readonly set_timezone: true;
700
737
  readonly get_cookie: true;
701
738
  readonly set_cookie: true;
@@ -741,6 +778,7 @@ export declare const BROWSER_COMMAND_ACTIONS: {
741
778
  readonly page_upload: true;
742
779
  readonly page_frames: true;
743
780
  readonly set_device_emulation: true;
781
+ readonly set_app_profile: true;
744
782
  readonly set_timezone: true;
745
783
  readonly get_cookie: true;
746
784
  readonly set_cookie: true;
@@ -783,6 +821,7 @@ export declare const EXTENSION_BROWSER_ACTIONS: {
783
821
  readonly page_upload: true;
784
822
  readonly page_frames: true;
785
823
  readonly set_device_emulation: true;
824
+ readonly set_app_profile: true;
786
825
  readonly set_timezone: true;
787
826
  readonly get_cookie: true;
788
827
  readonly set_cookie: true;
@@ -6,6 +6,34 @@ export const SEND_REQUEST_MAX_TOTAL_FILE_BYTES = 40 * 1024 * 1024;
6
6
  // Base64 expands by 4/3; 7 MiB leaves roughly 680 KiB for JSON framing under
7
7
  // the 10 MiB cloud message limit.
8
8
  export const SEND_REQUEST_MAX_TOTAL_BASE64_FILE_BYTES = 7 * 1024 * 1024;
9
+ /**
10
+ * 客户端容器模拟可用档案名。
11
+ *
12
+ * 档案数据(UA / 桥对象 / 方法映射)在 @mearl/app-profiles 维护,但名单属于协议:
13
+ * 它是 set_app_profile.profile 与 tab_open.appProfile 的取值域,CLI 帮助与 MCP 工具
14
+ * schema 的 enum 也由它生成。app-profiles 反向引用本清单约束自己的档案表,
15
+ * 因此新增档案时只需改两处(名单 + 档案数据),且漏改会在类型检查时暴露。
16
+ */
17
+ export const APP_PROFILE_NAMES = [
18
+ 'fliggy',
19
+ 'taobao',
20
+ 'wechat',
21
+ 'tmall',
22
+ 'alipay',
23
+ 'koubei',
24
+ 'taobao-tj',
25
+ 'taobao-live',
26
+ 'xianyu',
27
+ 'etao',
28
+ 'eleme',
29
+ 'damai',
30
+ 'btrip',
31
+ 'amap',
32
+ 'qianwen',
33
+ 'lingyou',
34
+ 'didi',
35
+ 'easybike',
36
+ ];
9
37
  export const PAGE_ACT_ACTIONS = [
10
38
  'page_click',
11
39
  'page_drag',
@@ -53,6 +81,7 @@ export const BROWSER_ACTIONS = {
53
81
  page_upload: true,
54
82
  page_frames: true,
55
83
  set_device_emulation: true,
84
+ set_app_profile: true,
56
85
  set_timezone: true,
57
86
  get_cookie: true,
58
87
  set_cookie: true,
@@ -98,6 +127,7 @@ export const BROWSER_COMMAND_ACTIONS = {
98
127
  page_upload: true,
99
128
  page_frames: true,
100
129
  set_device_emulation: true,
130
+ set_app_profile: true,
101
131
  set_timezone: true,
102
132
  get_cookie: true,
103
133
  set_cookie: true,
@@ -140,6 +170,7 @@ export const EXTENSION_BROWSER_ACTIONS = {
140
170
  page_upload: true,
141
171
  page_frames: true,
142
172
  set_device_emulation: true,
173
+ set_app_profile: true,
143
174
  set_timezone: true,
144
175
  get_cookie: true,
145
176
  set_cookie: true,
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@
6
6
  */
7
7
  export { UnifiedClient, UnifiedClient as MearlClient, decodeBrowserTarget, invoke, listCloudConnectors, } from './unified.js';
8
8
  export type { UnifiedClientOptions, UnifiedInvokeOptions, UnifiedInvokeOptions as InvokeOptions, } from './unified.js';
9
- export { 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, isBrowserCommandAction, isExtensionBrowserAction, } from './generated-browser-action-protocol.js';
10
- export type { ActionStep, BrowserAction, BrowserActionMap, BrowserActionRequest, BrowserActionResponse, BrowserCloseParams, BrowserCommandAction, BrowserInfo, BrowserInfoBase, BrowserLaunchParams, BrowserListResult, BrowserReleaseFailure, BrowserReleaseResult, BrowserSource, BrowserStatus, CaptureCheckpointParams, CaptureCheckpointResult, BrowserDevicePresetName, BrowserEmulationOptions, ExtensionBrowserAction, GetApiSchemaParams, GetCookieParams, GetCookieResult, GetEventsParams, GetLogsParams, GetMocksParams, GetRequestsParams, GetUserInfoParams, ManagedBrowserAccount, ManagedBrowserInfo, PageClickParams, PageDragEndpoint, PageDragParams, PageDragPoint, PageActAction, PageDiagnosticsOptions, PageDiagnosticsSetting, PageEvalParams, PageFramesParams, PageHoverParams, PageNavigateParams, PageObservationWaitOptions, PagePressParams, PageScreenshotParams, PageScrollParams, PageSelectedElementParams, PageSnapshotParams, PageSnapshotQuery, PageTypeParams, PageUploadParams, PageWaitParams, RecordParams, RegularBrowserInfo, RequestDomainPermissionParams, RulesResult, RunActionName, RunActionsParams, SelectBrowserParams, SelectBrowserResult, SendRequestFile, SendRequestFormValue, SendMtopRequestParams, SendRequestParams, SetCookieParams, SetCookieResult, SetDeviceEmulationParams, SetMockParams, SetRuleParams, SetTimezoneParams, SetTimezoneResult, TabCloseParams, TabOpenParams, TdbankAccountParams, } from './generated-browser-action-protocol.js';
9
+ export { APP_PROFILE_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, isBrowserCommandAction, isExtensionBrowserAction, } from './generated-browser-action-protocol.js';
10
+ export type { ActionStep, AppProfileName, BrowserAction, BrowserActionMap, BrowserActionRequest, BrowserActionResponse, BrowserCloseParams, BrowserCommandAction, BrowserInfo, BrowserInfoBase, BrowserLaunchParams, BrowserListResult, BrowserReleaseFailure, BrowserReleaseResult, BrowserSource, BrowserStatus, CaptureCheckpointParams, CaptureCheckpointResult, BrowserDevicePresetName, BrowserEmulationOptions, ExtensionBrowserAction, GetApiSchemaParams, GetCookieParams, GetCookieResult, GetEventsParams, GetLogsParams, GetMocksParams, GetRequestsParams, GetUserInfoParams, ManagedBrowserAccount, ManagedBrowserInfo, PageClickParams, PageDragEndpoint, PageDragParams, PageDragPoint, PageActAction, PageDiagnosticsOptions, PageDiagnosticsSetting, PageEvalParams, PageFramesParams, PageHoverParams, PageNavigateParams, PageObservationWaitOptions, PagePressParams, PageScreenshotParams, PageScrollParams, PageSelectedElementParams, PageSnapshotParams, PageSnapshotQuery, PageTypeParams, PageUploadParams, PageWaitParams, RecordParams, RegularBrowserInfo, RequestDomainPermissionParams, RulesResult, RunActionName, RunActionsParams, SelectBrowserParams, SelectBrowserResult, SendRequestFile, SendRequestFormValue, SendMtopRequestParams, SendRequestParams, SetAppProfileParams, SetCookieParams, SetCookieResult, SetDeviceEmulationParams, SetMockParams, SetRuleParams, SetTimezoneParams, SetTimezoneResult, TabCloseParams, TabOpenParams, TdbankAccountParams, } from './generated-browser-action-protocol.js';
11
11
  import { type UnifiedInvokeOptions } from './unified.js';
12
12
  import type * as Protocol from './generated-browser-action-protocol.js';
13
13
  export declare function tabCheckpoint(params?: Protocol.CaptureCheckpointParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_checkpoint'>>;
@@ -47,6 +47,7 @@ export declare function pageNavigate(params: Protocol.PageNavigateParams, option
47
47
  export declare function pageUpload(params: Protocol.PageUploadParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'page_upload'>>;
48
48
  export declare function pageFrames(params: Protocol.PageFramesParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'page_frames'>>;
49
49
  export declare function setDeviceEmulation(params: Protocol.SetDeviceEmulationParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_device_emulation'>>;
50
+ export declare function setAppProfile(params: Protocol.SetAppProfileParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_app_profile'>>;
50
51
  export declare function setTimezone(params: Protocol.SetTimezoneParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_timezone'>>;
51
52
  export declare function getCookie(params: Protocol.GetCookieParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_cookie'>>;
52
53
  export declare function setCookie(params: Protocol.SetCookieParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_cookie'>>;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * then routes actions using the global browser ids returned by browser_list.
6
6
  */
7
7
  export { UnifiedClient, UnifiedClient as MearlClient, decodeBrowserTarget, invoke, listCloudConnectors, } from './unified.js';
8
- export { 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, isBrowserCommandAction, isExtensionBrowserAction, } from './generated-browser-action-protocol.js';
8
+ export { APP_PROFILE_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, isBrowserCommandAction, isExtensionBrowserAction, } from './generated-browser-action-protocol.js';
9
9
  import { invoke } from './unified.js';
10
10
  export function tabCheckpoint(params = {}, options) {
11
11
  return invoke('tab_checkpoint', params, options);
@@ -116,6 +116,9 @@ export function pageFrames(params, options) {
116
116
  export function setDeviceEmulation(params, options) {
117
117
  return invoke('set_device_emulation', params, options);
118
118
  }
119
+ export function setAppProfile(params, options) {
120
+ return invoke('set_app_profile', params, options);
121
+ }
119
122
  export function setTimezone(params, options) {
120
123
  return invoke('set_timezone', params, options);
121
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/client",
3
- "version": "2.7.3",
3
+ "version": "2.8.1",
4
4
  "description": "Unified Mearl SDK & CLI for local and remote browsers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -51,7 +51,7 @@
51
51
  "dependencies": {
52
52
  "fastest-levenshtein": "^1.0.16",
53
53
  "ws": "^8.18.0",
54
- "@mearl/cloud-types": "2.7.3"
54
+ "@mearl/cloud-types": "2.8.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/node": "^24.9.1",