@sciagent/cli 1.1.43 → 1.1.44

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/bin/sciagent.js CHANGED
@@ -7,9 +7,9 @@
7
7
  * 二进制查找策略:
8
8
  * 1. %LOCALAPPDATA%\sciagent\bin\ (Windows) 或 ~/.sciagent/bin/ (Linux/Mac)
9
9
  * - 带严格版本校验(.version文件必须匹配CURRENT_VERSION)
10
- * - 版本不匹配时自动从极狐GitLab下载正确版本
10
+ * - 版本不匹配时自动从 Release Server 下载正确版本
11
11
  * 2. 本地开发目录(仅开发模式)
12
- * 3. 未找到时自动从极狐GitLab下载
12
+ * 3. 未找到时自动从 Release Server 下载
13
13
  *
14
14
  * 注意:不再从npm optionalDependencies中查找二进制,因为:
15
15
  * - npm缓存中的旧包可能包含旧版二进制
@@ -25,13 +25,10 @@ const https = require('https');
25
25
  const http = require('http');
26
26
 
27
27
  // 当前版本号 - 与 postinstall.js 和 package.json 保持同步
28
- const CURRENT_VERSION = '1.1.43';
28
+ const CURRENT_VERSION = '1.1.44';
29
29
 
30
- // 极狐GitLab下载配置
31
- const JIHULAB_URL = 'https://jihulab.com';
32
- const JIHULAB_PROJECT_ID = 351778;
33
- const JIHULAB_PACKAGE_NAME = 'sciagent';
34
- const JIHULAB_DOWNLOAD_TOKEN = '2qxfs606HfwESUYJxtRlgm86MQp1OjVnazAK.01.101vzs2qo';
30
+ // Releases 服务器下载配置
31
+ const RELEASE_SERVER_URL = process.env.RELEASE_SERVER_URL || 'https://sciagent.tech';
35
32
 
36
33
  // 平台和架构映射
