blockmine 1.22.0 → 1.23.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.json +5 -1
- package/.claude/settings.local.json +10 -1
- package/CHANGELOG.md +27 -3
- package/CLAUDE.md +284 -0
- package/README.md +302 -152
- package/backend/package-lock.json +681 -9
- package/backend/package.json +8 -0
- package/backend/prisma/migrations/20251116111851_add_execution_trace/migration.sql +22 -0
- package/backend/prisma/migrations/20251120154914_add_panel_api_keys/migration.sql +21 -0
- package/backend/prisma/migrations/20251121110241_add_proxy_table/migration.sql +45 -0
- package/backend/prisma/migrations/migration_lock.toml +2 -2
- package/backend/prisma/schema.prisma +70 -1
- package/backend/src/__tests__/services/BotLifecycleService.test.js +9 -4
- package/backend/src/ai/plugin-assistant-system-prompt.md +788 -0
- package/backend/src/api/middleware/auth.js +27 -0
- package/backend/src/api/middleware/botAccess.js +7 -3
- package/backend/src/api/middleware/panelApiAuth.js +135 -0
- package/backend/src/api/routes/aiAssistant.js +995 -0
- package/backend/src/api/routes/auth.js +669 -633
- package/backend/src/api/routes/botCommands.js +107 -0
- package/backend/src/api/routes/botGroups.js +165 -0
- package/backend/src/api/routes/botHistory.js +108 -0
- package/backend/src/api/routes/botPermissions.js +99 -0
- package/backend/src/api/routes/botStatus.js +36 -0
- package/backend/src/api/routes/botUsers.js +162 -0
- package/backend/src/api/routes/bots.js +2451 -2402
- package/backend/src/api/routes/eventGraphs.js +4 -1
- package/backend/src/api/routes/logs.js +13 -3
- package/backend/src/api/routes/panel.js +66 -66
- package/backend/src/api/routes/panelApiKeys.js +179 -0
- package/backend/src/api/routes/pluginIde.js +1715 -135
- package/backend/src/api/routes/plugins.js +376 -219
- package/backend/src/api/routes/proxies.js +130 -0
- package/backend/src/api/routes/search.js +4 -0
- package/backend/src/api/routes/servers.js +20 -3
- package/backend/src/api/routes/settings.js +5 -0
- package/backend/src/api/routes/system.js +174 -174
- package/backend/src/api/routes/traces.js +131 -0
- package/backend/src/config/debug.config.js +36 -0
- package/backend/src/core/BotHistoryStore.js +180 -0
- package/backend/src/core/BotManager.js +14 -4
- package/backend/src/core/BotProcess.js +1517 -1092
- package/backend/src/core/EventGraphManager.js +37 -123
- package/backend/src/core/GraphExecutionEngine.js +977 -321
- package/backend/src/core/MessageQueue.js +12 -6
- package/backend/src/core/PluginLoader.js +99 -5
- package/backend/src/core/PluginManager.js +74 -13
- package/backend/src/core/TaskScheduler.js +1 -1
- package/backend/src/core/commands/whois.js +1 -1
- package/backend/src/core/node-registries/actions.js +70 -0
- package/backend/src/core/node-registries/arrays.js +18 -0
- package/backend/src/core/node-registries/data.js +1 -1
- package/backend/src/core/node-registries/events.js +14 -0
- package/backend/src/core/node-registries/logic.js +17 -0
- package/backend/src/core/node-registries/strings.js +34 -0
- package/backend/src/core/node-registries/type.js +25 -0
- package/backend/src/core/nodes/actions/bot_look_at.js +1 -1
- package/backend/src/core/nodes/actions/create_command.js +189 -0
- package/backend/src/core/nodes/actions/delete_command.js +92 -0
- package/backend/src/core/nodes/actions/update_command.js +133 -0
- package/backend/src/core/nodes/arrays/join.js +28 -0
- package/backend/src/core/nodes/data/cast.js +2 -1
- package/backend/src/core/nodes/logic/not.js +22 -0
- package/backend/src/core/nodes/strings/starts_with.js +1 -1
- package/backend/src/core/nodes/strings/to_lower.js +22 -0
- package/backend/src/core/nodes/strings/to_upper.js +22 -0
- package/backend/src/core/nodes/type/to_string.js +32 -0
- package/backend/src/core/services/BotLifecycleService.js +255 -16
- package/backend/src/core/services/CommandExecutionService.js +430 -351
- package/backend/src/core/services/DebugSessionManager.js +347 -0
- package/backend/src/core/services/GraphCollaborationManager.js +501 -0
- package/backend/src/core/services/MinecraftBotManager.js +259 -0
- package/backend/src/core/services/MinecraftViewerService.js +216 -0
- package/backend/src/core/services/TraceCollectorService.js +545 -0
- package/backend/src/core/system/RuntimeCommandRegistry.js +116 -0
- package/backend/src/core/system/Transport.js +0 -4
- package/backend/src/core/validation/nodeSchemas.js +6 -6
- package/backend/src/real-time/botApi/handlers/graphHandlers.js +2 -2
- package/backend/src/real-time/botApi/handlers/graphWebSocketHandlers.js +1 -1
- package/backend/src/real-time/botApi/utils.js +11 -0
- package/backend/src/real-time/panelNamespace.js +387 -0
- package/backend/src/real-time/presence.js +7 -2
- package/backend/src/real-time/socketHandler.js +395 -4
- package/backend/src/server.js +18 -0
- package/frontend/dist/assets/index-B1serztM.js +11210 -0
- package/frontend/dist/assets/index-t6K1u4OV.css +32 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/package-lock.json +9437 -0
- package/frontend/package.json +8 -0
- package/package.json +2 -2
- package/screen/console.png +0 -0
- package/screen/dashboard.png +0 -0
- package/screen/graph_collabe.png +0 -0
- package/screen/graph_live_debug.png +0 -0
- package/screen/management_command.png +0 -0
- package/screen/node_debug_trace.png +0 -0
- package/screen/plugin_/320/276/320/261/320/267/320/276/321/200.png +0 -0
- package/screen/websocket.png +0 -0
- package/screen//320/275/320/260/321/201/321/202/321/200/320/276/320/271/320/272/320/270_/320/276/321/202/320/264/320/265/320/273/321/214/320/275/321/213/321/205_/320/272/320/276/320/274/320/260/320/275/320/264_/320/272/320/260/320/266/320/264/321/203_/320/272/320/276/320/274/320/260/320/275/320/273/320/264/321/203_/320/274/320/276/320/266/320/275/320/276_/320/275/320/260/321/201/321/202/321/200/320/260/320/270/320/262/320/260/321/202/321/214.png +0 -0
- package/screen//320/277/320/273/320/260/320/275/320/270/321/200/320/276/320/262/321/211/320/270/320/272_/320/274/320/276/320/266/320/275/320/276_/320/267/320/260/320/264/320/260/320/262/320/260/321/202/321/214_/320/264/320/265/320/271/321/201/321/202/320/262/320/270/321/217_/320/277/320/276_/320/262/321/200/320/265/320/274/320/265/320/275/320/270.png +0 -0
- package/frontend/dist/assets/index-CfTo92bP.css +0 -1
- package/frontend/dist/assets/index-CiFD5X9Z.js +0 -8344
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const DependencyService = require('../DependencyService');
|
|
2
2
|
const { decrypt } = require('../utils/crypto');
|
|
3
3
|
const UserService = require('../UserService');
|
|
4
|
+
const PermissionManager = require('../PermissionManager');
|
|
4
5
|
|
|
5
6
|
class BotLifecycleService {
|
|
6
7
|
constructor({
|
|
@@ -72,6 +73,14 @@ class BotLifecycleService {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
const decryptedConfig = { ...botConfig };
|
|
76
|
+
|
|
77
|
+
if (decryptedConfig.proxy) {
|
|
78
|
+
decryptedConfig.proxyHost = decryptedConfig.proxy.host;
|
|
79
|
+
decryptedConfig.proxyPort = decryptedConfig.proxy.port;
|
|
80
|
+
decryptedConfig.proxyUsername = decryptedConfig.proxy.username;
|
|
81
|
+
decryptedConfig.proxyPassword = decryptedConfig.proxy.password;
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
if (decryptedConfig.password) decryptedConfig.password = decrypt(decryptedConfig.password);
|
|
76
85
|
if (decryptedConfig.proxyPassword) decryptedConfig.proxyPassword = decrypt(decryptedConfig.proxyPassword);
|
|
77
86
|
if (decryptedConfig.proxyUsername) decryptedConfig.proxyUsername = decryptedConfig.proxyUsername.trim();
|
|
@@ -109,6 +118,11 @@ class BotLifecycleService {
|
|
|
109
118
|
if (child) {
|
|
110
119
|
this.eventGraphManager.unloadGraphsForBot(botId);
|
|
111
120
|
|
|
121
|
+
// Очищаем traces для этого бота
|
|
122
|
+
const { getTraceCollector } = require('./TraceCollectorService');
|
|
123
|
+
const traceCollector = getTraceCollector();
|
|
124
|
+
traceCollector.clearForBot(botId);
|
|
125
|
+
|
|
112
126
|
child.send({ type: 'stop' });
|
|
113
127
|
|
|
114
128
|
// Принудительное завершение через 5 секунд
|
|
@@ -129,6 +143,10 @@ class BotLifecycleService {
|
|
|
129
143
|
return { success: false, message: 'Бот не найден или уже остановлен' };
|
|
130
144
|
}
|
|
131
145
|
|
|
146
|
+
getChildProcess(botId) {
|
|
147
|
+
return this.processManager.getProcess(botId);
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
async restartBot(botId) {
|
|
133
151
|
const botConfig = this.processManager.getProcess(botId)?.botConfig;
|
|
134
152
|
if (!botConfig) {
|
|
@@ -161,6 +179,9 @@ class BotLifecycleService {
|
|
|
161
179
|
case 'log':
|
|
162
180
|
this.appendLog(botId, message.content);
|
|
163
181
|
break;
|
|
182
|
+
case 'plugin-log':
|
|
183
|
+
this._handlePluginLog(message.log);
|
|
184
|
+
break;
|
|
164
185
|
case 'status':
|
|
165
186
|
this.emitStatusUpdate(botId, message.status);
|
|
166
187
|
break;
|
|
@@ -190,6 +211,24 @@ class BotLifecycleService {
|
|
|
190
211
|
case 'register_command':
|
|
191
212
|
await this._handleCommandRegistration(botId, message.commandConfig);
|
|
192
213
|
break;
|
|
214
|
+
case 'register_permissions':
|
|
215
|
+
await this._handlePermissionsRegistration(botId, message);
|
|
216
|
+
break;
|
|
217
|
+
case 'register_group':
|
|
218
|
+
await this._handleGroupRegistration(botId, message);
|
|
219
|
+
break;
|
|
220
|
+
case 'add_permissions_to_group':
|
|
221
|
+
await this._handleAddPermissionsToGroup(botId, message);
|
|
222
|
+
break;
|
|
223
|
+
case 'trace:completed':
|
|
224
|
+
await this._handleTraceCompleted(botId, message.trace);
|
|
225
|
+
break;
|
|
226
|
+
case 'debug:check_breakpoint':
|
|
227
|
+
await this._handleDebugBreakpointCheck(botId, child, message);
|
|
228
|
+
break;
|
|
229
|
+
case 'debug:check_step_mode':
|
|
230
|
+
await this._handleDebugStepModeCheck(botId, child, message);
|
|
231
|
+
break;
|
|
193
232
|
}
|
|
194
233
|
} catch (error) {
|
|
195
234
|
this.appendLog(botId, `[SYSTEM-ERROR] Критическая ошибка в обработчике: ${error.stack}`);
|
|
@@ -209,15 +248,25 @@ class BotLifecycleService {
|
|
|
209
248
|
async _handleEventMessage(botId, message) {
|
|
210
249
|
if (message.eventType === 'raw_message') {
|
|
211
250
|
try {
|
|
212
|
-
const {
|
|
251
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
213
252
|
const { broadcastToApiClients } = require('../../real-time/botApi');
|
|
214
|
-
broadcastToApiClients(
|
|
253
|
+
broadcastToApiClients(getIOSafe(), botId, 'chat:raw_message', {
|
|
215
254
|
raw_message: message.args.rawText || message.args.raw_message,
|
|
216
255
|
json: message.args.json
|
|
217
256
|
});
|
|
218
257
|
} catch (e) { /* Socket.IO может быть не инициализирован */ }
|
|
219
258
|
}
|
|
220
259
|
|
|
260
|
+
try {
|
|
261
|
+
const { broadcastToPanelNamespace } = require('../../real-time/panelNamespace');
|
|
262
|
+
broadcastToPanelNamespace(botId, 'bot:event', {
|
|
263
|
+
botId,
|
|
264
|
+
eventType: message.eventType,
|
|
265
|
+
data: message.args || {},
|
|
266
|
+
timestamp: new Date().toISOString()
|
|
267
|
+
});
|
|
268
|
+
} catch (e) { /* Socket.IO может быть не инициализирован */ }
|
|
269
|
+
|
|
221
270
|
if (this.eventGraphManager) {
|
|
222
271
|
this.eventGraphManager.handleEvent(botId, message.eventType, message.args);
|
|
223
272
|
}
|
|
@@ -234,10 +283,25 @@ class BotLifecycleService {
|
|
|
234
283
|
}
|
|
235
284
|
}
|
|
236
285
|
|
|
286
|
+
_handlePluginLog(logData) {
|
|
287
|
+
const { getIOSafe, addPluginLogToBuffer } = require('../../real-time/socketHandler');
|
|
288
|
+
const { botId, pluginName } = logData;
|
|
289
|
+
|
|
290
|
+
// Добавляем лог в буфер
|
|
291
|
+
addPluginLogToBuffer(botId, pluginName, logData);
|
|
292
|
+
|
|
293
|
+
// Отправляем через Socket.IO в комнату плагина
|
|
294
|
+
const io = getIOSafe();
|
|
295
|
+
if (io) {
|
|
296
|
+
const room = `plugin-logs:${botId}:${pluginName}`;
|
|
297
|
+
io.to(room).emit('plugin-log', logData);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
237
301
|
_handleWebSocketMessage(message) {
|
|
238
|
-
const {
|
|
302
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
239
303
|
const { botId, message: msg } = message.payload;
|
|
240
|
-
|
|
304
|
+
getIOSafe().to(`bot_${botId}`).emit('bot:message', { message: msg });
|
|
241
305
|
}
|
|
242
306
|
|
|
243
307
|
_handleBotReady(botId) {
|
|
@@ -245,10 +309,15 @@ class BotLifecycleService {
|
|
|
245
309
|
this.crashCounters.delete(botId);
|
|
246
310
|
|
|
247
311
|
try {
|
|
248
|
-
const {
|
|
312
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
249
313
|
const { broadcastBotStatus } = require('../../real-time/botApi');
|
|
250
|
-
broadcastBotStatus(
|
|
314
|
+
broadcastBotStatus(getIOSafe(), botId, true);
|
|
251
315
|
} catch (e) { /* Socket.IO может быть не инициализирован */ }
|
|
316
|
+
|
|
317
|
+
// Триггерим событие запуска бота
|
|
318
|
+
if (this.eventGraphManager) {
|
|
319
|
+
this.eventGraphManager.handleEvent(botId, 'botStartup', {});
|
|
320
|
+
}
|
|
252
321
|
}
|
|
253
322
|
|
|
254
323
|
async _handleCommandRegistration(botId, commandConfig) {
|
|
@@ -260,6 +329,33 @@ class BotLifecycleService {
|
|
|
260
329
|
}
|
|
261
330
|
}
|
|
262
331
|
|
|
332
|
+
async _handlePermissionsRegistration(botId, message) {
|
|
333
|
+
try {
|
|
334
|
+
await PermissionManager.registerPermissions(botId, message.permissions);
|
|
335
|
+
this.logger.debug({ botId, count: message.permissions.length }, 'Права зарегистрированы');
|
|
336
|
+
} catch (error) {
|
|
337
|
+
this.logger.error({ botId, error }, 'Ошибка регистрации прав');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async _handleGroupRegistration(botId, message) {
|
|
342
|
+
try {
|
|
343
|
+
await PermissionManager.registerGroup(botId, message.groupConfig);
|
|
344
|
+
this.logger.debug({ botId, groupName: message.groupConfig.name }, 'Группа зарегистрирована');
|
|
345
|
+
} catch (error) {
|
|
346
|
+
this.logger.error({ botId, error }, 'Ошибка регистрации группы');
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
async _handleAddPermissionsToGroup(botId, message) {
|
|
351
|
+
try {
|
|
352
|
+
await PermissionManager.addPermissionsToGroup(botId, message.groupName, message.permissionNames);
|
|
353
|
+
this.logger.debug({ botId, groupName: message.groupName, count: message.permissionNames.length }, 'Права добавлены в группу');
|
|
354
|
+
} catch (error) {
|
|
355
|
+
this.logger.error({ botId, error }, 'Ошибка добавления прав в группу');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
263
359
|
async _handleUserAction(botId, child, message) {
|
|
264
360
|
const { requestId, payload } = message;
|
|
265
361
|
const { targetUsername, action, data } = payload;
|
|
@@ -309,9 +405,9 @@ class BotLifecycleService {
|
|
|
309
405
|
this.emitStatusUpdate(botId, 'stopped', `Процесс завершился с кодом ${code} (сигнал: ${signal || 'none'}).`);
|
|
310
406
|
|
|
311
407
|
try {
|
|
312
|
-
const {
|
|
408
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
313
409
|
const { broadcastBotStatus } = require('../../real-time/botApi');
|
|
314
|
-
broadcastBotStatus(
|
|
410
|
+
broadcastBotStatus(getIOSafe(), botId, false);
|
|
315
411
|
} catch (e) { /* Socket.IO может быть не инициализирован */ }
|
|
316
412
|
|
|
317
413
|
// Автоперезапуск при критических ошибках
|
|
@@ -391,12 +487,12 @@ class BotLifecycleService {
|
|
|
391
487
|
}
|
|
392
488
|
|
|
393
489
|
reloadBotConfigInRealTime(botId) {
|
|
394
|
-
const {
|
|
490
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
395
491
|
this.invalidateConfigCache(botId);
|
|
396
492
|
|
|
397
493
|
if (this.processManager.sendMessage(botId, { type: 'config:reload' })) {
|
|
398
494
|
this.logger.info({ botId }, 'Отправлен config:reload');
|
|
399
|
-
|
|
495
|
+
getIOSafe().emit('bot:config_reloaded', { botId });
|
|
400
496
|
}
|
|
401
497
|
}
|
|
402
498
|
|
|
@@ -438,7 +534,7 @@ class BotLifecycleService {
|
|
|
438
534
|
}
|
|
439
535
|
|
|
440
536
|
appendLog(botId, logContent) {
|
|
441
|
-
const {
|
|
537
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
442
538
|
const logEntry = {
|
|
443
539
|
id: Date.now() + Math.random(),
|
|
444
540
|
content: logContent,
|
|
@@ -448,7 +544,7 @@ class BotLifecycleService {
|
|
|
448
544
|
const newLogs = [...currentLogs.slice(-199), logEntry];
|
|
449
545
|
this.logCache.set(botId, newLogs);
|
|
450
546
|
|
|
451
|
-
|
|
547
|
+
getIOSafe().emit('bot:log', { botId, log: logEntry });
|
|
452
548
|
}
|
|
453
549
|
|
|
454
550
|
getBotLogs(botId) {
|
|
@@ -456,9 +552,17 @@ class BotLifecycleService {
|
|
|
456
552
|
}
|
|
457
553
|
|
|
458
554
|
emitStatusUpdate(botId, status, message = null) {
|
|
459
|
-
const {
|
|
555
|
+
const { getIOSafe, broadcastToPanelNamespace } = require('../../real-time/socketHandler');
|
|
460
556
|
if (message) this.appendLog(botId, `[SYSTEM] ${message}`);
|
|
461
|
-
|
|
557
|
+
|
|
558
|
+
getIOSafe().emit('bot:status', { botId, status, message });
|
|
559
|
+
|
|
560
|
+
broadcastToPanelNamespace(getIOSafe(), 'bots:status', {
|
|
561
|
+
botId,
|
|
562
|
+
status,
|
|
563
|
+
message,
|
|
564
|
+
timestamp: new Date().toISOString()
|
|
565
|
+
});
|
|
462
566
|
}
|
|
463
567
|
|
|
464
568
|
getFullState() {
|
|
@@ -500,8 +604,8 @@ class BotLifecycleService {
|
|
|
500
604
|
async reloadPlugins(botId) {
|
|
501
605
|
if (this.processManager.sendMessage(botId, { type: 'plugins:reload' })) {
|
|
502
606
|
this.logger.info({ botId }, 'Отправлен plugins:reload');
|
|
503
|
-
const {
|
|
504
|
-
|
|
607
|
+
const { getIOSafe } = require('../../real-time/socketHandler');
|
|
608
|
+
getIOSafe().emit('bot:plugins_reloaded', { botId });
|
|
505
609
|
return { success: true, message: 'Команда на перезагрузку плагинов отправлена.' };
|
|
506
610
|
}
|
|
507
611
|
return { success: false, message: 'Бот не запущен.' };
|
|
@@ -591,6 +695,141 @@ class BotLifecycleService {
|
|
|
591
695
|
|
|
592
696
|
return { success: true };
|
|
593
697
|
}
|
|
698
|
+
|
|
699
|
+
async _handleTraceCompleted(botId, trace) {
|
|
700
|
+
try {
|
|
701
|
+
const { getTraceCollector } = require('../services/TraceCollectorService');
|
|
702
|
+
const traceCollector = getTraceCollector();
|
|
703
|
+
|
|
704
|
+
// Сохраняем трассировку в главном TraceCollectorService
|
|
705
|
+
await traceCollector._storeCompletedTrace(trace);
|
|
706
|
+
} catch (error) {
|
|
707
|
+
this.logger.error({ botId, error }, 'Ошибка обработки завершённой трассировки');
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
async _handleDebugBreakpointCheck(botId, child, message) {
|
|
712
|
+
const { requestId, payload } = message;
|
|
713
|
+
const { graphId, nodeId, nodeType, inputs, executedSteps, context } = payload;
|
|
714
|
+
|
|
715
|
+
try {
|
|
716
|
+
const { getGlobalDebugManager } = require('../services/DebugSessionManager');
|
|
717
|
+
const debugManager = getGlobalDebugManager();
|
|
718
|
+
|
|
719
|
+
const debugState = debugManager.get(graphId);
|
|
720
|
+
if (!debugState) {
|
|
721
|
+
// Нет debug сессии для этого графа - просто продолжаем выполнение
|
|
722
|
+
child.send({
|
|
723
|
+
type: 'debug:breakpoint_response',
|
|
724
|
+
requestId,
|
|
725
|
+
overrides: null
|
|
726
|
+
});
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
const breakpoint = debugState.breakpoints.get(nodeId);
|
|
731
|
+
if (!breakpoint || !breakpoint.enabled) {
|
|
732
|
+
// Нет брейкпоинта для этой ноды или он отключен
|
|
733
|
+
child.send({
|
|
734
|
+
type: 'debug:breakpoint_response',
|
|
735
|
+
requestId,
|
|
736
|
+
overrides: null
|
|
737
|
+
});
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// Проверяем условие брейкпоинта (пока всегда срабатывает)
|
|
742
|
+
// TODO: добавить evaluateBreakpointCondition
|
|
743
|
+
|
|
744
|
+
breakpoint.hitCount++;
|
|
745
|
+
|
|
746
|
+
// Приостанавливаем выполнение и ждём действий от пользователя
|
|
747
|
+
const overrides = await debugState.pause({
|
|
748
|
+
nodeId,
|
|
749
|
+
nodeType,
|
|
750
|
+
inputs,
|
|
751
|
+
executedSteps,
|
|
752
|
+
context,
|
|
753
|
+
breakpoint: {
|
|
754
|
+
condition: breakpoint.condition,
|
|
755
|
+
hitCount: breakpoint.hitCount
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
// Отправляем результат обратно в дочерний процесс
|
|
760
|
+
child.send({
|
|
761
|
+
type: 'debug:breakpoint_response',
|
|
762
|
+
requestId,
|
|
763
|
+
overrides: overrides || null
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
} catch (error) {
|
|
767
|
+
this.logger.error({ botId, error }, 'Ошибка обработки debug breakpoint check');
|
|
768
|
+
// В случае ошибки отправляем null чтобы продолжить выполнение
|
|
769
|
+
child.send({
|
|
770
|
+
type: 'debug:breakpoint_response',
|
|
771
|
+
requestId,
|
|
772
|
+
overrides: null
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
async _handleDebugStepModeCheck(botId, child, message) {
|
|
778
|
+
const { requestId, payload } = message;
|
|
779
|
+
const { graphId, nodeId, nodeType, inputs, executedSteps, context } = payload;
|
|
780
|
+
|
|
781
|
+
try {
|
|
782
|
+
const { getGlobalDebugManager } = require('../services/DebugSessionManager');
|
|
783
|
+
const debugManager = getGlobalDebugManager();
|
|
784
|
+
|
|
785
|
+
const debugState = debugManager.get(graphId);
|
|
786
|
+
if (!debugState) {
|
|
787
|
+
// Нет debug сессии - продолжаем выполнение
|
|
788
|
+
child.send({
|
|
789
|
+
type: 'debug:breakpoint_response', // Используем тот же тип ответа
|
|
790
|
+
requestId,
|
|
791
|
+
overrides: null
|
|
792
|
+
});
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// Проверяем, нужно ли остановиться в step mode
|
|
797
|
+
if (!debugState.shouldStepPause(nodeId)) {
|
|
798
|
+
// Step mode не активен или не нужно останавливаться на этой ноде
|
|
799
|
+
child.send({
|
|
800
|
+
type: 'debug:breakpoint_response',
|
|
801
|
+
requestId,
|
|
802
|
+
overrides: null
|
|
803
|
+
});
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// Приостанавливаем выполнение и ждём действий от пользователя
|
|
808
|
+
const overrides = await debugState.pause({
|
|
809
|
+
nodeId,
|
|
810
|
+
nodeType,
|
|
811
|
+
inputs,
|
|
812
|
+
executedSteps,
|
|
813
|
+
context
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
// Отправляем результат обратно в дочерний процесс
|
|
817
|
+
child.send({
|
|
818
|
+
type: 'debug:breakpoint_response',
|
|
819
|
+
requestId,
|
|
820
|
+
overrides: overrides || null
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
} catch (error) {
|
|
824
|
+
this.logger.error({ botId, error }, 'Ошибка обработки debug step mode check');
|
|
825
|
+
// В случае ошибки отправляем null чтобы продолжить выполнение
|
|
826
|
+
child.send({
|
|
827
|
+
type: 'debug:breakpoint_response',
|
|
828
|
+
requestId,
|
|
829
|
+
overrides: null
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
}
|
|
594
833
|
}
|
|
595
834
|
|
|
596
835
|
module.exports = BotLifecycleService;
|