@mearl/client 2.10.0 → 2.11.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.md +4 -2
- package/dist/commands.d.ts +12 -9
- package/dist/commands.js +18 -7
- package/dist/generated-browser-action-protocol.d.ts +20 -4
- package/dist/socket.js +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -69,7 +69,9 @@ mearl browser_launch --payload '{"name":"account-b","query":"test_account"}'
|
|
|
69
69
|
mearl browser_launch --payload '{"name":"cookie-copy","copyCookieDomains":["example.com"]}'
|
|
70
70
|
mearl browser_launch --payload '{"name":"cloud-login","provider":"agentbay","persistent":true,"userAgentMode":"desktop","copyCookieDomains":["example.com"],"url":"https://example.com/account"}'
|
|
71
71
|
mearl browser_launch --browser '<控制浏览器 browserId>' --payload '{"name":"cloud-login","provider":"agentbay","reuse":"require","copyCookieDomains":["example.com"]}'
|
|
72
|
+
mearl browser_launch --browser '<本地来源 browserId>' --payload '{"sessionId":"<其他设备创建的 AgentBay sessionId>","copyCookieDomains":["example.com"]}'
|
|
72
73
|
mearl browser_launch --payload '{"name":"cloud-tools","provider":"agentbay","copyCookieDomains":"mearl-services"}'
|
|
74
|
+
mearl browser_launch --payload '{"name":"cloud-tools-plus","provider":"agentbay","copyCookieDomains":{"presets":["mearl-services"],"domains":["figma.com"]}}'
|
|
73
75
|
mearl browser_launch --payload '{"name":"figma","userAgentMode":"desktop","copyCookieDomains":["figma.com"]}'
|
|
74
76
|
mearl browser_list
|
|
75
77
|
mearl browser_release
|
|
@@ -120,9 +122,9 @@ mearl browser_release
|
|
|
120
122
|
|
|
121
123
|
`browser_list` 统一列出普通浏览器和托管浏览器。`type` 区分 `regular` / `managed`,`status` 区分 `connected` / `running_disconnected` / `stopped`;只有 `connected` 的浏览器可作为操作目标。
|
|
122
124
|
|
|
123
|
-
`browser_release`
|
|
125
|
+
按 `sessionId` 接入的 AgentBay 浏览器用 `browser_release` 收尾:它会移除本机 attachment 并退出对应宿主,但不会关闭云端 Session。其他浏览器仅在用户明确要求结束调试、退出接管或清理会话资源时调用;它会释放 debugger/CDP 控制和会话级临时状态(包括设备/时区模拟),保留浏览器及全部标签页,后续浏览器操作可自动重新建立控制。
|
|
124
126
|
|
|
125
|
-
托管浏览器使用独立 Profile。控制浏览器需先登录 TDBank;生成的 SSO 地址在本地内部传递,本地实例可以使用 `headless: true`(默认)完成测试账号登录。AgentBay 固定为非 headless,传 `headless: true` 会被拒绝;`imageId` 可指定镜像别名或具体镜像 ID,省略时使用已验证的 Linux Browser Use 内网镜像。`persistent: true` 会让本地实例保留 Profile,让 AgentBay 同名实例绑定稳定的云端 Browser Context;正常关闭时同步 Cookie、LocalStorage、IndexedDB 等状态,下次启动无需再次复制本地登录态。`deleteProfile: true` 会显式删除对应 Profile 或 Context。AgentBay 的 `reuse` 支持 `never`(默认)、`prefer` 和 `require`:`prefer` 存在运行实例时复用、否则创建,`require`
|
|
127
|
+
托管浏览器使用独立 Profile。控制浏览器需先登录 TDBank;生成的 SSO 地址在本地内部传递,本地实例可以使用 `headless: true`(默认)完成测试账号登录。AgentBay 固定为非 headless,传 `headless: true` 会被拒绝;`imageId` 可指定镜像别名或具体镜像 ID,省略时使用已验证的 Linux Browser Use 内网镜像。`persistent: true` 会让本地实例保留 Profile,让 AgentBay 同名实例绑定稳定的云端 Browser Context;正常关闭时同步 Cookie、LocalStorage、IndexedDB 等状态,下次启动无需再次复制本地登录态。`deleteProfile: true` 会显式删除对应 Profile 或 Context。AgentBay 的 `reuse` 支持 `never`(默认)、`prefer` 和 `require`:`prefer` 存在运行实例时复用、否则创建,`require` 只复用且不会意外创建计费会话。另一台设备已知确切 Session 时,可传 `sessionId` 直接通过 AgentBay CDP 接入,不需要 cloud-server;当前设备需配置能访问该 Session 的 `AGENTBAY_KEY`。provider-local ID 为 `managed:agentbay:session:<sessionId>`,跨 CLI 调用使用启动响应中的全局 `browserId`,且本机只持有 attachment。`copyCookieDomains` 传数组时复制指定域,传 `"mearl-services"` 时同步 Mearl 依赖平台登录态;需要同时复制基础登录态和额外站点时传 `{ "presets": ["mearl-services"], "domains": [...] }`。Cookie 值不会经过 cloud-server,也不会出现在命令结果或日志中;`userAgentMode: "desktop"` 让本地实例使用匹配本机 Chrome 版本的桌面 UA,AgentBay 则复用当前控制浏览器的桌面 UA。`browser_list` 仅返回浏览器的稳定配置,不携带 AgentBay 串流入口或沙箱 noVNC 地址。需要时显式运行 `mearl check --browser <id|名称>`,由统一的浏览器访问入口能力实时返回 `browserAccess`;AgentBay、OpenSandbox 和 AONE Sandbox 地址都应按敏感信息处理。完整设计见 [托管浏览器与 TDBank 多账号设计](../../docs/managed-browsers.md)。
|
|
126
128
|
|
|
127
129
|
## 架构
|
|
128
130
|
|
package/dist/commands.d.ts
CHANGED
|
@@ -386,21 +386,24 @@ export declare const COMMANDS: readonly [{
|
|
|
386
386
|
readonly examples: ["browser_list"];
|
|
387
387
|
}, {
|
|
388
388
|
readonly name: "browser_release";
|
|
389
|
-
readonly description: "
|
|
390
|
-
readonly summary: "
|
|
389
|
+
readonly description: "sessionId 接入的 AgentBay 浏览器用它解除本机 attachment且不关闭云端 Session;其他浏览器仅按用户明确要求释放调试控制和会话级临时效果(含设备/时区模拟),不用于普通任务收尾";
|
|
390
|
+
readonly summary: "释放浏览器控制或解除 Session attachment";
|
|
391
391
|
readonly examples: ["browser_release", "browser_release --browser chrome-a"];
|
|
392
392
|
}, {
|
|
393
393
|
readonly name: "browser_launch";
|
|
394
|
-
readonly description: "启动本地 Chrome
|
|
394
|
+
readonly description: "启动本地 Chrome、创建/复用同名 AgentBay 云浏览器,或用 sessionId 接入现有云端 Session";
|
|
395
395
|
readonly params: [{
|
|
396
396
|
readonly name: "name";
|
|
397
397
|
readonly type: "string";
|
|
398
|
-
readonly
|
|
399
|
-
readonly description: "实例名称,最多 64 个字符";
|
|
398
|
+
readonly description: "实例名称,创建浏览器时必填;按 sessionId 接入时可省略";
|
|
400
399
|
}, {
|
|
401
400
|
readonly name: "provider";
|
|
402
401
|
readonly type: "\"local\" | \"agentbay\"";
|
|
403
|
-
readonly description: "运行环境,默认 local
|
|
402
|
+
readonly description: "运行环境,默认 local;传 sessionId 时自动使用 agentbay,否则 agentbay 从 AGENTBAY_KEY 创建云浏览器";
|
|
403
|
+
}, {
|
|
404
|
+
readonly name: "sessionId";
|
|
405
|
+
readonly type: "string";
|
|
406
|
+
readonly description: "显式接入现有 AgentBay Session;不会创建、初始化或取得其生命周期所有权";
|
|
404
407
|
}, {
|
|
405
408
|
readonly name: "reuse";
|
|
406
409
|
readonly type: "\"never\" | \"prefer\" | \"require\"";
|
|
@@ -451,10 +454,10 @@ export declare const COMMANDS: readonly [{
|
|
|
451
454
|
readonly description: "CDP 控制浏览器中用于读取 TDBank Cookie 的标签页";
|
|
452
455
|
}, {
|
|
453
456
|
readonly name: "copyCookieDomains";
|
|
454
|
-
readonly type: "string[] | \"mearl-services\"";
|
|
455
|
-
readonly description: "从控制浏览器复制 Cookie
|
|
457
|
+
readonly type: "string[] | \"mearl-services\" | { presets?: [\"mearl-services\"]; domains?: string[] }";
|
|
458
|
+
readonly description: "从控制浏览器复制 Cookie:可传域名数组、Mearl 登录态预设,或组合预设与额外域名";
|
|
456
459
|
}];
|
|
457
|
-
readonly examples: ["browser_launch --payload '{\"name\":\"cloud-a\",\"provider\":\"agentbay\",\"userAgentMode\":\"desktop\",\"url\":\"https://example.com\"}'", "browser_launch --payload '{\"name\":\"cloud-public\",\"provider\":\"agentbay\",\"imageId\":\"browser_latest\",\"url\":\"https://example.com\"}'", "browser_launch --payload '{\"name\":\"cloud-login\",\"provider\":\"agentbay\",\"persistent\":true,\"copyCookieDomains\":[\"example.com\"],\"url\":\"https://example.com/account\"}'", "browser_launch --payload '{\"name\":\"cloud-login\",\"provider\":\"agentbay\",\"reuse\":\"require\",\"copyCookieDomains\":[\"example.com\"]}'", "browser_launch --payload '{\"name\":\"cloud-tools\",\"provider\":\"agentbay\",\"copyCookieDomains\":\"mearl-services\"}'", "browser_launch --payload '{\"name\":\"account-a\",\"headless\":true,\"accountId\":12345}'", "browser_launch --payload '{\"name\":\"figma\",\"userAgentMode\":\"desktop\",\"copyCookieDomains\":[\"figma.com\"]}'", "browser_launch --payload '{\"name\":\"account-b\",\"query\":\"test_account\",\"url\":\"https://www.taobao.com\"}'", "browser_launch --payload '{\"name\":\"with-cookies\",\"copyCookieDomains\":[\"example.com\",\"sub.example.org\"]}'"];
|
|
460
|
+
readonly examples: ["browser_launch --payload '{\"name\":\"cloud-a\",\"provider\":\"agentbay\",\"userAgentMode\":\"desktop\",\"url\":\"https://example.com\"}'", "browser_launch --payload '{\"name\":\"cloud-public\",\"provider\":\"agentbay\",\"imageId\":\"browser_latest\",\"url\":\"https://example.com\"}'", "browser_launch --payload '{\"name\":\"cloud-login\",\"provider\":\"agentbay\",\"persistent\":true,\"copyCookieDomains\":[\"example.com\"],\"url\":\"https://example.com/account\"}'", "browser_launch --payload '{\"name\":\"cloud-login\",\"provider\":\"agentbay\",\"reuse\":\"require\",\"copyCookieDomains\":[\"example.com\"]}'", "browser_launch --browser '<本地浏览器 browserId>' --payload '{\"sessionId\":\"<AgentBay sessionId>\",\"copyCookieDomains\":[\"example.com\"]}'", "browser_launch --payload '{\"name\":\"cloud-tools\",\"provider\":\"agentbay\",\"copyCookieDomains\":\"mearl-services\"}'", "browser_launch --payload '{\"name\":\"cloud-tools\",\"provider\":\"agentbay\",\"copyCookieDomains\":{\"presets\":[\"mearl-services\"],\"domains\":[\"figma.com\"]}}'", "browser_launch --payload '{\"name\":\"account-a\",\"headless\":true,\"accountId\":12345}'", "browser_launch --payload '{\"name\":\"figma\",\"userAgentMode\":\"desktop\",\"copyCookieDomains\":[\"figma.com\"]}'", "browser_launch --payload '{\"name\":\"account-b\",\"query\":\"test_account\",\"url\":\"https://www.taobao.com\"}'", "browser_launch --payload '{\"name\":\"with-cookies\",\"copyCookieDomains\":[\"example.com\",\"sub.example.org\"]}'"];
|
|
458
461
|
}, {
|
|
459
462
|
readonly name: "browser_close";
|
|
460
463
|
readonly description: "关闭指定托管浏览器并按策略保留或清理本地 Profile / AgentBay Context";
|
package/dist/commands.js
CHANGED
|
@@ -290,19 +290,28 @@ export const COMMANDS = [
|
|
|
290
290
|
},
|
|
291
291
|
{
|
|
292
292
|
name: 'browser_release',
|
|
293
|
-
description: '
|
|
294
|
-
summary: '
|
|
293
|
+
description: 'sessionId 接入的 AgentBay 浏览器用它解除本机 attachment且不关闭云端 Session;其他浏览器仅按用户明确要求释放调试控制和会话级临时效果(含设备/时区模拟),不用于普通任务收尾',
|
|
294
|
+
summary: '释放浏览器控制或解除 Session attachment',
|
|
295
295
|
examples: ['browser_release', 'browser_release --browser chrome-a'],
|
|
296
296
|
},
|
|
297
297
|
{
|
|
298
298
|
name: 'browser_launch',
|
|
299
|
-
description: '启动本地 Chrome
|
|
299
|
+
description: '启动本地 Chrome、创建/复用同名 AgentBay 云浏览器,或用 sessionId 接入现有云端 Session',
|
|
300
300
|
params: [
|
|
301
|
-
{
|
|
301
|
+
{
|
|
302
|
+
name: 'name',
|
|
303
|
+
type: 'string',
|
|
304
|
+
description: '实例名称,创建浏览器时必填;按 sessionId 接入时可省略',
|
|
305
|
+
},
|
|
302
306
|
{
|
|
303
307
|
name: 'provider',
|
|
304
308
|
type: '"local" | "agentbay"',
|
|
305
|
-
description: '运行环境,默认 local
|
|
309
|
+
description: '运行环境,默认 local;传 sessionId 时自动使用 agentbay,否则 agentbay 从 AGENTBAY_KEY 创建云浏览器',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'sessionId',
|
|
313
|
+
type: 'string',
|
|
314
|
+
description: '显式接入现有 AgentBay Session;不会创建、初始化或取得其生命周期所有权',
|
|
306
315
|
},
|
|
307
316
|
{
|
|
308
317
|
name: 'reuse',
|
|
@@ -346,8 +355,8 @@ export const COMMANDS = [
|
|
|
346
355
|
},
|
|
347
356
|
{
|
|
348
357
|
name: 'copyCookieDomains',
|
|
349
|
-
type: 'string[] | "mearl-services"',
|
|
350
|
-
description: '从控制浏览器复制 Cookie
|
|
358
|
+
type: 'string[] | "mearl-services" | { presets?: ["mearl-services"]; domains?: string[] }',
|
|
359
|
+
description: '从控制浏览器复制 Cookie:可传域名数组、Mearl 登录态预设,或组合预设与额外域名',
|
|
351
360
|
},
|
|
352
361
|
],
|
|
353
362
|
examples: [
|
|
@@ -355,7 +364,9 @@ export const COMMANDS = [
|
|
|
355
364
|
`browser_launch --payload '{"name":"cloud-public","provider":"agentbay","imageId":"browser_latest","url":"https://example.com"}'`,
|
|
356
365
|
`browser_launch --payload '{"name":"cloud-login","provider":"agentbay","persistent":true,"copyCookieDomains":["example.com"],"url":"https://example.com/account"}'`,
|
|
357
366
|
`browser_launch --payload '{"name":"cloud-login","provider":"agentbay","reuse":"require","copyCookieDomains":["example.com"]}'`,
|
|
367
|
+
`browser_launch --browser '<本地浏览器 browserId>' --payload '{"sessionId":"<AgentBay sessionId>","copyCookieDomains":["example.com"]}'`,
|
|
358
368
|
`browser_launch --payload '{"name":"cloud-tools","provider":"agentbay","copyCookieDomains":"mearl-services"}'`,
|
|
369
|
+
`browser_launch --payload '{"name":"cloud-tools","provider":"agentbay","copyCookieDomains":{"presets":["mearl-services"],"domains":["figma.com"]}}'`,
|
|
359
370
|
`browser_launch --payload '{"name":"account-a","headless":true,"accountId":12345}'`,
|
|
360
371
|
`browser_launch --payload '{"name":"figma","userAgentMode":"desktop","copyCookieDomains":["figma.com"]}'`,
|
|
361
372
|
`browser_launch --payload '{"name":"account-b","query":"test_account","url":"https://www.taobao.com"}'`,
|
|
@@ -157,6 +157,8 @@ export interface ManagedBrowserInfo extends BrowserInfoBase {
|
|
|
157
157
|
persistent: boolean;
|
|
158
158
|
cdpPort?: number;
|
|
159
159
|
agentbaySessionId?: string;
|
|
160
|
+
/** Whether this host owns the AgentBay session lifecycle or only attaches to it. */
|
|
161
|
+
agentbaySessionMode?: 'owned' | 'attached';
|
|
160
162
|
/** AgentBay image used to create the session. */
|
|
161
163
|
agentbayImageId?: string;
|
|
162
164
|
/** Persistent AgentBay browser context ID when enabled for this instance. */
|
|
@@ -199,12 +201,26 @@ export interface BrowserReleaseResult {
|
|
|
199
201
|
hadActiveControl: boolean;
|
|
200
202
|
transports: Array<'extension' | 'cdp'>;
|
|
201
203
|
affectedTabIds: number[];
|
|
204
|
+
/** True when browser_release also removed a sessionId-based local AgentBay attachment. */
|
|
205
|
+
detached?: boolean;
|
|
206
|
+
/** Attached sessions remain alive in AgentBay after the local attachment is released. */
|
|
207
|
+
sessionClosed?: boolean;
|
|
208
|
+
agentbaySessionId?: string;
|
|
202
209
|
failures?: BrowserReleaseFailure[];
|
|
203
210
|
}
|
|
211
|
+
export interface CookieCopyScope {
|
|
212
|
+
/** Maintained authentication-domain presets to include. */
|
|
213
|
+
presets?: Array<'mearl-services'>;
|
|
214
|
+
/** Additional domains or URLs to copy alongside the selected presets. */
|
|
215
|
+
domains?: string[];
|
|
216
|
+
}
|
|
204
217
|
export interface BrowserLaunchParams {
|
|
205
|
-
|
|
206
|
-
|
|
218
|
+
/** Required when creating a browser; optional when attaching by AgentBay sessionId. */
|
|
219
|
+
name?: string;
|
|
220
|
+
/** Browser runtime provider. Defaults to local Chrome unless sessionId is present. */
|
|
207
221
|
provider?: 'local' | 'agentbay';
|
|
222
|
+
/** Attach to an exact live AgentBay session without creating or owning it. */
|
|
223
|
+
sessionId?: string;
|
|
208
224
|
/** AgentBay running-session reuse policy. Defaults to never. */
|
|
209
225
|
reuse?: 'never' | 'prefer' | 'require';
|
|
210
226
|
/** AgentBay image alias or concrete image ID. Only supported by the AgentBay provider. */
|
|
@@ -221,8 +237,8 @@ export interface BrowserLaunchParams {
|
|
|
221
237
|
site?: string | number;
|
|
222
238
|
query?: string;
|
|
223
239
|
tabId?: number;
|
|
224
|
-
/** Copy explicit domains
|
|
225
|
-
copyCookieDomains?: string[] | 'mearl-services';
|
|
240
|
+
/** Copy explicit domains, the Mearl-service preset, or a combination of both. */
|
|
241
|
+
copyCookieDomains?: string[] | 'mearl-services' | CookieCopyScope;
|
|
226
242
|
}
|
|
227
243
|
export interface BrowserCloseParams {
|
|
228
244
|
browser: string;
|
package/dist/socket.js
CHANGED
|
@@ -11,6 +11,7 @@ import fs from 'node:fs';
|
|
|
11
11
|
import os from 'node:os';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { createRequire } from 'node:module';
|
|
14
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
14
15
|
import { resolveFileRefs } from './fileRefs.js';
|
|
15
16
|
import { listLiveBrowsers, findBrowser, describeBrowser } from './browserRegistry.js';
|
|
16
17
|
import { resolveActionTimeoutSec } from './actionTimeouts.js';
|
|
@@ -255,6 +256,7 @@ function invokeOnce(action, data, timeoutSec, transport, socketPath, controlSour
|
|
|
255
256
|
const socket = net.createConnection(socketPath);
|
|
256
257
|
let settled = false;
|
|
257
258
|
let buffer = '';
|
|
259
|
+
const decoder = new StringDecoder('utf8');
|
|
258
260
|
const settle = (error, result) => {
|
|
259
261
|
if (settled)
|
|
260
262
|
return;
|
|
@@ -283,7 +285,7 @@ function invokeOnce(action, data, timeoutSec, transport, socketPath, controlSour
|
|
|
283
285
|
socket.write(JSON.stringify(message) + '\n');
|
|
284
286
|
});
|
|
285
287
|
socket.on('data', chunk => {
|
|
286
|
-
buffer +=
|
|
288
|
+
buffer += decoder.write(chunk);
|
|
287
289
|
if (Buffer.byteLength(buffer, 'utf-8') > MAX_SOCKET_BUFFER_SIZE) {
|
|
288
290
|
settle(new Error(`Socket 响应超过 ${MAX_SOCKET_BUFFER_SIZE} 字节限制`));
|
|
289
291
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Unified Mearl SDK & CLI for local and remote browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"commander": "^15.0.0",
|
|
56
56
|
"fastest-levenshtein": "^1.0.16",
|
|
57
57
|
"ws": "^8.18.0",
|
|
58
|
-
"@mearl/cloud-types": "2.
|
|
58
|
+
"@mearl/cloud-types": "2.11.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "^24.9.1",
|