blockmine 1.23.0 → 1.23.2

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.
Files changed (29) hide show
  1. package/.claude/agents/code-architect.md +34 -0
  2. package/.claude/agents/code-explorer.md +51 -0
  3. package/.claude/agents/code-reviewer.md +46 -0
  4. package/.claude/commands/feature-dev.md +125 -0
  5. package/.claude/settings.json +1 -1
  6. package/.claude/settings.local.json +3 -1
  7. package/.claude/skills/frontend-design/SKILL.md +42 -0
  8. package/CHANGELOG.md +31 -16
  9. package/backend/prisma/migrations/20251116111851_add_execution_trace/migration.sql +22 -22
  10. package/backend/prisma/migrations/20251120154914_add_panel_api_keys/migration.sql +21 -21
  11. package/backend/prisma/migrations/20251121110241_add_proxy_table/migration.sql +45 -45
  12. package/backend/prisma/migrations/migration_lock.toml +2 -2
  13. package/backend/src/api/routes/auth.js +669 -669
  14. package/backend/src/api/routes/bots.js +2451 -2451
  15. package/backend/src/api/routes/panel.js +66 -66
  16. package/backend/src/api/routes/panelApiKeys.js +179 -179
  17. package/backend/src/api/routes/plugins.js +376 -376
  18. package/backend/src/api/routes/system.js +174 -174
  19. package/backend/src/core/EventGraphManager.js +194 -194
  20. package/backend/src/core/GraphExecutionEngine.js +28 -1
  21. package/backend/src/core/node-registries/actions.js +2 -2
  22. package/backend/src/core/nodes/actions/http_request.js +23 -4
  23. package/backend/src/core/nodes/actions/send_message.js +2 -12
  24. package/backend/src/core/nodes/data/string_literal.js +2 -13
  25. package/backend/src/core/services/BotLifecycleService.js +835 -835
  26. package/frontend/dist/assets/{index-B1serztM.js → index-DqzDkFsP.js} +185 -185
  27. package/frontend/dist/index.html +1 -1
  28. package/package.json +2 -1
  29. package/CLAUDE.md +0 -284
