@bolloon/bolloon-agent 0.4.15 → 0.4.17
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/index.js +59 -18
- package/package.json +2 -17
package/dist/index.js
CHANGED
|
@@ -497,8 +497,12 @@ function statusBarLine() {
|
|
|
497
497
|
const usage = getCliCtxUsage();
|
|
498
498
|
return `${C_ACCENT}${cliModelName}${RESET}${C_DIM} │${RESET} ${cliAgentName} ${C_DIM}│${RESET} ⏱ ${C_ACCENT}${dur}${RESET} ${C_DIM}│${RESET} ${buildContextBar(usage)}`;
|
|
499
499
|
}
|
|
500
|
-
async function startCLI(
|
|
500
|
+
async function startCLI(commReady) {
|
|
501
501
|
isRunning = true;
|
|
502
|
+
// 2026-09-08 加速启动: P2P 后台就绪, UI 直接渲染不阻塞 — comm 就绪前为 null,
|
|
503
|
+
// 内部用法全空安全 (P2P 功能自动降级, 就绪后立即可用)
|
|
504
|
+
let comm = null;
|
|
505
|
+
commReady.then((c) => { comm = c; }).catch(() => { });
|
|
502
506
|
// CLI 模式下静音所有 console.log/warn
|
|
503
507
|
// (Ink 用自己的 render 引擎, console.log 输出会污染终端)
|
|
504
508
|
console.log = () => { };
|
|
@@ -513,10 +517,11 @@ async function startCLI(comm) {
|
|
|
513
517
|
return _origStdout(chunk, ...rest);
|
|
514
518
|
});
|
|
515
519
|
let peerCount = 0;
|
|
516
|
-
try {
|
|
517
|
-
|
|
520
|
+
void commReady.then((c) => { try {
|
|
521
|
+
if (c)
|
|
522
|
+
peerCount = c.getConnections().length;
|
|
518
523
|
}
|
|
519
|
-
catch { /* */ }
|
|
524
|
+
catch { /* */ } });
|
|
520
525
|
// 读取 LLM 模型名 — 优先 bolloon-config.json (activeProvider), 再退 env (2026-08-07:
|
|
521
526
|
// 之前只读 env → 用户配了配置文件但状态栏显示"未配置")
|
|
522
527
|
const providerNames = [
|
|
@@ -693,7 +698,7 @@ async function startCLI(comm) {
|
|
|
693
698
|
catch { /* 非致命 */ }
|
|
694
699
|
if (cliCronTimer)
|
|
695
700
|
clearInterval(cliCronTimer);
|
|
696
|
-
comm
|
|
701
|
+
comm?.stop();
|
|
697
702
|
process.exit(0);
|
|
698
703
|
}
|
|
699
704
|
async function processInput(input, comm) {
|
|
@@ -1830,7 +1835,7 @@ async function processInput(input, comm) {
|
|
|
1830
1835
|
return;
|
|
1831
1836
|
}
|
|
1832
1837
|
if (trimmed.toLowerCase() === 'peers') {
|
|
1833
|
-
const peers = comm
|
|
1838
|
+
const peers = comm?.getConnections() || [];
|
|
1834
1839
|
appendLine(`${GRAY}已连接节点: ${peers.length}${RESET}`);
|
|
1835
1840
|
for (const c of peers) {
|
|
1836
1841
|
appendLine(` ${GRAY}·${RESET} ${c.publicKey.substring(0, 16)}...`);
|
|
@@ -3555,6 +3560,7 @@ async function main() {
|
|
|
3555
3560
|
})();
|
|
3556
3561
|
const verifier = createVerificationManager();
|
|
3557
3562
|
let comm = null;
|
|
3563
|
+
let commReady = null;
|
|
3558
3564
|
try {
|
|
3559
3565
|
if (mode === 'web') {
|
|
3560
3566
|
bootstrapP2P(verifier).then(c => {
|
|
@@ -3568,6 +3574,24 @@ async function main() {
|
|
|
3568
3574
|
s.warn(`P2P Web 模式启动失败: ${err.message}`);
|
|
3569
3575
|
});
|
|
3570
3576
|
}
|
|
3577
|
+
else if (isCLIInteractive) {
|
|
3578
|
+
// 2026-09-08 加速启动: 交互 CLI 不阻塞等 P2P — 后台 20s 超时门, 就绪后自动挂上;
|
|
3579
|
+
// startCLI 收 Promise, 内部空安全 (P2P 功能就绪前自动降级, 一般 1-3s 内可用)
|
|
3580
|
+
commReady = withTimeout(bootstrapP2P(verifier), 20_000, 'P2P 网络初始化')
|
|
3581
|
+
.catch((err) => {
|
|
3582
|
+
s.warn(`P2P 初始化超时/失败, 降级无 P2P 模式: ${err.message}`);
|
|
3583
|
+
return null;
|
|
3584
|
+
});
|
|
3585
|
+
void commReady.then((c) => {
|
|
3586
|
+
if (c) {
|
|
3587
|
+
const connections = c.getConnections();
|
|
3588
|
+
if (connections.length > 0) {
|
|
3589
|
+
agentIdentity.peerId = connections[0].publicKey;
|
|
3590
|
+
agentIdentity.p2pChannel = 'bolloon-agent-harness';
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}).catch(() => { });
|
|
3594
|
+
}
|
|
3571
3595
|
else {
|
|
3572
3596
|
// 2026-08-07: 弱网下 hyperswarm DHT start/joinTopic 可能无限挂起 → 20s 超时门, 超时降级无 P2P 模式
|
|
3573
3597
|
comm = await withTimeout(bootstrapP2P(verifier), 20_000, 'P2P 网络初始化')
|
|
@@ -3588,18 +3612,35 @@ async function main() {
|
|
|
3588
3612
|
s.warn(`P2P 初始化失败: ${err.message}`);
|
|
3589
3613
|
s.warn('将使用无 P2P 模式运行');
|
|
3590
3614
|
}
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3615
|
+
if (isCLIInteractive) {
|
|
3616
|
+
// 2026-09-08 加速启动: iroh + Bolloon bootstrap 也全部后台, 不阻塞 UI 首帧
|
|
3617
|
+
void withTimeout(bootstrapIroh(keypair, name), 15_000, 'iroh P2P 初始化')
|
|
3618
|
+
.catch((err) => s.warn(`iroh 初始化超时, 继续使用 Hyperswarm P2P: ${err.message}`));
|
|
3619
|
+
void (async () => {
|
|
3620
|
+
try {
|
|
3621
|
+
const { bootstrapBolloon } = await import('./pi-ecosystem-judgment/human-value-pipeline.js');
|
|
3622
|
+
const bs = await withTimeout(bootstrapBolloon({ cwd: process.cwd() }), 20_000, 'Bolloon 上下文扫描');
|
|
3623
|
+
s.info(`Bootstrap 完成 (${bs.durationMs}ms, ${bs.errors.length} 个非致命错误)`);
|
|
3624
|
+
}
|
|
3625
|
+
catch (err) {
|
|
3626
|
+
s.warn(`Bootstrap 失败 (非致命, 主流程继续): ${err.message}`);
|
|
3627
|
+
}
|
|
3628
|
+
})();
|
|
3600
3629
|
}
|
|
3601
|
-
|
|
3602
|
-
|
|
3630
|
+
else {
|
|
3631
|
+
await withTimeout(bootstrapIroh(keypair, name), 15_000, 'iroh P2P 初始化')
|
|
3632
|
+
.catch((err) => s.warn(`iroh 初始化超时, 继续使用 Hyperswarm P2P: ${err.message}`));
|
|
3633
|
+
// Bolloon Bootstrap: 启动扫描 + Context 收集 + 挂定时任务
|
|
3634
|
+
// 失败静默 (主流程不被阻塞)
|
|
3635
|
+
try {
|
|
3636
|
+
const { bootstrapBolloon } = await import('./pi-ecosystem-judgment/human-value-pipeline.js');
|
|
3637
|
+
s.info('正在 bootstrap bolloon 上下文...');
|
|
3638
|
+
const bs = await withTimeout(bootstrapBolloon({ cwd: process.cwd() }), 20_000, 'Bolloon 上下文扫描');
|
|
3639
|
+
s.info(`Bootstrap 完成 (${bs.durationMs}ms, ${bs.errors.length} 个非致命错误)`);
|
|
3640
|
+
}
|
|
3641
|
+
catch (err) {
|
|
3642
|
+
s.warn(`Bootstrap 失败 (非致命, 主流程继续): ${err.message}`);
|
|
3643
|
+
}
|
|
3603
3644
|
}
|
|
3604
3645
|
if (mode === 'web') {
|
|
3605
3646
|
const port = parseInt(process.env.PORT || '54188');
|
|
@@ -3634,7 +3675,7 @@ async function main() {
|
|
|
3634
3675
|
console.log = originalLog;
|
|
3635
3676
|
console.info = originalInfo;
|
|
3636
3677
|
process.stdout.write = originalStdoutWrite;
|
|
3637
|
-
await startCLI(
|
|
3678
|
+
await startCLI(commReady ?? Promise.resolve(null));
|
|
3638
3679
|
}
|
|
3639
3680
|
}
|
|
3640
3681
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolloon/bolloon-agent",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
|
|
6
6
|
"main": "dist/cli-entry.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@capacitor/ios": "^8.5.1",
|
|
64
64
|
"@chainsafe/libp2p-noise": "^17.0.0",
|
|
65
65
|
"@chainsafe/libp2p-yamux": "^8.0.1",
|
|
66
|
-
"@diap/sdk": "^0.2.
|
|
66
|
+
"@diap/sdk": "^0.2.5",
|
|
67
67
|
"@libp2p/autonat": "^3.0.28",
|
|
68
68
|
"@libp2p/circuit-relay-v2": "^4.2.13",
|
|
69
69
|
"@libp2p/dcutr": "^3.0.28",
|
|
@@ -78,24 +78,9 @@
|
|
|
78
78
|
"@orbitdb/core": "^4.0.0",
|
|
79
79
|
"@polymarket/client": "^0.9.0",
|
|
80
80
|
"@rayhanadev/iroh": "^0.1.1",
|
|
81
|
-
"@x402/aptos": "^2.25.0",
|
|
82
|
-
"@x402/avm": "^2.25.0",
|
|
83
|
-
"@x402/axios": "^2.25.0",
|
|
84
81
|
"@x402/core": "^2.25.0",
|
|
85
82
|
"@x402/evm": "^2.25.0",
|
|
86
|
-
"@x402/express": "^2.25.0",
|
|
87
|
-
"@x402/extensions": "^2.25.0",
|
|
88
|
-
"@x402/fastify": "^2.25.0",
|
|
89
83
|
"@x402/fetch": "^2.25.0",
|
|
90
|
-
"@x402/hedera": "^2.25.0",
|
|
91
|
-
"@x402/hono": "^2.25.0",
|
|
92
|
-
"@x402/keeta": "^2.25.0",
|
|
93
|
-
"@x402/mcp": "^2.25.0",
|
|
94
|
-
"@x402/next": "^2.25.0",
|
|
95
|
-
"@x402/paywall": "^2.25.0",
|
|
96
|
-
"@x402/stellar": "^2.25.0",
|
|
97
|
-
"@x402/svm": "^2.25.0",
|
|
98
|
-
"@x402/tvm": "^2.25.0",
|
|
99
84
|
"b4a": "^1.8.1",
|
|
100
85
|
"dotenv": "^17.4.2",
|
|
101
86
|
"express": "^5.2.1",
|