@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/README.en.md +38 -30
- package/README.md +37 -29
- package/dist/actionTimeouts.js +8 -4
- package/dist/browserRegistry.d.ts +1 -1
- package/dist/browserRegistry.js +3 -1
- package/dist/capabilityHelp.js +21 -12
- package/dist/check.d.ts +0 -1
- package/dist/check.js +7 -22
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +16 -22
- package/dist/commandHelp.js +5 -8
- package/dist/commands.d.ts +86 -60
- package/dist/commands.js +85 -72
- package/dist/guides/api-browser-setup.md +23 -19
- package/dist/guides/api-page-automation.md +1 -1
- package/dist/guides/api-page-environment.md +5 -5
- package/dist/guides/api-request-debugging.md +1 -1
- package/dist/guides/browser-tool-cooperation.md +2 -2
- package/dist/guides/core.md +5 -5
- package/dist/guides/related-skills.md +16 -4
- package/dist/guides/troubleshooting.md +2 -2
- package/dist/index.d.ts +5 -6
- package/dist/index.js +9 -11
- package/dist/plugins/runtime/pluginDiagnostics.js +0 -1
- package/dist/plugins/runtime/pluginTaskManager.js +2 -5
- package/dist/script.js +22 -9
- package/dist/scriptCli.js +3 -5
- package/dist/sdkMethods.js +6 -1
- package/dist/socket.d.ts +0 -2
- package/dist/socket.js +159 -146
- package/dist/unified.d.ts +2 -3
- package/dist/unified.js +171 -84
- package/package.json +6 -6
|
@@ -20,63 +20,68 @@
|
|
|
20
20
|
- `status` 为 `connected`、`pairing`、`running_disconnected` 或 `stopped`;只有 `connected` 可作为页面操作目标。
|
|
21
21
|
- Provider 实例还会返回 `provider`、`ownership`、`persistence`、`operations`、`references`、`details` 和可选的 `pairing`。用 `operations` 判断当前可执行的生命周期操作。
|
|
22
22
|
|
|
23
|
-
`
|
|
23
|
+
`browser_manage` 的 `launch` 默认启动本地独立 Chrome。Provider 使用以下通用结构。外部 Provider 的参数可通过 `mearl <providerId>` 查询。
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
mearl
|
|
26
|
+
mearl browser_manage --payload '{"operation":"launch","provider":"<providerId>","providerOptions":{}}'
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
本机与远端 connector 同时存在时,用 `--local`、`--connector <id|name>`,或用 `--browser <global-id>` 同时指定宿主和 Cookie/UA 的来源浏览器。启动响应中的全局 `browserId` 用于首次操作和交付;建立控制会话后,后续操作由 `--session` 固定目标,无会话时继续传选定的 `--browser`。
|
|
30
30
|
|
|
31
|
-
`
|
|
31
|
+
`browser_manage close` 关闭托管实例;`deleteProfile: true` 表示同时删除 Provider 持久化数据。是否支持关闭、删除、启动、同步 Cookie、detach 或访问入口,以实例的 `operations` 和 Provider 命令帮助为准。
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
`browser_manage` 的 `release` 通过 `--browser <id|名称>` 选择浏览器,只在用户明确要求结束调试、退出接管或清理环境时调用。它会释放 debugger/CDP 控制,清理依赖当前调试连接的 Mock、设备/时区模拟与持续采集,保留浏览器、标签页和原有接入。存在活动控制会话时拒绝浏览器级释放。会话任务的收尾见[控制会话](#control-sessions)。外部 Provider 的收尾方式见 `mearl <providerId>`。
|
|
34
34
|
|
|
35
35
|
浏览器访问入口不会出现在 `browser_list` 中。只有用户明确需要时才运行 `mearl check --browser <id|名称>`,并把返回的 `browserAccess.url` 按敏感信息处理,不写入日志或转发给无关方。
|
|
36
36
|
|
|
37
37
|
<a id="electron-cdp"></a>
|
|
38
38
|
|
|
39
|
-
## Electron
|
|
39
|
+
## 接入已有 Chrome 或 Electron
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
CDP Provider 可接入已启用远程调试的 Chrome 或 Electron,并使用已有页面和登录态。Chrome 可在 `chrome://inspect/#remote-debugging` 开启调试,有授权提示时在浏览器中允许连接。
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
本机没有已连接的扩展或已接入的 CDP 实例时,`browser_list` 会通过 CDP Provider 发现默认 Chrome。脚本直接执行 `tab_list` 等浏览器命令时,如果没有可用目标,也会尝试发现。默认接入读取 Chrome 默认 Profile 的 `DevToolsActivePort`,并在需要时探测本机 9222 端口。可以用下列命令显式接入。
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
```bash
|
|
46
|
+
mearl browser_manage --local --payload '{"operation":"attach","provider":"cdp","providerOptions":{}}'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
连接 Electron 时,传入已启用的渲染页面调试端口。若需为应用启用调试,可在启动时传入 `--remote-debugging-port=9223`。参见 [Electron 调试开关](https://www.electronjs.org/docs/latest/api/command-line-switches#--remote-debugging-portport)。
|
|
46
50
|
|
|
47
51
|
```bash
|
|
48
|
-
mearl
|
|
52
|
+
mearl browser_manage --local --payload '{"operation":"attach","provider":"cdp","providerOptions":{"name":"Electron App","port":9223}}'
|
|
49
53
|
```
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
使用响应里的 `browserId`,也可在 `browser_list` 中查找:
|
|
52
56
|
|
|
53
57
|
```bash
|
|
58
|
+
mearl check --browser '<browserId>'
|
|
54
59
|
mearl tab_list --browser '<browserId>'
|
|
55
60
|
mearl page_snapshot --browser '<browserId>' --payload '{"tabId":12345,"mode":"viewport"}'
|
|
56
61
|
```
|
|
57
62
|
|
|
58
|
-
`tabId` 使用 `tab_list`
|
|
63
|
+
`tabId` 使用 `tab_list` 返回的真实值。Electron 的操作范围是渲染页面。结束接管时运行 `mearl browser_manage --browser '<browserId>' --payload '{"operation":"detach"}'`,浏览器和标签页继续运行。
|
|
59
64
|
|
|
60
65
|
<a id="control-sessions"></a>
|
|
61
66
|
|
|
62
67
|
## 控制会话与人工交接
|
|
63
68
|
|
|
64
|
-
扩展免打扰默认开启;`tab_open active:true` 为 HTTP(S) 页面启用后台焦点模拟,新页在首次导航前生效,不切换标签页或窗口。关闭免打扰后,`active:true` 才会真实激活并恢复最小化窗口。普通页面操作不会自动启用模拟。`activation.mode` 区分 `background` / `foreground`;模拟后的 `document.visibilityState` 可为 `visible`,不能据此判断窗口在前台。交给用户、释放控制或扩展连接断开时恢复,`preserveEnvironment` 不保留此临时状态;交还后按需用 `reuse:"require", active:true` 再次激活。未带会话时通过 `
|
|
69
|
+
扩展免打扰默认开启;`tab_open active:true` 为 HTTP(S) 页面启用后台焦点模拟,新页在首次导航前生效,不切换标签页或窗口。关闭免打扰后,`active:true` 才会真实激活并恢复最小化窗口。普通页面操作不会自动启用模拟。`activation.mode` 区分 `background` / `foreground`;模拟后的 `document.visibilityState` 可为 `visible`,不能据此判断窗口在前台。交给用户、释放控制或扩展连接断开时恢复,`preserveEnvironment` 不保留此临时状态;交还后按需用 `reuse:"require", active:true` 再次激活。未带会话时通过 `browser_manage release` 清理。纯 CDP 和外部 Provider 沿用各自激活能力。
|
|
65
70
|
|
|
66
|
-
|
|
71
|
+
用 `session_list` 列出当前会话。用 `session_manage` 的 `new` 和 `--browser` 显式创建空会话,或在首次 `tab_open` / `page_snapshot` / `page_screenshot` 传 `--session new`,后续命令传 `--session <sessionId>`,使用响应的完整 `session.sessionId`。会话绑定浏览器与传输,页面操作同时指定 `tabId`;仅支持视觉感知的 Provider 可从截图建立会话。
|
|
67
72
|
|
|
68
73
|
扩展新建的后台页面默认进入折叠的 `Mearl` 标签组,前台新页进入展开的 `Mearl · 待操作` 组;两个管理组复用同一个已有窗口,页面打开的后续标签继承源组状态。复用用户的普通页面保留原窗口和分组,`tab_open.group` 可指定其他分组。接管时会话内的管理页移入待操作组,交还后收回 `Mearl` 组;用户正在查看组内其他页面或窗口没有其他页面时保留展开状态。纯 CDP 和外部 Provider 沿用各自的页面组织方式。
|
|
69
74
|
|
|
70
|
-
常规响应的 session 只包含 ID、浏览器、传输、状态、代次和可选 reason,不重复标签页清单。页面列表用 tab_list 查询;
|
|
75
|
+
常规响应的 session 只包含 ID、浏览器、传输、状态、代次和可选 reason,不重复标签页清单。页面列表用 tab_list 查询;session_manage 的交接结果还包含会话页面的 tabs。CLI、SDK、MCP 使用同一结构。
|
|
71
76
|
|
|
72
77
|
会话自动记录新建与复用页面,串行执行同页面操作,并阻止其他会话或无会话调用占用其页面。不同任务使用独立会话;会话不隔离 Cookie 与存储,账号或浏览器共享资源冲突时使用独立浏览器。Extension、CDP 和采用 Mearl 控制的 Provider 共用这些规则;声明外部控制的 Provider(如 Ego)拒绝 Mearl 会话,交接和收尾沿用原工具。
|
|
73
78
|
|
|
74
|
-
`
|
|
79
|
+
`session_manage` 的 `operation:"handoff"` 将控制权交给用户,用 `--session` 或 `sessionId` 指定会话,`reason` 说明需要用户处理的事项。用户在 Mearl Popup 浏览器管理页接管和交还;无扩展 UI 的环境,在用户明确确认交还后调用 `operation:"resume"`。
|
|
75
80
|
|
|
76
81
|
- `CONTROL_SESSION_PAUSED`:停止派发动作,交还后重新快照或截图,根据当前状态继续,不重放未完成批次;已派发的操作可能仍然生效。
|
|
77
82
|
- `CONTROL_SESSION_NOT_FOUND`:会话不存在或已失效,在原浏览器以普通调用执行 `tab_list`,获取当前 `tabId` 并检查操作结果,再按任务需要建立新会话,避免重复写操作。
|
|
78
83
|
|
|
79
|
-
任务结束调用 `
|
|
84
|
+
任务结束调用 `session_manage --session <sessionId> --payload '{"operation":"end"}'`,释放该会话的控制归属并清理临时文件,默认保留页面、Mock 与模拟环境。payload 支持以下保留与清理选项:
|
|
80
85
|
|
|
81
86
|
| 参数 | 行为 |
|
|
82
87
|
| --- | --- |
|
|
@@ -95,12 +100,11 @@ mearl page_snapshot --browser '<browserId>' --payload '{"tabId":12345,"mode":"vi
|
|
|
95
100
|
|
|
96
101
|
| 参数 | 作用 | 使用时机 |
|
|
97
102
|
| --- | --- | --- |
|
|
98
|
-
| `--local` | 只使用当前机器 |
|
|
103
|
+
| `--local` | 只使用当前机器 | 限定本机清单、检查,或在本机执行 `browser_manage` |
|
|
99
104
|
| `--connector <id\|name>` | 只使用一台远端 connector | 限定远端清单、检查或启动宿主;名称或 ID 片段必须唯一 |
|
|
100
|
-
| `--cdp` | 本机强制使用 CDP,并隐含 `--local` | 需要验证或绕过 Extension 控制链路时 |
|
|
101
105
|
| `--server <url>` | 覆盖当前调用使用的 cloud-server URL | 自动配置不可用或临时排障时 |
|
|
102
106
|
|
|
103
|
-
`--local`
|
|
107
|
+
`--local` 不能与 `--connector` 同时使用。全局远端 `browserId` 已包含 connector,普通页面 action 不重复传 `--connector`。`--server` 的解析顺序见 `mearl check --help`,连接排障见[环境安装与连接排查](./troubleshooting.md#cloud-agent)。高级诊断命令 `mearl connector_list` 只用于查看没有可列出浏览器的 connector,普通浏览器操作无需先调用它。
|
|
104
108
|
|
|
105
109
|
<a id="browser-providers"></a>
|
|
106
110
|
|
|
@@ -131,7 +131,7 @@ JS
|
|
|
131
131
|
|
|
132
132
|
## 文件产物与传输
|
|
133
133
|
|
|
134
|
-
文件中转的单文件上限为 256 MiB。Extension/CDP 支持上传与下载;外部 Provider 按 `capabilities.actions` 声明的 `page_upload`、`page_download` 使用对应能力。无会话产物空闲一小时回收,会话产物默认随 `
|
|
134
|
+
文件中转的单文件上限为 256 MiB。Extension/CDP 支持上传与下载;外部 Provider 按 `capabilities.actions` 声明的 `page_upload`、`page_download` 使用对应能力。无会话产物空闲一小时回收,会话产物默认随 `session_manage --session <sessionId> --payload '{"operation":"end"}'` 清理,需要保留时传 `keepArtifactIds`。宿主退出清理暂存文件,保存到调用方的结果文件保留。
|
|
135
135
|
|
|
136
136
|
## run_actions
|
|
137
137
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Mearl 场景:页面测试环境准备
|
|
2
2
|
|
|
3
|
-
需要联动设备/App、折叠屏/分屏、时区或 Cookie
|
|
3
|
+
需要联动设备/App、折叠屏/分屏、时区或 Cookie 时读取本文件。设备预设与 Profile 列表以当前 CLI 为准,不从静态文档推断当前列表。远端/Provider 选择见[浏览器管理](./api-browser-setup.md)。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
设备模拟直接可用。已安装的 Profile 提供 App 端模拟,可声明 UA、JSBridge 和容器行为。先查看 `mearl set_app_profile --help` 展示的目标浏览器动态目录;需要机器可读的桥方法、可调设置与默认版本时用 SDK `mearl.getCapabilities({ app: '目录中的完整 ID' })` 或 MCP `browser_get_capabilities`。按需读取 `usage.skills` / `usage.documentation`,再执行对应动作。
|
|
6
6
|
|
|
7
7
|
## 设备模拟与设备外壳
|
|
8
8
|
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
|
|
11
11
|
scale 只改变视觉比例,不改变页面读取的视口或 DPR。预设的真实生效方向、尺寸、UA 和触摸能力以设置响应为准;折叠设备可能按自然方向归一化,不自行按 ID 推断方向。旧预设仍保留原尺寸与 UA。
|
|
12
12
|
|
|
13
|
-
设备外壳开启/移除需要重载。任务会话用 `
|
|
13
|
+
设备外壳开启/移除需要重载。任务会话用 `session_manage --session <sessionId> --payload '{"operation":"end"}'` 收尾,默认保留设备与 App 模拟;明确需要清理时传 `preserveEnvironment=false`。不带会话的浏览器级 release 会清理依赖调试连接的模拟,关闭 Tab 后该 Tab 的配置失效。任务只要求切换配置时,成功响应足够;要求查看页面效果时再做快照/截图。
|
|
14
14
|
|
|
15
15
|
## App 与设备联动
|
|
16
16
|
|
|
17
17
|
只有用户明确要求 App、客户端、容器、JSBridge 或容器栈模拟时启用 set_app_profile / tab_open.appProfile;普通 H5、唤端链接、客户端分支或操作失败不是启用理由。
|
|
18
18
|
|
|
19
19
|
- 只注入桥:省略 emulation,保留设备状态;App 注入本身不创建根 iframe 或系统栏。
|
|
20
|
-
- 完整端模拟:同一个 set_app_profile 调用传 emulation
|
|
20
|
+
- 完整端模拟:同一个 set_app_profile 调用传 emulation;空对象采用 Profile 推荐的设备,设备外壳默认开启。
|
|
21
21
|
- 左右分屏:端模拟与 deviceShell=true、orientation=landscape、splitScreen=true 必须同时满足。新建页需要首屏分屏时,在 tab_open 同时传 appProfile 与该 emulation 组合。
|
|
22
22
|
- 桥方法覆盖:bridgeConfig 只声明受控行为、固定 JSON 回包或成功空实现,不执行配置脚本。
|
|
23
23
|
- 恢复:enabled=false 且省略 emulation 只清除 App;传 emulation={} 同时清除设备模拟。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
页面网络环境通过已安装 Preset 声明的 networkControl 切换,传入其 id 和 value;省略保留当前设置,null 清除。可用控制项与取值以当前能力目录和 Preset 文档为准。仅作用于目标 Tab,扩展模式与该 Tab 的快捷设置共享;关闭 Tab 或重启浏览器后清除。单次协议请求的参数不等于修改页面网络环境。
|
|
26
26
|
|
|
27
27
|
## 时区
|
|
28
28
|
|
|
@@ -47,7 +47,7 @@ send_request 报 Cookie access not authorized / Permission denied / Host permiss
|
|
|
47
47
|
|
|
48
48
|
完整 mockData 适合替换响应,fields 适合基于真实响应微调。需要同一接口多种情况时用 conditions 子集匹配,按业务入参隔离;无条件规则会覆盖。$index 从 0 起描述同一场景调用顺序,不作为业务请求字段匹配。
|
|
49
49
|
|
|
50
|
-
用 get_mocks 回查目标 tabId 的配置,然后触发页面业务请求验证效果。设置成功不等于页面已收到 Mock。`
|
|
50
|
+
用 get_mocks 回查目标 tabId 的配置,然后触发页面业务请求验证效果。设置成功不等于页面已收到 Mock。`session_manage --session <sessionId> --payload '{"operation":"end"}'` 默认保留 Mock;不带 `--session` 的浏览器级释放会清理依赖调试连接的 Mock,保持 Mock 终态时保留环境。禁用目标 Mock 用 enabled=false。
|
|
51
51
|
|
|
52
52
|
## 大 payload 与文件引用
|
|
53
53
|
|
|
@@ -9,11 +9,11 @@ Mearl 单独使用时沿用主 Skill 的页面操作流程。任务已有 Ego、
|
|
|
9
9
|
- 无需浏览器扩展。已有扩展可关闭 Agent 服务,保留人工调试面板。Mearl 本地运行时仍负责 Provider 路由和已安装 App 资源解析。
|
|
10
10
|
- 一个 Provider 浏览器对应一个 Ego Space。启动时传 `providerOptions.name`;已有任务传数字 `providerOptions.spaceId`。只关联 Agent 所有的 Space,不隐式认领用户 Space。
|
|
11
11
|
- 使用 Provider 返回的完整 `browserId` 和页面 `tabId`,不需要 Agent 手工匹配扩展标签页。不传 Mearl `--session`。
|
|
12
|
-
- Space 交接、恢复和完成统一使用 `mearl
|
|
12
|
+
- Space 交接、恢复和完成统一使用 `mearl session_manage --browser '<browserId>' --payload '{"operation":"handoff"}'`;operation 支持 `handoff`、`resume`、`end`。end 可带 `keepTabIds` 保留数字 ID 对应的结果页。仅在用户明确交还后 resume。
|
|
13
13
|
- 所有页面操作经过 Ego 原生通道;用户接管、Space 失活时由 Ego 阻断,不改走扩展。连接断开或效果未知时不重放动作。
|
|
14
14
|
- 设备和 App 分别通过 `set_device_emulation`、`set_app_profile` 设置。App 来自已安装目录,使用当前已解析版本;UA、声明式全局变量和页面桥通过原生 CDP 安装。导航、截图继续使用同一个 Provider。
|
|
15
15
|
- 共享原生页面宿主提供设备外壳、根 WebView、网络控制和已安装 App 的协议/授权桥。真实授权仍需用户批准;接管会取消待授权会话,交还不恢复旧请求。不提供扩展专属请求/日志入口,其他参数限制以 Provider 指引为准。
|
|
16
|
-
- `
|
|
16
|
+
- `end` 默认不保留 Agent 页面;需要保留结果时显式传 `keepTabIds`。`browser_manage detach` 只解绑,不结束 Space、不清除模拟;需要普通页面时先清除模拟再 end。
|
|
17
17
|
|
|
18
18
|
## agent-browser 等其他工具
|
|
19
19
|
|
package/dist/guides/core.md
CHANGED
|
@@ -17,7 +17,7 @@ mearl page_click --payload '{"tabId":12345,"selector":"@e3"}'
|
|
|
17
17
|
|
|
18
18
|
页面动作持续复用同一浏览器与传输返回的 `tabId`。无可用页时才打开;已知 URL 优先 `reuse:"prefer"`,绑定开发页时沿用其 `openerTabId`。默认后台操作;确需可见输入时激活同一页。
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
默认使用统一发现。需要选择目标时用 `browser_list`,沿用返回的完整实例名或 `browserId`。远端连接与 Provider 选择见[浏览器管理](./api-browser-setup.md)。
|
|
21
21
|
|
|
22
22
|
需要任务归属、并行协作或人工交接时,首次 `tab_open` / `page_snapshot` / `page_screenshot` 传 `--session new`,后续复用完整 `session.sessionId` 与 `tabId`。会话固定目标,但 Cookie/存储仍共享。目标声明由外部工具控制时(例如 Ego 任务),沿用其交接与收尾,不传 Mearl `--session`;跨工具先核验同一实例和物理页面,不能仅凭 URL/标题或直接复用 ref、label、tab ID。详见[工具协作](./browser-tool-cooperation.md)。
|
|
23
23
|
|
|
@@ -35,7 +35,7 @@ mearl page_click --payload '{"tabId":12345,"selector":"@e3"}'
|
|
|
35
35
|
|
|
36
36
|
移动视口、UA、触摸使用 `set_device_emulation`,首屏生效用 `tab_open.emulation`。仅在用户明确要求客户端、JSBridge 或容器时启用 App 模拟;普通 H5、唤端链接或操作失败不构成启用理由。
|
|
37
37
|
|
|
38
|
-
App 可用性以当前目标的 `set_app_profile --help` 或 `get_capabilities` 为准,沿用当前 browser/session。`partial`、`unsupported` 不等于空目录,`available:false`
|
|
38
|
+
App 可用性以当前目标的 `set_app_profile --help` 或 `get_capabilities` 为准,沿用当前 browser/session。`partial`、`unsupported` 不等于空目录,`available:false` 不可启用。按需读 Profile 的 usage 指引,不自动安装;方法存在不证明真实授权、支付等业务能力可用。环境准备见[设备与 App](./api-page-environment.md)。
|
|
39
39
|
|
|
40
40
|
已注册插件通过当前 `mearl --help` 或 SDK `mearl.help()` 发现,具体调用看插件帮助;本指南的专用 Skill 列表不代表全部已安装扩展。插件与 Provider 自己提供业务用法,核心入口不枚举它们的参数。
|
|
41
41
|
|
|
@@ -43,9 +43,9 @@ App 可用性以当前目标的 `set_app_profile --help` 或 `get_capabilities`
|
|
|
43
43
|
|
|
44
44
|
## 人工交接与收尾
|
|
45
45
|
|
|
46
|
-
扫码、验证码或系统交互需要用户时,用 `
|
|
46
|
+
扫码、验证码或系统交互需要用户时,用 `session_manage` 的 handoff 交接,说明原因。用户接管或 `CONTROL_SESSION_PAUSED` 后停止派发;交回后重新观察,不重放未完成批次。无扩展 UI 时,须在用户明确确认交还后再 resume。
|
|
47
47
|
|
|
48
|
-
会话任务用 `
|
|
48
|
+
会话任务用 `session_manage --session <id> --payload '{"operation":"end"}'` 释放归属,默认保留页面、Mock 和模拟环境。保留用户原有页和结果页,只有确认不需要的过程页才关闭。不带 session 的浏览器级释放仅用于用户要求结束调试或清理环境;外部工具按其自身约定收尾。具体归属与保留参数见[控制会话](./api-browser-setup.md#control-sessions)。
|
|
49
49
|
|
|
50
50
|
## 按需深入
|
|
51
51
|
|
|
@@ -56,5 +56,5 @@ App 可用性以当前目标的 `set_app_profile --help` 或 `get_capabilities`
|
|
|
56
56
|
- [接口与埋点调试](./api-request-debugging.md):请求、日志、权限、Mock。
|
|
57
57
|
- [浏览器管理](./api-browser-setup.md):目标、会话、远端与 Provider。
|
|
58
58
|
- [工具协作](./browser-tool-cooperation.md):与 Ego、agent-browser 配合。
|
|
59
|
-
- [专用 Skill 使用与安装](./related-skills.md)
|
|
59
|
+
- [专用 Skill 使用与安装](./related-skills.md):Web 终端、本地微信小程序等专用能力的入口与按需安装方法。
|
|
60
60
|
- [连接排查](./troubleshooting.md):连接失败与环境管理。
|
|
@@ -8,27 +8,39 @@
|
|
|
8
8
|
| 时间戳、Base64、图片编码、URL 编解码 | format-converter |
|
|
9
9
|
| 记录或检索笔记与跨会话记忆 | notes-memory |
|
|
10
10
|
| 管理已有浏览器标签分组、关闭受控标签页 | browser-tab-manager |
|
|
11
|
+
| 读取 Web 终端、发送控制键或获取脚本退出码 | web-terminal |
|
|
11
12
|
| 用户明确要求使用 TinyPNG 压缩图片 | tinypng-compress |
|
|
12
13
|
| 把设计稿叠加到网页并做像素差异对比 | design-overlay |
|
|
13
14
|
| 为网页提供持续双语阅读 | immersive-translate |
|
|
14
15
|
| 运行 bb-browser 站点适配器 | mearl-bbrowser |
|
|
16
|
+
| 新建、修改或审查 App WebView 端模拟配置 | mearl-profile-creator |
|
|
15
17
|
| 开发或审查外部浏览器、真机 Provider | mearl-provider-creator |
|
|
16
18
|
| 把网站操作沉淀为可复用 Skill、CLI 或工具箱 GUI | mearl-skill-creator |
|
|
17
19
|
|
|
18
20
|
有脚本入口的 Skill 可安装并自动注册插件:
|
|
19
21
|
|
|
20
22
|
```bash
|
|
21
|
-
{{setup}} plugin install
|
|
23
|
+
{{setup}} plugin install mearlhq/mearl --github --skill <skill-name> --yes
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
已可用的专用 Skill 按其说明执行。用户明确要求使用表中某项专用能力、且执行任务需要该插件时,可在缺失时按需安装并继续。普通网页操作使用通用流程。
|
|
25
27
|
|
|
28
|
+
## 操作 Web 终端
|
|
29
|
+
|
|
30
|
+
任务需要读取或操作已打开的 Web 终端时,先用 `mearl --help` 查看已注册插件中是否有 `terminal`。缺失时用安装器安装 `web-terminal` 并注册 CLI:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
{{setup}} plugin install mearlhq/mearl --github --skill web-terminal --yes
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
已有包含此 Skill 的本地源码时,可以直接注册其 `skills/web-terminal` 目录。安装后用 `mearl terminal discover <tabId>` 找到页面或 iframe 中的面板,用 `mearl terminal --help` 查看命令。
|
|
37
|
+
|
|
26
38
|
## 运行本地微信小程序
|
|
27
39
|
|
|
28
40
|
任务要运行小程序工程或已编译的微信产物时,先用 `mearl --help` 检查已注册插件中是否有 `wxa`。缺失时,从已包含此 Skill 且当前可访问的官方来源补装:
|
|
29
41
|
|
|
30
42
|
```bash
|
|
31
|
-
{{setup}} plugin install
|
|
43
|
+
{{setup}} plugin install mearlhq/profile-wechat --github --skill wechat-miniprogram --yes
|
|
32
44
|
```
|
|
33
45
|
|
|
34
46
|
官方来源暂不可用且本机已有包含此 Skill 的源码时,可直接注册:
|
|
@@ -43,10 +55,10 @@
|
|
|
43
55
|
|
|
44
56
|
EgoLite 使用独立 `@mearl/provider-ego`,具体流程见工具协作(`mearl guide cooperation`),不需要额外协作 Skill。
|
|
45
57
|
|
|
46
|
-
`mearl-
|
|
58
|
+
`mearl-profile-creator`、`mearl-provider-creator` 和 `mearl-skill-creator` 是指引型 Skill。用标准 Skills 工具安装所需的 Skill。
|
|
47
59
|
|
|
48
60
|
```bash
|
|
49
|
-
npx skills add https://github.com/mearlhq/mearl --skill mearl-
|
|
61
|
+
npx skills add https://github.com/mearlhq/mearl --skill mearl-profile-creator --global
|
|
50
62
|
```
|
|
51
63
|
|
|
52
64
|
已有源码时也可将 Git 来源替换为实际 Skill 目录。安装前核对所选分支或标签确实包含目标 Skill;普通任务不主动安装开发指引。
|
|
@@ -102,7 +102,7 @@ client 会自动拉起 native host 并重试。自动恢复失败时按错误提
|
|
|
102
102
|
|
|
103
103
|
**使用 CDP 模式:**
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
在 Chrome 开启调试并允许授权,通过 [CDP Provider](./api-browser-setup.md#electron-cdp) 接入,再用 `mearl check --browser '<browserId>'` 验证连接。
|
|
106
106
|
|
|
107
107
|
<a id="econnrefused"></a>
|
|
108
108
|
|
|
@@ -159,7 +159,7 @@ client 会处理当前用户的 stale socket 并尝试恢复 native host;恢
|
|
|
159
159
|
|
|
160
160
|
### 可选云连接协议
|
|
161
161
|
|
|
162
|
-
Qoder Cloud Agent 需要在浏览器机器先安装 `@mearl/plugin-qoder
|
|
162
|
+
Qoder Cloud Agent 需要在浏览器机器先安装 Qoder 集成 `@mearl/plugin-qoder`,再按该包 README 和 `docs/cloud-pairing.md` 生成配对信息、配置自定义工具。普通远端 Agent 使用上述 WebSocket 模式。核心未安装对应协议时会报告能力缺失,不会自动安装或读取该协议的凭据。
|
|
163
163
|
|
|
164
164
|
### 请求超时
|
|
165
165
|
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { UnifiedClient, UnifiedClient as MearlClient, decodeBrowserTarget, invok
|
|
|
13
13
|
export type { UnifiedClientOptions, UnifiedInvokeOptions, UnifiedInvokeOptions as InvokeOptions, } from './unified.js';
|
|
14
14
|
export type { PluginInvocation, PluginInvokeOptions, PluginProgress, StructuredPluginProgress, } from './plugins/sdk/plugin.js';
|
|
15
15
|
export { APP_PROFILE_NAMES, BROWSER_DEVICE_PRESET_NAMES, BROWSER_ACTIONS, BROWSER_CAPABILITY_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 '@mearl/browser-core';
|
|
16
|
-
export type { ActionStep, AppProfileName, BrowserAction, BrowserActionMap, BrowserActionRequest, BrowserActionResponse, BrowserCapabilities, BrowserCapabilityAction, BrowserCloseParams, BrowserCommandAction, BrowserInfo, BrowserInfoBase, BrowserJsonValue, BrowserLaunchParams, BrowserProviderOperation, BrowserListResult, BrowserListParams, 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, RequestPermissionParams, RulesResult, RunActionName, RunActionsParams, SelectBrowserParams, SelectBrowserResult, SendRequestFile, SendRequestBinaryBody, SendRequestFormValue, SendRequestParams, SetAppProfileParams, SetCookieParams, SetCookieResult, SetDeviceEmulationParams, SetMockParams, SetRuleParams, SetTimezoneParams, SetTimezoneResult, TabCloseParams, TabOpenParams, } from '@mearl/browser-core';
|
|
16
|
+
export type { ActionStep, AppProfileName, BrowserAction, BrowserActionMap, BrowserActionRequest, BrowserActionResponse, BrowserCapabilities, BrowserCapabilityAction, BrowserCloseParams, BrowserCommandAction, BrowserInfo, BrowserInfoBase, BrowserJsonValue, BrowserLaunchParams, BrowserManageParams, ControlSessionInfo, SessionManageParams, BrowserProviderOperation, BrowserListResult, BrowserListParams, 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, RequestPermissionParams, RulesResult, RunActionName, RunActionsParams, SelectBrowserParams, SelectBrowserResult, SendRequestFile, SendRequestBinaryBody, SendRequestFormValue, SendRequestParams, SetAppProfileParams, SetCookieParams, SetCookieResult, SetDeviceEmulationParams, SetMockParams, SetRuleParams, SetTimezoneParams, SetTimezoneResult, TabCloseParams, TabOpenParams, } from '@mearl/browser-core';
|
|
17
17
|
import { type UnifiedInvokeOptions } from './unified.js';
|
|
18
18
|
import type * as Protocol from '@mearl/browser-core';
|
|
19
19
|
export declare function tabCheckpoint(params: Protocol.CaptureCheckpointParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'tab_checkpoint'>>;
|
|
@@ -28,10 +28,9 @@ export declare function sendRequest(params: Protocol.SendRequestParams, options?
|
|
|
28
28
|
export declare function browserList(options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'browser_list'>>;
|
|
29
29
|
export declare function browserList(params: Protocol.BrowserListParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'browser_list'>>;
|
|
30
30
|
export declare function selectBrowser(params?: Protocol.SelectBrowserParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'browser_select_browser'>>;
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function browserClose(params: Protocol.BrowserCloseParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'browser_close'>>;
|
|
31
|
+
export declare function browserManage(params: Protocol.BrowserManageParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'browser_manage'>>;
|
|
32
|
+
export declare function sessionList(options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'session_list'>>;
|
|
33
|
+
export declare function sessionManage(params: Protocol.SessionManageParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'session_manage'>>;
|
|
35
34
|
export declare function setRule(params: Protocol.SetRuleParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_rule'>>;
|
|
36
35
|
export declare function getRules(options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_rules'>>;
|
|
37
36
|
export declare function pageScreenshot(params: Protocol.PageScreenshotParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'page_screenshot'>>;
|
|
@@ -60,8 +59,8 @@ export declare function setTimezone(params: Protocol.SetTimezoneParams, options?
|
|
|
60
59
|
export declare function getCookie(params: Protocol.GetCookieParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'get_cookie'>>;
|
|
61
60
|
export declare function setCookie(params: Protocol.SetCookieParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'set_cookie'>>;
|
|
62
61
|
export declare function runActions(params: Protocol.RunActionsParams, options?: UnifiedInvokeOptions): Promise<Protocol.BrowserActionResponse<'run_actions'>>;
|
|
63
|
-
export declare function browserControl(params: Protocol.BrowserControlParams, options?: UnifiedInvokeOptions): Promise<any>;
|
|
64
62
|
export declare function pageDownload(params: Protocol.PageDownloadParams, options?: UnifiedInvokeOptions): Promise<any>;
|
|
63
|
+
export declare function pageRecord(params: Protocol.PageRecordParams, options?: UnifiedInvokeOptions): Promise<any>;
|
|
65
64
|
export declare function saveArtifact(artifact: Protocol.BrowserArtifact & {
|
|
66
65
|
browserId?: string;
|
|
67
66
|
}, outputPath: string, options?: UnifiedInvokeOptions): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -44,16 +44,14 @@ export function browserList(paramsOrOptions = {}, options) {
|
|
|
44
44
|
export function selectBrowser(params = {}, options) {
|
|
45
45
|
return invoke('browser_select_browser', params, options);
|
|
46
46
|
}
|
|
47
|
-
export function
|
|
48
|
-
return options
|
|
49
|
-
? invoke('browser_release', paramsOrOptions, options)
|
|
50
|
-
: invoke('browser_release', {}, paramsOrOptions);
|
|
47
|
+
export function browserManage(params, options) {
|
|
48
|
+
return invoke('browser_manage', params, options);
|
|
51
49
|
}
|
|
52
|
-
export function
|
|
53
|
-
return invoke('
|
|
50
|
+
export function sessionList(options) {
|
|
51
|
+
return invoke('session_list', {}, options);
|
|
54
52
|
}
|
|
55
|
-
export function
|
|
56
|
-
return invoke('
|
|
53
|
+
export function sessionManage(params, options) {
|
|
54
|
+
return invoke('session_manage', params, options);
|
|
57
55
|
}
|
|
58
56
|
export function setRule(params, options) {
|
|
59
57
|
return invoke('set_rule', params, options);
|
|
@@ -139,12 +137,12 @@ export function setCookie(params, options) {
|
|
|
139
137
|
export function runActions(params, options) {
|
|
140
138
|
return invoke('run_actions', params, options);
|
|
141
139
|
}
|
|
142
|
-
export function browserControl(params, options) {
|
|
143
|
-
return invoke('browser_control', params, options);
|
|
144
|
-
}
|
|
145
140
|
export function pageDownload(params, options) {
|
|
146
141
|
return invoke('page_download', params, options);
|
|
147
142
|
}
|
|
143
|
+
export function pageRecord(params, options) {
|
|
144
|
+
return invoke('page_record', params, options);
|
|
145
|
+
}
|
|
148
146
|
export async function saveArtifact(artifact, outputPath, options = {}) {
|
|
149
147
|
const { exportArtifact } = await import('./artifacts.js');
|
|
150
148
|
return exportArtifact({ invoke }, artifact, outputPath, options);
|
|
@@ -168,7 +168,6 @@ function taskProjection(record, options, observedAt) {
|
|
|
168
168
|
...(routing.session ? { session: text(routing.session) } : {}),
|
|
169
169
|
...(routing.connector ? { connector: text(routing.connector) } : {}),
|
|
170
170
|
...(routing.local !== undefined ? { local: routing.local } : {}),
|
|
171
|
-
...(routing.transport ? { transport: routing.transport } : {}),
|
|
172
171
|
},
|
|
173
172
|
}
|
|
174
173
|
: {}),
|
|
@@ -240,9 +240,6 @@ export class PluginTaskManager {
|
|
|
240
240
|
throw new Error('Invalid plugin task invocation timeout');
|
|
241
241
|
if (request.options.local !== undefined && typeof request.options.local !== 'boolean')
|
|
242
242
|
throw new Error('Invalid plugin task local routing option');
|
|
243
|
-
if (request.options.transport !== undefined &&
|
|
244
|
-
!['extension', 'cdp'].includes(request.options.transport))
|
|
245
|
-
throw new Error('Invalid plugin task transport');
|
|
246
243
|
if (bridge.scope.bridge === 'service' &&
|
|
247
244
|
request.options.browser &&
|
|
248
245
|
!decodeBrowserTarget(request.options.browser))
|
|
@@ -978,9 +975,9 @@ export class PluginTaskManager {
|
|
|
978
975
|
}
|
|
979
976
|
}
|
|
980
977
|
assertRouting(options, bound) {
|
|
981
|
-
if (Object.keys(options).some(key => !['browser', 'connector', 'session', 'local', '
|
|
978
|
+
if (Object.keys(options).some(key => !['browser', 'connector', 'session', 'local', 'timeoutSec'].includes(key)))
|
|
982
979
|
throw error('PLUGIN_TASK_TARGET_CHANGED', 'Plugin task cannot override internal routing options');
|
|
983
|
-
for (const key of ['browser', 'connector', 'session', 'local'
|
|
980
|
+
for (const key of ['browser', 'connector', 'session', 'local'])
|
|
984
981
|
if (options[key] !== undefined && options[key] !== bound[key])
|
|
985
982
|
throw error('PLUGIN_TASK_TARGET_CHANGED', 'Plugin task cannot change its bound browser routing');
|
|
986
983
|
}
|
package/dist/script.js
CHANGED
|
@@ -37,18 +37,24 @@ export async function executeScript(code, options = {}) {
|
|
|
37
37
|
const controller = new AbortController();
|
|
38
38
|
const invoke = async (action, payload, overrides = {}) => {
|
|
39
39
|
controller.signal.throwIfAborted();
|
|
40
|
+
const managesSession = action === 'session_manage';
|
|
41
|
+
const sessionOverride = managesSession ? payload.sessionId : undefined;
|
|
42
|
+
const inheritsSession = action !== 'browser_manage' &&
|
|
43
|
+
action !== 'session_list' &&
|
|
44
|
+
!(managesSession && (payload.operation === 'new' || sessionOverride));
|
|
40
45
|
const result = await client.invoke(action, payload, {
|
|
41
46
|
...defaults,
|
|
42
|
-
session: sessionId,
|
|
47
|
+
session: inheritsSession ? sessionId : undefined,
|
|
43
48
|
...overrides,
|
|
44
49
|
});
|
|
45
50
|
if (result?.action?.stage === 'dispatch-uncertain' || result?.stage === 'dispatch-uncertain')
|
|
46
51
|
uncertainEffects = true;
|
|
47
52
|
if (result?.session?.sessionId &&
|
|
48
|
-
(!overrides.session || overrides.session === 'new' || overrides.session === sessionId)
|
|
53
|
+
(!overrides.session || overrides.session === 'new' || overrides.session === sessionId) &&
|
|
54
|
+
(!sessionOverride || !sessionId || sessionOverride === sessionId)) {
|
|
49
55
|
session = result.session;
|
|
50
56
|
if (!overrides.session || overrides.session === 'new')
|
|
51
|
-
sessionId = result.session.sessionId;
|
|
57
|
+
sessionId = result.session.status === 'released' ? undefined : result.session.sessionId;
|
|
52
58
|
}
|
|
53
59
|
return result;
|
|
54
60
|
};
|
|
@@ -95,7 +101,14 @@ export async function executeScript(code, options = {}) {
|
|
|
95
101
|
}
|
|
96
102
|
};
|
|
97
103
|
const abort = () => stop({ code: 'SCRIPT_CANCELLED', message: 'Script execution cancelled' });
|
|
98
|
-
const
|
|
104
|
+
const timeOut = () => stop({ code: 'SCRIPT_TIMEOUT', message: 'Script execution deadline exceeded' });
|
|
105
|
+
const pastDeadline = () => {
|
|
106
|
+
if (Date.now() < executionDeadline)
|
|
107
|
+
return false;
|
|
108
|
+
timeOut();
|
|
109
|
+
return true;
|
|
110
|
+
};
|
|
111
|
+
const deadline = setTimeout(timeOut, Math.max(0, executionDeadline - Date.now()));
|
|
99
112
|
signal?.addEventListener('abort', abort, { once: true });
|
|
100
113
|
if (signal?.aborted)
|
|
101
114
|
abort();
|
|
@@ -138,7 +151,8 @@ export async function executeScript(code, options = {}) {
|
|
|
138
151
|
}
|
|
139
152
|
};
|
|
140
153
|
const send = (message) => {
|
|
141
|
-
|
|
154
|
+
// A transport timer can settle a pending call before the script timer gets its turn.
|
|
155
|
+
if (outcome !== undefined || !child.connected || pastDeadline())
|
|
142
156
|
return;
|
|
143
157
|
child.send(message, error => {
|
|
144
158
|
if (error)
|
|
@@ -146,7 +160,7 @@ export async function executeScript(code, options = {}) {
|
|
|
146
160
|
});
|
|
147
161
|
};
|
|
148
162
|
child.on('message', (message) => {
|
|
149
|
-
if (outcome !== undefined || !message || typeof message !== 'object')
|
|
163
|
+
if (outcome !== undefined || !message || typeof message !== 'object' || pastDeadline())
|
|
150
164
|
return;
|
|
151
165
|
if (message.type === 'done' || message.type === 'error') {
|
|
152
166
|
stop(message.type === 'error'
|
|
@@ -210,11 +224,10 @@ export async function executeScript(code, options = {}) {
|
|
|
210
224
|
session: sessionId,
|
|
211
225
|
...args[2],
|
|
212
226
|
});
|
|
213
|
-
const optionsOnly =
|
|
227
|
+
const optionsOnly = OPTIONS_ONLY.has(method) &&
|
|
214
228
|
!(method === 'browserList' &&
|
|
215
229
|
args[0] &&
|
|
216
|
-
('provider' in args[0] || 'launchForm' in args[0]))
|
|
217
|
-
(method === 'browserRelease' && args.length < 2);
|
|
230
|
+
('provider' in args[0] || 'launchForm' in args[0]));
|
|
218
231
|
return invoke(METHOD_ACTIONS.get(method), optionsOnly ? {} : (args[0] ?? {}), optionsOnly ? args[0] : args[1]);
|
|
219
232
|
})
|
|
220
233
|
.then(result => send({ type: 'response', id, result, session }), error => send({ type: 'response', id, error: serializeError(error), session }))
|
package/dist/scriptCli.js
CHANGED
|
@@ -11,7 +11,6 @@ export async function runScriptCli(args, commandName) {
|
|
|
11
11
|
.option('--browser <id-or-name>', '指定浏览器')
|
|
12
12
|
.option('--connector <id-or-name>', '限制到远端 connector')
|
|
13
13
|
.option('--local', '仅使用本机浏览器')
|
|
14
|
-
.option('--cdp', '强制本机 CDP')
|
|
15
14
|
.option('--server <url>', '覆盖 cloud-server 地址')
|
|
16
15
|
.option('--timeout <seconds>', '整个脚本的执行时限(默认 60 秒)', '60')
|
|
17
16
|
.allowExcessArguments(false)
|
|
@@ -25,8 +24,8 @@ export async function runScriptCli(args, commandName) {
|
|
|
25
24
|
const timeout = Number(options.timeout);
|
|
26
25
|
if (!Number.isFinite(timeout) || timeout <= 0 || timeout * 1000 > 2_147_483_647)
|
|
27
26
|
throw new Error('--timeout 必须是有效范围内的大于 0 的秒数');
|
|
28
|
-
if (
|
|
29
|
-
throw new Error('--local
|
|
27
|
+
if (options.local && options.connector)
|
|
28
|
+
throw new Error('--local 不能与 --connector 同时使用');
|
|
30
29
|
if (options.file)
|
|
31
30
|
source = await readFile(resolve(options.file), 'utf8');
|
|
32
31
|
else {
|
|
@@ -64,8 +63,7 @@ export async function runScriptCli(args, commandName) {
|
|
|
64
63
|
...(options.session ? { session: options.session } : {}),
|
|
65
64
|
...(options.browser ? { browser: options.browser } : {}),
|
|
66
65
|
...(options.connector ? { connector: options.connector } : {}),
|
|
67
|
-
...(options.local
|
|
68
|
-
...(options.cdp ? { transport: 'cdp' } : {}),
|
|
66
|
+
...(options.local ? { local: true } : {}),
|
|
69
67
|
...(options.server ? { serverUrl: options.server } : {}),
|
|
70
68
|
});
|
|
71
69
|
if (result.stdout)
|
package/dist/sdkMethods.js
CHANGED
|
@@ -6,4 +6,9 @@ export const SDK_METHOD_ACTIONS = new Map(Object.keys(BROWSER_COMMAND_ACTIONS).m
|
|
|
6
6
|
]));
|
|
7
7
|
SDK_METHOD_ACTIONS.set('selectBrowser', 'browser_select_browser');
|
|
8
8
|
SDK_METHOD_ACTIONS.set('captureCheckpoint', 'tab_checkpoint');
|
|
9
|
-
export const SDK_OPTIONS_ONLY_METHODS = new Set([
|
|
9
|
+
export const SDK_OPTIONS_ONLY_METHODS = new Set([
|
|
10
|
+
'browserList',
|
|
11
|
+
'sessionList',
|
|
12
|
+
'tabList',
|
|
13
|
+
'getRules',
|
|
14
|
+
]);
|
package/dist/socket.d.ts
CHANGED
|
@@ -25,8 +25,6 @@ export interface InvokeOptions {
|
|
|
25
25
|
timeoutSec?: number;
|
|
26
26
|
/** Absolute cutoff for sending this request, including any routing retries. */
|
|
27
27
|
deadline?: number;
|
|
28
|
-
/** Force CDP transport instead of extension */
|
|
29
|
-
transport?: 'cdp';
|
|
30
28
|
/** Target a specific browser by id / name (see the browser registry). */
|
|
31
29
|
browser?: string;
|
|
32
30
|
/** Identifies whether browser control originated on this machine or through a remote connector. */
|