@bolloon/bolloon-agent 0.3.11 → 0.3.13
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/agents/pi-sdk-tools.js +147 -0
- package/dist/agents/pi-sdk.js +21 -0
- package/dist/agents/x402/x402Pay.js +281 -0
- package/dist/electron/config.js +14 -9
- package/dist/electron/dialogs.js +53 -16
- package/dist/electron/first-run.js +65 -24
- package/dist/electron/ipc.js +14 -10
- package/dist/electron/logger.js +44 -7
- package/dist/electron/main.js +45 -42
- package/dist/electron/menu.js +18 -13
- package/dist/electron/paths.js +54 -12
- package/dist/electron/server.js +57 -18
- package/dist/electron/tray.js +53 -15
- package/dist/electron/window.js +61 -22
- package/dist/electron-preload.js +19 -16
- package/dist/electron.js +4 -1
- package/dist/index.js +18 -44
- package/dist/utils/auto-update.js +51 -12
- package/dist/web/client.js +4787 -4138
- package/dist/web/components/p2p/index.js +234 -276
- package/dist/web/index.html +14 -0
- package/dist/web/server-storage.js +41 -9
- package/dist/web/server.js +71 -0
- package/dist/web/style.css +25 -0
- package/dist/web/ui/message-renderer.js +396 -535
- package/dist/web/ui/step-timeline.js +272 -371
- package/package.json +22 -3
- package/dist/web/components/p2p/P2PModal.js +0 -188
- package/dist/web/components/p2p/p2p-modal.js +0 -664
- package/dist/web/components/p2p/p2p-tools.js +0 -248
package/dist/electron/tray.js
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createTray = createTray;
|
|
37
|
+
exports.destroyTray = destroyTray;
|
|
1
38
|
/**
|
|
2
39
|
* 系统托盘 — Show / Hide / Quit
|
|
3
40
|
*
|
|
@@ -7,33 +44,33 @@
|
|
|
7
44
|
*
|
|
8
45
|
* 若 build 目录没有 tray 图标, 降级为不创建托盘 (主菜单和窗口关闭行为不变)
|
|
9
46
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
47
|
+
const electron_1 = require("electron");
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const fs = __importStar(require("fs"));
|
|
50
|
+
const paths_1 = require("./paths");
|
|
51
|
+
const logger_1 = require("./logger");
|
|
15
52
|
let trayInstance = null;
|
|
16
53
|
function loadTrayIcon() {
|
|
17
54
|
const isMac = process.platform === 'darwin';
|
|
18
55
|
const file = isMac ? 'trayTemplate.png' : 'tray.png';
|
|
19
|
-
const iconPath = path.join(buildResourcesDir(), file);
|
|
56
|
+
const iconPath = path.join((0, paths_1.buildResourcesDir)(), file);
|
|
20
57
|
if (!fs.existsSync(iconPath)) {
|
|
21
|
-
log(`托盘图标缺失: ${iconPath} (跳过托盘创建)`, 'warn');
|
|
58
|
+
(0, logger_1.log)(`托盘图标缺失: ${iconPath} (跳过托盘创建)`, 'warn');
|
|
22
59
|
return null;
|
|
23
60
|
}
|
|
24
|
-
const img = nativeImage.createFromPath(iconPath);
|
|
61
|
+
const img = electron_1.nativeImage.createFromPath(iconPath);
|
|
25
62
|
if (isMac)
|
|
26
63
|
img.setTemplateImage(true);
|
|
27
64
|
return img;
|
|
28
65
|
}
|
|
29
|
-
|
|
66
|
+
function createTray(getMainWindow) {
|
|
30
67
|
if (trayInstance)
|
|
31
68
|
return;
|
|
32
69
|
const icon = loadTrayIcon();
|
|
33
70
|
if (!icon)
|
|
34
71
|
return;
|
|
35
|
-
trayInstance = new Tray(icon);
|
|
36
|
-
trayInstance.setToolTip(`Bolloon Agent v${app.getVersion()}`);
|
|
72
|
+
trayInstance = new electron_1.Tray(icon);
|
|
73
|
+
trayInstance.setToolTip(`Bolloon Agent v${electron_1.app.getVersion()}`);
|
|
37
74
|
const toggle = () => {
|
|
38
75
|
const w = getMainWindow();
|
|
39
76
|
if (!w)
|
|
@@ -48,14 +85,14 @@ export function createTray(getMainWindow) {
|
|
|
48
85
|
w.focus();
|
|
49
86
|
}
|
|
50
87
|
};
|
|
51
|
-
const menu = Menu.buildFromTemplate([
|
|
88
|
+
const menu = electron_1.Menu.buildFromTemplate([
|
|
52
89
|
{ label: 'Show / Hide', click: () => toggle() },
|
|
53
90
|
{ type: 'separator' },
|
|
54
91
|
{
|
|
55
92
|
label: 'Quit',
|
|
56
93
|
click: () => {
|
|
57
|
-
log('托盘菜单 Quit');
|
|
58
|
-
app.quit();
|
|
94
|
+
(0, logger_1.log)('托盘菜单 Quit');
|
|
95
|
+
electron_1.app.quit();
|
|
59
96
|
},
|
|
60
97
|
},
|
|
61
98
|
]);
|
|
@@ -65,9 +102,10 @@ export function createTray(getMainWindow) {
|
|
|
65
102
|
trayInstance.on('click', () => toggle());
|
|
66
103
|
}
|
|
67
104
|
}
|
|
68
|
-
|
|
105
|
+
function destroyTray() {
|
|
69
106
|
if (trayInstance) {
|
|
70
107
|
trayInstance.destroy();
|
|
71
108
|
trayInstance = null;
|
|
72
109
|
}
|
|
73
110
|
}
|
|
111
|
+
//# sourceMappingURL=tray.js.map
|
package/dist/electron/window.js
CHANGED
|
@@ -1,25 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getMainWindow = getMainWindow;
|
|
37
|
+
exports.createMainWindow = createMainWindow;
|
|
38
|
+
exports.focusMainWindow = focusMainWindow;
|
|
1
39
|
/**
|
|
2
40
|
* 主窗口工厂 — preload 路径解析 + dev/prod loadURL + 外部链接走系统浏览器
|
|
3
41
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
42
|
+
const electron_1 = require("electron");
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const logger_1 = require("./logger");
|
|
45
|
+
const config_1 = require("./config");
|
|
46
|
+
const server_1 = require("./server");
|
|
9
47
|
const g = globalThis;
|
|
10
48
|
const __basedir = g.__dirname
|
|
11
49
|
?? (g.__filename ? path.dirname(g.__filename) : process.cwd());
|
|
12
50
|
let mainWindow = null;
|
|
13
|
-
|
|
51
|
+
function getMainWindow() {
|
|
14
52
|
return mainWindow;
|
|
15
53
|
}
|
|
16
|
-
|
|
17
|
-
log('创建主窗口...');
|
|
18
|
-
mainWindow = new BrowserWindow({
|
|
19
|
-
width: MAIN_WINDOW_DEFAULT.width,
|
|
20
|
-
height: MAIN_WINDOW_DEFAULT.height,
|
|
21
|
-
minWidth: MAIN_WINDOW_MIN.width,
|
|
22
|
-
minHeight: MAIN_WINDOW_MIN.height,
|
|
54
|
+
async function createMainWindow() {
|
|
55
|
+
(0, logger_1.log)('创建主窗口...');
|
|
56
|
+
mainWindow = new electron_1.BrowserWindow({
|
|
57
|
+
width: config_1.MAIN_WINDOW_DEFAULT.width,
|
|
58
|
+
height: config_1.MAIN_WINDOW_DEFAULT.height,
|
|
59
|
+
minWidth: config_1.MAIN_WINDOW_MIN.width,
|
|
60
|
+
minHeight: config_1.MAIN_WINDOW_MIN.height,
|
|
23
61
|
title: 'Bolloon Agent',
|
|
24
62
|
webPreferences: {
|
|
25
63
|
nodeIntegration: false,
|
|
@@ -29,40 +67,40 @@ export async function createMainWindow() {
|
|
|
29
67
|
},
|
|
30
68
|
show: false,
|
|
31
69
|
});
|
|
32
|
-
if (isDev) {
|
|
70
|
+
if (config_1.isDev) {
|
|
33
71
|
// dev:web 用 tsx 起 server, 端口固定 preferredPort, 不会 EADDRINUSE 自增
|
|
34
|
-
const port = preferredPort();
|
|
72
|
+
const port = (0, config_1.preferredPort)();
|
|
35
73
|
mainWindow.loadURL(`http://localhost:${port}`);
|
|
36
74
|
mainWindow.webContents.openDevTools();
|
|
37
75
|
}
|
|
38
76
|
else {
|
|
39
77
|
try {
|
|
40
|
-
log('启动内置 Web 服务器...');
|
|
41
|
-
const { port: actualPort } = await startWebServer(preferredPort());
|
|
78
|
+
(0, logger_1.log)('启动内置 Web 服务器...');
|
|
79
|
+
const { port: actualPort } = await (0, server_1.startWebServer)((0, config_1.preferredPort)());
|
|
42
80
|
mainWindow.loadURL(`http://localhost:${actualPort}`);
|
|
43
81
|
}
|
|
44
82
|
catch (err) {
|
|
45
|
-
log(`启动服务器失败: ${err.message}`, 'error');
|
|
83
|
+
(0, logger_1.log)(`启动服务器失败: ${err.message}`, 'error');
|
|
46
84
|
console.error('启动服务器失败:', err);
|
|
47
85
|
}
|
|
48
86
|
}
|
|
49
87
|
mainWindow.once('ready-to-show', () => {
|
|
50
88
|
mainWindow?.show();
|
|
51
|
-
log('窗口已显示');
|
|
89
|
+
(0, logger_1.log)('窗口已显示');
|
|
52
90
|
});
|
|
53
91
|
// 外部链接走系统浏览器, 不在 app 内开新窗口
|
|
54
92
|
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
|
55
93
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
56
|
-
shell.openExternal(url);
|
|
94
|
+
electron_1.shell.openExternal(url);
|
|
57
95
|
}
|
|
58
96
|
return { action: 'deny' };
|
|
59
97
|
});
|
|
60
98
|
mainWindow.on('closed', () => {
|
|
61
99
|
mainWindow = null;
|
|
62
100
|
});
|
|
63
|
-
log('窗口创建完成');
|
|
101
|
+
(0, logger_1.log)('窗口创建完成');
|
|
64
102
|
}
|
|
65
|
-
|
|
103
|
+
function focusMainWindow() {
|
|
66
104
|
if (!mainWindow)
|
|
67
105
|
return;
|
|
68
106
|
if (mainWindow.isMinimized())
|
|
@@ -70,3 +108,4 @@ export function focusMainWindow() {
|
|
|
70
108
|
mainWindow.show();
|
|
71
109
|
mainWindow.focus();
|
|
72
110
|
}
|
|
111
|
+
//# sourceMappingURL=window.js.map
|
package/dist/electron-preload.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
/**
|
|
2
4
|
* Electron Preload 脚本
|
|
3
5
|
* 在渲染进程和主进程之间建立安全的通信桥梁
|
|
4
6
|
* contextIsolation: true, nodeIntegration: false — 只能通过这里暴露的 API 触达主进程
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
contextBridge.exposeInMainWorld('electronAPI', {
|
|
8
|
+
const electron_1 = require("electron");
|
|
9
|
+
electron_1.contextBridge.exposeInMainWorld('electronAPI', {
|
|
8
10
|
// === 原有 (保留) ===
|
|
9
|
-
getVersion: () => ipcRenderer.invoke('get-version'),
|
|
10
|
-
getUserDataPath: () => ipcRenderer.invoke('get-user-data-path'),
|
|
11
|
-
openExternal: (url) => ipcRenderer.invoke('open-external', url),
|
|
11
|
+
getVersion: () => electron_1.ipcRenderer.invoke('get-version'),
|
|
12
|
+
getUserDataPath: () => electron_1.ipcRenderer.invoke('get-user-data-path'),
|
|
13
|
+
openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url),
|
|
12
14
|
// === 新增: 数据目录 ===
|
|
13
|
-
getDataPath: () => ipcRenderer.invoke('get-data-path'),
|
|
15
|
+
getDataPath: () => electron_1.ipcRenderer.invoke('get-data-path'),
|
|
14
16
|
// === 新增: 文件 dialog ===
|
|
15
|
-
openFile: (opts) => ipcRenderer.invoke('dialog:open-file', opts),
|
|
16
|
-
saveFile: (opts) => ipcRenderer.invoke('dialog:save-file', opts),
|
|
17
|
-
openDirectory: (opts) => ipcRenderer.invoke('dialog:open-directory', opts),
|
|
17
|
+
openFile: (opts) => electron_1.ipcRenderer.invoke('dialog:open-file', opts),
|
|
18
|
+
saveFile: (opts) => electron_1.ipcRenderer.invoke('dialog:save-file', opts),
|
|
19
|
+
openDirectory: (opts) => electron_1.ipcRenderer.invoke('dialog:open-directory', opts),
|
|
18
20
|
// === 新增: 文件系统 (限大小, 主进程守卫) ===
|
|
19
|
-
readTextFile: (opts) => ipcRenderer.invoke('fs:read-text-file', opts),
|
|
20
|
-
writeTextFile: (opts) => ipcRenderer.invoke('fs:write-text-file', opts),
|
|
21
|
-
pathExists: (opts) => ipcRenderer.invoke('fs:path-exists', opts),
|
|
21
|
+
readTextFile: (opts) => electron_1.ipcRenderer.invoke('fs:read-text-file', opts),
|
|
22
|
+
writeTextFile: (opts) => electron_1.ipcRenderer.invoke('fs:write-text-file', opts),
|
|
23
|
+
pathExists: (opts) => electron_1.ipcRenderer.invoke('fs:path-exists', opts),
|
|
22
24
|
// === 新增: 首启引导 ===
|
|
23
|
-
getFirstRunSeen: () => ipcRenderer.invoke('first-run:seen'),
|
|
24
|
-
markFirstRunSeen: () => ipcRenderer.invoke('first-run:mark-seen'),
|
|
25
|
-
getDataPathSync: () => ipcRenderer.invoke('first-run:data-dir'),
|
|
26
|
-
getLogsPathSync: () => ipcRenderer.invoke('first-run:logs-dir'),
|
|
25
|
+
getFirstRunSeen: () => electron_1.ipcRenderer.invoke('first-run:seen'),
|
|
26
|
+
markFirstRunSeen: () => electron_1.ipcRenderer.invoke('first-run:mark-seen'),
|
|
27
|
+
getDataPathSync: () => electron_1.ipcRenderer.invoke('first-run:data-dir'),
|
|
28
|
+
getLogsPathSync: () => electron_1.ipcRenderer.invoke('first-run:logs-dir'),
|
|
27
29
|
// === 元数据 ===
|
|
28
30
|
platform: process.platform,
|
|
29
31
|
});
|
|
32
|
+
//# sourceMappingURL=electron-preload.js.map
|
package/dist/electron.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
/**
|
|
2
4
|
* Electron 入口 shim — 真正逻辑在 src/electron/main.ts
|
|
3
5
|
* (保留 src/electron.ts 平铺入口, 不动 package.json 的 dist/electron.js 解析)
|
|
4
6
|
*/
|
|
5
|
-
|
|
7
|
+
require("./electron/main");
|
|
8
|
+
//# sourceMappingURL=electron.js.map
|
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, model) {
|
|
556
|
+
async function runToolCommand(tool, args, outputJson, comm, model, prompt) {
|
|
557
557
|
const a = await getAgent();
|
|
558
558
|
const startTime = Date.now();
|
|
559
559
|
let response;
|
|
@@ -1030,56 +1030,25 @@ async function runToolCommand(tool, args, outputJson, comm, model) {
|
|
|
1030
1030
|
}
|
|
1031
1031
|
case 'engine': {
|
|
1032
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
1033
|
const engineId = args[0];
|
|
1053
1034
|
if (!engineId) {
|
|
1054
1035
|
response = '用法: --engine <engine-id> [--model <model>] <prompt>\n可用引擎: opencode, codex, claude-code, hermes';
|
|
1055
1036
|
error = response;
|
|
1056
1037
|
break;
|
|
1057
1038
|
}
|
|
1058
|
-
|
|
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, {
|
|
1039
|
+
const result = await delegateToEngine(engineId, prompt || '', {
|
|
1067
1040
|
...(model ? { model } : {}),
|
|
1068
1041
|
});
|
|
1069
1042
|
const elapsed = Date.now() - startTime;
|
|
1070
|
-
if (
|
|
1071
|
-
|
|
1043
|
+
if (result.success) {
|
|
1044
|
+
response = result.output || '(无输出)';
|
|
1072
1045
|
}
|
|
1073
1046
|
else {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
else {
|
|
1078
|
-
response = `❌ 委派失败: ${result.error}`;
|
|
1079
|
-
if (result.output)
|
|
1080
|
-
response += `\n[输出]\n${result.output.slice(0, 2000)}`;
|
|
1081
|
-
}
|
|
1047
|
+
response = `❌ 委派失败: ${result.error}`;
|
|
1048
|
+
if (result.output)
|
|
1049
|
+
response += `\n[输出]\n${result.output.slice(0, 2000)}`;
|
|
1082
1050
|
}
|
|
1051
|
+
metadata = { ...metadata, duration: elapsed };
|
|
1083
1052
|
break;
|
|
1084
1053
|
}
|
|
1085
1054
|
case 'context': {
|
|
@@ -1456,7 +1425,7 @@ async function runNonInteractive(args, comm) {
|
|
|
1456
1425
|
outputBuffer += params.join(' ') + '\n';
|
|
1457
1426
|
};
|
|
1458
1427
|
if (tool) {
|
|
1459
|
-
await runToolCommand(tool, toolArgs, false, comm);
|
|
1428
|
+
await runToolCommand(tool, toolArgs, false, comm, args.model, prompt);
|
|
1460
1429
|
}
|
|
1461
1430
|
else if (prompt) {
|
|
1462
1431
|
const a = await getAgent();
|
|
@@ -1496,7 +1465,7 @@ async function runNonInteractive(args, comm) {
|
|
|
1496
1465
|
return;
|
|
1497
1466
|
}
|
|
1498
1467
|
if (tool) {
|
|
1499
|
-
await runToolCommand(tool, toolArgs, !!json, comm);
|
|
1468
|
+
await runToolCommand(tool, toolArgs, !!json, comm, args.model, prompt);
|
|
1500
1469
|
}
|
|
1501
1470
|
else if (prompt) {
|
|
1502
1471
|
const startTime = Date.now();
|
|
@@ -1634,6 +1603,7 @@ function parseArgs() {
|
|
|
1634
1603
|
case '-e':
|
|
1635
1604
|
result.engine = args[++i];
|
|
1636
1605
|
result.tool = 'engine';
|
|
1606
|
+
result.toolArgs = [result.engine];
|
|
1637
1607
|
break;
|
|
1638
1608
|
case '--context':
|
|
1639
1609
|
result.context = true;
|
|
@@ -1784,6 +1754,7 @@ function parseArgs() {
|
|
|
1784
1754
|
result.tui = true;
|
|
1785
1755
|
break;
|
|
1786
1756
|
case '--model':
|
|
1757
|
+
case '-m':
|
|
1787
1758
|
result.model = args[++i];
|
|
1788
1759
|
break;
|
|
1789
1760
|
case '--output':
|
|
@@ -1869,9 +1840,9 @@ function printHelp() {
|
|
|
1869
1840
|
# 跨机 agent 协作 (对方 bolloon --web 起着才能处理, 走 P2P 不经 GitHub)
|
|
1870
1841
|
--collab <peer|publicKey> "<任务描述>" 派任务给对端 LLM 干活, 等回结果 (90s 超时)
|
|
1871
1842
|
|
|
1872
|
-
#
|
|
1873
|
-
--
|
|
1874
|
-
--model <name>
|
|
1843
|
+
# 外部编码智能体委派
|
|
1844
|
+
--engine, -e <id> [--model <m>] <prompt> 委派任务给外部引擎,如 opencode/codex
|
|
1845
|
+
--model <name> 指定委派时使用的模型
|
|
1875
1846
|
|
|
1876
1847
|
# 输出控制
|
|
1877
1848
|
--json, -j 输出 JSON 格式
|
|
@@ -1898,6 +1869,9 @@ function printHelp() {
|
|
|
1898
1869
|
# 交互模式
|
|
1899
1870
|
npx tsx src/index.ts
|
|
1900
1871
|
|
|
1872
|
+
# 外部引擎委派
|
|
1873
|
+
npx tsx src/index.ts --engine opencode --model opencode/deepseek-v4-flash-free "说你好"
|
|
1874
|
+
|
|
1901
1875
|
# Web 模式
|
|
1902
1876
|
npx tsx src/index.ts --web
|
|
1903
1877
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* npm 自动更新检查器
|
|
3
4
|
*
|
|
@@ -13,11 +14,48 @@
|
|
|
13
14
|
* 开发态下若 cwd 的 package.json 就是本包则回退到 cwd,不受任意工作目录影响。
|
|
14
15
|
* - 检查频率受节流缓存约束(默认 24h 一次),不会每次启动都打 npm。
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
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"));
|
|
21
59
|
// ANSI 颜色
|
|
22
60
|
const RESET = '\x1b[0m';
|
|
23
61
|
const BOLD = '\x1b[1m';
|
|
@@ -75,7 +113,7 @@ function getGlobalBolloonDir() {
|
|
|
75
113
|
const candidates = [];
|
|
76
114
|
// 1. npm root -g(最可靠)
|
|
77
115
|
try {
|
|
78
|
-
const npmRoot = execSync('npm root -g', { encoding: 'utf-8', timeout: 8000 }).trim();
|
|
116
|
+
const npmRoot = (0, child_process_1.execSync)('npm root -g', { encoding: 'utf-8', timeout: 8000 }).trim();
|
|
79
117
|
if (npmRoot)
|
|
80
118
|
candidates.push(path.join(npmRoot, '@bolloon', 'bolloon-agent'));
|
|
81
119
|
}
|
|
@@ -84,7 +122,7 @@ function getGlobalBolloonDir() {
|
|
|
84
122
|
}
|
|
85
123
|
// 2. npm prefix -g
|
|
86
124
|
try {
|
|
87
|
-
const npmPrefix = execSync('npm prefix -g', { encoding: 'utf-8', timeout: 8000 }).trim();
|
|
125
|
+
const npmPrefix = (0, child_process_1.execSync)('npm prefix -g', { encoding: 'utf-8', timeout: 8000 }).trim();
|
|
88
126
|
if (npmPrefix)
|
|
89
127
|
candidates.push(path.join(npmPrefix, 'lib', 'node_modules', '@bolloon', 'bolloon-agent'));
|
|
90
128
|
}
|
|
@@ -242,7 +280,7 @@ async function checkBolloonUpdates() {
|
|
|
242
280
|
*/
|
|
243
281
|
function checkNpmOutdated() {
|
|
244
282
|
try {
|
|
245
|
-
const output = execSync('npm outdated --json', {
|
|
283
|
+
const output = (0, child_process_1.execSync)('npm outdated --json', {
|
|
246
284
|
encoding: 'utf-8',
|
|
247
285
|
timeout: 30000,
|
|
248
286
|
maxBuffer: 10 * 1024 * 1024,
|
|
@@ -306,7 +344,7 @@ async function updatePackagesWithVersion(packagesWithVersion) {
|
|
|
306
344
|
const args = ['npm', 'install', '-g', ...packagesWithVersion];
|
|
307
345
|
notify(`\n${CYAN}📦 正在更新包...${RESET}\n`, RESET);
|
|
308
346
|
try {
|
|
309
|
-
execSync(args.join(' '), {
|
|
347
|
+
(0, child_process_1.execSync)(args.join(' '), {
|
|
310
348
|
encoding: 'utf-8',
|
|
311
349
|
timeout: 300000,
|
|
312
350
|
stdio: 'inherit',
|
|
@@ -424,7 +462,7 @@ function resolveAutoUpdatePolicy() {
|
|
|
424
462
|
* 例如 Electron 用 app.relaunch(),Node 用 detached 重新 spawn)。
|
|
425
463
|
* 若未提供或 autoRestart=false,则仅提示用户手动重启。
|
|
426
464
|
*/
|
|
427
|
-
|
|
465
|
+
async function checkAndUpdate(opts = {}) {
|
|
428
466
|
const policy = resolveAutoUpdatePolicy();
|
|
429
467
|
if (policy.blocked) {
|
|
430
468
|
return { hasUpdate: false, info: null, updated: false, message: '跳过更新检查(已显式禁用)' };
|
|
@@ -528,13 +566,13 @@ export async function checkAndUpdate(opts = {}) {
|
|
|
528
566
|
/**
|
|
529
567
|
* 仅检查更新,不自动安装
|
|
530
568
|
*/
|
|
531
|
-
|
|
569
|
+
async function checkForUpdates() {
|
|
532
570
|
return await checkBolloonUpdates();
|
|
533
571
|
}
|
|
534
572
|
/**
|
|
535
573
|
* 手动触发更新
|
|
536
574
|
*/
|
|
537
|
-
|
|
575
|
+
async function performUpdate(packages) {
|
|
538
576
|
return await updatePackages(packages);
|
|
539
577
|
}
|
|
540
578
|
// CLI 入口
|
|
@@ -557,3 +595,4 @@ if (process.argv[1]?.includes('auto-update')) {
|
|
|
557
595
|
}
|
|
558
596
|
})();
|
|
559
597
|
}
|
|
598
|
+
//# sourceMappingURL=auto-update.js.map
|