37
34
  const PLATFORM_MAP = {
@@ -154,16 +151,13 @@ function applyPendingUpdate(installDir) {
154
151
  }
155
152
 
156
153
  /**
157
- * 从极狐GitLab查询最新版本号
154
+ * 从 Release Server 查询最新版本号
158
155
  * 返回: 版本字符串 或 null
159
156
  */
160
157
  function fetchLatestVersion() {
161
158
  return new Promise((resolve) => {
162
- const url = (
163
- `${JIHULAB_URL}/api/v4/projects/${JIHULAB_PROJECT_ID}` +
164
- `/packages?package_name=${JIHULAB_PACKAGE_NAME}&per_page=1&order_by=version&sort=desc` +
165
- `&access_token=${JIHULAB_DOWNLOAD_TOKEN}`
166
- );
159
+ // 使用 /api/releases/list 获取所有版本,取最新的
160
+ const url = `${RELEASE_SERVER_URL}/api/releases/list`;
167
161
 
168
162
  const protocol = url.startsWith('https') ? https : http;
169
163
  const request = protocol.get(url, {
@@ -174,12 +168,19 @@ function fetchLatestVersion() {
174
168
  response.on('data', (chunk) => { data += chunk; });
175
169
  response.on('end', () => {
176
170
  try {
177
- const packages = JSON.parse(data);
178
- if (Array.isArray(packages) && packages.length > 0 && packages[0].version) {
179
- resolve(packages[0].version);
180
- } else {
181
- resolve(null);
171
+ const result = JSON.parse(data);
172
+ const releases = result.releases || {};
173
+ // 找到所有版本中的最新版本
174
+ let latestVersion = null;
175
+ for (const key of Object.keys(releases)) {
176
+ const versions = releases[key];
177
+ if (Array.isArray(versions) && versions.length > 0 && versions[0].version) {
178
+ if (!latestVersion || compareVersions(versions[0].version, latestVersion) > 0) {
179
+ latestVersion = versions[0].version;
180
+ }
181
+ }
182
182
  }
183
+ resolve(latestVersion);
183
184
  } catch (e) {
184
185
  resolve(null);
185
186
  }
@@ -202,9 +203,7 @@ function backgroundDownloadUpdate(platform, arch, latestVersion) {
202
203
  const filename = `sciagent-${platform}-${arch}${ext}`;
203
204
 
204
205
  const downloadUrl = (
205
- `${JIHULAB_URL}/api/v4/projects/${JIHULAB_PROJECT_ID}` +
206
- `/packages/generic/${JIHULAB_PACKAGE_NAME}/${latestVersion}/${filename}` +
207
- `?access_token=${JIHULAB_DOWNLOAD_TOKEN}`
206
+ `${RELEASE_SERVER_URL}/api/releases/download/${platform}/${arch}/${latestVersion}`
208
207
  );
209
208
 
210
209
  const installDir = getInstallDir(platform);
@@ -289,7 +288,7 @@ function backgroundDownloadUpdate(platform, arch, latestVersion) {
289
288
 
290
289
  /**
291
290
  * 检查自动更新(后台异步)
292
- * 1. 查询极狐GitLab最新版本
291
+ * 1. 查询 Release Server 最新版本
293
292
  * 2. 如果有新版本,后台下载到临时目录
294
293
  * 3. 下载完成后写入 .pending-update 标记
295
294
  * 4. 下次启动时自动应用
@@ -399,7 +398,7 @@ function getBinaryPath() {
399
398
  } else if (cmp < 0) {
400
399
  // 版本过低 → 自动下载新版本
401
400
  console.log(`[INFO] SciAgent version outdated: v${installedVersion} (${(stats.size / (1024 * 1024)).toFixed(1)} MB) → v${CURRENT_VERSION}`);
402
- console.log(`[INFO] Downloading new version from JiHuLab...`);
401
+ console.log(`[INFO] Downloading new version from server...`);
403
402
  // 注意:此时当前进程正在运行旧二进制,无法直接替换
404
403
  // 下载到临时目录,写入 .pending-update,下次启动时应用
405
404
  const downloaded = downloadBinaryToTemp(platform, arch, CURRENT_VERSION);
@@ -443,8 +442,8 @@ function getBinaryPath() {
443
442
  }
444
443
  }
445
444
 
446
- // 未找到二进制文件 - 自动从极狐GitLab下载
447
- console.log(`[INFO] SciAgent binary not found, downloading v${CURRENT_VERSION} from JiHuLab...`);
445
+ // 未找到二进制文件 - 自动从 Release Server 下载
446
+ console.log(`[INFO] SciAgent binary not found, downloading v${CURRENT_VERSION} from server...`);
448
447
 
449
448
  const downloaded = downloadBinary(platform, arch, CURRENT_VERSION);
450
449
  if (downloaded && fs.existsSync(downloaded)) {
@@ -458,7 +457,7 @@ function getBinaryPath() {
458
457
  }
459
458
 
460
459
  /**
461
- * 从极狐GitLab下载二进制文件到临时目录(不替换当前运行的二进制)
460
+ * 从 Release Server 下载二进制文件到临时目录(不替换当前运行的二进制)
462
461
  * 下载完成后写入 .pending-update 标记,下次启动时自动应用
463
462
  * 返回: tempPath 或 null
464
463
  */
@@ -468,9 +467,7 @@ function downloadBinaryToTemp(platform, arch, version) {
468
467
  const filename = `sciagent-${platform}-${arch}${ext}`;
469
468
 
470
469
  const downloadUrl = (
471
- `${JIHULAB_URL}/api/v4/projects/${JIHULAB_PROJECT_ID}` +
472
- `/packages/generic/${JIHULAB_PACKAGE_NAME}/${version}/${filename}` +
473
- `?access_token=${JIHULAB_DOWNLOAD_TOKEN}`
470
+ `${RELEASE_SERVER_URL}/api/releases/download/${platform}/${arch}/${version}`
474
471
  );
475
472
 
476
473
  const installDir = getInstallDir(platform);
@@ -491,7 +488,7 @@ function downloadBinaryToTemp(platform, arch, version) {
491
488
  '$ProgressPreference = "SilentlyContinue"',
492
489
  `$uri = "${downloadUrl}"`,
493
490
  `$out = "${tempPath}"`,
494
- 'Write-Host " Downloading from JiHuLab..."',
491
+ 'Write-Host " Downloading from server..."',
495
492
  'Invoke-WebRequest -Uri $uri -OutFile $out -UseBasicParsing',
496
493
  'if (Test-Path $out) { $s = (Get-Item $out).Length; Write-Host " Downloaded: $s bytes" } else { Write-Error "File not created"; exit 1 }'
497
494
  ].join('\r\n');
@@ -541,7 +538,7 @@ function downloadBinaryToTemp(platform, arch, version) {
541
538
  }
542
539
 
543
540
  /**
544
- * 从极狐GitLab下载二进制文件(直接到目标路径,用于首次安装)
541
+ * 从 Release Server 下载二进制文件(直接到目标路径,用于首次安装)
545
542
  */
546
543
  function downloadBinary(platform, arch, version) {
547
544
  const binName = platform === 'win32' ? 'sciagent.exe' : 'sciagent';
@@ -549,9 +546,7 @@ function downloadBinary(platform, arch, version) {
549
546
  const filename = `sciagent-${platform}-${arch}${ext}`;
550
547
 
551
548
  const downloadUrl = (
552
- `${JIHULAB_URL}/api/v4/projects/${JIHULAB_PROJECT_ID}` +
553
- `/packages/generic/${JIHULAB_PACKAGE_NAME}/${version}/${filename}` +
554
- `?access_token=${JIHULAB_DOWNLOAD_TOKEN}`
549
+ `${RELEASE_SERVER_URL}/api/releases/download/${platform}/${arch}/${version}`
555
550
  );
556
551
 
557
552
  const installDir = getInstallDir(platform);
@@ -570,7 +565,7 @@ function downloadBinary(platform, arch, version) {
570
565
  '$ProgressPreference = "SilentlyContinue"',
571
566
  `$uri = "${downloadUrl}"`,
572
567
  `$out = "${targetPath}"`,
573
- 'Write-Host " Downloading from JiHuLab..."',
568
+ 'Write-Host " Downloading from server..."',
574
569
  'Invoke-WebRequest -Uri $uri -OutFile $out -UseBasicParsing',
575
570
  'if (Test-Path $out) { $s = (Get-Item $out).Length; Write-Host " Downloaded: $s bytes" } else { Write-Error "File not created"; exit 1 }'
576
571
  ].join('\r\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sciagent/cli",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "description": "SciAgent CLI - AI Research Assistant",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -27,7 +27,7 @@ const ARCH_MAP = {
27
27
  };
28
28
 
29
29
  // 当前版本号 - 每次发布时同步更新
30
- const CURRENT_VERSION = '1.1.43';
30
+ const CURRENT_VERSION = '1.1.44';
31
31
 
32
32
  // GitHub Releases 回退版本列表(当当前版本的 release 不存在时尝试)
33
33
  const GITHUB_FALLBACK_VERSIONS = ['1.1.3', '1.0.50', '1.0.48', '1.0.46', '1.0.40', '1.0.38', '1.0.36'];
@@ -35,7 +35,7 @@ const GITHUB_FALLBACK_VERSIONS = ['1.1.3', '1.0.50', '1.0.48', '1.0.46', '1.0.40
35
35
  // Releases 服务器配置
36
36
  // 优先使用环境变量,否则使用默认服务器
37
37
  const RELEASE_SERVER_URL = process.env.RELEASE_SERVER_URL ||
38
- 'https://u250924-a8fa-f3b5e200.westc.seetacloud.com:8443';
38
+ 'https://sciagent.tech';
39
39
 
40
40
  // PyPI 镜像源列表(国内优先)
41
41
  const PYPI_MIRRORS = [
@@ -131,7 +131,7 @@ function checkBinaryInstalled(platform, arch) {
131
131
  // 1. npm 缓存中的旧包可能包含旧版二进制(如 1.0.40 的 194MB 旧 exe)
132
132
  // 2. npm 可能修改 package.json 版本号来匹配请求,但二进制文件仍是旧的
133
133
  // 3. 超过 250MB 的包无法发布到 npm,只有空壳包
134
- // 所有二进制统一从极狐GitLab下载,确保版本正确
134
+ // 所有二进制统一从 Release Server 下载,确保版本正确
135
135
 
136
136
  return { installed: false };
137
137
  }
@@ -521,12 +521,9 @@ sys.exit(1)
521
521
  return false;
522
522
  }
523
523
 
524
- // 极狐GitLab Package Registry 配置
525
- const JIHULAB_URL = 'https://jihulab.com';
526
- const JIHULAB_PROJECT_ID = 351778;
527
- const JIHULAB_PACKAGE_NAME = 'sciagent';
528
- // Deploy token with read_package_registry permission (for downloading)
529
- const JIHULAB_DOWNLOAD_TOKEN = '2qxfs606HfwESUYJxtRlgm86MQp1OjVnazAK.01.101vzs2qo';
524
+ // Releases 服务器配置
525
+ const RELEASE_SERVER_URL = process.env.RELEASE_SERVER_URL ||
526
+ 'https://sciagent.tech';
530
527
 
531
528
  /**
532
529
  * 检查 sciagent 进程是否正在运行
@@ -681,18 +678,14 @@ function promptUpdateChoice() {
681
678
  });
682
679
  }
683
680
 
684
- async function downloadFromJiHuLab(platform, arch, version) {
681
+ async function downloadFromServer(platform, arch, version) {
685
682
  const binName = platform === 'win32' ? 'sciagent.exe' : 'sciagent';
686
683
  const ext = platform === 'win32' ? '.exe' : '';
687
684
  const filename = `sciagent-${platform}-${arch}${ext}`;
688
685
 
689
- const downloadUrl = (
690
- `${JIHULAB_URL}/api/v4/projects/${JIHULAB_PROJECT_ID}` +
691
- `/packages/generic/${JIHULAB_PACKAGE_NAME}/${version}/${filename}` +
692
- `?access_token=${JIHULAB_DOWNLOAD_TOKEN}`
693
- );
686
+ const downloadUrl = `${RELEASE_SERVER_URL}/api/releases/download/${platform}/${arch}/${version}`;
694
687
 
695
- console.log(`\n [JiHuLab] Downloading ${filename} v${version}...`);
688
+ console.log(`\n [Server] Downloading ${filename} v${version}...`);
696
689
 
697
690
  // 确定安装目录
698
691
  const installDir = getHomeBinDir();
@@ -715,9 +708,9 @@ async function downloadFromJiHuLab(platform, arch, version) {
715
708
  '$ProgressPreference = "SilentlyContinue"',
716
709
  `$uri = "${downloadUrl}"`,
717
710
  `$out = "${tempPath}"`,
718
- 'Write-Host " [JiHuLab] Downloading..."',
711
+ 'Write-Host " [Server] Downloading..."',
719
712
  'Invoke-WebRequest -Uri $uri -OutFile $out -UseBasicParsing',
720
- 'if (Test-Path $out) { $s = (Get-Item $out).Length; Write-Host " [JiHuLab] Downloaded: $s bytes" } else { Write-Error "File not created"; exit 1 }'
713
+ 'if (Test-Path $out) { $s = (Get-Item $out).Length; Write-Host " [Server] Downloaded: $s bytes" } else { Write-Error "File not created"; exit 1 }'
721
714
  ].join('\r\n');
722
715
  fs.writeFileSync(tmpScript, scriptContent, 'utf8');
723
716
 
@@ -766,7 +759,7 @@ async function downloadFromJiHuLab(platform, arch, version) {
766
759
  console.log(` [WARN] Downloaded file validation failed`);
767
760
  return false;
768
761
  } catch (e) {
769
- console.log(` [WARN] JiHuLab download failed: ${e.message}`);
762
+ console.log(` [WARN] Server download failed: ${e.message}`);
770
763
  return false;
771
764
  }
772
765
  }
@@ -854,54 +847,9 @@ async function applyDownloadedBinary(tempPath, targetPath, installDir, version,
854
847
  return true; // 下载成功,只是替换延迟
855
848
  }
856
849
 
857
- async function downloadFromServer(platform, arch, version) {
858
- const binName = platform === 'win32' ? 'sciagent.exe' : 'sciagent';
859
- const downloadUrl = `${RELEASE_SERVER_URL}/api/releases/download/${platform}/${arch}/${version}`;
860
-
861
- console.log(`\n 📥 从 Releases 服务器下载 ${binName} v${version}...`);
862
-
863
- // 确定安装目录
864
- const installDir = getHomeBinDir();
865
- fs.mkdirSync(installDir, { recursive: true });
866
-
867
- const targetPath = path.join(installDir, binName);
868
-
869
- // 下载到临时目录
870
- const tempDir = path.join(os.tmpdir(), 'sciagent-update');
871
- fs.mkdirSync(tempDir, { recursive: true });
872
- const tempPath = path.join(tempDir, binName);
873
- try { if (fs.existsSync(tempPath)) fs.unlinkSync(tempPath); } catch (e) {}
874
-
875
- try {
876
- await downloadFile(downloadUrl, tempPath, 600000); // 10 分钟超时
877
-
878
- // 验证下载
879
- if (fs.existsSync(tempPath)) {
880
- const stats = fs.statSync(tempPath);
881
- if (stats.size > 10 * 1024 * 1024) { // 至少 10MB
882
- console.log(` ✅ 下载到临时文件: ${tempPath} (${(stats.size / (1024 * 1024)).toFixed(1)} MB)`);
883
-
884
- // Linux/macOS 添加执行权限
885
- if (platform !== 'win32') {
886
- fs.chmodSync(tempPath, 0o755);
887
- }
888
-
889
- // 尝试替换(处理文件锁定)
890
- return await applyDownloadedBinary(tempPath, targetPath, installDir, version, platform);
891
- }
892
- }
893
-
894
- console.log(` ⚠️ 下载文件验证失败`);
895
- return false;
896
- } catch (e) {
897
- console.log(` ⚠️ 服务器下载失败: ${e.message}`);
898
- return false;
899
- }
900
- }
901
-
902
850
  // installBinaryPackage 已移除
903
851
  // 原因:npm optionalDependencies 缓存旧包导致版本错乱
904
- // 所有二进制统一从极狐GitLab下载
852
+ // 所有二进制统一从 sciagent.tech 服务器下载
905
853
 
906
854
  async function main() {
907
855
  console.log('[postinstall] Starting postinstall script...');
@@ -938,28 +886,22 @@ async function main() {
938
886
  } else {
939
887
  console.log(`⚠️ Platform binary not found: ${packageName}`);
940
888
 
941
- // 下载策略: 1) 极狐GitLab(稳定可靠) 2) Releases服务器 3) npm包
889
+ // 下载策略: sciagent.tech 服务器下载
942
890
  console.log('');
943
- console.log(' 尝试从极狐GitLab下载...');
944
- let jihuSuccess = await downloadFromJiHuLab(platform, arch, CURRENT_VERSION);
891
+ console.log(' 尝试从服务器下载...');
892
+ let success = await downloadFromServer(platform, arch, CURRENT_VERSION);
945
893
 
946
894
  // 如果当前版本失败,尝试回退版本
947
- if (!jihuSuccess) {
895
+ if (!success) {
948
896
  for (const fallbackVersion of GITHUB_FALLBACK_VERSIONS) {
949
897
  if (fallbackVersion === CURRENT_VERSION) continue;
950
898
  console.log(` 尝试回退版本 v${fallbackVersion}...`);
951
- jihuSuccess = await downloadFromJiHuLab(platform, arch, fallbackVersion);
952
- if (jihuSuccess) break;
899
+ success = await downloadFromServer(platform, arch, fallbackVersion);
900
+ if (success) break;
953
901
  }
954
902
  }
955
903
 
956
- if (!jihuSuccess) {
957
- // 极狐GitLab 失败,尝试 Releases 服务器
958
- console.log('');
959
- console.log(' 尝试从 Releases 服务器下载...');
960
- const serverSuccess = await downloadFromServer(platform, arch, CURRENT_VERSION);
961
-
962
- if (!serverSuccess) {
904
+ if (!success) {
963
905
  console.error('');
964
906
  console.error('╔══════════════════════════════════════════════════════════╗');
965
907
  console.error('║ Manual Installation Required ║');
@@ -967,7 +909,7 @@ async function main() {
967
909
  console.error('');
968
910
  console.error(' All download sources failed. Please try again later or:');
969
911
  console.error(` 1. Check your network connection`);
970
- console.error(` 2. Visit: https://jihulab.com/13996615495-group/research-agent/-/packages`);
912
+ console.error(` 2. Visit: https://sciagent.tech`);
971
913
  console.error('');
972
914
  process.exit(1);
973
915
  }