@@ -1,174 +1,174 @@
1
- const express = require('express');
2
- const { authenticate, authenticateUniversal } = require('../middleware/auth');
3
- const os = require('os');
4
- const pidusage = require('pidusage');
5
- const rateLimit = require('express-rate-limit');
6
-
7
- const router = express.Router();
8
-
9
-
10
- const serverStartTime = Date.now();
11
-
12
- /**
13
- * Вычисляет системное использование CPU на основе средней загрузки
14
- * Избегает состояния гонки, не используя глобальное состояние
15
- */
16
- function getSystemCpuUsage() {
17
- // Используем среднюю загрузку системы за 1 минуту
18
- const loadAvg = os.loadavg()[0]; // 1-минутное среднее
19
- const cpuCount = os.cpus().length;
20
- // Конвертируем в процент (loadAvg / cpuCount * 100)
21
- const cpuPercentage = Math.round((loadAvg / cpuCount) * 100);
22
- return Math.max(0, Math.min(100, cpuPercentage));
23
- }
24
-
25
- /**
26
- * @route GET /api/system/health
27
- * @desc Получить информацию о здоровье системы
28
- * @access Требуется авторизация
29
- */
30
- router.get('/health', authenticateUniversal, async (req, res) => {
31
- try {
32
- const uptime = process.uptime();
33
- const serverUptime = (Date.now() - serverStartTime) / 1000;
34
-
35
- const totalMemory = os.totalmem();
36
- const freeMemory = os.freemem();
37
- const usedMemory = totalMemory - freeMemory;
38
-
39
- const cpus = os.cpus();
40
-
41
- const systemCpuUsage = getSystemCpuUsage();
42
-
43
- let panelCpu = 0;
44
- let panelMemory = 0;
45
- try {
46
- const stats = await pidusage(process.pid);
47
- panelCpu = parseFloat(stats.cpu.toFixed(1));
48
- panelMemory = parseFloat((stats.memory / 1024 / 1024).toFixed(1)); // MB
49
- } catch (error) {
50
- console.error('Ошибка получения статистики процесса:', error);
51
- }
52
-
53
- const platform = process.platform;
54
- const arch = process.arch;
55
-
56
- const platformName = {
57
- 'win32': 'Windows',
58
- 'linux': 'Linux',
59
- 'darwin': 'macOS',
60
- 'freebsd': 'FreeBSD',
61
- 'openbsd': 'OpenBSD',
62
- 'aix': 'AIX'
63
- }[platform] || platform;
64
-
65
- // Форматируем uptime
66
- const formatUptime = (seconds) => {
67
- const days = Math.floor(seconds / 86400);
68
- const hours = Math.floor((seconds % 86400) / 3600);
69
- const minutes = Math.floor((seconds % 3600) / 60);
70
-
71
- if (days > 0) return `${days}д ${hours}ч`;
72
- if (hours > 0) return `${hours}ч ${minutes}м`;
73
- return `${minutes}м`;
74
- };
75
-
76
- let websocketStatus = true;
77
- let databaseStatus = true;
78
-
79
- try {
80
- const prisma = req.app.get('prisma') || require('../../lib/prisma');
81
- await prisma.$queryRaw`SELECT 1`;
82
- } catch (error) {
83
- databaseStatus = false;
84
- }
85
-
86
- try {
87
- const botManager = req.app.get('botManager');
88
- websocketStatus = botManager !== null && botManager !== undefined;
89
- } catch (error) {
90
- websocketStatus = false;
91
- }
92
-
93
- res.json({
94
- status: 'ok',
95
- uptime: formatUptime(serverUptime),
96
- uptimeSeconds: Math.floor(serverUptime),
97
- processUptime: formatUptime(uptime),
98
- memory: {
99
- total: Math.round(totalMemory / 1024 / 1024), // MB
100
- free: Math.round(freeMemory / 1024 / 1024), // MB
101
- used: Math.round(usedMemory / 1024 / 1024), // MB
102
- usedPercent: Math.round((usedMemory / totalMemory) * 100),
103
- panel: panelMemory // Память используемая панелью
104
- },
105
- cpu: {
106
- cores: cpus.length,
107
- model: cpus[0]?.model || 'Unknown',
108
- usage: systemCpuUsage,
109
- panelUsage: panelCpu,
110
- loadAverage: os.loadavg()
111
- },
112
- platform: platformName,
113
- platformRaw: platform,
114
- arch: arch,
115
- osRelease: os.release(),
116
- hostname: os.hostname(),
117
- nodeVersion: process.version,
118
- services: {
119
- panel: true,
120
- websocket: websocketStatus,
121
- database: databaseStatus
122
- }
123
- });
124
- } catch (error) {
125
- console.error('Error getting system health:', error);
126
- res.status(500).json({
127
- error: 'Failed to get system health',
128
- message: error.message
129
- });
130
- }
131
- });
132
-
133
- /**
134
- * @route GET /api/system/stats
135
- * @desc Получить статистику системы
136
- * @access Требуется авторизация
137
- */
138
- router.get('/stats', authenticateUniversal, async (req, res) => {
139
- try {
140
- const prisma = req.app.get('prisma') || require('../../lib/prisma');
141
-
142
- const totalBots = await prisma.bot.count();
143
- const totalServers = await prisma.server.count();
144
- const totalUsers = await prisma.panelUser.count();
145
-
146
- const botManager = req.app.get('botManager');
147
- let runningBots = 0;
148
-
149
- if (botManager && botManager.bots) {
150
- runningBots = Array.from(botManager.bots.values())
151
- .filter(bot => typeof bot.isRunning === 'function' && bot.isRunning())
152
- .length;
153
- }
154
-
155
- res.json({
156
- bots: {
157
- total: totalBots,
158
- running: runningBots,
159
- stopped: totalBots - runningBots
160
- },
161
- servers: totalServers,
162
- users: totalUsers
163
- });
164
- } catch (error) {
165
- console.error('Error getting system stats:', error);
166
- res.status(500).json({
167
- error: 'Failed to get system stats',
168
- message: error.message
169
- });
170
- }
171
- });
172
-
173
- module.exports = router;
174
-
1
+ const express = require('express');
2
+ const { authenticate, authenticateUniversal } = require('../middleware/auth');
3
+ const os = require('os');
4
+ const pidusage = require('pidusage');
5
+ const rateLimit = require('express-rate-limit');
6
+
7
+ const router = express.Router();
8
+
9
+
10
+ const serverStartTime = Date.now();
11
+
12
+ /**
13
+ * Вычисляет системное использование CPU на основе средней загрузки
14
+ * Избегает состояния гонки, не используя глобальное состояние
15
+ */
16
+ function getSystemCpuUsage() {
17
+ // Используем среднюю загрузку системы за 1 минуту
18
+ const loadAvg = os.loadavg()[0]; // 1-минутное среднее
19
+ const cpuCount = os.cpus().length;
20
+ // Конвертируем в процент (loadAvg / cpuCount * 100)
21
+ const cpuPercentage = Math.round((loadAvg / cpuCount) * 100);
22
+ return Math.max(0, Math.min(100, cpuPercentage));
23
+ }
24
+
25
+ /**
26
+ * @route GET /api/system/health
27
+ * @desc Получить информацию о здоровье системы
28
+ * @access Требуется авторизация
29
+ */
30
+ router.get('/health', authenticateUniversal, async (req, res) => {
31
+ try {
32
+ const uptime = process.uptime();
33
+ const serverUptime = (Date.now() - serverStartTime) / 1000;
34
+
35
+ const totalMemory = os.totalmem();
36
+ const freeMemory = os.freemem();
37
+ const usedMemory = totalMemory - freeMemory;
38
+
39
+ const cpus = os.cpus();
40
+
41
+ const systemCpuUsage = getSystemCpuUsage();
42
+
43
+ let panelCpu = 0;
44
+ let panelMemory = 0;
45
+ try {
46
+ const stats = await pidusage(process.pid);
47
+ panelCpu = parseFloat(stats.cpu.toFixed(1));
48
+ panelMemory = parseFloat((stats.memory / 1024 / 1024).toFixed(1)); // MB
49
+ } catch (error) {
50
+ console.error('Ошибка получения статистики процесса:', error);
51
+ }
52
+
53
+ const platform = process.platform;
54
+ const arch = process.arch;
55
+
56
+ const platformName = {
57
+ 'win32': 'Windows',
58
+ 'linux': 'Linux',
59
+ 'darwin': 'macOS',
60
+ 'freebsd': 'FreeBSD',
61
+ 'openbsd': 'OpenBSD',
62
+ 'aix': 'AIX'
63
+ }[platform] || platform;
64
+
65
+ // Форматируем uptime
66
+ const formatUptime = (seconds) => {
67
+ const days = Math.floor(seconds / 86400);
68
+ const hours = Math.floor((seconds % 86400) / 3600);
69
+ const minutes = Math.floor((seconds % 3600) / 60);
70
+
71
+ if (days > 0) return `${days}д ${hours}ч`;
72
+ if (hours > 0) return `${hours}ч ${minutes}м`;
73
+ return `${minutes}м`;
74
+ };
75
+
76
+ let websocketStatus = true;
77
+ let databaseStatus = true;
78
+
79
+ try {
80
+ const prisma = req.app.get('prisma') || require('../../lib/prisma');
81
+ await prisma.$queryRaw`SELECT 1`;
82
+ } catch (error) {
83
+ databaseStatus = false;
84
+ }
85
+
86
+ try {
87
+ const botManager = req.app.get('botManager');
88
+ websocketStatus = botManager !== null && botManager !== undefined;
89
+ } catch (error) {
90
+ websocketStatus = false;
91
+ }
92
+
93
+ res.json({
94
+ status: 'ok',
95
+ uptime: formatUptime(serverUptime),
96
+ uptimeSeconds: Math.floor(serverUptime),
97
+ processUptime: formatUptime(uptime),
98
+ memory: {
99
+ total: Math.round(totalMemory / 1024 / 1024), // MB
100
+ free: Math.round(freeMemory / 1024 / 1024), // MB
101
+ used: Math.round(usedMemory / 1024 / 1024), // MB
102
+ usedPercent: Math.round((usedMemory / totalMemory) * 100),
103
+ panel: panelMemory // Память используемая панелью
104
+ },
105
+ cpu: {
106
+ cores: cpus.length,
107
+ model: cpus[0]?.model || 'Unknown',
108
+ usage: systemCpuUsage,
109
+ panelUsage: panelCpu,
110
+ loadAverage: os.loadavg()
111
+ },
112
+ platform: platformName,
113
+ platformRaw: platform,
114
+ arch: arch,
115
+ osRelease: os.release(),
116
+ hostname: os.hostname(),
117
+ nodeVersion: process.version,
118
+ services: {
119
+ panel: true,
120
+ websocket: websocketStatus,
121
+ database: databaseStatus
122
+ }
123
+ });
124
+ } catch (error) {
125
+ console.error('Error getting system health:', error);
126
+ res.status(500).json({
127
+ error: 'Failed to get system health',
128
+ message: error.message
129
+ });
130
+ }
131
+ });
132
+
133
+ /**
134
+ * @route GET /api/system/stats
135
+ * @desc Получить статистику системы
136
+ * @access Требуется авторизация
137
+ */
138
+ router.get('/stats', authenticateUniversal, async (req, res) => {
139
+ try {
140
+ const prisma = req.app.get('prisma') || require('../../lib/prisma');
141
+
142
+ const totalBots = await prisma.bot.count();
143
+ const totalServers = await prisma.server.count();
144
+ const totalUsers = await prisma.panelUser.count();
145
+
146
+ const botManager = req.app.get('botManager');
147
+ let runningBots = 0;
148
+
149
+ if (botManager && botManager.bots) {
150
+ runningBots = Array.from(botManager.bots.values())
151
+ .filter(bot => typeof bot.isRunning === 'function' && bot.isRunning())
152
+ .length;
153
+ }
154
+
155
+ res.json({
156
+ bots: {
157
+ total: totalBots,
158
+ running: runningBots,
159
+ stopped: totalBots - runningBots
160
+ },
161
+ servers: totalServers,
162
+ users: totalUsers
163
+ });
164
+ } catch (error) {
165
+ console.error('Error getting system stats:', error);
166
+ res.status(500).json({
167
+ error: 'Failed to get system stats',
168
+ message: error.message
169
+ });
170
+ }
171
+ });
172
+
173
+ module.exports = router;
174
+