blockmine 1.19.1 → 1.20.0
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/.claude/settings.local.json +11 -0
- package/CHANGELOG.md +8 -0
- package/backend/src/core/BotManager.js +34 -4
- package/backend/src/core/GraphExecutionEngine.js +12 -1
- package/backend/src/core/NodeRegistry.js +2 -1
- package/frontend/dist/assets/{index-DxdxTe6I.js → index-CMMutadc.js} +33 -33
- package/frontend/dist/index.html +1 -1
- package/nul +0 -0
- package/package.json +1 -1
- package/.kiro/steering/product.md +0 -27
- package/.kiro/steering/structure.md +0 -89
- package/.kiro/steering/tech.md +0 -94
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# История версий
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [1.20.0](https://github.com/blockmineJS/blockmine/compare/v1.19.1...v1.20.0) (2025-10-23)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### ✨ Новые возможности
|
|
8
|
+
|
|
9
|
+
* если бот падает 5 раз с критической ошибкой, то перезапуск отменяется ([2ba022f](https://github.com/blockmineJS/blockmine/commit/2ba022fff038cc83bb1edfa04d3edf97fc76c255))
|
|
10
|
+
* action:send_message to support dynamic variables. example. Сообщение: привет, {username} ([457639d](https://github.com/blockmineJS/blockmine/commit/457639d70e7a8933f0508d93196a2be6951f1a0a))
|
|
11
|
+
|
|
4
12
|
### [1.19.1](https://github.com/blockmineJS/blockmine/compare/v1.19.0...v1.19.1) (2025-10-01)
|
|
5
13
|
|
|
6
14
|
|
|
@@ -52,6 +52,7 @@ class BotManager {
|
|
|
52
52
|
this.playerListCache = new Map();
|
|
53
53
|
this.eventGraphManager = null;
|
|
54
54
|
this.uiSubscriptions = new Map();
|
|
55
|
+
this.crashCounters = new Map();
|
|
55
56
|
|
|
56
57
|
getInstanceId();
|
|
57
58
|
setInterval(() => this.updateAllResourceUsage(), 5000);
|
|
@@ -393,7 +394,13 @@ class BotManager {
|
|
|
393
394
|
|
|
394
395
|
const fullBotConfig = { ...decryptedConfig, plugins: sortedPlugins };
|
|
395
396
|
const botProcessPath = path.resolve(__dirname, 'BotProcess.js');
|
|
396
|
-
const child = fork(botProcessPath, [], {
|
|
397
|
+
const child = fork(botProcessPath, [], {
|
|
398
|
+
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
|
399
|
+
env: {
|
|
400
|
+
...process.env,
|
|
401
|
+
NODE_PATH: path.resolve(__dirname, '../../../node_modules')
|
|
402
|
+
}
|
|
403
|
+
});
|
|
397
404
|
|
|
398
405
|
child.botConfig = botConfig;
|
|
399
406
|
|
|
@@ -440,6 +447,7 @@ class BotManager {
|
|
|
440
447
|
break;
|
|
441
448
|
case 'bot_ready':
|
|
442
449
|
this.emitStatusUpdate(botId, 'running', 'Бот успешно подключился к серверу.');
|
|
450
|
+
this.crashCounters.delete(botId);
|
|
443
451
|
break;
|
|
444
452
|
case 'validate_and_run_command':
|
|
445
453
|
await this.handleCommandValidation(botConfig, message);
|
|
@@ -527,13 +535,35 @@ class BotManager {
|
|
|
527
535
|
this.bots.delete(botId);
|
|
528
536
|
this.resourceUsage.delete(botId);
|
|
529
537
|
this.botConfigs.delete(botId);
|
|
530
|
-
|
|
538
|
+
|
|
531
539
|
this.emitStatusUpdate(botId, 'stopped', `Процесс завершился с кодом ${code} (сигнал: ${signal || 'none'}).`);
|
|
532
540
|
this.updateAllResourceUsage();
|
|
533
541
|
|
|
534
542
|
if (code === 1) {
|
|
535
|
-
|
|
536
|
-
|
|
543
|
+
const MAX_RESTART_ATTEMPTS = 5;
|
|
544
|
+
const RESTART_COOLDOWN = 60000;
|
|
545
|
+
|
|
546
|
+
const counter = this.crashCounters.get(botId) || { count: 0, firstCrash: Date.now() };
|
|
547
|
+
const timeSinceFirstCrash = Date.now() - counter.firstCrash;
|
|
548
|
+
|
|
549
|
+
if (timeSinceFirstCrash > RESTART_COOLDOWN) {
|
|
550
|
+
counter.count = 0;
|
|
551
|
+
counter.firstCrash = Date.now();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
counter.count++;
|
|
555
|
+
this.crashCounters.set(botId, counter);
|
|
556
|
+
|
|
557
|
+
if (counter.count >= MAX_RESTART_ATTEMPTS) {
|
|
558
|
+
console.log(`[BotManager] Бот ${botId} упал ${counter.count} раз подряд. Автоперезапуск остановлен.`);
|
|
559
|
+
this.appendLog(botId, `[SYSTEM] ❌ Обнаружено ${counter.count} критических ошибок подряд.`);
|
|
560
|
+
this.appendLog(botId, `[SYSTEM] 💡 Исправьте проблему и запустите бота вручную.`);
|
|
561
|
+
this.crashCounters.delete(botId);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
console.log(`[BotManager] Обнаружена ошибка с кодом 1 для бота ${botId}. Попытка ${counter.count}/${MAX_RESTART_ATTEMPTS}. Перезапуск через 5 секунд...`);
|
|
566
|
+
this.appendLog(botId, `[SYSTEM] Обнаружена критическая ошибка, перезапуск через 5 секунд... (попытка ${counter.count}/${MAX_RESTART_ATTEMPTS})`);
|
|
537
567
|
setTimeout(() => {
|
|
538
568
|
console.log(`[BotManager] Перезапуск бота ${botId}...`);
|
|
539
569
|
this.startBot(botConfig);
|
|
@@ -129,9 +129,20 @@ class GraphExecutionEngine {
|
|
|
129
129
|
break;
|
|
130
130
|
}
|
|
131
131
|
case 'action:send_message': {
|
|
132
|
-
|
|
132
|
+
let message = String(await this.resolvePinValue(node, 'message', ''));
|
|
133
133
|
const chatType = await this.resolvePinValue(node, 'chat_type', this.context.typeChat);
|
|
134
134
|
const recipient = await this.resolvePinValue(node, 'recipient', this.context.user?.username);
|
|
135
|
+
|
|
136
|
+
// Парсим и заменяем переменные в формате {varName}
|
|
137
|
+
const variablePattern = /\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;
|
|
138
|
+
const matches = [...message.matchAll(variablePattern)];
|
|
139
|
+
|
|
140
|
+
for (const match of matches) {
|
|
141
|
+
const varName = match[1];
|
|
142
|
+
const varValue = await this.resolvePinValue(node, `var_${varName}`, '');
|
|
143
|
+
message = message.replace(match[0], String(varValue));
|
|
144
|
+
}
|
|
145
|
+
|
|
135
146
|
this.context.bot.sendMessage(chatType, message, recipient);
|
|
136
147
|
await this.traverse(node, 'exec');
|
|
137
148
|
break;
|
|
@@ -299,8 +299,9 @@ class NodeRegistry {
|
|
|
299
299
|
type: 'action:send_message',
|
|
300
300
|
label: '🗣️ Отправить сообщение',
|
|
301
301
|
category: 'Действия',
|
|
302
|
-
description: 'Отправляет сообщение в
|
|
302
|
+
description: 'Отправляет сообщение в чат. Поддерживает переменные в формате {varName}',
|
|
303
303
|
graphType: all,
|
|
304
|
+
dynamicPins: true,
|
|
304
305
|
pins: {
|
|
305
306
|
inputs: [
|
|
306
307
|
{ id: 'exec', name: 'Выполнить', type: 'Exec', required: true },
|