@sokeai/cli 1.0.122 → 1.0.123

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
@@ -50,6 +50,8 @@
50
50
  npm install -g @sokeai/cli@latest
51
51
  ```
52
52
 
53
+ 从 `1.0.123` 起同时安装 `soke-cli` 和 `soke-ma`。`soke-ma --help` 使用独立的千问 MA 入口,其会话凭证由 Vault 注入;`1.0.122` 及更早版本未分发该入口。构建环境、预发离线包和 MA Skill 打包方式见 [环境配置](docs/ENVIRONMENT_CONFIG.md)。
54
+
53
55
  鸿蒙电脑版 ARM64 采用专用 Go 工具链、静态 ELF 和 OpenHarmony 自签名,仍需设备验收;构建和安装见 [鸿蒙适配说明](docs/harmonyos.md)。不能使用普通 Linux ARM64 包替代。Windows 企业设备的签名与放行说明见 [Windows 代码签名](docs/windows-signing.md)。
54
56
 
55
57
  ### 方式二:通过源码编译安装 (需要 Go 环境)
package/docs/harmonyos.md CHANGED
@@ -30,6 +30,7 @@ HARMONY_GO=/path/to/ohos-go/bin/go npm run package:harmony
30
30
  默认产物位于 `bin/`:
31
31
 
32
32
  - `soke-cli-openharmony-arm64`:签名后的原始二进制,供 npm 安装器下载。
33
+ - 从 `1.0.123` 起另外构建 `soke-ma-openharmony-arm64` 及校验和,独立完成同样的静态 ELF 和自签名复验;专用安装包内包含 `soke-cli` 与 `soke-ma`。
33
34
  - `soke-cli-openharmony-arm64.sha256`:签名后文件的 SHA-256。
34
35
  - `soke-cli-openharmony-arm64.tar.gz` 及同名 `.sha256`:独立安装包,无需 Node.js。
35
36
 
@@ -49,7 +50,7 @@ go run ./cmd/harmony-sign verify --input /path/to/soke-cli-openharmony-arm64
49
50
 
50
51
  ## 安装与客户复测
51
52
 
52
- 从 [1.0.121 发布目录](https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v1.0.121/soke-cli-openharmony-arm64.tar.gz)下载独立安装包,以及同目录 [checksums.txt](https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v1.0.121/checksums.txt),先验证 SHA-256。原始二进制位于同目录 `soke-cli-openharmony-arm64`。后续版本的 CDN 目录格式为:
53
+ 从 [1.0.123 发布目录](https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v1.0.123/soke-cli-openharmony-arm64.tar.gz)下载独立安装包,以及同目录 [checksums.txt](https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v1.0.123/checksums.txt),先验证 SHA-256。原始二进制位于同目录 `soke-cli-openharmony-arm64` 和 `soke-ma-openharmony-arm64`。后续版本的 CDN 目录格式为:
53
54
 
54
55
  ```text
55
56
  https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases/v<新版本>/
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "@sokeai/cli",
3
- "version": "1.0.122",
3
+ "version": "1.0.123",
4
4
  "description": "授客AI官方CLI工具 - 支持AI Agent Skills",
5
5
  "bin": {
6
- "soke-cli": "scripts/run.js"
6
+ "soke-cli": "scripts/run.js",
7
+ "soke-ma": "scripts/run-ma.js"
7
8
  },
8
9
  "scripts": {
9
10
  "postinstall": "node scripts/install.js",
10
11
  "build": "./scripts/build-binaries.sh",
11
12
  "build:harmony": "bash ./scripts/build-harmony.sh",
12
13
  "package:harmony": "bash ./scripts/package-harmony.sh",
13
- "test:distribution": "node scripts/test-runtime-platform.js && node scripts/test-harmony-install.js && node scripts/test-runtime-errors.js && node scripts/test-install-portal-skill.js",
14
+ "test:distribution": "node scripts/test-runtime-platform.js && node scripts/test-harmony-install.js && node scripts/test-dual-entry.js && node scripts/test-runtime-errors.js && node scripts/test-install-portal-skill.js",
14
15
  "release": "./scripts/release.sh"
15
16
  },
