@mearl/client 3.1.3 → 3.1.4

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 CHANGED
@@ -4,9 +4,26 @@
4
4
 
5
5
  Use `mearl` in a terminal or `@mearl/client` in TypeScript to control browsers, inspect requests and logs, or run Skill commands. The CLI, SDK, and script runner share browser routing and plugin runtimes. `@mearl/setup` manages installation and connections.
6
6
 
7
- Run `mearl guide` for the core workflow in this version; `mearl guide --list` lists topics. For example, `mearl guide run` covers SDK composition and `mearl guide environment` covers devices/Apps. Guides read bundled npm resources without browser connections, plugin loading, installation, or automatic updates. Use `mearl <action> --help` for arguments and existing catalogs for installed target capabilities.
7
+ Run `mearl guide` for the core workflow in this version. Use `mearl guide --list` to list topics. For example, `mearl guide run` covers SDK composition and `mearl guide environment` covers devices and Apps. Guides read bundled npm resources and local Preset metadata. Use `mearl <action> --help` for arguments and existing catalogs for installed target capabilities.
8
8
 
9
- Guide content is maintained only in this package's `guides/`, copied to `dist/guides/` at build time, and checked by `pnpm check:skills`. CLI output converts local document links into guide commands. `skills/mearl/` distributes only a compact `SKILL.md`, without guide copies. MCP-only clients unable to run CLI use current tool descriptions/schemas.
9
+ `mearl guide skills` lists specialized Skills for the selected Preset. In `defaults.skillCatalog`, map each Skill name to an entry with a `description` of its use cases, or provide the description as a string. On-demand installs use `defaults.skillCatalogSource` by default. Set an individual entry's `source` to use a different repository, using a repository identifier supported by the installer or a full HTTPS repository URL. The Preset manages enabled entries in its top-level `skills` map. `defaults.extension.links.agentDocs` can link to team Skill instructions.
10
+
11
+ ```json
12
+ {
13
+ "defaults": {
14
+ "skillCatalogSource": "team/skills",
15
+ "skillCatalog": {
16
+ "team-report": { "description": "Read team reports" },
17
+ "other-report": {
18
+ "description": "Read another team's reports",
19
+ "source": "https://github.com/example/other-skills"
20
+ }
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ This package maintains its bundled guides in `guides/`, copies them to `dist/guides/` at build time, and checks them with `pnpm check:skills`. CLI output converts local document links into guide commands. `skills/mearl/` distributes a compact `SKILL.md`. MCP-only clients use the current tool descriptions and schemas.
10
27
 
11
28
  A unified browser SDK and CLI discovering browsers on this machine and all connectors under configured cloud-server instances. Global `browserId` from `browser_list` selects local Socket or cloud WebSocket routing automatically.
12
29
 
package/README.md CHANGED
@@ -4,9 +4,26 @@
4
4
 
5
5
  在终端使用 `mearl`,或在 TypeScript 中使用 `@mearl/client`,控制浏览器、查看请求和日志,或执行 Skill 命令。CLI、SDK 和脚本运行器共用浏览器路由与插件运行时,安装和连接由 `@mearl/setup` 管理。
6
6
 
7
- 首次使用当前版本可运行 `mearl guide`,默认只读取核心工作流。`mearl guide --list` 列出专题;例如 `mearl guide run` 读取 SDK 组合调用,`mearl guide environment` 读取设备与 App 指引。指南只读 npm 包内资源,不连接浏览器、加载插件、安装环境或触发自动更新。动作参数继续使用 `mearl <action> --help`,目标的已安装能力继续按现有目录查询。
7
+ 首次使用当前版本可运行 `mearl guide`,默认只读取核心工作流。`mearl guide --list` 列出专题;例如 `mearl guide run` 读取 SDK 组合调用,`mearl guide environment` 读取设备与 App 指引。指南读取 npm 包内资源和本地 Preset 元数据。动作参数继续使用 `mearl <action> --help`,目标的已安装能力继续按现有目录查询。
8
8
 
9
- 指南正文唯一维护在本包的 `guides/`,构建时复制到 `dist/guides/`,`pnpm check:skills` 校验一致性。CLI 输出将本地文档链接转换为下一条指南命令。`skills/mearl/` 只分发精简的 `SKILL.md`,不附带正文副本;仅使用 MCP、无法执行 CLI 时,直接使用当前工具说明与 schema。
9
+ `mearl guide skills` 会在正文展示已选 Preset 的专用 Skill。`defaults.skillCatalog` 以 Skill 名称为键,每项用 `description` 描述适用场景,也可直接写成字符串。按需安装的 Skill 默认使用 `defaults.skillCatalogSource`。某个条目使用其他仓库时,给该条目填写 `source`,值可用当前安装器支持的仓库标识或完整 HTTPS 仓库地址。顶层 `skills` 中启用的条目由 Preset 管理。`defaults.extension.links.agentDocs` 可链接团队 Skill 的使用说明。
10
+
11
+ ```json
12
+ {
13
+ "defaults": {
14
+ "skillCatalogSource": "team/skills",
15
+ "skillCatalog": {
16
+ "team-report": { "description": "读取团队报表" },
17
+ "other-report": {
18
+ "description": "读取其他团队的报表",
19
+ "source": "https://github.com/example/other-skills"
20
+ }
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ 本包随附的指南维护在 `guides/`,构建时复制到 `dist/guides/`,由 `pnpm check:skills` 校验一致性。CLI 输出将本地文档链接转换为指南命令。`skills/mearl/` 分发精简的 `SKILL.md`。仅使用 MCP 时,直接使用当前工具说明与 schema。
10
27
 
11
28
  统一浏览器 SDK 与 CLI。它会发现当前机器及已配置 cloud-server 下所有 connector 的浏览器,并根据 `browser_list` 返回的全局 `browserId` 自动选择本地 Socket 或云端 WebSocket 链路。
12
29
 
@@ -390,6 +390,7 @@ export declare const COMMANDS: readonly [{
390
390
  readonly name: "browser_list";
391
391
  readonly description: "列出所有浏览器及其连接状态、类型和 Provider 托管实例信息";
392
392
  readonly summary: "列出本地及远端浏览器与连接状态";
393
+ readonly result: readonly ["installedProviders lists registered external Providers by source, even when they have no browser instances."];
393
394
  readonly params: [{
394
395
  readonly name: "provider";
395
396
  readonly type: "string";
package/dist/commands.js CHANGED
@@ -396,6 +396,9 @@ export const COMMANDS = [
396
396
  name: 'browser_list',
397
397
  description: '列出所有浏览器及其连接状态、类型和 Provider 托管实例信息',
398
398
  summary: '列出本地及远端浏览器与连接状态',
399
+ result: [
400
+ 'installedProviders lists registered external Providers by source, even when they have no browser instances.',
401
+ ],
399
402
  params: [
400
403
  {
401
404
  name: 'provider',
package/dist/guide.js CHANGED
@@ -24,6 +24,30 @@ export function renderGuideLinks(source, commandName = 'mearl') {
24
24
  return `${label}(\`${commandName} guide ${topic.id}\`${section ? `,小节 \`${section}\`` : ''})`;
25
25
  });
26
26
  }
27
+ function renderPresetSkills(setupCommand, skillCatalog, agentDocs) {
28
+ if (!skillCatalog && !agentDocs)
29
+ return '';
30
+ const lines = ['## 当前 Preset 的专用 Skill', ''];
31
+ if (skillCatalog) {
32
+ const entries = Object.entries(skillCatalog);
33
+ lines.push('| 适用场景 | Skill | 安装来源 |', '| --- | --- | --- |');
34
+ for (const [name, { description, source, managed }] of entries) {
35
+ const cell = description.replaceAll('\\', '\\\\').replaceAll('|', '\\|');
36
+ const install = managed ? 'Preset 管理' : source ? `\`${source}\`` : '见 Skill 说明';
37
+ lines.push(`| ${cell} | \`${name}\` | ${install} |`);
38
+ }
39
+ lines.push('');
40
+ if (entries.some(([, entry]) => entry.source)) {
41
+ lines.push('按需安装时,将同一行的安装来源和 Skill 名称填入命令。', '', '```bash', `${setupCommand} plugin install '<source>' --skill <skill-name> --yes`, '```', '');
42
+ }
43
+ if (entries.some(([, entry]) => entry.managed)) {
44
+ lines.push(`Preset 管理的 Skill 缺失时,先用 \`${setupCommand} preset status\` 检查,再用 \`${setupCommand} preset apply\` 重试同步。`, '');
45
+ }
46
+ }
47
+ if (agentDocs)
48
+ lines.push(`查看未安装 Skill 的用法和安装方式:${agentDocs}`, '');
49
+ return lines.join('\n') + '\n';
50
+ }
27
51
  /** Only packaged files are read; unknown IDs never become filesystem paths. */
28
52
  export async function readGuide(id, commandName = 'mearl', version = CLIENT_VERSION) {
29
53
  const topic = GUIDE_TOPICS.find(topic => topic.id === id);
@@ -37,19 +61,29 @@ export async function readGuide(id, commandName = 'mearl', version = CLIENT_VERS
37
61
  throw new Error(`当前安装缺少指南资源:${topic.id}。请通过当前发行版的安装入口修复安装包;参数可用 ${commandName} <action> --help 查询。`, { cause: error });
38
62
  }
39
63
  let management;
40
- if (source.includes('{{setup}}')) {
64
+ let presetSkills = '';
65
+ const hasSetup = source.includes('{{setup}}');
66
+ if (id === 'skills' || hasSetup) {
41
67
  const { readInstallationManagement, setupManagementCommand } = await import('@mearl/daemon-core/installation');
42
68
  const installed = await readInstallationManagement();
43
69
  const command = setupManagementCommand(installed.setup ?? { package: '@mearl/setup', version: 'beta' });
44
- source = source.replaceAll('{{setup}}', command);
45
- management = installed.source ? `管理入口:${command};沿用本机已选 preset。` : `首次安装入口:${command};本机尚未选择 preset。`;
70
+ if (hasSetup) {
71
+ source = source.replaceAll('{{setup}}', command);
72
+ if (id !== 'skills') {
73
+ management = installed.source
74
+ ? `管理入口:${command};沿用本机已选 preset。`
75
+ : `首次安装入口:${command};本机尚未选择 preset。`;
76
+ }
77
+ }
78
+ if (id === 'skills')
79
+ presetSkills = renderPresetSkills(command, installed.skillCatalog, installed.agentDocs);
46
80
  }
47
81
  return [
48
82
  `[mearl:guide] CLI ${version} · ${topic.id}`,
49
83
  '本指南随 CLI 分发;扩展、远端宿主与已安装能力仍须按目标实际帮助核验。',
50
84
  ...(management ? [management] : []),
51
85
  '',
52
- renderGuideLinks(source.trim(), commandName),
86
+ renderGuideLinks(source.trim(), commandName).replace(/^\{\{presetSkills\}\}\r?\n\r?\n/m, () => presetSkills),
53
87
  '',
54
88
  `其他主题:${commandName} guide --list;具体参数:${commandName} <action> --help。`,
55
89
  `[mearl:guide] end ${topic.id}`,
@@ -65,7 +99,9 @@ export async function runGuideCli(args, commandName = 'mearl', version = CLIENT_
65
99
  console.log(`${commandName} guide — CLI ${version}\n${list()}`);
66
100
  return 0;
67
101
  }
68
- if (args.length > 1 || args[0]?.startsWith('-') || !GUIDE_TOPICS.some(topic => topic.id === (args[0] ?? 'core'))) {
102
+ if (args.length > 1 ||
103
+ args[0]?.startsWith('-') ||
104
+ !GUIDE_TOPICS.some(topic => topic.id === (args[0] ?? 'core'))) {
69
105
  console.error(`未知指南主题或选项:${args.join(' ')}。用 ${commandName} guide --list 查看主题。`);
70
106
  return 2;
71
107
  }
@@ -2,6 +2,10 @@
2
2
 
3
3
  站点或业务对象与任务意图都匹配时,优先使用已安装的专用 Skill。通用网页操作继续使用 Mearl;不要仅因关键词相同就改用其他能力。专用站点的路由说明由对应 Skill 提供。
4
4
 
5
+ {{presetSkills}}
6
+
7
+ ## 通用 Skill
8
+
5
9
  | 意图 | Skill |
6
10
  | --- | --- |
7
11
  | 时间戳、Base64、图片编码、URL 编解码 | format-converter |
@@ -1,7 +1,7 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { closeSync, mkdirSync, openSync } from 'node:fs';
3
3
  import { createConnection } from 'node:net';
4
- import { PLUGIN_TASK_HOST_PATH } from '../../runtimePaths.js';
4
+ import { resolvePluginTaskHostPath } from '../../runtimePaths.js';
5
5
  import { claimRecord, isProcessOwnerAlive, processIdentity, readRecord, removeInvalidRecord, removeRecordIfPid, rotateLogIfNeeded, } from '@mearl/daemon-core';
6
6
  import { pluginHostPaths } from '../runtime/pluginHostPaths.js';
7
7
  import { PLUGIN_TASK_PROTOCOL_VERSION } from '@mearl/browser-core';
@@ -112,7 +112,7 @@ export class PluginHostConnection {
112
112
  if (!['ENOENT', 'ECONNREFUSED', 'PLUGIN_TASK_CONNECTION_LOST'].includes(code ?? ''))
113
113
  throw error;
114
114
  }
115
- await ensureHost(this.configuration.runtimePath ?? PLUGIN_TASK_HOST_PATH);
115
+ await ensureHost(this.configuration.runtimePath ?? resolvePluginTaskHostPath());
116
116
  const deadline = Date.now() + 10000;
117
117
  let failure;
118
118
  do {
@@ -1,5 +1,5 @@
1
1
  export declare const CLIENT_VERSION: string;
2
- export declare const PLUGIN_TASK_HOST_PATH: string;
2
+ export declare function resolvePluginTaskHostPath(): string;
3
3
  export declare const PLUGIN_WORKER_PATH: string;
4
4
  export declare const SCRIPT_WORKER_PATH: string;
5
5
  export declare const PLUGIN_MODEL_SESSION_WORKER_PATH: string;
@@ -1,9 +1,11 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { fileURLToPath } from 'node:url';
3
- // Package metadata and process entries share this anchor in compiled and bundled hosts.
4
3
  const require = createRequire(import.meta.url);
5
4
  export const CLIENT_VERSION = require('../package.json').version;
6
- export const PLUGIN_TASK_HOST_PATH = fileURLToPath(new URL('./plugin-task-host.js', import.meta.url));
5
+ // SDK bundles resolve the task service from the installed Client package on demand.
6
+ export function resolvePluginTaskHostPath() {
7
+ return require.resolve('@mearl/client/plugin-task-host');
8
+ }
7
9
  export const PLUGIN_WORKER_PATH = fileURLToPath(new URL('./plugin-worker.js', import.meta.url));
8
10
  export const SCRIPT_WORKER_PATH = fileURLToPath(new URL('./scriptWorker.js', import.meta.url));
9
11
  export const PLUGIN_MODEL_SESSION_WORKER_PATH = fileURLToPath(new URL('./pluginModelSessionWorker.js', import.meta.url));
package/dist/socket.js CHANGED
@@ -372,7 +372,19 @@ export function invoke(action, data = {}, options = {}) {
372
372
  });
373
373
  })();
374
374
  }
375
- return dispatchInvoke(action, resolvedData, timeoutSec, undefined, controlSource, options.socketPath, options.deadline).then(decorateBrowserListResult);
375
+ return dispatchInvoke(action, resolvedData, timeoutSec, undefined, controlSource, options.socketPath, options.deadline).then(result => {
376
+ const installedProviders = listInstalledProviders().map(provider => ({
377
+ id: provider.providerId,
378
+ name: provider.name,
379
+ builtin: false,
380
+ version: provider.version,
381
+ protocolVersion: provider.protocolVersion,
382
+ }));
383
+ return decorateBrowserListResult({
384
+ ...result,
385
+ ...(installedProviders.length ? { installedProviders } : {}),
386
+ });
387
+ });
376
388
  }
377
389
  const selector = browser ?? defaultBrowser ?? process.env.MEARL_BROWSER ?? undefined;
378
390
  return dispatchInvoke(action, resolvedData, timeoutSec, selector, controlSource, options.socketPath, options.deadline);
package/dist/unified.js CHANGED
@@ -557,6 +557,10 @@ export class UnifiedClient {
557
557
  ? result.browsers
558
558
  : [];
559
559
  const browsers = rawBrowsers.map(browser => decorateBrowser(browser, source));
560
+ const providers = result?.installedProviders;
561
+ const installedProviders = Array.isArray(providers)
562
+ ? providers.map(provider => ({ ...provider, source }))
563
+ : [];
560
564
  const resultWarnings = Array.isArray(result?.warnings)
561
565
  ? result.warnings.filter((warning) => typeof warning === 'string')
562
566
  : [];
@@ -570,6 +574,7 @@ export class UnifiedClient {
570
574
  })
571
575
  : null,
572
576
  browsers,
577
+ ...(installedProviders.length ? { installedProviders } : {}),
573
578
  ...(result?.discovery ? { discovery: result.discovery } : {}),
574
579
  ...(resultWarnings.length > 0 ? { warnings: resultWarnings } : {}),
575
580
  };
@@ -687,6 +692,7 @@ export class UnifiedClient {
687
692
  for (const listing of listings)
688
693
  warnings.push(...(listing.warnings ?? []));
689
694
  const browsers = listings.flatMap(listing => listing.browsers);
695
+ const installedProviders = listings.flatMap(listing => listing.installedProviders ?? []);
690
696
  const defaults = listings
691
697
  .map(listing => listing.defaultBrowserId)
692
698
  .filter((browserId) => typeof browserId === 'string');
@@ -703,6 +709,7 @@ export class UnifiedClient {
703
709
  connectedCount: browsers.filter(browser => browser.status === 'connected').length,
704
710
  defaultBrowserId,
705
711
  browsers,
712
+ ...(installedProviders.length ? { installedProviders } : {}),
706
713
  ...(warnings.length > 0 ? { warnings } : {}),
707
714
  });
708
715
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/client",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "Unified Mearl SDK & CLI for local and remote browsers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -38,6 +38,7 @@
38
38
  "types": "./dist/plugin.d.ts",
39
39
  "import": "./dist/plugin.js"
40
40
  },
41
+ "./plugin-task-host": "./dist/plugin-task-host.js",
41
42
  "./script": {
42
43
  "types": "./dist/script.d.ts",
43
44
  "import": "./dist/script.js"
@@ -68,11 +69,11 @@
68
69
  "commander": "^14.0.3",
69
70
  "fastest-levenshtein": "^1.0.16",
70
71
  "ws": "^8.18.0",
71
- "@mearl/daemon-core": "3.1.3",
72
- "@mearl/cloud-types": "3.1.3",
73
- "@mearl/provider": "3.1.3",
74
- "@mearl/browser-core": "3.1.3",
75
- "@mearl/agent-runtime": "3.1.3"
72
+ "@mearl/daemon-core": "3.1.4",
73
+ "@mearl/provider": "3.1.4",
74
+ "@mearl/cloud-types": "3.1.4",
75
+ "@mearl/agent-runtime": "3.1.4",
76
+ "@mearl/browser-core": "3.1.4"
76
77
  },
77
78
  "devDependencies": {
78
79
  "@types/node": "^24.9.1",