@sciagent/cli 1.0.41 → 1.0.45
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/package.json +3 -3
- package/scripts/postinstall.js +66 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sciagent/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"description": "SciAgent CLI - AI Research Assistant",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"postinstall": "node scripts/postinstall.js"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@sciagent/cli-linux-x64": "1.0.
|
|
18
|
+
"@sciagent/cli-linux-x64": "1.0.45",
|
|
19
19
|
"@sciagent/cli-linux-arm64": "1.0.39",
|
|
20
20
|
"@sciagent/cli-darwin-x64": "1.0.39",
|
|
21
21
|
"@sciagent/cli-darwin-arm64": "1.0.39",
|
|
22
|
-
"@sciagent/cli-win32-x64": "1.0.
|
|
22
|
+
"@sciagent/cli-win32-x64": "1.0.45",
|
|
23
23
|
"@sciagent/cli-win32-arm64": "1.0.39"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
package/scripts/postinstall.js
CHANGED
|
@@ -27,7 +27,12 @@ const ARCH_MAP = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// 当前版本号 - 每次发布时同步更新
|
|
30
|
-
const CURRENT_VERSION = '1.0.
|
|
30
|
+
const CURRENT_VERSION = '1.0.45';
|
|
31
|
+
|
|
32
|
+
// Releases 服务器配置
|
|
33
|
+
// 优先使用环境变量,否则使用默认服务器
|
|
34
|
+
const RELEASE_SERVER_URL = process.env.RELEASE_SERVER_URL ||
|
|
35
|
+
'https://u250924-badf-b5de25de.westc.seetacloud.com:8443';
|
|
31
36
|
|
|
32
37
|
// PyPI 镜像源列表(国内优先)
|
|
33
38
|
const PYPI_MIRRORS = [
|
|
@@ -364,6 +369,44 @@ sys.exit(1)
|
|
|
364
369
|
}
|
|
365
370
|
}
|
|
366
371
|
|
|
372
|
+
async function downloadFromServer(platform, arch, version) {
|
|
373
|
+
const binName = platform === 'win32' ? 'sciagent.exe' : 'sciagent';
|
|
374
|
+
const downloadUrl = `${RELEASE_SERVER_URL}/api/releases/download/${platform}/${arch}/${version}`;
|
|
375
|
+
|
|
376
|
+
console.log(`\n 📥 从服务器下载: ${downloadUrl}`);
|
|
377
|
+
|
|
378
|
+
// 确定安装目录
|
|
379
|
+
const installDir = path.join(os.homedir(), '.sciagent', 'bin');
|
|
380
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
381
|
+
|
|
382
|
+
const targetPath = path.join(installDir, binName);
|
|
383
|
+
|
|
384
|
+
try {
|
|
385
|
+
await downloadFile(downloadUrl, targetPath, 600000); // 10 分钟超时
|
|
386
|
+
|
|
387
|
+
// 验证下载
|
|
388
|
+
if (fs.existsSync(targetPath)) {
|
|
389
|
+
const stats = fs.statSync(targetPath);
|
|
390
|
+
if (stats.size > 10 * 1024 * 1024) { // 至少 10MB
|
|
391
|
+
console.log(` ✅ 下载成功: ${targetPath} (${(stats.size / (1024 * 1024)).toFixed(1)} MB)`);
|
|
392
|
+
|
|
393
|
+
// Linux/macOS 添加执行权限
|
|
394
|
+
if (platform !== 'win32') {
|
|
395
|
+
fs.chmodSync(targetPath, 0o755);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
console.log(` ⚠️ 下载文件验证失败`);
|
|
403
|
+
return false;
|
|
404
|
+
} catch (e) {
|
|
405
|
+
console.log(` ⚠️ 服务器下载失败: ${e.message}`);
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
367
410
|
function installBinaryPackage(platform, arch) {
|
|
368
411
|
// 版本回退列表:先尝试当前版本,再尝试已知存在的版本
|
|
369
412
|
const FALLBACK_VERSIONS = [CURRENT_VERSION, '1.0.40', '1.0.38', '1.0.36', '1.0.33'];
|
|
@@ -433,23 +476,33 @@ async function main() {
|
|
|
433
476
|
} else {
|
|
434
477
|
console.log(`⚠️ Platform binary not found: ${packageName}`);
|
|
435
478
|
|
|
436
|
-
|
|
479
|
+
// 优先尝试从服务器下载(更快、更可靠)
|
|
480
|
+
console.log('');
|
|
481
|
+
console.log(' 尝试从服务器下载...');
|
|
482
|
+
const serverSuccess = await downloadFromServer(platform, arch, CURRENT_VERSION);
|
|
437
483
|
|
|
438
|
-
if (!
|
|
439
|
-
|
|
440
|
-
console.
|
|
441
|
-
console.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
484
|
+
if (!serverSuccess) {
|
|
485
|
+
// 服务器下载失败,回退到 npm 包安装
|
|
486
|
+
console.log('');
|
|
487
|
+
console.log(' 回退到 npm 包安装...');
|
|
488
|
+
const npmSuccess = installBinaryPackage(platform, arch);
|
|
489
|
+
|
|
490
|
+
if (!npmSuccess) {
|
|
491
|
+
console.error('');
|
|
492
|
+
console.error('╔══════════════════════════════════════════════════════════╗');
|
|
493
|
+
console.error('║ Manual Installation Required ║');
|
|
494
|
+
console.error('╚══════════════════════════════════════════════════════════╝');
|
|
495
|
+
console.error('');
|
|
496
|
+
console.error(' Please run this command manually:');
|
|
497
|
+
console.error(` npm install -g ${packageName}@${CURRENT_VERSION}`);
|
|
498
|
+
console.error('');
|
|
499
|
+
process.exit(1);
|
|
500
|
+
}
|
|
448
501
|
}
|
|
449
502
|
|
|
450
503
|
const verifyResult = checkBinaryInstalled(platform, arch);
|
|
451
504
|
if (verifyResult.installed) {
|
|
452
|
-
console.log(`\n✅ Platform binary installed successfully
|
|
505
|
+
console.log(`\n✅ Platform binary installed successfully`);
|
|
453
506
|
} else {
|
|
454
507
|
console.error(`\n❌ Installation verification failed. Please install manually:`);
|
|
455
508
|
console.error(` npm install -g ${packageName}@${CURRENT_VERSION}`);
|