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,25 +1,20 @@
|
|
|
1
|
-
const GraphExecutionEngine = require('./GraphExecutionEngine');
|
|
2
|
-
const nodeRegistry = require('./NodeRegistry');
|
|
3
1
|
const prismaService = require('./PrismaService');
|
|
4
2
|
const { safeJsonParse } = require('./utils/jsonParser');
|
|
5
|
-
const { parseVariables
|
|
3
|
+
const { parseVariables } = require('./utils/variableParser');
|
|
6
4
|
const validationService = require('./services/ValidationService');
|
|
5
|
+
const botHistoryStore = require('./BotHistoryStore');
|
|
7
6
|
|
|
8
7
|
const prisma = prismaService.getClient();
|
|
9
8
|
|
|
10
9
|
class EventGraphManager {
|
|
11
10
|
constructor(botManager = null) {
|
|
12
11
|
this.botManager = botManager;
|
|
13
|
-
this.graphEngine = botManager ? new GraphExecutionEngine(nodeRegistry, botManager) : null;
|
|
14
12
|
this.activeGraphs = new Map();
|
|
15
13
|
this.graphStates = new Map();
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
setBotManager(botManager) {
|
|
19
17
|
this.botManager = botManager;
|
|
20
|
-
if (!this.graphEngine) {
|
|
21
|
-
this.graphEngine = new GraphExecutionEngine(nodeRegistry, botManager);
|
|
22
|
-
}
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
async loadGraphsForBot(botId) {
|
|
@@ -86,125 +81,33 @@ class EventGraphManager {
|
|
|
86
81
|
|
|
87
82
|
for (const graph of graphsToRun) {
|
|
88
83
|
try {
|
|
89
|
-
await this.
|
|
84
|
+
await this.executeGraphInChildProcess(botId, eventType, graph, args);
|
|
90
85
|
} catch (error) {
|
|
91
|
-
console.error(`[EventGraphManager]
|
|
92
|
-
this.botManager.appendLog(botId, `[ERROR]
|
|
86
|
+
console.error(`[EventGraphManager] Error sending event to child process for '${eventType}':`, error);
|
|
87
|
+
this.botManager.appendLog(botId, `[ERROR] Error in event graph: ${error.message}`);
|
|
93
88
|
}
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Отправляет граф в child process для выполнения
|
|
94
|
+
*/
|
|
95
|
+
async executeGraphInChildProcess(botId, eventType, graph, eventArgs) {
|
|
98
96
|
if (!graph || !graph.nodes || graph.nodes.length === 0) return;
|
|
99
97
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.botManager.sendMessageToBot(botId, message, chatType, recipient);
|
|
105
|
-
},
|
|
106
|
-
executeCommand: (command) => {
|
|
107
|
-
this.botManager.sendMessageToBot(botId, command, 'command');
|
|
108
|
-
},
|
|
109
|
-
lookAt: (position) => {
|
|
110
|
-
this.botManager.lookAt(botId, position);
|
|
111
|
-
},
|
|
112
|
-
getPlayerList: () => players,
|
|
113
|
-
getNearbyEntities: (position = null, radius = 32) => {
|
|
114
|
-
return this.botManager.getNearbyEntities(botId, position, radius);
|
|
115
|
-
},
|
|
116
|
-
sendLog: (message) => {
|
|
117
|
-
this.botManager.appendLog(botId, message);
|
|
118
|
-
},
|
|
119
|
-
entity: eventArgs.botEntity || null,
|
|
120
|
-
api: {
|
|
121
|
-
emitApiEvent: (eventName, payload) => {
|
|
122
|
-
this.emitCustomApiEvent(botId, eventName, payload);
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const stateKey = `${botId}-${graph.id}`;
|
|
128
|
-
|
|
129
|
-
const initialContext = this.getInitialContextForEvent(eventType, eventArgs);
|
|
130
|
-
initialContext.bot = botApi;
|
|
131
|
-
initialContext.botId = botId;
|
|
132
|
-
initialContext.players = players;
|
|
133
|
-
initialContext.botState = eventArgs.botState || {};
|
|
134
|
-
|
|
135
|
-
const savedVariables = { ...(this.graphStates.get(stateKey) || {}) };
|
|
136
|
-
|
|
137
|
-
if (graph.variables && Array.isArray(graph.variables)) {
|
|
138
|
-
for (const v of graph.variables) {
|
|
139
|
-
if (!savedVariables.hasOwnProperty(v.name)) {
|
|
140
|
-
savedVariables[v.name] = parseVariableValue(v, `EventGraph ID ${graph.id}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
98
|
+
const childProcess = this.botManager.getChildProcess(botId);
|
|
99
|
+
if (!childProcess || !childProcess.send) {
|
|
100
|
+
console.error(`[EventGraphManager] No child process found for bot ${botId}`);
|
|
101
|
+
return;
|
|
143
102
|
}
|
|
144
|
-
|
|
145
|
-
initialContext.variables = savedVariables;
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const finalContext = await this.graphEngine.execute(graph, initialContext, eventType);
|
|
149
103
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
getInitialContextForEvent(eventType, args) {
|
|
159
|
-
const context = {};
|
|
160
|
-
switch (eventType) {
|
|
161
|
-
case 'chat':
|
|
162
|
-
case 'private':
|
|
163
|
-
case 'global':
|
|
164
|
-
case 'clan':
|
|
165
|
-
context.user = { username: args.username };
|
|
166
|
-
context.username = args.username;
|
|
167
|
-
context.message = args.message;
|
|
168
|
-
context.chat_type = args.chatType;
|
|
169
|
-
break;
|
|
170
|
-
case 'raw_message':
|
|
171
|
-
context.rawText = args.rawText;
|
|
172
|
-
break;
|
|
173
|
-
case 'playerJoined':
|
|
174
|
-
case 'playerLeft':
|
|
175
|
-
context.user = args.user;
|
|
176
|
-
break;
|
|
177
|
-
case 'botDied':
|
|
178
|
-
context.user = args.user;
|
|
179
|
-
break;
|
|
180
|
-
case 'health':
|
|
181
|
-
context.health = args.health;
|
|
182
|
-
context.food = args.food;
|
|
183
|
-
context.saturation = args.saturation;
|
|
184
|
-
break;
|
|
185
|
-
case 'tick':
|
|
186
|
-
break;
|
|
187
|
-
case 'entitySpawn':
|
|
188
|
-
case 'entityMoved':
|
|
189
|
-
case 'entityGone':
|
|
190
|
-
context.entity = args.entity;
|
|
191
|
-
break;
|
|
192
|
-
case 'command':
|
|
193
|
-
context.command_name = args.commandName;
|
|
194
|
-
context.user = args.user;
|
|
195
|
-
context.args = args.args;
|
|
196
|
-
context.chat_type = args.typeChat;
|
|
197
|
-
context.success = args.success !== undefined ? args.success : true;
|
|
198
|
-
break;
|
|
199
|
-
case 'websocket_call':
|
|
200
|
-
context.graphName = args.graphName;
|
|
201
|
-
context.data = args.data || {};
|
|
202
|
-
context.socketId = args.socketId;
|
|
203
|
-
context.keyPrefix = args.keyPrefix;
|
|
204
|
-
context.sendResponse = args.sendResponse;
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
return context;
|
|
104
|
+
childProcess.send({
|
|
105
|
+
type: 'execute_event_graph',
|
|
106
|
+
botId: botId,
|
|
107
|
+
graph: graph,
|
|
108
|
+
eventType: eventType,
|
|
109
|
+
eventArgs: eventArgs
|
|
110
|
+
});
|
|
208
111
|
}
|
|
209
112
|
|
|
210
113
|
/**
|
|
@@ -213,21 +116,30 @@ class EventGraphManager {
|
|
|
213
116
|
broadcastEventToApi(botId, eventType, args) {
|
|
214
117
|
try {
|
|
215
118
|
// Динамический импорт для избежания циклической зависимости
|
|
216
|
-
const {
|
|
119
|
+
const { getIOSafe } = require('../real-time/socketHandler');
|
|
217
120
|
const { broadcastToApiClients } = require('../real-time/botApi');
|
|
218
121
|
|
|
219
|
-
const io =
|
|
122
|
+
const io = getIOSafe();
|
|
123
|
+
if (!io) return;
|
|
220
124
|
|
|
221
125
|
switch (eventType) {
|
|
222
126
|
case 'chat':
|
|
223
127
|
case 'private':
|
|
224
128
|
case 'global':
|
|
225
129
|
case 'clan':
|
|
226
|
-
|
|
130
|
+
const chatData = {
|
|
227
131
|
type: eventType,
|
|
228
132
|
username: args.username,
|
|
229
133
|
message: args.message,
|
|
230
134
|
raw_message: args.rawText || args.raw_message,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
broadcastToApiClients(io, botId, 'chat:message', chatData);
|
|
138
|
+
|
|
139
|
+
botHistoryStore.addChatMessage(botId, {
|
|
140
|
+
type: eventType,
|
|
141
|
+
username: args.username,
|
|
142
|
+
message: args.message
|
|
231
143
|
});
|
|
232
144
|
break;
|
|
233
145
|
|
|
@@ -263,17 +175,19 @@ class EventGraphManager {
|
|
|
263
175
|
*/
|
|
264
176
|
emitCustomApiEvent(botId, eventName, payload = {}) {
|
|
265
177
|
try {
|
|
266
|
-
const {
|
|
178
|
+
const { getIOSafe } = require('../real-time/socketHandler');
|
|
267
179
|
const { broadcastToApiClients } = require('../real-time/botApi');
|
|
268
180
|
|
|
269
|
-
const io =
|
|
181
|
+
const io = getIOSafe();
|
|
182
|
+
if (!io) return;
|
|
183
|
+
|
|
270
184
|
broadcastToApiClients(io, botId, 'plugin:custom_event', {
|
|
271
185
|
eventName,
|
|
272
186
|
payload,
|
|
273
187
|
timestamp: new Date().toISOString(),
|
|
274
188
|
});
|
|
275
189
|
} catch (error) {
|
|
276
|
-
// Игнорируем ошибки
|
|
190
|
+
// Игнорируем другие ошибки
|
|
277
191
|
}
|
|
278
192
|
}
|
|
279
193
|
}
|