@mearl/setup 2.17.0 → 2.18.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 CHANGED
@@ -88,8 +88,9 @@ npx @mearl/setup provider update brow
88
88
  npx @mearl/setup provider uninstall brow
89
89
  ```
90
90
 
91
- 安装参数接受包名、版本或 dist-tag;更新和卸载可使用 `providerId` 或完整包名。阿里包在
92
- 本机存在 `tnpm` 时优先使用 `tnpm`,其他情况沿用启动 setup 的包管理器。Provider 登记只保存
91
+ 安装参数接受包名、版本或 dist-tag;更新和卸载可使用 `providerId` 或完整包名。`@ali/*` 包的
92
+ 安装和更新固定使用 `https://registry.anpm.alibaba-inc.com/`。安装沿用启动 setup 的包管理器,
93
+ 更新和卸载沿用当前 Provider 的原包管理器。Provider 登记只保存
93
94
  经过校验的包名、安装目录和包内入口;不接受包自行注入启动命令、参数、工作目录或环境变量。
94
95
  卸载仅在包管理器成功移除包后清除登记,以便失败时可以重试。
95
96
 
@@ -2,7 +2,7 @@ import { findPluginRegistration, listPluginNames, unregisterPlugin } from '@mear
2
2
  import { resolveAliSkillsInvocation } from './aliSkills.js';
3
3
  import { installPlugins } from './plugin.js';
4
4
  import { findExecutable, type CommandRunner } from './process.js';
5
- export declare const ALIBABA_NPM_REGISTRY = "https://registry.anpm.alibaba-inc.com/";
5
+ export { ALIBABA_NPM_REGISTRY } from './npmRegistry.js';
6
6
  export declare const ALIBABA_INTERNAL_PLUGIN_NAMES: string[];
7
7
  export interface InternalPluginOptions {
8
8
  env?: NodeJS.ProcessEnv;
@@ -1,9 +1,10 @@
1
1
  import { dirname } from 'node:path';
2
2
  import { findOfficialPlugin, findPluginRegistration, listPluginNames, listOfficialPluginNames, OFFICIAL_PLUGIN_MANAGER, unregisterPlugin, } from '@mearl/client/plugin';
3
3
  import { resolveAliSkillsInvocation } from './aliSkills.js';
4
+ import { ALIBABA_NPM_REGISTRY } from './npmRegistry.js';
4
5
  import { installPlugins } from './plugin.js';
5
6
  import { findExecutable, prependCommandPath, runCommand } from './process.js';
6
- export const ALIBABA_NPM_REGISTRY = 'https://registry.anpm.alibaba-inc.com/';
7
+ export { ALIBABA_NPM_REGISTRY } from './npmRegistry.js';
7
8
  export const ALIBABA_INTERNAL_PLUGIN_NAMES = listOfficialPluginNames('alibaba');
8
9
  export async function canAccessAlibabaNpmRegistry(options = {}, dependencies = {}) {
9
10
  const env = options.env ?? process.env;
@@ -0,0 +1,2 @@
1
+ export declare const ALIBABA_NPM_REGISTRY = "https://registry.anpm.alibaba-inc.com/";
2
+ export declare function packageRegistryEnvironment(packageName: string, env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -0,0 +1,6 @@
1
+ export const ALIBABA_NPM_REGISTRY = 'https://registry.anpm.alibaba-inc.com/';
2
+ export function packageRegistryEnvironment(packageName, env) {
3
+ if (!packageName.startsWith('@ali/'))
4
+ return env;
5
+ return { ...env, npm_config_registry: ALIBABA_NPM_REGISTRY };
6
+ }
package/dist/plugin.js CHANGED
@@ -19,7 +19,7 @@ export async function setupPlugin(name, target) {
19
19
  const entry = resolvePluginEntry(target);
20
20
  const plugin = await loadPlugin(entry, registrationContext);
21
21
  await ensurePluginRuntime();
22
- return registerPlugin(name, entry, plugin.description);
22
+ return registerPlugin(name, entry, plugin.description, { toolbox: plugin.toolbox });
23
23
  }
24
24
  export async function ensureOfficialPlugin(name, runner = runCommand) {
25
25
  const definition = findOfficialPlugin(name);
@@ -186,15 +186,22 @@ export async function installPlugins(args, runner = runCommand, options = {}) {
186
186
  assertPluginName(name);
187
187
  if (plugins.has(name))
188
188
  throw new Error(`多个 skill 使用插件名称 ${name},请通过 setup plugin <name> <path> 分别注册。`);
189
- plugins.set(name, { entry, description: plugin.description });
189
+ plugins.set(name, {
190
+ entry,
191
+ description: plugin.description,
192
+ ...(plugin.toolbox ? { toolbox: plugin.toolbox } : {}),
193
+ });
190
194
  }
191
195
  if (plugins.size === 0) {
192
196
  console.error('未找到 scripts/main.mjs 或 scripts/main.py 插件入口;自定义入口可用 setup plugin <name> <path> 注册。');
193
197
  return 0;
194
198
  }
195
199
  await ensurePluginRuntime(runner);
196
- for (const [name, { entry, description }] of plugins) {
197
- registerPlugin(name, entry, description, { managedBy: options.registrationManagedBy });
200
+ for (const [name, { entry, description, toolbox }] of plugins) {
201
+ registerPlugin(name, entry, description, {
202
+ managedBy: options.registrationManagedBy,
203
+ ...(toolbox ? { toolbox } : {}),
204
+ });
198
205
  console.error(`Plugin ${name} registered: ${entry}\nRun: mearl ${name} --help`);
199
206
  }
200
207
  return 0;
@@ -1,13 +1,12 @@
1
1
  import { listInstalledProviders, registerProviderPackage, stopProvider, uninstallProvider, type InstalledProviderManifest } from '@mearl/provider/host';
2
2
  import { resolvePackageManagerInstallation, type PackageManagerInstallation } from './packageManager.js';
3
- import { findExecutable, type CommandRunner } from './process.js';
3
+ import { type CommandRunner } from './process.js';
4
4
  interface ProviderPackageSpec {
5
5
  packageName: string;
6
6
  target: string;
7
7
  }
8
8
  export interface ProviderSetupDependencies {
9
9
  existsSync?: (filePath: string) => boolean;
10
- findExecutable?: typeof findExecutable;
11
10
  listProviders?: typeof listInstalledProviders;
12
11
  registerPackage?: typeof registerProviderPackage;
13
12
  resolveInvokingManager?: (env: NodeJS.ProcessEnv) => PackageManagerInstallation;
package/dist/provider.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
2
+ import { join, resolve } from 'node:path';
3
3
  import { listInstalledProviders, registerProviderPackage, stopProvider, uninstallProvider, } from '@mearl/provider/host';
4
4
  import { buildGlobalPackageCommand, resolveInvokingPackageManager, resolvePackageManagerInstallation, } from './packageManager.js';
5
- import { findExecutable, prependCommandPath, runCommand } from './process.js';
5
+ import { packageRegistryEnvironment } from './npmRegistry.js';
6
+ import { prependCommandPath, runCommand } from './process.js';
6
7
  export function parseProviderPackageSpec(value) {
7
8
  const input = value.trim();
8
9
  const nameMatch = input.match(/^(@[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*|[a-z0-9][a-z0-9._-]*)(?:@(.+))?$/i);
@@ -11,17 +12,10 @@ export function parseProviderPackageSpec(value) {
11
12
  }
12
13
  return { packageName: nameMatch[1], target: nameMatch[2] || 'latest' };
13
14
  }
14
- function providerManager(packageName, env, dependencies, resolvedManager) {
15
- const resolved = resolvedManager ??
15
+ function providerManager(env, dependencies, resolvedManager) {
16
+ return (resolvedManager ??
16
17
  (dependencies.resolveInvokingManager ??
17
- (childEnv => resolveInvokingPackageManager({ env: childEnv })))(env);
18
- if (!packageName.startsWith('@ali/') || resolved.command.includes('tnpm'))
19
- return resolved;
20
- const tnpm = (dependencies.findExecutable ?? findExecutable)('tnpm', {
21
- env,
22
- extraDirectories: [dirname(process.execPath)],
23
- });
24
- return tnpm ? { manager: 'npm', command: tnpm } : resolved;
18
+ (childEnv => resolveInvokingPackageManager({ env: childEnv })))(env));
25
19
  }
26
20
  function outputPath(output) {
27
21
  const lines = output
@@ -71,8 +65,9 @@ function findRegisteredProvider(selector, listProviders) {
71
65
  }
72
66
  async function runPackageCommand(installation, operation, packageName, target, runner, env) {
73
67
  const command = buildGlobalPackageCommand(installation, operation, [packageName], target);
68
+ const commandEnv = operation === 'uninstall' ? env : packageRegistryEnvironment(packageName, env);
74
69
  const result = await runner(command.command, command.args, {
75
- env: prependCommandPath(command.command, env),
70
+ env: prependCommandPath(command.command, commandEnv),
76
71
  tee: true,
77
72
  });
78
73
  if (result.code !== 0) {
@@ -83,7 +78,7 @@ export async function installProviderPackage(packageSpec, dependencies = {}) {
83
78
  const { packageName, target } = parseProviderPackageSpec(packageSpec);
84
79
  const env = process.env;
85
80
  const runner = dependencies.runCommand ?? runCommand;
86
- const installation = providerManager(packageName, env, dependencies);
81
+ const installation = providerManager(env, dependencies);
87
82
  await runPackageCommand(installation, 'install', packageName, target, runner, env);
88
83
  const packageRoot = await (dependencies.resolvePackageRoot ?? resolveGlobalProviderPackageRoot)(installation, packageName, runner, env);
89
84
  if (!(dependencies.existsSync ?? existsSync)(join(packageRoot, 'package.json'))) {
@@ -98,7 +93,7 @@ export async function updateProviderPackage(selector, dependencies = {}) {
98
93
  const env = process.env;
99
94
  const runner = dependencies.runCommand ?? runCommand;
100
95
  const detectedManager = (dependencies.resolvePackageManager ?? resolvePackageManagerInstallation)(current.packageRoot, current.packageName) ?? undefined;
101
- const installation = providerManager(current.packageName, env, dependencies, detectedManager);
96
+ const installation = providerManager(env, dependencies, detectedManager);
102
97
  (dependencies.stopProvider ?? stopProvider)(current.providerId);
103
98
  await runPackageCommand(installation, 'update', current.packageName, 'latest', runner, env);
104
99
  const manifest = (dependencies.registerPackage ?? registerProviderPackage)(current.packageRoot);
@@ -108,7 +103,7 @@ export async function uninstallProviderPackage(selector, dependencies = {}) {
108
103
  const listProviders = dependencies.listProviders ?? listInstalledProviders;
109
104
  const manifest = findRegisteredProvider(selector, listProviders);
110
105
  const env = process.env;
111
- const installation = (dependencies.resolvePackageManager ?? resolvePackageManagerInstallation)(manifest.packageRoot, manifest.packageName) ?? providerManager(manifest.packageName, env, dependencies);
106
+ const installation = (dependencies.resolvePackageManager ?? resolvePackageManagerInstallation)(manifest.packageRoot, manifest.packageName) ?? providerManager(env, dependencies);
112
107
  (dependencies.stopProvider ?? stopProvider)(manifest.providerId);
113
108
  await runPackageCommand(installation, 'uninstall', manifest.packageName, 'latest', dependencies.runCommand ?? runCommand, env);
114
109
  (dependencies.unregisterProvider ?? uninstallProvider)(manifest.providerId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/setup",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "One-shot environment setup and configuration for Mearl",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -61,8 +61,8 @@
61
61
  "commander": "^15.0.0",
62
62
  "extract-zip": "^2.0.1",
63
63
  "ws": "^8.18.3",
64
- "@mearl/client": "2.17.0",
65
- "@mearl/provider": "2.17.0"
64
+ "@mearl/client": "2.18.0",
65
+ "@mearl/provider": "2.18.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^24.9.1",