@bolloon/bolloon-agent 0.3.22 → 0.3.23
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/deny-pipeline.js +116 -0
- package/dist/agents/parse-tool-call.js +26 -4
- package/dist/agents/pi-sdk.js +247 -50
- package/dist/agents/session-store.js +87 -2
- package/dist/bootstrap/snip-collapse.js +135 -0
- package/dist/cli/loading-tui.js +64 -10
- 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/external-engines/delegate.js +19 -0
- package/dist/hooks/hooks-engine.js +329 -0
- package/dist/index.js +41 -23
- package/dist/llm/pi-ai.js +5 -17
- package/dist/security/tool-gate.js +8 -1
- package/dist/social/dunbar-tier.js +409 -0
- package/dist/utils/auto-update.js +51 -12
- package/dist/web/client.js +4833 -4328
- package/dist/web/components/p2p/index.js +234 -276
- package/dist/web/server.js +17 -3
- package/dist/web/style.css +2 -2
- package/dist/web/ui/message-renderer.js +396 -535
- package/dist/web/ui/step-timeline.js +273 -372
- package/package.json +24 -24
- 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/logger.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
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.log = log;
|
|
1
37
|
/**
|
|
2
38
|
* 简单 logger: 写日志到 <userData>/logs/bolloon.log, size-based 轮转
|
|
3
39
|
* (5MB 上限, 保留 .1 .2 .3 共 3 个备份 → ~20MB 上限)
|
|
@@ -5,8 +41,8 @@
|
|
|
5
41
|
* 同步写是因为 Electron 主进程日志量小, 同步 append 简单可靠, 不丢日志.
|
|
6
42
|
* 量大的会话级 jsonl 走自己路径 (lifecycle-hooks 等), 跟本 logger 无关.
|
|
7
43
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const paths_1 = require("./paths");
|
|
10
46
|
const MAX_BYTES = 5 * 1024 * 1024;
|
|
11
47
|
const MAX_BACKUPS = 3; // 保留 bolloon.log.1 .2 .3
|
|
12
48
|
let currentSize = 0;
|
|
@@ -16,9 +52,9 @@ function ensureLogFile() {
|
|
|
16
52
|
return;
|
|
17
53
|
initialized = true;
|
|
18
54
|
try {
|
|
19
|
-
fs.mkdirSync(logsDir(), { recursive: true });
|
|
55
|
+
fs.mkdirSync((0, paths_1.logsDir)(), { recursive: true });
|
|
20
56
|
try {
|
|
21
|
-
currentSize = fs.statSync(mainLogPath()).size;
|
|
57
|
+
currentSize = fs.statSync((0, paths_1.mainLogPath)()).size;
|
|
22
58
|
}
|
|
23
59
|
catch {
|
|
24
60
|
currentSize = 0;
|
|
@@ -31,7 +67,7 @@ function ensureLogFile() {
|
|
|
31
67
|
}
|
|
32
68
|
}
|
|
33
69
|
function rotate() {
|
|
34
|
-
const logPath = mainLogPath();
|
|
70
|
+
const logPath = (0, paths_1.mainLogPath)();
|
|
35
71
|
for (let i = MAX_BACKUPS; i >= 1; i--) {
|
|
36
72
|
const src = `${logPath}.${i}`;
|
|
37
73
|
const dst = `${logPath}.${i + 1}`;
|
|
@@ -54,14 +90,14 @@ function rotate() {
|
|
|
54
90
|
catch { /* missing ok */ }
|
|
55
91
|
currentSize = 0;
|
|
56
92
|
}
|
|
57
|
-
|
|
93
|
+
function log(message, level = 'info') {
|
|
58
94
|
ensureLogFile();
|
|
59
95
|
const ts = new Date().toISOString();
|
|
60
96
|
const line = `[${ts}] [${level}] ${message}\n`;
|
|
61
97
|
if (currentSize + line.length > MAX_BYTES)
|
|
62
98
|
rotate();
|
|
63
99
|
try {
|
|
64
|
-
fs.appendFileSync(mainLogPath(), line);
|
|
100
|
+
fs.appendFileSync((0, paths_1.mainLogPath)(), line);
|
|
65
101
|
currentSize += line.length;
|
|
66
102
|
}
|
|
67
103
|
catch (err) {
|
|
@@ -75,3 +111,4 @@ export function log(message, level = 'info') {
|
|
|
75
111
|
else
|
|
76
112
|
console.log(line.trimEnd());
|
|
77
113
|
}
|
|
114
|
+
//# sourceMappingURL=logger.js.map
|
package/dist/electron/main.js
CHANGED
|
@@ -1,43 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
/**
|
|
2
4
|
* Electron 主进程 lifecycle 入口
|
|
3
5
|
* 单实例锁 → whenReady → createMainWindow → cleanup on quit
|
|
4
6
|
* 启动时: 装 menu / tray / IPC handlers / 首启引导
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
log('Bolloon Electron 启动');
|
|
8
|
+
const electron_1 = require("electron");
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
|
+
const window_1 = require("./window");
|
|
11
|
+
const server_1 = require("./server");
|
|
12
|
+
const menu_1 = require("./menu");
|
|
13
|
+
const tray_1 = require("./tray");
|
|
14
|
+
const ipc_1 = require("./ipc");
|
|
15
|
+
const dialogs_1 = require("./dialogs");
|
|
16
|
+
const first_run_1 = require("./first-run");
|
|
17
|
+
const auto_update_js_1 = require("../utils/auto-update.js");
|
|
18
|
+
(0, logger_1.log)('Bolloon Electron 启动');
|
|
17
19
|
// 单实例锁
|
|
18
|
-
const gotTheLock = app.requestSingleInstanceLock();
|
|
20
|
+
const gotTheLock = electron_1.app.requestSingleInstanceLock();
|
|
19
21
|
if (!gotTheLock) {
|
|
20
|
-
log('已有实例在运行,退出');
|
|
21
|
-
app.quit();
|
|
22
|
+
(0, logger_1.log)('已有实例在运行,退出');
|
|
23
|
+
electron_1.app.quit();
|
|
22
24
|
}
|
|
23
|
-
app.on('second-instance', () => {
|
|
24
|
-
focusMainWindow();
|
|
25
|
+
electron_1.app.on('second-instance', () => {
|
|
26
|
+
(0, window_1.focusMainWindow)();
|
|
25
27
|
});
|
|
26
|
-
app.whenReady().then(async () => {
|
|
27
|
-
log('Electron 准备好');
|
|
28
|
-
registerCoreIpc();
|
|
29
|
-
registerDialogIpc();
|
|
30
|
-
registerFirstRunIpc();
|
|
31
|
-
installAppMenu(getMainWindow);
|
|
32
|
-
createTray(getMainWindow);
|
|
28
|
+
electron_1.app.whenReady().then(async () => {
|
|
29
|
+
(0, logger_1.log)('Electron 准备好');
|
|
30
|
+
(0, ipc_1.registerCoreIpc)();
|
|
31
|
+
(0, dialogs_1.registerDialogIpc)();
|
|
32
|
+
(0, first_run_1.registerFirstRunIpc)();
|
|
33
|
+
(0, menu_1.installAppMenu)(window_1.getMainWindow);
|
|
34
|
+
(0, tray_1.createTray)(window_1.getMainWindow);
|
|
33
35
|
// 启动自动更新检查(后台,不阻塞 UI)。
|
|
34
36
|
// 安装成功后用 app.relaunch() 自动重启以应用新版本(避免单实例锁冲突)。
|
|
35
37
|
void (async () => {
|
|
36
38
|
try {
|
|
37
|
-
await checkAndUpdate({
|
|
39
|
+
await (0, auto_update_js_1.checkAndUpdate)({
|
|
38
40
|
onUpdated: () => {
|
|
39
|
-
app.relaunch();
|
|
40
|
-
app.exit(0);
|
|
41
|
+
electron_1.app.relaunch();
|
|
42
|
+
electron_1.app.exit(0);
|
|
41
43
|
},
|
|
42
44
|
});
|
|
43
45
|
}
|
|
@@ -45,32 +47,33 @@ app.whenReady().then(async () => {
|
|
|
45
47
|
// 自动更新失败不影响主程序
|
|
46
48
|
}
|
|
47
49
|
})();
|
|
48
|
-
await createMainWindow();
|
|
50
|
+
await (0, window_1.createMainWindow)();
|
|
49
51
|
// 首启引导 (在主窗口就绪后弹, 不阻塞 UI)
|
|
50
|
-
const win = getMainWindow();
|
|
52
|
+
const win = (0, window_1.getMainWindow)();
|
|
51
53
|
if (win) {
|
|
52
54
|
win.webContents.once('did-finish-load', () => {
|
|
53
|
-
void maybeShowFirstRun(win);
|
|
55
|
+
void (0, first_run_1.maybeShowFirstRun)(win);
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
|
-
app.on('activate', async () => {
|
|
58
|
+
electron_1.app.on('activate', async () => {
|
|
57
59
|
// macOS: dock 图标被点击且没有窗口时, 重开
|
|
58
|
-
if (BrowserWindow.getAllWindows().length === 0) {
|
|
59
|
-
await createMainWindow();
|
|
60
|
+
if (electron_1.BrowserWindow.getAllWindows().length === 0) {
|
|
61
|
+
await (0, window_1.createMainWindow)();
|
|
60
62
|
}
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
|
-
app.on('window-all-closed', () => {
|
|
64
|
-
log('所有窗口已关闭');
|
|
65
|
-
destroyTray();
|
|
66
|
-
killWebServer();
|
|
65
|
+
electron_1.app.on('window-all-closed', () => {
|
|
66
|
+
(0, logger_1.log)('所有窗口已关闭');
|
|
67
|
+
(0, tray_1.destroyTray)();
|
|
68
|
+
(0, server_1.killWebServer)();
|
|
67
69
|
if (process.platform !== 'darwin') {
|
|
68
|
-
app.quit();
|
|
70
|
+
electron_1.app.quit();
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
|
-
app.on('before-quit', () => {
|
|
72
|
-
log('应用即将退出');
|
|
73
|
-
destroyTray();
|
|
74
|
-
killWebServer();
|
|
73
|
+
electron_1.app.on('before-quit', () => {
|
|
74
|
+
(0, logger_1.log)('应用即将退出');
|
|
75
|
+
(0, tray_1.destroyTray)();
|
|
76
|
+
(0, server_1.killWebServer)();
|
|
75
77
|
});
|
|
76
|
-
log('主进程初始化完成');
|
|
78
|
+
(0, logger_1.log)('主进程初始化完成');
|
|
79
|
+
//# sourceMappingURL=main.js.map
|
package/dist/electron/menu.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAppMenu = buildAppMenu;
|
|
4
|
+
exports.installAppMenu = installAppMenu;
|
|
1
5
|
/**
|
|
2
6
|
* 应用菜单 — macOS 标准 + File/Edit/View/Window/Help 自定义项
|
|
3
7
|
* "Open Data Folder" 等会跨平台显示 (mac 也会出现, 不会冲突)
|
|
4
8
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
const electron_1 = require("electron");
|
|
10
|
+
const paths_1 = require("./paths");
|
|
11
|
+
const logger_1 = require("./logger");
|
|
8
12
|
function openDataFolder() {
|
|
9
|
-
shell.openPath(dataDir()).catch((e) => log(`open data folder 失败: ${e.message}`, 'error'));
|
|
13
|
+
electron_1.shell.openPath((0, paths_1.dataDir)()).catch((e) => (0, logger_1.log)(`open data folder 失败: ${e.message}`, 'error'));
|
|
10
14
|
}
|
|
11
15
|
function openLogsFolder() {
|
|
12
|
-
shell.openPath(logsDir()).catch((e) => log(`open logs folder 失败: ${e.message}`, 'error'));
|
|
16
|
+
electron_1.shell.openPath((0, paths_1.logsDir)()).catch((e) => (0, logger_1.log)(`open logs folder 失败: ${e.message}`, 'error'));
|
|
13
17
|
}
|
|
14
18
|
function openExternal(url) {
|
|
15
|
-
shell.openExternal(url).catch((e) => log(`openExternal 失败: ${e.message}`, 'error'));
|
|
19
|
+
electron_1.shell.openExternal(url).catch((e) => (0, logger_1.log)(`openExternal 失败: ${e.message}`, 'error'));
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
function buildAppMenu(getMainWindow) {
|
|
18
22
|
const isMac = process.platform === 'darwin';
|
|
19
23
|
const win = getMainWindow();
|
|
20
24
|
const appMenu = {
|
|
21
|
-
label: app.getName(),
|
|
25
|
+
label: electron_1.app.getName(),
|
|
22
26
|
submenu: [
|
|
23
27
|
{ role: 'about' },
|
|
24
28
|
{ type: 'separator' },
|
|
@@ -117,8 +121,8 @@ export function buildAppMenu(getMainWindow) {
|
|
|
117
121
|
dialog.showMessageBox({
|
|
118
122
|
type: 'info',
|
|
119
123
|
title: 'About Bolloon Agent',
|
|
120
|
-
message: `Bolloon Agent v${app.getVersion()}`,
|
|
121
|
-
detail: `P2P AI Document Agent\nData: ${dataDir()}\nLogs: ${logsDir()}`,
|
|
124
|
+
message: `Bolloon Agent v${electron_1.app.getVersion()}`,
|
|
125
|
+
detail: `P2P AI Document Agent\nData: ${(0, paths_1.dataDir)()}\nLogs: ${(0, paths_1.logsDir)()}`,
|
|
122
126
|
buttons: ['OK'],
|
|
123
127
|
}).catch(() => { });
|
|
124
128
|
},
|
|
@@ -133,8 +137,9 @@ export function buildAppMenu(getMainWindow) {
|
|
|
133
137
|
windowMenu,
|
|
134
138
|
helpMenu,
|
|
135
139
|
];
|
|
136
|
-
return Menu.buildFromTemplate(template);
|
|
140
|
+
return electron_1.Menu.buildFromTemplate(template);
|
|
137
141
|
}
|
|
138
|
-
|
|
139
|
-
Menu.setApplicationMenu(buildAppMenu(getMainWindow));
|
|
142
|
+
function installAppMenu(getMainWindow) {
|
|
143
|
+
electron_1.Menu.setApplicationMenu(buildAppMenu(getMainWindow));
|
|
140
144
|
}
|
|
145
|
+
//# sourceMappingURL=menu.js.map
|
package/dist/electron/paths.js
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
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.dataDir = dataDir;
|
|
37
|
+
exports.userDataDir = userDataDir;
|
|
38
|
+
exports.logsDir = logsDir;
|
|
39
|
+
exports.mainLogPath = mainLogPath;
|
|
40
|
+
exports.firstRunFlagPath = firstRunFlagPath;
|
|
41
|
+
exports.buildResourcesDir = buildResourcesDir;
|
|
1
42
|
/**
|
|
2
43
|
* 路径常量 — 单一来源, 避免散落各处
|
|
3
44
|
*
|
|
@@ -6,28 +47,29 @@
|
|
|
6
47
|
* userDataDir: Electron 的 app.getPath('userData'), 用来放日志 / 临时 / 锁文件
|
|
7
48
|
* logsDir: userData 下的 logs/ 子目录
|
|
8
49
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
50
|
+
const electron_1 = require("electron");
|
|
51
|
+
const os = __importStar(require("os"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
function dataDir() {
|
|
13
54
|
return path.join(os.homedir(), '.bolloon');
|
|
14
55
|
}
|
|
15
|
-
|
|
16
|
-
return app.getPath('userData');
|
|
56
|
+
function userDataDir() {
|
|
57
|
+
return electron_1.app.getPath('userData');
|
|
17
58
|
}
|
|
18
|
-
|
|
59
|
+
function logsDir() {
|
|
19
60
|
return path.join(userDataDir(), 'logs');
|
|
20
61
|
}
|
|
21
|
-
|
|
62
|
+
function mainLogPath() {
|
|
22
63
|
return path.join(logsDir(), 'bolloon.log');
|
|
23
64
|
}
|
|
24
|
-
|
|
65
|
+
function firstRunFlagPath() {
|
|
25
66
|
return path.join(userDataDir(), '.bolloon-first-run-seen');
|
|
26
67
|
}
|
|
27
68
|
/** 资源目录: packaged 下是 process.resourcesPath/build, dev 下是 repo/build/ */
|
|
28
|
-
|
|
29
|
-
if (app.isPackaged) {
|
|
69
|
+
function buildResourcesDir() {
|
|
70
|
+
if (electron_1.app.isPackaged) {
|
|
30
71
|
return path.join(process.resourcesPath, 'build');
|
|
31
72
|
}
|
|
32
|
-
return path.join(app.getAppPath(), 'build');
|
|
73
|
+
return path.join(electron_1.app.getAppPath(), 'build');
|
|
33
74
|
}
|
|
75
|
+
//# sourceMappingURL=paths.js.map
|
package/dist/electron/server.js
CHANGED
|
@@ -1,13 +1,51 @@
|
|
|
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.getWebServerProcess = getWebServerProcess;
|
|
37
|
+
exports.killWebServer = killWebServer;
|
|
38
|
+
exports.startWebServer = startWebServer;
|
|
1
39
|
/**
|
|
2
40
|
* Spawns dist/web/server.js as a child Node process (via Electron's
|
|
3
41
|
* ELECTRON_RUN_AS_NODE=1) and parses BOLLOON_PORT=NNNN to learn the
|
|
4
42
|
* actually-bound port (which may have drifted from the preferred port
|
|
5
43
|
* due to EADDRINUSE auto-bump).
|
|
6
44
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const logger_1 = require("./logger");
|
|
48
|
+
const config_1 = require("./config");
|
|
11
49
|
// Resolve to the directory holding this file. See src/electron/window.ts for the rationale;
|
|
12
50
|
// this avoids the same `import.meta` / `__dirname` redeclaration conflicts that broke
|
|
13
51
|
// the electron tsconfig when esnext module mode was set.
|
|
@@ -15,30 +53,30 @@ const g = globalThis;
|
|
|
15
53
|
const __basedir = g.__dirname
|
|
16
54
|
?? (g.__filename ? path.dirname(g.__filename) : process.cwd());
|
|
17
55
|
let webServerProcess = null;
|
|
18
|
-
|
|
56
|
+
function getWebServerProcess() {
|
|
19
57
|
return webServerProcess;
|
|
20
58
|
}
|
|
21
|
-
|
|
59
|
+
function killWebServer() {
|
|
22
60
|
if (webServerProcess && !webServerProcess.killed) {
|
|
23
|
-
log('终止 Web 服务器进程');
|
|
61
|
+
(0, logger_1.log)('终止 Web 服务器进程');
|
|
24
62
|
webServerProcess.kill();
|
|
25
63
|
}
|
|
26
64
|
webServerProcess = null;
|
|
27
65
|
}
|
|
28
|
-
|
|
66
|
+
function startWebServer(preferredPort) {
|
|
29
67
|
return new Promise((resolve, reject) => {
|
|
30
68
|
const serverScript = path.join(__basedir, '..', 'web', 'server.js');
|
|
31
|
-
log(`启动 Web 服务器进程: ${serverScript}`);
|
|
69
|
+
(0, logger_1.log)(`启动 Web 服务器进程: ${serverScript}`);
|
|
32
70
|
// ELECTRON_RUN_AS_NODE=1 — packaged 时 process.execPath 是 Electron 二进制,
|
|
33
71
|
// 没这行 require() 会失败. Dev 模式 (electron dist/electron.js) 同样情况.
|
|
34
|
-
webServerProcess = spawn(process.execPath, [serverScript], {
|
|
72
|
+
webServerProcess = (0, child_process_1.spawn)(process.execPath, [serverScript], {
|
|
35
73
|
env: {
|
|
36
74
|
...process.env,
|
|
37
75
|
ELECTRON_RUN_AS_NODE: '1',
|
|
38
76
|
NODE_ENV: 'production',
|
|
39
77
|
PORT: String(preferredPort),
|
|
40
78
|
ELECTRON_PORT: String(preferredPort),
|
|
41
|
-
BOLLOON_HOST: DEFAULT_HOST,
|
|
79
|
+
BOLLOON_HOST: config_1.DEFAULT_HOST,
|
|
42
80
|
},
|
|
43
81
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
44
82
|
});
|
|
@@ -50,31 +88,32 @@ export function startWebServer(preferredPort) {
|
|
|
50
88
|
const m = stdoutBuf.match(/^BOLLOON_PORT=(\d+)/m);
|
|
51
89
|
if (m) {
|
|
52
90
|
const actualPort = parseInt(m[1], 10);
|
|
53
|
-
log(`Web 服务器就绪: 实际端口=${actualPort} (preferred=${preferredPort})`);
|
|
91
|
+
(0, logger_1.log)(`Web 服务器就绪: 实际端口=${actualPort} (preferred=${preferredPort})`);
|
|
54
92
|
resolve({ port: actualPort });
|
|
55
93
|
}
|
|
56
94
|
});
|
|
57
95
|
webServerProcess.stderr?.on('data', (data) => {
|
|
58
96
|
stderrData += data.toString();
|
|
59
97
|
process.stderr.write(`[WebServer ERR] ${data}`);
|
|
60
|
-
log(`[WebServer stderr] ${data.toString().trim()}`, 'warn');
|
|
98
|
+
(0, logger_1.log)(`[WebServer stderr] ${data.toString().trim()}`, 'warn');
|
|
61
99
|
});
|
|
62
100
|
webServerProcess.on('error', (err) => {
|
|
63
|
-
log(`Web 服务器启动失败: ${err.message}`, 'error');
|
|
101
|
+
(0, logger_1.log)(`Web 服务器启动失败: ${err.message}`, 'error');
|
|
64
102
|
reject(err);
|
|
65
103
|
});
|
|
66
104
|
webServerProcess.on('exit', (code, signal) => {
|
|
67
|
-
log(`Web 服务器退出: code=${code} signal=${signal}`);
|
|
105
|
+
(0, logger_1.log)(`Web 服务器退出: code=${code} signal=${signal}`);
|
|
68
106
|
if (code !== 0 && code !== null) {
|
|
69
|
-
log(`Web 服务器 stderr: ${stderrData.slice(0, 500)}`, 'error');
|
|
107
|
+
(0, logger_1.log)(`Web 服务器 stderr: ${stderrData.slice(0, 500)}`, 'error');
|
|
70
108
|
}
|
|
71
109
|
webServerProcess = null;
|
|
72
110
|
});
|
|
73
111
|
setTimeout(() => {
|
|
74
112
|
if (webServerProcess && !webServerProcess.killed) {
|
|
75
|
-
log(`Web 服务器启动超时 (${WEB_SERVER_STARTUP_TIMEOUT_MS}ms)`, 'error');
|
|
113
|
+
(0, logger_1.log)(`Web 服务器启动超时 (${config_1.WEB_SERVER_STARTUP_TIMEOUT_MS}ms)`, 'error');
|
|
76
114
|
reject(new Error('Web server startup timeout'));
|
|
77
115
|
}
|
|
78
|
-
}, WEB_SERVER_STARTUP_TIMEOUT_MS);
|
|
116
|
+
}, config_1.WEB_SERVER_STARTUP_TIMEOUT_MS);
|
|
79
117
|
});
|
|
80
118
|
}
|
|
119
|
+
//# sourceMappingURL=server.js.map
|
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
|