evolclaw 2.5.7 → 2.5.8
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/dist/config.js +2 -0
- package/dist/utils/init-channel.js +50 -20
- package/dist/utils/init.js +10 -22
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -377,6 +377,8 @@ function validateConfig(config) {
|
|
|
377
377
|
// Feishu 配置可选,但如果配置了就要完整(支持 array / object 两种格式)
|
|
378
378
|
const feishuInstances = normalizeChannelInstances(config.channels?.feishu, 'feishu');
|
|
379
379
|
for (const inst of feishuInstances) {
|
|
380
|
+
if (inst.enabled === false)
|
|
381
|
+
continue;
|
|
380
382
|
const label = feishuInstances.length > 1 ? ` [${inst.name}]` : '';
|
|
381
383
|
if (!inst.appId || inst.appId.startsWith('YOUR_')) {
|
|
382
384
|
logger.warn(`⚠ Feishu${label} appId not configured (Feishu channel will be disabled)`);
|
|
@@ -627,6 +627,44 @@ export function resolveAunCoreSdkPkg() {
|
|
|
627
627
|
catch { /* not found */ }
|
|
628
628
|
return null;
|
|
629
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* Download AUN CA root certificate to ~/.aun/CA/root/root.crt.
|
|
632
|
+
* Idempotent: skips if file already exists. Returns true if a cert is on disk
|
|
633
|
+
* after the call (either pre-existing or freshly downloaded).
|
|
634
|
+
*
|
|
635
|
+
* Must be called BEFORE constructing any AUNClient that needs to verify
|
|
636
|
+
* gateway-issued certificates (e.g. for uploadAgentMd) — the SDK loads trusted
|
|
637
|
+
* roots from disk at client construction time and won't pick up later writes.
|
|
638
|
+
*/
|
|
639
|
+
export async function downloadCaRoot(aunPath, gatewayUrl, indent = '') {
|
|
640
|
+
const caDir = path.join(aunPath, 'CA', 'root');
|
|
641
|
+
const caCertPath = path.join(caDir, 'root.crt');
|
|
642
|
+
if (fs.existsSync(caCertPath))
|
|
643
|
+
return true;
|
|
644
|
+
if (!gatewayUrl)
|
|
645
|
+
return false;
|
|
646
|
+
try {
|
|
647
|
+
fs.mkdirSync(caDir, { recursive: true });
|
|
648
|
+
const gwHttp = gatewayUrl.replace(/^wss?:/, 'https:').replace(/\/aun$/, '');
|
|
649
|
+
const resp = await fetch(`${gwHttp}/pki/chain`, { redirect: 'follow' });
|
|
650
|
+
if (!resp.ok) {
|
|
651
|
+
console.warn(`${indent}⚠ CA 根证书下载失败: HTTP ${resp.status}`);
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
const body = await resp.text();
|
|
655
|
+
if (!body.includes('BEGIN CERTIFICATE')) {
|
|
656
|
+
console.warn(`${indent}⚠ CA 根证书响应内容无效,跳过写入`);
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
fs.writeFileSync(caCertPath, body);
|
|
660
|
+
console.log(`${indent}✓ CA 根证书已下载`);
|
|
661
|
+
return true;
|
|
662
|
+
}
|
|
663
|
+
catch (e) {
|
|
664
|
+
console.warn(`${indent}⚠ CA 根证书下载失败: ${e},可稍后手动下载`);
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
630
668
|
export async function checkAunEnvironment(rl) {
|
|
631
669
|
console.log('\n🔍 AUN 环境检查...\n');
|
|
632
670
|
const minVer = MIN_AUN_CORE_SDK.join('.');
|
|
@@ -718,7 +756,7 @@ export async function setupAunAid(rl, _config) {
|
|
|
718
756
|
let failed = false;
|
|
719
757
|
try {
|
|
720
758
|
const { AUNClient } = await import('@agentunion/aun-node');
|
|
721
|
-
|
|
759
|
+
let client = new AUNClient({ aun_path: aunPath });
|
|
722
760
|
// 如果用户指定了自定义端口,手动设置 gateway URL;否则让 SDK 自动发现
|
|
723
761
|
if (gatewayPort) {
|
|
724
762
|
const domain = aid.split('.').slice(1).join('.');
|
|
@@ -727,26 +765,18 @@ export async function setupAunAid(rl, _config) {
|
|
|
727
765
|
const result = await client.auth.createAid({ aid });
|
|
728
766
|
console.log(` ✓ AID ${result.aid} 创建成功`);
|
|
729
767
|
// 下载 CA 根证书(如果本地不存在),从 SDK 返回的实际网关 URL 派生
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
|
|
768
|
+
const caDownloaded = await downloadCaRoot(aunPath, result.gateway || '', ' ');
|
|
769
|
+
// 关键:CA 下载后必须重建 client,让 SDK 重新加载 trusted roots。
|
|
770
|
+
// 否则 uploadAgentMd 会因为 "no trusted roots available" 而失败。
|
|
771
|
+
if (caDownloaded) {
|
|
733
772
|
try {
|
|
734
|
-
|
|
735
|
-
const gwHttp = result.gateway.replace(/^wss?:/, 'https:').replace(/\/aun$/, '');
|
|
736
|
-
const resp = await fetch(`${gwHttp}/pki/chain`, { redirect: 'follow' });
|
|
737
|
-
if (resp.ok) {
|
|
738
|
-
const body = await resp.text();
|
|
739
|
-
if (body.includes('BEGIN CERTIFICATE')) {
|
|
740
|
-
fs.writeFileSync(caCertPath, body);
|
|
741
|
-
console.log(' ✓ CA 根证书已下载');
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
console.warn(' ⚠ CA 根证书响应内容无效,跳过写入');
|
|
745
|
-
}
|
|
746
|
-
}
|
|
773
|
+
await client.close();
|
|
747
774
|
}
|
|
748
|
-
catch
|
|
749
|
-
|
|
775
|
+
catch { /* ignore */ }
|
|
776
|
+
client = new AUNClient({ aun_path: aunPath });
|
|
777
|
+
if (gatewayPort) {
|
|
778
|
+
const domain = aid.split('.').slice(1).join('.');
|
|
779
|
+
client._gatewayUrl = `wss://gateway.${domain}:${gatewayPort}/aun`;
|
|
750
780
|
}
|
|
751
781
|
}
|
|
752
782
|
// Collect agent.md info and publish
|
|
@@ -760,7 +790,7 @@ export async function setupAunAid(rl, _config) {
|
|
|
760
790
|
console.log(' ✓ agent.md 已发布');
|
|
761
791
|
}
|
|
762
792
|
catch (e) {
|
|
763
|
-
console.log(` ⚠ agent.md
|
|
793
|
+
console.log(` ⚠ agent.md 发布失败(首次连接将自动重试): ${String(e.message || e).slice(0, 100)}`);
|
|
764
794
|
}
|
|
765
795
|
fs.writeFileSync(agentMdPath, agentMdContent, 'utf-8');
|
|
766
796
|
if (!fs.existsSync(agentMdPath)) {
|
package/dist/utils/init.js
CHANGED
|
@@ -406,7 +406,7 @@ export async function cmdInit(options) {
|
|
|
406
406
|
}
|
|
407
407
|
if (options.channel === 'aun' && options.aunAid) {
|
|
408
408
|
// 自动安装 AUN SDK
|
|
409
|
-
const { resolveAunCoreSdkPkg, npmInstallGlobal } = await import('./init-channel.js');
|
|
409
|
+
const { resolveAunCoreSdkPkg, npmInstallGlobal, downloadCaRoot } = await import('./init-channel.js');
|
|
410
410
|
if (!resolveAunCoreSdkPkg()) {
|
|
411
411
|
console.log('正在安装 @agentunion/aun-node...');
|
|
412
412
|
await npmInstallGlobal('@agentunion/aun-node@latest');
|
|
@@ -416,31 +416,19 @@ export async function cmdInit(options) {
|
|
|
416
416
|
const aidDir = path.join(aunPath, 'AIDs', options.aunAid);
|
|
417
417
|
if (!fs.existsSync(path.join(aidDir, 'private'))) {
|
|
418
418
|
const { AUNClient } = await import('@agentunion/aun-node');
|
|
419
|
-
|
|
419
|
+
let client = new AUNClient({ aun_path: aunPath });
|
|
420
420
|
// 让 SDK 通过 well-known 自动发现网关
|
|
421
421
|
const result = await client.auth.createAid({ aid: options.aunAid });
|
|
422
422
|
// 下载 CA 根证书(如果本地不存在),从 SDK 返回的实际网关 URL 派生
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
const caDownloaded = await downloadCaRoot(aunPath, result.gateway || '');
|
|
424
|
+
// 关键:CA 下载后必须重建 client,让 SDK 重新加载 trusted roots。
|
|
425
|
+
// 否则 uploadAgentMd 会因为 "no trusted roots available" 而失败。
|
|
426
|
+
if (caDownloaded) {
|
|
426
427
|
try {
|
|
427
|
-
|
|
428
|
-
const gwHttp = result.gateway.replace(/^wss?:/, 'https:').replace(/\/aun$/, '');
|
|
429
|
-
const resp = await fetch(`${gwHttp}/pki/chain`, { redirect: 'follow' });
|
|
430
|
-
if (resp.ok) {
|
|
431
|
-
const body = await resp.text();
|
|
432
|
-
if (body.includes('BEGIN CERTIFICATE')) {
|
|
433
|
-
fs.writeFileSync(caCertPath, body);
|
|
434
|
-
console.log('✓ CA 根证书已下载');
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
console.warn('⚠ CA 根证书响应内容无效,跳过写入');
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
catch (e) {
|
|
442
|
-
console.warn(`⚠ CA 根证书下载失败: ${e},可稍后手动下载`);
|
|
428
|
+
await client.close();
|
|
443
429
|
}
|
|
430
|
+
catch { }
|
|
431
|
+
client = new AUNClient({ aun_path: aunPath });
|
|
444
432
|
}
|
|
445
433
|
// 写入初始 agent.md(initialized: false)
|
|
446
434
|
const agentName = options.aunAid.split('.')[0];
|
|
@@ -450,7 +438,7 @@ export async function cmdInit(options) {
|
|
|
450
438
|
await client.auth.uploadAgentMd(agentMd);
|
|
451
439
|
}
|
|
452
440
|
catch (e) {
|
|
453
|
-
console.warn(`⚠ agent.md
|
|
441
|
+
console.warn(`⚠ agent.md 网络发布失败(首次连接将自动重试): ${String(e?.message || e).slice(0, 100)}`);
|
|
454
442
|
}
|
|
455
443
|
fs.writeFileSync(agentMdPath, agentMd, 'utf-8');
|
|
456
444
|
if (!fs.existsSync(agentMdPath)) {
|
package/package.json
CHANGED