16
17
  "files": [
17
18
  "scripts/install.js",
18
19
  "scripts/run.js",
20
+ "scripts/run-ma.js",
19
21
  "scripts/runtime-platform.js",
20
22
  "scripts/runtime-errors.js",
21
23
  "docs/harmonyos.md",
@@ -456,22 +456,26 @@ try {
456
456
  process.exit(1);
457
457
  }
458
458
 
459
- const { platform: mappedPlatform, arch: mappedArch, binaryName, binaryFileName } = runtimeTarget;
459
+ const { platform: mappedPlatform, arch: mappedArch } = runtimeTarget;
460
460
 
461
461
  // 默认 CDN 二进制源。用户安装时会优先从这里下载,失败后回退 GitHub Releases。
462
462
  const DEFAULT_BINARY_HOST = 'https://soke-frontendstatic-cdn.soke.cn/soke-cli/releases';
463
463
  const GITHUB_RELEASE_HOST = 'https://github.com/sokeai/soke-cli/releases/download';
464
464
 
465
465
  const binDir = path.join(__dirname, '..', 'bin');
466
- const binaryPath = path.join(binDir, binaryName);
467
- const tempBinaryPath = `${binaryPath}.download`;
466
+ const binaryTargets = ['soke-cli', 'soke-ma'].map(command => ({
467
+ command,
468
+ binaryFileName: runtimeTarget.binaryFileName.replace(/^soke-cli/, command),
469
+ binaryPath: path.join(binDir, runtimeTarget.binaryName.replace(/^soke-cli/, command)),
470
+ tempBinaryPath: path.join(binDir, runtimeTarget.binaryName.replace(/^soke-cli/, command) + '.download')
471
+ }));
468
472
 
469
473
  function normalizeHost(host) {
470
474
  if (typeof host !== 'string') return '';
471
475
  return host.trim().replace(/\/+$/, '');
472
476
  }
473
477
 
474
- function buildDownloadSources() {
478
+ function buildDownloadSources(binaryFileName) {
475
479
  const hosts = [
476
480
  normalizeHost(process.env.SOKE_CLI_BINARY_HOST),
477
481
  normalizeHost(DEFAULT_BINARY_HOST)
@@ -597,7 +601,7 @@ function sha256File(filePath) {
597
601
  return hash.digest('hex');
598
602
  }
599
603
 
600
- async function verifyChecksum(source, filePath) {
604
+ async function verifyChecksum(source, filePath, binaryFileName) {
601
605
  let checksumsText;
602
606
  try {
603
607
  checksumsText = await downloadText(source.checksumURL);
@@ -618,8 +622,9 @@ async function verifyChecksum(source, filePath) {
618
622
  console.log('sha256 校验通过');
619
623
  }
620
624
 
621
- async function downloadWithFallback() {
622
- const sources = buildDownloadSources();
625
+ async function downloadWithFallback(target) {
626
+ const { binaryFileName, tempBinaryPath } = target;
627
+ const sources = buildDownloadSources(binaryFileName);
623
628
  const errors = [];
624
629
 
625
630
  for (const source of sources) {
@@ -629,9 +634,7 @@ async function downloadWithFallback() {
629
634
  try {
630
635
  try { fs.unlinkSync(tempBinaryPath); } catch (_) {}
631
636
  await downloadFile(source.binaryURL, tempBinaryPath);
632
- await verifyChecksum(source, tempBinaryPath);
633
- try { fs.unlinkSync(binaryPath); } catch (_) {}
634
- fs.renameSync(tempBinaryPath, binaryPath);
637
+ await verifyChecksum(source, tempBinaryPath, binaryFileName);
635
638
  return source;
636
639
  } catch (err) {
637
640
  try { fs.unlinkSync(tempBinaryPath); } catch (_) {}
@@ -650,19 +653,15 @@ if (require.main === module) {
650
653
  fs.mkdirSync(binDir, { recursive: true });
651
654
  }
652
655
 
653
- downloadWithFallback()
654
- .then((source) => {
655
- console.log(`已使用下载源: ${source.name}`);
656
-
657
- // 设置可执行权限(非 Windows 平台)
658
- if (platform !== 'win32') {
659
- try {
660
- fs.chmodSync(binaryPath, 0o755);
661
- console.log('已设置可执行权限');
662
- } catch (err) {
663
- console.error('设置可执行权限失败:', err.message);
664
- process.exit(1);
665
- }
656
+ (async () => {
657
+ // 两个入口均下载并校验后才安装,避免 MA 缺失时留下半套安装结果。
658
+ for (const target of binaryTargets) {
659
+ const source = await downloadWithFallback(target);
660
+ console.log(`${target.command} 已使用下载源: ${source.name}`);
661
+ if (platform !== 'win32') fs.chmodSync(target.tempBinaryPath, 0o755);
662
+ }
663
+ for (const target of binaryTargets) {
664
+ fs.renameSync(target.tempBinaryPath, target.binaryPath);
666
665
  }
667
666
 
668
667
  const portalSkillPaths = syncPortalSkillToExistingAgentDirs();
@@ -672,17 +671,20 @@ if (require.main === module) {
672
671
 
673
672
  // WorkBuddy manages Connector Skills, PATH and the runtime sandbox. Keep
674
673
  // broad all-skill registry mutation and GUI restart behavior disabled.
675
- return Promise.resolve();
676
- })
674
+ })()
677
675
  .then(() => {
678
676
  console.log('soke-cli 安装成功!');
679
- console.log(`二进制文件位置: ${binaryPath}`);
677
+ for (const target of binaryTargets) console.log(`二进制文件位置: ${target.binaryPath}`);
680
678
  console.log('\n使用方法:');
681
679
  console.log(' soke-cli --help');
682
680
  console.log(' soke-cli config init');
683
681
  console.log(' soke-cli auth login');
682
+ console.log(' soke-ma --help');
684
683
  })
685
684
  .catch((err) => {
685
+ for (const target of binaryTargets) {
686
+ try { fs.unlinkSync(target.tempBinaryPath); } catch (_) {}
687
+ }
686
688
  console.error('\n安装失败:', err.message);
687
689
  console.error('\n可能的原因:');
688
690
  console.error('1. 网络连接问题');
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { describeLaunchError } = require('./runtime-errors');
7
+
8
+ // MA 入口仅启动独立二进制,不触发普通 CLI 的登录或 GUI 环境操作。
9
+ const binaryName = process.platform === 'win32' ? 'soke-ma.exe' : 'soke-ma';
10
+ const binaryPath = path.join(__dirname, '..', 'bin', binaryName);
11
+ if (!fs.existsSync(binaryPath)) {
12
+ console.error('未找到 soke-ma 二进制文件,请重新安装当前 CLI 包。');
13
+ process.exit(1);
14
+ }
15
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit', env: process.env });
16
+ child.on('error', error => {
17
+ console.error(describeLaunchError(error, binaryPath));
18
+ process.exit(1);
19
+ });
20
+ child.on('exit', (code, signal) => {
21
+ if (signal) process.kill(process.pid, signal);
22
+ else process.exit(code == null ? 1 : code);
23
+ });
@@ -12,13 +12,13 @@ function resolveRuntimePlatform(platform = os.platform(), arch = os.arch(), syst
12
12
 
13
13
  const targets = {
14
14
  darwin: { x64: 'amd64', arm64: 'arm64' },
15
- linux: { x64: 'amd64' },
15
+ linux: { x64: 'amd64', arm64: 'arm64' },
16
16
  win32: { x64: 'amd64' },
17
17
  openharmony: { arm64: 'arm64' }
18
18
  };
19
19
  const mappedArch = targets[target] && targets[target][arch];
20
20
  if (!mappedArch) {
21
- throw new Error(`不支持的平台: ${platform}-${arch};支持 macOS x64/arm64、Linux x64、Windows x64、鸿蒙 ARM64`);
21
+ throw new Error(`不支持的平台: ${platform}-${arch};支持 macOS x64/arm64、Linux x64/arm64、Windows x64、鸿蒙 ARM64`);
22
22
  }
23
23
 
24
24
  return {