@bolloon/bolloon-agent 0.3.10 → 0.3.11
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/cli-entry.js +94 -0
- package/dist/electron/config.js +9 -14
- package/dist/electron/dialogs.js +16 -53
- package/dist/electron/first-run.js +24 -65
- package/dist/electron/ipc.js +10 -14
- package/dist/electron/logger.js +7 -44
- package/dist/electron/main.js +42 -45
- package/dist/electron/menu.js +13 -18
- package/dist/electron/paths.js +12 -54
- package/dist/electron/server.js +18 -57
- package/dist/electron/tray.js +15 -53
- package/dist/electron/window.js +22 -61
- package/dist/electron-preload.js +16 -19
- package/dist/electron.js +1 -4
- package/dist/index.js +63 -3
- package/dist/utils/auto-update.js +12 -51
- package/dist/web/client.js +4133 -4656
- package/dist/web/components/p2p/P2PModal.js +188 -0
- package/dist/web/components/p2p/index.js +276 -234
- package/dist/web/components/p2p/p2p-modal.js +664 -0
- package/dist/web/components/p2p/p2p-tools.js +248 -0
- package/dist/web/ui/message-renderer.js +535 -396
- package/dist/web/ui/step-timeline.js +371 -272
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -553,7 +553,7 @@ const AVAILABLE_TOOLS = [
|
|
|
553
553
|
{ name: 'update_check', description: '检查 npm 包更新', example: '--update-check' },
|
|
554
554
|
{ name: 'update_now', description: '立即更新到最新版本', example: '--update-now [package]' },
|
|
555
555
|
];
|
|
556
|
-
async function runToolCommand(tool, args, outputJson, comm) {
|
|
556
|
+
async function runToolCommand(tool, args, outputJson, comm, model) {
|
|
557
557
|
const a = await getAgent();
|
|
558
558
|
const startTime = Date.now();
|
|
559
559
|
let response;
|
|
@@ -1028,6 +1028,60 @@ async function runToolCommand(tool, args, outputJson, comm) {
|
|
|
1028
1028
|
}
|
|
1029
1029
|
break;
|
|
1030
1030
|
}
|
|
1031
|
+
case 'engine': {
|
|
1032
|
+
const { delegateToEngine } = await import('./external-engines/delegate.js');
|
|
1033
|
+
const { prompt } = (() => {
|
|
1034
|
+
const p = process.argv.slice(2).reduce((acc, arg, idx, arr) => {
|
|
1035
|
+
if (arg === '-e' || arg === '--engine') {
|
|
1036
|
+
acc.skip = idx + 2;
|
|
1037
|
+
return acc;
|
|
1038
|
+
}
|
|
1039
|
+
if (idx < acc.skip)
|
|
1040
|
+
return acc;
|
|
1041
|
+
if (arg.startsWith('--model') || arg.startsWith('-m')) {
|
|
1042
|
+
acc.skip = idx + 2;
|
|
1043
|
+
return acc;
|
|
1044
|
+
}
|
|
1045
|
+
if (arg.startsWith('-') || idx < acc.skip)
|
|
1046
|
+
return acc;
|
|
1047
|
+
acc.parts.push(arg);
|
|
1048
|
+
return acc;
|
|
1049
|
+
}, { skip: 0, parts: [] });
|
|
1050
|
+
return { prompt: p.parts.join(' ') };
|
|
1051
|
+
})();
|
|
1052
|
+
const engineId = args[0];
|
|
1053
|
+
if (!engineId) {
|
|
1054
|
+
response = '用法: --engine <engine-id> [--model <model>] <prompt>\n可用引擎: opencode, codex, claude-code, hermes';
|
|
1055
|
+
error = response;
|
|
1056
|
+
break;
|
|
1057
|
+
}
|
|
1058
|
+
if (!prompt) {
|
|
1059
|
+
response = '错误: 缺少 prompt 文本';
|
|
1060
|
+
error = response;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
if (outputJson) {
|
|
1064
|
+
process.stdout.write(JSON.stringify({ tool: 'engine', id: engineId, model, prompt: prompt.slice(0, 60) }) + '\n');
|
|
1065
|
+
}
|
|
1066
|
+
const result = await delegateToEngine(engineId, prompt, {
|
|
1067
|
+
...(model ? { model } : {}),
|
|
1068
|
+
});
|
|
1069
|
+
const elapsed = Date.now() - startTime;
|
|
1070
|
+
if (outputJson) {
|
|
1071
|
+
console.log(JSON.stringify({ ...result, elapsedMs: elapsed }, null, 2));
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
if (result.success) {
|
|
1075
|
+
response = result.output || '(无输出)';
|
|
1076
|
+
}
|
|
1077
|
+
else {
|
|
1078
|
+
response = `❌ 委派失败: ${result.error}`;
|
|
1079
|
+
if (result.output)
|
|
1080
|
+
response += `\n[输出]\n${result.output.slice(0, 2000)}`;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1031
1085
|
case 'context': {
|
|
1032
1086
|
const ctx = await getGlobalSharedContext();
|
|
1033
1087
|
response = await ctx.getContextSummary();
|
|
@@ -1576,6 +1630,11 @@ function parseArgs() {
|
|
|
1576
1630
|
}
|
|
1577
1631
|
result.toolArgs = delArgs;
|
|
1578
1632
|
break;
|
|
1633
|
+
case '--engine':
|
|
1634
|
+
case '-e':
|
|
1635
|
+
result.engine = args[++i];
|
|
1636
|
+
result.tool = 'engine';
|
|
1637
|
+
break;
|
|
1579
1638
|
case '--context':
|
|
1580
1639
|
result.context = true;
|
|
1581
1640
|
result.tool = 'context';
|
|
@@ -1736,9 +1795,10 @@ function parseArgs() {
|
|
|
1736
1795
|
i = args.length;
|
|
1737
1796
|
break;
|
|
1738
1797
|
default:
|
|
1739
|
-
if (!arg.startsWith('-') && !result.prompt
|
|
1798
|
+
if (!arg.startsWith('-') && !result.prompt) {
|
|
1740
1799
|
result.prompt = arg;
|
|
1741
|
-
result.tool
|
|
1800
|
+
if (!result.tool)
|
|
1801
|
+
result.tool = 'prompt';
|
|
1742
1802
|
}
|
|
1743
1803
|
}
|
|
1744
1804
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* npm 自动更新检查器
|
|
4
3
|
*
|
|
@@ -14,48 +13,11 @@
|
|
|
14
13
|
* 开发态下若 cwd 的 package.json 就是本包则回退到 cwd,不受任意工作目录影响。
|
|
15
14
|
* - 检查频率受节流缓存约束(默认 24h 一次),不会每次启动都打 npm。
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
-
var ownKeys = function(o) {
|
|
35
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
-
var ar = [];
|
|
37
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
|
-
return ownKeys(o);
|
|
41
|
-
};
|
|
42
|
-
return function (mod) {
|
|
43
|
-
if (mod && mod.__esModule) return mod;
|
|
44
|
-
var result = {};
|
|
45
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
-
__setModuleDefault(result, mod);
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
})();
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.checkAndUpdate = checkAndUpdate;
|
|
52
|
-
exports.checkForUpdates = checkForUpdates;
|
|
53
|
-
exports.performUpdate = performUpdate;
|
|
54
|
-
const child_process_1 = require("child_process");
|
|
55
|
-
const fs = __importStar(require("fs"));
|
|
56
|
-
const path = __importStar(require("path"));
|
|
57
|
-
const https = __importStar(require("https"));
|
|
58
|
-
const http = __importStar(require("http"));
|
|
16
|
+
import { execSync } from 'child_process';
|
|
17
|
+
import * as fs from 'fs';
|
|
18
|
+
import * as path from 'path';
|
|
19
|
+
import * as https from 'https';
|
|
20
|
+
import * as http from 'http';
|
|
59
21
|
// ANSI 颜色
|
|
60
22
|
const RESET = '\x1b[0m';
|
|
61
23
|
const BOLD = '\x1b[1m';
|
|
@@ -113,7 +75,7 @@ function getGlobalBolloonDir() {
|
|
|
113
75
|
const candidates = [];
|
|
114
76
|
// 1. npm root -g(最可靠)
|
|
115
77
|
try {
|
|
116
|
-
const npmRoot =
|
|
78
|
+
const npmRoot = execSync('npm root -g', { encoding: 'utf-8', timeout: 8000 }).trim();
|
|
117
79
|
if (npmRoot)
|
|
118
80
|
candidates.push(path.join(npmRoot, '@bolloon', 'bolloon-agent'));
|
|
119
81
|
}
|
|
@@ -122,7 +84,7 @@ function getGlobalBolloonDir() {
|
|
|
122
84
|
}
|
|
123
85
|
// 2. npm prefix -g
|
|
124
86
|
try {
|
|
125
|
-
const npmPrefix =
|
|
87
|
+
const npmPrefix = execSync('npm prefix -g', { encoding: 'utf-8', timeout: 8000 }).trim();
|
|
126
88
|
if (npmPrefix)
|
|
127
89
|
candidates.push(path.join(npmPrefix, 'lib', 'node_modules', '@bolloon', 'bolloon-agent'));
|
|
128
90
|
}
|
|
@@ -280,7 +242,7 @@ async function checkBolloonUpdates() {
|
|
|
280
242
|
*/
|
|
281
243
|
function checkNpmOutdated() {
|
|
282
244
|
try {
|
|
283
|
-
const output =
|
|
245
|
+
const output = execSync('npm outdated --json', {
|
|
284
246
|
encoding: 'utf-8',
|
|
285
247
|
timeout: 30000,
|
|
286
248
|
maxBuffer: 10 * 1024 * 1024,
|
|
@@ -344,7 +306,7 @@ async function updatePackagesWithVersion(packagesWithVersion) {
|
|
|
344
306
|
const args = ['npm', 'install', '-g', ...packagesWithVersion];
|
|
345
307
|
notify(`\n${CYAN}📦 正在更新包...${RESET}\n`, RESET);
|
|
346
308
|
try {
|
|
347
|
-
|
|
309
|
+
execSync(args.join(' '), {
|
|
348
310
|
encoding: 'utf-8',
|
|
349
311
|
timeout: 300000,
|
|
350
312
|
stdio: 'inherit',
|
|
@@ -462,7 +424,7 @@ function resolveAutoUpdatePolicy() {
|
|
|
462
424
|
* 例如 Electron 用 app.relaunch(),Node 用 detached 重新 spawn)。
|
|
463
425
|
* 若未提供或 autoRestart=false,则仅提示用户手动重启。
|
|
464
426
|
*/
|
|
465
|
-
async function checkAndUpdate(opts = {}) {
|
|
427
|
+
export async function checkAndUpdate(opts = {}) {
|
|
466
428
|
const policy = resolveAutoUpdatePolicy();
|
|
467
429
|
if (policy.blocked) {
|
|
468
430
|
return { hasUpdate: false, info: null, updated: false, message: '跳过更新检查(已显式禁用)' };
|
|
@@ -566,13 +528,13 @@ async function checkAndUpdate(opts = {}) {
|
|
|
566
528
|
/**
|
|
567
529
|
* 仅检查更新,不自动安装
|
|
568
530
|
*/
|
|
569
|
-
async function checkForUpdates() {
|
|
531
|
+
export async function checkForUpdates() {
|
|
570
532
|
return await checkBolloonUpdates();
|
|
571
533
|
}
|
|
572
534
|
/**
|
|
573
535
|
* 手动触发更新
|
|
574
536
|
*/
|
|
575
|
-
async function performUpdate(packages) {
|
|
537
|
+
export async function performUpdate(packages) {
|
|
576
538
|
return await updatePackages(packages);
|
|
577
539
|
}
|
|
578
540
|
// CLI 入口
|
|
@@ -595,4 +557,3 @@ if (process.argv[1]?.includes('auto-update')) {
|
|
|
595
557
|
}
|
|
596
558
|
})();
|
|
597
559
|
}
|
|
598
|
-
//# sourceMappingURL=auto-update.js.map
|