@mearl/client 3.0.12 → 3.1.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/cli.js CHANGED
@@ -26,7 +26,7 @@ const CATEGORIES = [
26
26
  { title: '标签页', names: ['tab_open', 'tab_list', 'tab_group', 'tab_close'] },
27
27
  {
28
28
  title: '页面感知',
29
- names: ['page_snapshot', 'page_inspect', 'page_screenshot', 'page_frames'],
29
+ names: ['page_snapshot', 'page_inspect', 'page_screenshot', 'page_record', 'page_frames'],
30
30
  },
31
31
  {
32
32
  title: '页面操作',
@@ -52,13 +52,11 @@ const CATEGORIES = [
52
52
  },
53
53
  {
54
54
  title: '浏览器',
55
- names: [
56
- 'browser_list',
57
- 'browser_launch',
58
- 'browser_release',
59
- 'browser_close',
60
- 'browser_control',
61
- ],
55
+ names: ['browser_list', 'browser_manage'],
56
+ },
57
+ {
58
+ title: '控制会话',
59
+ names: ['session_list', 'session_manage'],
62
60
  },
63
61
  ];
64
62
  const BUILTIN_COMMANDS = [
@@ -92,7 +90,6 @@ const ADVANCED_BUILTIN_COMMANDS = new Set(['connector_list']);
92
90
  const PLUGIN_HOST_OPTIONS = new Set([
93
91
  '--all',
94
92
  '--browser',
95
- '--cdp',
96
93
  '--compact',
97
94
  '--connector',
98
95
  '--help',
@@ -228,7 +225,7 @@ function printProviderHelp(commandName, provider, extensionHelp) {
228
225
  ];
229
226
  if (browserType.help?.length)
230
227
  lines.push('');
231
- lines.push('创建:', ` ${commandName} browser_launch --payload '{"provider":"${provider.providerId}","providerOptions":{}}'`, '', '启动参数(providerOptions):');
228
+ lines.push('创建:', ` ${commandName} browser_manage --payload '{"operation":"${browserType.openOperation ?? 'launch'}","provider":"${provider.providerId}","providerOptions":{}}'`, '', '启动参数(providerOptions):');
232
229
  const required = new Set(browserType.inputSchema.required ?? []);
233
230
  const properties = Object.entries(browserType.inputSchema.properties);
234
231
  if (properties.length === 0)
@@ -294,7 +291,6 @@ function printCheckHelp(commandName) {
294
291
  ' --browser <id|名称> 只检查指定浏览器',
295
292
  ' --connector <id|名称> 限制到一台远端 connector',
296
293
  ' --local 只检查当前机器,不能与 --connector 同时使用',
297
- ' --cdp 当前机器强制使用 CDP(隐含 --local)',
298
294
  ' --server <url> 覆盖 cloud-server WebSocket URL',
299
295
  ' --timeout <seconds> 单项检查超时时间,默认 5 秒',
300
296
  ' --json 输出机器可读 JSON',
@@ -419,7 +415,6 @@ export function parseClientArgs(args, plugin = false) {
419
415
  .option('--connector <id-or-name>')
420
416
  .option('--local')
421
417
  .option('--updates')
422
- .option('--cdp')
423
418
  .option('--server <url>');
424
419
  if (plugin)
425
420
  program
@@ -461,18 +456,16 @@ export function parseClientArgs(args, plugin = false) {
461
456
  const parsedPayload = parsePayload(options.payload, options.payloadFile);
462
457
  const { payload, outputPath } = normalizeScreenshotOutput(action, parsedPayload, options.output);
463
458
  const fallbackTimeout = resolveActionTimeoutSec(action, payload, 60);
464
- const forceCdp = options.cdp === true;
465
- const local = forceCdp || options.local === true;
459
+ const local = options.local === true;
466
460
  const connector = options.connector;
467
461
  if (local && connector)
468
- throw new Error('--local/--cdp 不能与 --connector 同时使用');
462
+ throw new Error('--local 不能与 --connector 同时使用');
469
463
  return {
470
464
  action,
471
465
  payload,
472
466
  timeoutSec: parsePositiveTimeout(options.timeout, fallbackTimeout),
473
467
  ...(options.timeout !== undefined ? { timeoutOption: options.timeout } : {}),
474
468
  compact: options.compact === true || process.stdout.isTTY !== true,
475
- forceCdp,
476
469
  json,
477
470
  local,
478
471
  updates: options.updates === true,
@@ -510,7 +503,6 @@ async function runPluginCli(args, commandName) {
510
503
  ...(parsed.session ? { session: parsed.session } : {}),
511
504
  ...(parsed.connector ? { connector: parsed.connector } : {}),
512
505
  ...(parsed.local ? { local: true } : {}),
513
- ...(parsed.forceCdp ? { transport: 'cdp' } : {}),
514
506
  };
515
507
  const plugin = await loadRegisteredPlugin(parsed.action, {
516
508
  async invoke(action, payload, options) {
@@ -684,7 +676,6 @@ export async function runMearlCli(args, options = {}) {
684
676
  ...(parsed.session ? { session: parsed.session } : {}),
685
677
  ...(parsed.connector ? { connector: parsed.connector } : {}),
686
678
  ...(parsed.local ? { local: true } : {}),
687
- ...(parsed.forceCdp ? { transport: 'cdp' } : {}),
688
679
  ...(parsed.updates ? { checkUpdates: true } : {}),
689
680
  };
690
681
  if (parsed.json) {
@@ -698,20 +689,23 @@ export async function runMearlCli(args, options = {}) {
698
689
  requestTimeoutSec: parsed.timeoutSec,
699
690
  });
700
691
  try {
692
+ if (parsed.action === 'page_record' && parsed.outputPath && parsed.payload.operation !== 'stop')
693
+ throw new Error('page_record --output requires operation "stop"');
701
694
  const result = await client.invoke(parsed.action, parsed.payload, {
702
695
  timeoutSec: parsed.timeoutSec,
703
696
  ...(parsed.browser ? { browser: parsed.browser } : {}),
704
697
  ...(parsed.session ? { session: parsed.session } : {}),
705
698
  ...(parsed.connector ? { connector: parsed.connector } : {}),
706
699
  ...(parsed.local ? { local: true } : {}),
707
- ...(parsed.forceCdp ? { transport: 'cdp' } : {}),
708
700
  });
709
- if (parsed.outputPath && parsed.action === 'page_download') {
710
- await client.saveArtifact(result.download, resolve(parsed.outputPath), {
701
+ if (parsed.outputPath &&
702
+ (parsed.action === 'page_download' || parsed.action === 'page_record')) {
703
+ const artifact = parsed.action === 'page_download' ? result.download : result.recording;
704
+ await client.saveArtifact(artifact, resolve(parsed.outputPath), {
711
705
  ...(parsed.session ? { session: parsed.session } : {}),
712
706
  });
713
707
  process.stdout.write(JSON.stringify({ ...result, outputPath: resolve(parsed.outputPath) }) + '\n');
714
- if (!parsed.session)
708
+ if (!parsed.session && parsed.action === 'page_download')
715
709
  await client.invoke('__artifact_remove', { artifactId: result.download.artifactId }, { browser: result.download.browserId });
716
710
  }
717
711
  else if (parsed.outputPath) {
@@ -39,11 +39,8 @@ export function formatCommandHelp(commandName, command) {
39
39
  ];
40
40
  const method = [...SDK_METHOD_ACTIONS].find(([, action]) => action === command.name)?.[0];
41
41
  if (method)
42
- lines.push('SDK:', ...(method === 'browserRelease' || method === 'browserList'
43
- ? [
44
- ` await mearl.${method}(options?)`,
45
- ` await mearl.${method}(params, options)`,
46
- ]
42
+ lines.push('SDK:', ...(method === 'browserList'
43
+ ? [` await mearl.${method}(options?)`, ` await mearl.${method}(params, options)`]
47
44
  : [
48
45
  ` await mearl.${method}(${SDK_OPTIONS_ONLY_METHODS.has(method) ? 'options?' : 'params, options?'})`,
49
46
  ]), '');
@@ -57,11 +54,11 @@ export function formatCommandHelp(commandName, command) {
57
54
  }
58
55
  lines.push('');
59
56
  }
60
- if (command.name === 'browser_list') {
57
+ if (command.name === 'browser_list' || command.name === 'session_list') {
61
58
  lines.push('目标范围(按需):', ' --local 只列出当前机器上的浏览器', ' --connector <id|名称> 只列出指定远端 connector 的浏览器', '');
62
59
  }
63
- else if (command.name === 'browser_launch') {
64
- lines.push('宿主选择(本机与远端同时可用时):', ' --local 在当前机器启动', ' --connector <id|名称> 在指定远端 connector 启动', ' --browser <id|名称> 在控制浏览器所在宿主启动,并可作为 Cookie/UA 来源', '');
60
+ else if (command.name === 'browser_manage') {
61
+ lines.push('宿主选择(本机与远端同时可用时):', ' --local 在当前机器启动或接入', ' --connector <id|名称> 在指定远端 connector 启动或接入', ' --browser <id|名称> 在控制浏览器所在宿主启动,并可作为 Cookie/UA 来源', '');
65
62
  }
66
63
  if (command.notes?.length) {
67
64
  lines.push('约束与行为:', ...command.notes.map(note => ` ${note}`), '');
@@ -34,28 +34,6 @@ export declare const COMMANDS: readonly [{
34
34
  }];
35
35
  readonly notes: readonly ["沿用 --browser / --session 路由;不传 app 返回摘要。apps.status=partial 表示目录未完整取得,unsupported 表示目标未提供目录;不能把两者当作未安装。", "available=false 的 App 当前不可启用;支持某个 action 不代表已有域名权限或真实设备授权。按需读取 usage.skills / usage.documentation,查询不会自动安装或加载 Skill。"];
36
36
  readonly examples: ["get_capabilities", "get_capabilities --payload '{\"app\":\"example/app\"}'"];
37
- }, {
38
- readonly name: "browser_control";
39
- readonly description: "交接或恢复浏览器控制;外部 Provider 也可结束任务";
40
- readonly params: [{
41
- readonly name: "operation";
42
- readonly type: "\"handoff\" | \"resume\" | \"finish\"";
43
- readonly required: true;
44
- readonly description: "交给用户操作;resume 仅在用户明确交还后使用";
45
- }, {
46
- readonly name: "tabId";
47
- readonly type: "number";
48
- readonly description: "可选的目标页面";
49
- }, {
50
- readonly name: "reason";
51
- readonly type: "string";
52
- readonly description: "用户需要处理的事项";
53
- }, {
54
- readonly name: "keepTabIds";
55
- readonly type: "number[]";
56
- readonly description: "外部 Provider finish 时保留的结果页;默认不保留任务页面";
57
- }];
58
- readonly notes: readonly ["统一使用 --browser 选择目标。普通浏览器自动选择唯一的控制会话;多个会话时用 tabId 或 --session 明确任务。外部 Provider 由宿主管理任务,不传 --session。finish 仅用于支持它的外部 Provider。仅在用户明确交还后 resume;已经发出的操作可能仍然生效。"];
59
37
  }, {
60
38
  readonly name: "page_download";
61
39
  readonly description: "先监听再点击,等待下载完成并创建浏览器文件产物";
@@ -80,6 +58,42 @@ export declare const COMMANDS: readonly [{
80
58
  readonly description: "下载等待毫秒,默认 30000,范围 1000–300000";
81
59
  }];
82
60
  readonly notes: readonly ["--output 把文件分块保存到调用方机器;未指定时返回 artifactId,可供 page_upload 复用。", "共享 CDP 浏览器保持原下载目录;Chrome 未返回文件路径时明确报错。超时不能直接重复点击。"];
61
+ }, {
62
+ readonly name: "page_record";
63
+ readonly description: "开始、查询或停止 Chrome 标签页录制,导出 MP4";
64
+ readonly outputFlag: true;
65
+ readonly params: [{
66
+ readonly name: "operation";
67
+ readonly type: "\"start\" | \"status\" | \"stop\"";
68
+ readonly required: true;
69
+ readonly description: "开始、查询或停止录制";
70
+ }, {
71
+ readonly name: "tabId";
72
+ readonly type: "number";
73
+ readonly description: "start 时指定目标标签页";
74
+ }, {
75
+ readonly name: "recordingId";
76
+ readonly type: "string";
77
+ readonly description: "status 或 stop 时传入 start 返回的 ID";
78
+ }, {
79
+ readonly name: "maxWidth";
80
+ readonly type: "number";
81
+ readonly description: "最大宽度,默认 1280,上限 1920";
82
+ }, {
83
+ readonly name: "maxHeight";
84
+ readonly type: "number";
85
+ readonly description: "最大高度,默认 720,上限 1080";
86
+ }, {
87
+ readonly name: "frameRate";
88
+ readonly type: "number";
89
+ readonly description: "帧率上限,默认 30,最高 60";
90
+ }, {
91
+ readonly name: "audio";
92
+ readonly type: "boolean";
93
+ readonly description: "是否录制标签页音频,默认 false";
94
+ }];
95
+ readonly examples: ["page_record --payload '{\"operation\":\"start\",\"tabId\":12345}'", "page_record --browser '<browserId>' --payload '{\"operation\":\"status\",\"recordingId\":\"<recordingId>\"}'", "page_record --browser '<browserId>' --payload '{\"operation\":\"stop\",\"recordingId\":\"<recordingId>\"}' --output ./repro.mp4"];
96
+ readonly notes: readonly ["支持本机 Chrome 153+。查询或停止时使用开始返回的 browserId,并沿用原控制会话与连接方式。", "60 秒后自动停止。stop 返回文件产物,支持用 --output 保存到调用方机器。", "status 返回 recording、finalizing、ready 或 interrupted。达到时长上限会标记 duration_limit。结束后状态保留 5 分钟,释放所属控制会话时清理。"];
83
97
  }, {
84
98
  readonly name: "tab_checkpoint";
85
99
  readonly description: "为目标标签页建立日志、请求和埋点增量边界";
@@ -387,39 +401,25 @@ export declare const COMMANDS: readonly [{
387
401
  }];
388
402
  readonly examples: ["browser_list", "browser_list --local"];
389
403
  }, {
390
- readonly name: "browser_release";
391
- readonly description: "释放当前浏览器的调试控制和会话级临时效果(含设备/时区模拟);不用于普通任务收尾,Provider 实例的行为以 mearl <providerId> 为准";
404
+ readonly name: "browser_manage";
405
+ readonly description: "启动、接入、断开、关闭浏览器或释放浏览器级控制资源";
392
406
  readonly params: [{
393
- readonly name: "closeCreatedTabs";
394
- readonly type: "boolean";
395
- readonly description: "带 --session 时关闭会话创建的过程页,默认 false";
396
- }, {
397
- readonly name: "keepTabIds";
398
- readonly type: "number[]";
399
- readonly description: "保留的结果页面;复用的用户页面始终保留";
407
+ readonly name: "operation";
408
+ readonly type: "\"launch\" | \"attach\" | \"detach\" | \"close\" | \"release\"";
409
+ readonly required: true;
410
+ readonly description: "launch 启动,attach 接入,detach 断开接入,close 关闭,release 清理调试控制";
400
411
  }, {
401
- readonly name: "preserveEnvironment";
412
+ readonly name: "deleteProfile";
402
413
  readonly type: "boolean";
403
- readonly description: "带 --session 时默认 true,保留 Mock 与模拟现场;false 清理这些页面的环境";
414
+ readonly description: "仅 close,删除持久化数据";
404
415
  }, {
405
- readonly name: "keepArtifactIds";
406
- readonly type: "string[]";
407
- readonly description: "保留在浏览器宿主的文件产物;其余会话临时文件删除";
408
- }];
409
- readonly notes: readonly ["带 --session 时可用于任务收尾,只释放该会话;未带会话时保留原浏览器级释放行为,活动会话存在时拒绝全局释放。"];
410
- readonly summary: "释放浏览器调试控制和会话级临时效果";
411
- readonly examples: ["browser_release", "browser_release --browser chrome-a"];
412
- }, {
413
- readonly name: "browser_launch";
414
- readonly description: "启动本地 Chrome,或通过已注册 Provider 创建浏览器实例";
415
- readonly params: [{
416
416
  readonly name: "name";
417
417
  readonly type: "string";
418
418
  readonly description: "本地实例名称;使用 local Provider 时必填";
419
419
  }, {
420
420
  readonly name: "provider";
421
421
  readonly type: "string";
422
- readonly description: "运行环境,默认 local;可传 mearl --help 中展示的已注册 Provider ID";
422
+ readonly description: "launch 默认 local;attach 指定接入 Provider,例如 cdp 接入已开启远程调试的 Chromium 或 Electron";
423
423
  }, {
424
424
  readonly name: "providerOptions";
425
425
  readonly type: "Record<string, JSON value>";
@@ -449,21 +449,47 @@ export declare const COMMANDS: readonly [{
449
449
  readonly type: "string[] | string | { presets?: string[]; domains?: string[] }";
450
450
  readonly description: "从控制浏览器复制 Cookie:可传域名数组、已安装能力提供的范围名,或组合范围与额外域名";
451
451
  }];
452
- readonly examples: ["browser_launch --payload '{\"provider\":\"example-device\",\"providerOptions\":{}}'", "browser_launch --payload '{\"name\":\"figma\",\"userAgentMode\":\"desktop\",\"copyCookieDomains\":[\"figma.com\"]}'", "browser_launch --payload '{\"name\":\"with-cookies\",\"copyCookieDomains\":[\"example.com\",\"sub.example.org\"]}'"];
452
+ readonly notes: readonly ["close / detach 使用 --browser 指定目标。detach 保留浏览器进程;release 清理浏览器级调试状态并保留接入。活动会话需先用 session_manage end 结束。"];
453
+ readonly examples: ["browser_manage --local --payload '{\"operation\":\"attach\",\"provider\":\"cdp\",\"providerOptions\":{\"name\":\"Electron\",\"port\":9223}}'", "browser_manage --payload '{\"operation\":\"launch\",\"provider\":\"example-device\",\"providerOptions\":{}}'", "browser_manage --payload '{\"operation\":\"launch\",\"name\":\"figma\",\"userAgentMode\":\"desktop\",\"copyCookieDomains\":[\"figma.com\"]}'", "browser_manage --payload '{\"operation\":\"launch\",\"name\":\"with-cookies\",\"copyCookieDomains\":[\"example.com\",\"sub.example.org\"]}'"];
453
454
  }, {
454
- readonly name: "browser_close";
455
- readonly description: "关闭指定托管浏览器,并按 Provider 策略保留或清理持久化数据";
455
+ readonly name: "session_list";
456
+ readonly description: "列出当前可用的 Mearl 控制会话,可按浏览器或宿主筛选";
457
+ readonly examples: ["session_list", "session_list --local", "session_list --browser chrome-a"];
458
+ }, {
459
+ readonly name: "session_manage";
460
+ readonly description: "创建、交接、恢复或结束控制会话";
456
461
  readonly params: [{
457
- readonly name: "browser";
458
- readonly type: "string";
462
+ readonly name: "operation";
463
+ readonly type: "\"new\" | \"handoff\" | \"resume\" | \"end\"";
459
464
  readonly required: true;
460
- readonly description: "托管浏览器的 browserId 或名称";
465
+ readonly description: "new 创建空会话,handoff 交给用户,resume 恢复控制,end 结束会话并释放资源";
461
466
  }, {
462
- readonly name: "deleteProfile";
467
+ readonly name: "sessionId";
468
+ readonly type: "string";
469
+ readonly description: "已有会话 ID,也可使用 --session";
470
+ }, {
471
+ readonly name: "reason";
472
+ readonly type: "string";
473
+ readonly description: "handoff 时说明需要用户处理的事项";
474
+ }, {
475
+ readonly name: "closeCreatedTabs";
463
476
  readonly type: "boolean";
464
- readonly description: "强制删除持久化数据,默认 false";
477
+ readonly description: "end 时关闭会话创建的过程页,默认 false";
478
+ }, {
479
+ readonly name: "keepTabIds";
480
+ readonly type: "number[]";
481
+ readonly description: "保留的结果页面;复用的用户页面始终保留";
482
+ }, {
483
+ readonly name: "preserveEnvironment";
484
+ readonly type: "boolean";
485
+ readonly description: "end 默认 true,保留 Mock 与模拟现场;false 清理这些页面的环境";
486
+ }, {
487
+ readonly name: "keepArtifactIds";
488
+ readonly type: "string[]";
489
+ readonly description: "保留在浏览器宿主的文件产物;其余会话临时文件删除";
465
490
  }];
466
- readonly examples: ["browser_close --payload '{\"browser\":\"managed:account-a\"}'", "browser_close --payload '{\"browser\":\"account-b\",\"deleteProfile\":true}'"];
491
+ readonly notes: readonly ["new 通过 --browser 选择浏览器,返回 session.sessionId。handoff、resume、end 使用已有会话 ID。", "仅在用户明确交还后 resume。外部 Provider 自行管理任务时通过 --browser 执行 handoff、resume 或 end。"];
492
+ readonly examples: ["session_manage --browser '<browserId>' --payload '{\"operation\":\"new\"}'", "session_manage --session '<sessionId>' --payload '{\"operation\":\"end\",\"closeCreatedTabs\":true}'"];
467
493
  }, {
468
494
  readonly name: "tab_open";
469
495
  readonly description: "打开或按 URL 规则复用 Tab,并观察新页面的导航状态";
@@ -511,7 +537,7 @@ export declare const COMMANDS: readonly [{
511
537
  }, {
512
538
  readonly name: "appProfile";
513
539
  readonly type: "string";
514
- readonly description: "启用已安装的端模拟,ID 与限制见当前动态帮助。需要系统栏时同时传 emulation.deviceShell=true";
540
+ readonly description: "应用已安装的 Profile,ID 与限制见当前动态帮助。需要系统栏时同时传 emulation.deviceShell=true";
515
541
  }, {
516
542
  readonly name: "os";
517
543
  readonly type: "\"ios\" | \"android\"";
@@ -1088,7 +1114,7 @@ export declare const COMMANDS: readonly [{
1088
1114
  readonly examples: ["set_device_emulation --payload '{\"tabId\":12345,\"enabled\":true,\"preset\":\"iphone-17-pro\"}'", "set_device_emulation --payload '{\"tabId\":12345,\"enabled\":true,\"preset\":\"pixel-11\",\"orientation\":\"landscape\"}'", "set_device_emulation --payload '{\"tabId\":12345,\"enabled\":true,\"preset\":\"ipad-mini-a17-pro\",\"orientation\":\"landscape\",\"deviceShell\":true,\"splitScreen\":true}'", "set_device_emulation --payload '{\"tabId\":12345,\"enabled\":false}'"];
1089
1115
  }, {
1090
1116
  readonly name: "set_app_profile";
1091
- readonly description: "设置目标标签页的端模拟;完整 JSBridge 由能力包提供。可同时设置已安装的网络控件,传 emulation 时联动设备模拟";
1117
+ readonly description: "为目标标签页应用 Profile,按配置启用 JSBridge 和容器行为。可同时设置已安装的网络控件,传 emulation 时联动设备模拟";
1092
1118
  readonly summary: "设置或清除目标标签页的 App 容器模拟";
1093
1119
  readonly params: [{
1094
1120
  readonly name: "enabled";
@@ -1098,7 +1124,7 @@ export declare const COMMANDS: readonly [{
1098
1124
  }, {
1099
1125
  readonly name: "profile";
1100
1126
  readonly type: "string";
1101
- readonly description: "已安装的端模拟 ID(enabled=true 时必填);当前动态帮助直接展示目标浏览器目录";
1127
+ readonly description: "已安装的 Profile ID(enabled=true 时必填);当前动态帮助直接展示目标浏览器目录";
1102
1128
  }, {
1103
1129
  readonly name: "os";
1104
1130
  readonly type: "\"ios\" | \"android\"";
@@ -1106,7 +1132,7 @@ export declare const COMMANDS: readonly [{
1106
1132
  }, {
1107
1133
  readonly name: "refreshDefinition";
1108
1134
  readonly type: "boolean";
1109
- readonly description: "立即采用最新端模拟配置,保留用户显式设置";
1135
+ readonly description: "立即采用最新 Profile,保留用户显式设置";
1110
1136
  }, {
1111
1137
  readonly name: "lockDefinition";
1112
1138
  readonly type: "boolean";
@@ -1130,7 +1156,7 @@ export declare const COMMANDS: readonly [{
1130
1156
  }, {
1131
1157
  readonly name: "emulation";
1132
1158
  readonly type: "object";
1133
- readonly description: "可选设备联动参数,字段同 set_device_emulation 去掉 enabled/reload;字段覆盖端模拟配置推荐的设备,deviceShell 默认 true,横屏时可传 splitScreen=true。省略时不设置或清除设备";
1159
+ readonly description: "可选设备联动参数,字段同 set_device_emulation 去掉 enabled/reload;字段覆盖Profile 推荐的设备,deviceShell 默认 true,横屏时可传 splitScreen=true。省略时不设置或清除设备";
1134
1160
  }, {
1135
1161
  readonly name: "reload";
1136
1162
  readonly type: "boolean";
@@ -1141,7 +1167,7 @@ export declare const COMMANDS: readonly [{
1141
1167
  readonly required: true;
1142
1168
  readonly description: "目标标签页 ID";
1143
1169
  }];
1144
- readonly notes: readonly ["只有用户明确要求 App/客户端/容器/JSBridge 模拟时启用。移动视口或普通 H5 调试使用 set_device_emulation。", "emulation={} 使用端模拟配置推荐的设备;enabled=false 时省略 emulation 只清除 App 注入,传 {} 同时清除设备模拟。", "bridgeConfig.methods 按方法声明 behavior / response / noop 三选一,可传 silent;只支持受控行为、固定 JSON 回包或成功空实现,不执行配置脚本。"];
1170
+ readonly notes: readonly ["只有用户明确要求 App/客户端/容器/JSBridge 模拟时启用。移动视口或普通 H5 调试使用 set_device_emulation。", "emulation={} 使用Profile 推荐的设备;enabled=false 时省略 emulation 只清除 App 注入,传 {} 同时清除设备模拟。", "bridgeConfig.methods 按方法声明 behavior / response / noop 三选一,可传 silent;只支持受控行为、固定 JSON 回包或成功空实现,不执行配置脚本。"];
1145
1171
  readonly result: readonly ["返回 enabled、profile、label、userAgent、os、networkControl、reloaded;联动设备时额外返回实际 emulation。"];
1146
1172
  readonly examples: ["set_app_profile --payload '{\"tabId\":12345,\"enabled\":true,\"profile\":\"reader\"}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":true,\"profile\":\"reader\",\"networkControl\":{\"id\":\"environment\",\"value\":\"pre\"}}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":false,\"networkControl\":null}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":true,\"profile\":\"reader\",\"emulation\":{}}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":true,\"profile\":\"wallet\",\"emulation\":{\"preset\":\"pixel-11\",\"deviceShell\":true}}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":true,\"profile\":\"reader\",\"emulation\":{\"preset\":\"ipad-mini-a17-pro\",\"orientation\":\"landscape\",\"deviceShell\":true,\"splitScreen\":true}}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":false}'", "set_app_profile --payload '{\"tabId\":12345,\"enabled\":false,\"emulation\":{}}'"];
1147
1173
  }, {
package/dist/commands.js CHANGED
@@ -51,28 +51,6 @@ export const COMMANDS = [
51
51
  ],
52
52
  examples: ['get_capabilities', `get_capabilities --payload '{"app":"example/app"}'`],
53
53
  },
54
- {
55
- name: 'browser_control',
56
- description: '交接或恢复浏览器控制;外部 Provider 也可结束任务',
57
- params: [
58
- {
59
- name: 'operation',
60
- type: '"handoff" | "resume" | "finish"',
61
- required: true,
62
- description: '交给用户操作;resume 仅在用户明确交还后使用',
63
- },
64
- { name: 'tabId', type: 'number', description: '可选的目标页面' },
65
- { name: 'reason', type: 'string', description: '用户需要处理的事项' },
66
- {
67
- name: 'keepTabIds',
68
- type: 'number[]',
69
- description: '外部 Provider finish 时保留的结果页;默认不保留任务页面',
70
- },
71
- ],
72
- notes: [
73
- '统一使用 --browser 选择目标。普通浏览器自动选择唯一的控制会话;多个会话时用 tabId 或 --session 明确任务。外部 Provider 由宿主管理任务,不传 --session。finish 仅用于支持它的外部 Provider。仅在用户明确交还后 resume;已经发出的操作可能仍然生效。',
74
- ],
75
- },
76
54
  {
77
55
  name: 'page_download',
78
56
  description: '先监听再点击,等待下载完成并创建浏览器文件产物',
@@ -101,6 +79,35 @@ export const COMMANDS = [
101
79
  '共享 CDP 浏览器保持原下载目录;Chrome 未返回文件路径时明确报错。超时不能直接重复点击。',
102
80
  ],
103
81
  },
82
+ {
83
+ name: 'page_record',
84
+ description: '开始、查询或停止 Chrome 标签页录制,导出 MP4',
85
+ outputFlag: true,
86
+ params: [
87
+ {
88
+ name: 'operation',
89
+ type: '"start" | "status" | "stop"',
90
+ required: true,
91
+ description: '开始、查询或停止录制',
92
+ },
93
+ { name: 'tabId', type: 'number', description: 'start 时指定目标标签页' },
94
+ { name: 'recordingId', type: 'string', description: 'status 或 stop 时传入 start 返回的 ID' },
95
+ { name: 'maxWidth', type: 'number', description: '最大宽度,默认 1280,上限 1920' },
96
+ { name: 'maxHeight', type: 'number', description: '最大高度,默认 720,上限 1080' },
97
+ { name: 'frameRate', type: 'number', description: '帧率上限,默认 30,最高 60' },
98
+ { name: 'audio', type: 'boolean', description: '是否录制标签页音频,默认 false' },
99
+ ],
100
+ examples: [
101
+ `page_record --payload '{"operation":"start","tabId":12345}'`,
102
+ `page_record --browser '<browserId>' --payload '{"operation":"status","recordingId":"<recordingId>"}'`,
103
+ `page_record --browser '<browserId>' --payload '{"operation":"stop","recordingId":"<recordingId>"}' --output ./repro.mp4`,
104
+ ],
105
+ notes: [
106
+ '支持本机 Chrome 153+。查询或停止时使用开始返回的 browserId,并沿用原控制会话与连接方式。',
107
+ '60 秒后自动停止。stop 返回文件产物,支持用 --output 保存到调用方机器。',
108
+ 'status 返回 recording、finalizing、ready 或 interrupted。达到时长上限会标记 duration_limit。结束后状态保留 5 分钟,释放所属控制会话时清理。',
109
+ ],
110
+ },
104
111
  // ── API 调试 ──────────────────────────────────────────────────────────────
105
112
  {
106
113
  name: 'tab_checkpoint',
@@ -404,40 +411,16 @@ export const COMMANDS = [
404
411
  examples: ['browser_list', 'browser_list --local'],
405
412
  },
406
413
  {
407
- name: 'browser_release',
408
- description: '释放当前浏览器的调试控制和会话级临时效果(含设备/时区模拟);不用于普通任务收尾,Provider 实例的行为以 mearl <providerId> 为准',
414
+ name: 'browser_manage',
415
+ description: '启动、接入、断开、关闭浏览器或释放浏览器级控制资源',
409
416
  params: [
410
417
  {
411
- name: 'closeCreatedTabs',
412
- type: 'boolean',
413
- description: '带 --session 时关闭会话创建的过程页,默认 false',
414
- },
415
- {
416
- name: 'keepTabIds',
417
- type: 'number[]',
418
- description: '保留的结果页面;复用的用户页面始终保留',
419
- },
420
- {
421
- name: 'preserveEnvironment',
422
- type: 'boolean',
423
- description: '带 --session 时默认 true,保留 Mock 与模拟现场;false 清理这些页面的环境',
424
- },
425
- {
426
- name: 'keepArtifactIds',
427
- type: 'string[]',
428
- description: '保留在浏览器宿主的文件产物;其余会话临时文件删除',
418
+ name: 'operation',
419
+ type: '"launch" | "attach" | "detach" | "close" | "release"',
420
+ required: true,
421
+ description: 'launch 启动,attach 接入,detach 断开接入,close 关闭,release 清理调试控制',
429
422
  },
430
- ],
431
- notes: [
432
- '带 --session 时可用于任务收尾,只释放该会话;未带会话时保留原浏览器级释放行为,活动会话存在时拒绝全局释放。',
433
- ],
434
- summary: '释放浏览器调试控制和会话级临时效果',
435
- examples: ['browser_release', 'browser_release --browser chrome-a'],
436
- },
437
- {
438
- name: 'browser_launch',
439
- description: '启动本地 Chrome,或通过已注册 Provider 创建浏览器实例',
440
- params: [
423
+ { name: 'deleteProfile', type: 'boolean', description: '仅 close,删除持久化数据' },
441
424
  {
442
425
  name: 'name',
443
426
  type: 'string',
@@ -446,7 +429,7 @@ export const COMMANDS = [
446
429
  {
447
430
  name: 'provider',
448
431
  type: 'string',
449
- description: '运行环境,默认 local;可传 mearl --help 中展示的已注册 Provider ID',
432
+ description: 'launch 默认 local;attach 指定接入 Provider,例如 cdp 接入已开启远程调试的 Chromium 或 Electron',
450
433
  },
451
434
  {
452
435
  name: 'providerOptions',
@@ -476,31 +459,61 @@ export const COMMANDS = [
476
459
  description: '从控制浏览器复制 Cookie:可传域名数组、已安装能力提供的范围名,或组合范围与额外域名',
477
460
  },
478
461
  ],
462
+ notes: [
463
+ 'close / detach 使用 --browser 指定目标。detach 保留浏览器进程;release 清理浏览器级调试状态并保留接入。活动会话需先用 session_manage end 结束。',
464
+ ],
479
465
  examples: [
480
- `browser_launch --payload '{"provider":"example-device","providerOptions":{}}'`,
481
- `browser_launch --payload '{"name":"figma","userAgentMode":"desktop","copyCookieDomains":["figma.com"]}'`,
482
- `browser_launch --payload '{"name":"with-cookies","copyCookieDomains":["example.com","sub.example.org"]}'`,
466
+ `browser_manage --local --payload '{"operation":"attach","provider":"cdp","providerOptions":{"name":"Electron","port":9223}}'`,
467
+ `browser_manage --payload '{"operation":"launch","provider":"example-device","providerOptions":{}}'`,
468
+ `browser_manage --payload '{"operation":"launch","name":"figma","userAgentMode":"desktop","copyCookieDomains":["figma.com"]}'`,
469
+ `browser_manage --payload '{"operation":"launch","name":"with-cookies","copyCookieDomains":["example.com","sub.example.org"]}'`,
483
470
  ],
484
471
  },
485
472
  {
486
- name: 'browser_close',
487
- description: '关闭指定托管浏览器,并按 Provider 策略保留或清理持久化数据',
473
+ name: 'session_list',
474
+ description: '列出当前可用的 Mearl 控制会话,可按浏览器或宿主筛选',
475
+ examples: ['session_list', 'session_list --local', 'session_list --browser chrome-a'],
476
+ },
477
+ {
478
+ name: 'session_manage',
479
+ description: '创建、交接、恢复或结束控制会话',
488
480
  params: [
489
481
  {
490
- name: 'browser',
491
- type: 'string',
482
+ name: 'operation',
483
+ type: '"new" | "handoff" | "resume" | "end"',
492
484
  required: true,
493
- description: '托管浏览器的 browserId 或名称',
485
+ description: 'new 创建空会话,handoff 交给用户,resume 恢复控制,end 结束会话并释放资源',
486
+ },
487
+ { name: 'sessionId', type: 'string', description: '已有会话 ID,也可使用 --session' },
488
+ { name: 'reason', type: 'string', description: 'handoff 时说明需要用户处理的事项' },
489
+ {
490
+ name: 'closeCreatedTabs',
491
+ type: 'boolean',
492
+ description: 'end 时关闭会话创建的过程页,默认 false',
493
+ },
494
+ {
495
+ name: 'keepTabIds',
496
+ type: 'number[]',
497
+ description: '保留的结果页面;复用的用户页面始终保留',
494
498
  },
495
499
  {
496
- name: 'deleteProfile',
500
+ name: 'preserveEnvironment',
497
501
  type: 'boolean',
498
- description: '强制删除持久化数据,默认 false',
502
+ description: 'end 默认 true,保留 Mock 与模拟现场;false 清理这些页面的环境',
499
503
  },
504
+ {
505
+ name: 'keepArtifactIds',
506
+ type: 'string[]',
507
+ description: '保留在浏览器宿主的文件产物;其余会话临时文件删除',
508
+ },
509
+ ],
510
+ notes: [
511
+ 'new 通过 --browser 选择浏览器,返回 session.sessionId。handoff、resume、end 使用已有会话 ID。',
512
+ '仅在用户明确交还后 resume。外部 Provider 自行管理任务时通过 --browser 执行 handoff、resume 或 end。',
500
513
  ],
501
514
  examples: [
502
- `browser_close --payload '{"browser":"managed:account-a"}'`,
503
- `browser_close --payload '{"browser":"account-b","deleteProfile":true}'`,
515
+ `session_manage --browser '<browserId>' --payload '{"operation":"new"}'`,
516
+ `session_manage --session '<sessionId>' --payload '{"operation":"end","closeCreatedTabs":true}'`,
504
517
  ],
505
518
  },
506
519
  // ── 标签页 ────────────────────────────────────────────────────────────────
@@ -556,7 +569,7 @@ export const COMMANDS = [
556
569
  {
557
570
  name: 'appProfile',
558
571
  type: 'string',
559
- description: '启用已安装的端模拟,ID 与限制见当前动态帮助。需要系统栏时同时传 emulation.deviceShell=true',
572
+ description: '应用已安装的 Profile,ID 与限制见当前动态帮助。需要系统栏时同时传 emulation.deviceShell=true',
560
573
  },
561
574
  {
562
575
  name: 'os',
@@ -1227,20 +1240,20 @@ export const COMMANDS = [
1227
1240
  },
1228
1241
  {
1229
1242
  name: 'set_app_profile',
1230
- description: '设置目标标签页的端模拟;完整 JSBridge 由能力包提供。可同时设置已安装的网络控件,传 emulation 时联动设备模拟',
1243
+ description: '为目标标签页应用 Profile,按配置启用 JSBridge 和容器行为。可同时设置已安装的网络控件,传 emulation 时联动设备模拟',
1231
1244
  summary: '设置或清除目标标签页的 App 容器模拟',
1232
1245
  params: [
1233
1246
  { name: 'enabled', type: 'boolean', required: true, description: 'true=启用,false=清除' },
1234
1247
  {
1235
1248
  name: 'profile',
1236
1249
  type: 'string',
1237
- description: '已安装的端模拟 ID(enabled=true 时必填);当前动态帮助直接展示目标浏览器目录',
1250
+ description: '已安装的 Profile ID(enabled=true 时必填);当前动态帮助直接展示目标浏览器目录',
1238
1251
  },
1239
1252
  { name: 'os', type: '"ios" | "android"', description: '容器系统,默认 ios' },
1240
1253
  {
1241
1254
  name: 'refreshDefinition',
1242
1255
  type: 'boolean',
1243
- description: '立即采用最新端模拟配置,保留用户显式设置',
1256
+ description: '立即采用最新 Profile,保留用户显式设置',
1244
1257
  },
1245
1258
  {
1246
1259
  name: 'lockDefinition',
@@ -1266,14 +1279,14 @@ export const COMMANDS = [
1266
1279
  {
1267
1280
  name: 'emulation',
1268
1281
  type: 'object',
1269
- description: '可选设备联动参数,字段同 set_device_emulation 去掉 enabled/reload;字段覆盖端模拟配置推荐的设备,deviceShell 默认 true,横屏时可传 splitScreen=true。省略时不设置或清除设备',
1282
+ description: '可选设备联动参数,字段同 set_device_emulation 去掉 enabled/reload;字段覆盖Profile 推荐的设备,deviceShell 默认 true,横屏时可传 splitScreen=true。省略时不设置或清除设备',
1270
1283
  },
1271
1284
  { name: 'reload', type: 'boolean', description: '应用/清除后是否重载页面,默认 true' },
1272
1285
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
1273
1286
  ],
1274
1287
  notes: [
1275
1288
  '只有用户明确要求 App/客户端/容器/JSBridge 模拟时启用。移动视口或普通 H5 调试使用 set_device_emulation。',
1276
- 'emulation={} 使用端模拟配置推荐的设备;enabled=false 时省略 emulation 只清除 App 注入,传 {} 同时清除设备模拟。',
1289
+ 'emulation={} 使用Profile 推荐的设备;enabled=false 时省略 emulation 只清除 App 注入,传 {} 同时清除设备模拟。',
1277
1290
  'bridgeConfig.methods 按方法声明 behavior / response / noop 三选一,可传 silent;只支持受控行为、固定 JSON 回包或成功空实现,不执行配置脚本。',
1278
1291
  ],
1279
1292
  result: [