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
package/backend/package.json
CHANGED
|
@@ -27,13 +27,21 @@
|
|
|
27
27
|
"ts-jest": "^29.4.5"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@octokit/rest": "^22.0.1",
|
|
30
31
|
"awilix": "^12.0.5",
|
|
31
32
|
"date-fns": "^4.1.0",
|
|
33
|
+
"diff": "^8.0.2",
|
|
32
34
|
"express-rate-limit": "^8.2.1",
|
|
33
35
|
"express-validator": "^7.2.1",
|
|
36
|
+
"google-ai-kit": "^1.1.3",
|
|
34
37
|
"lru-cache": "^10.4.3",
|
|
38
|
+
"mineflayer": "^4.33.0",
|
|
39
|
+
"mineflayer-pathfinder": "^2.4.5",
|
|
40
|
+
"openrouter-kit": "^0.1.81",
|
|
35
41
|
"pino": "^9.7.0",
|
|
36
42
|
"pino-pretty": "^13.0.0",
|
|
43
|
+
"prismarine-viewer": "^1.33.0",
|
|
44
|
+
"vec3": "^0.1.10",
|
|
37
45
|
"zod": "^4.1.12"
|
|
38
46
|
}
|
|
39
47
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "execution_traces" (
|
|
3
|
+
"id" TEXT NOT NULL PRIMARY KEY,
|
|
4
|
+
"graphId" INTEGER NOT NULL,
|
|
5
|
+
"botId" INTEGER NOT NULL,
|
|
6
|
+
"eventType" TEXT NOT NULL,
|
|
7
|
+
"eventArgs" TEXT NOT NULL,
|
|
8
|
+
"startTime" DATETIME NOT NULL,
|
|
9
|
+
"endTime" DATETIME,
|
|
10
|
+
"status" TEXT NOT NULL,
|
|
11
|
+
"error" TEXT,
|
|
12
|
+
"steps" TEXT NOT NULL,
|
|
13
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
14
|
+
CONSTRAINT "execution_traces_botId_fkey" FOREIGN KEY ("botId") REFERENCES "Bot" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
15
|
+
CONSTRAINT "execution_traces_graphId_fkey" FOREIGN KEY ("graphId") REFERENCES "EventGraph" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
-- CreateIndex
|
|
19
|
+
CREATE INDEX "execution_traces_botId_graphId_idx" ON "execution_traces"("botId", "graphId");
|
|
20
|
+
|
|
21
|
+
-- CreateIndex
|
|
22
|
+
CREATE INDEX "execution_traces_createdAt_idx" ON "execution_traces"("createdAt");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "PanelApiKey" (
|
|
3
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
"userId" INTEGER NOT NULL,
|
|
5
|
+
"name" TEXT NOT NULL,
|
|
6
|
+
"keyHash" TEXT NOT NULL,
|
|
7
|
+
"prefix" TEXT NOT NULL,
|
|
8
|
+
"customScopes" TEXT,
|
|
9
|
+
"lastUsedAt" DATETIME,
|
|
10
|
+
"expiresAt" DATETIME,
|
|
11
|
+
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
|
12
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
13
|
+
"updatedAt" DATETIME NOT NULL,
|
|
14
|
+
CONSTRAINT "PanelApiKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "PanelUser" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
-- CreateIndex
|
|
18
|
+
CREATE INDEX "PanelApiKey_userId_idx" ON "PanelApiKey"("userId");
|
|
19
|
+
|
|
20
|
+
-- CreateIndex
|
|
21
|
+
CREATE INDEX "PanelApiKey_keyHash_idx" ON "PanelApiKey"("keyHash");
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "Proxy" (
|
|
3
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
"name" TEXT NOT NULL,
|
|
5
|
+
"type" TEXT NOT NULL DEFAULT 'socks5',
|
|
6
|
+
"host" TEXT NOT NULL,
|
|
7
|
+
"port" INTEGER NOT NULL,
|
|
8
|
+
"username" TEXT,
|
|
9
|
+
"password" TEXT,
|
|
10
|
+
"note" TEXT,
|
|
11
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
12
|
+
"updatedAt" DATETIME NOT NULL
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
-- RedefineTables
|
|
16
|
+
PRAGMA defer_foreign_keys=ON;
|
|
17
|
+
PRAGMA foreign_keys=OFF;
|
|
18
|
+
CREATE TABLE "new_Bot" (
|
|
19
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
20
|
+
"username" TEXT NOT NULL,
|
|
21
|
+
"password" TEXT,
|
|
22
|
+
"prefix" TEXT DEFAULT '@',
|
|
23
|
+
"note" TEXT,
|
|
24
|
+
"owners" TEXT DEFAULT '',
|
|
25
|
+
"sortOrder" INTEGER,
|
|
26
|
+
"serverId" INTEGER NOT NULL,
|
|
27
|
+
"proxyId" INTEGER,
|
|
28
|
+
"proxyHost" TEXT,
|
|
29
|
+
"proxyPort" INTEGER,
|
|
30
|
+
"proxyUsername" TEXT,
|
|
31
|
+
"proxyPassword" TEXT,
|
|
32
|
+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
33
|
+
"updatedAt" DATETIME NOT NULL,
|
|
34
|
+
CONSTRAINT "Bot_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
|
35
|
+
CONSTRAINT "Bot_proxyId_fkey" FOREIGN KEY ("proxyId") REFERENCES "Proxy" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
|
36
|
+
);
|
|
37
|
+
INSERT INTO "new_Bot" ("createdAt", "id", "note", "owners", "password", "prefix", "proxyHost", "proxyPassword", "proxyPort", "proxyUsername", "serverId", "sortOrder", "updatedAt", "username") SELECT "createdAt", "id", "note", "owners", "password", "prefix", "proxyHost", "proxyPassword", "proxyPort", "proxyUsername", "serverId", "sortOrder", "updatedAt", "username" FROM "Bot";
|
|
38
|
+
DROP TABLE "Bot";
|
|
39
|
+
ALTER TABLE "new_Bot" RENAME TO "Bot";
|
|
40
|
+
CREATE UNIQUE INDEX "Bot_username_key" ON "Bot"("username");
|
|
41
|
+
PRAGMA foreign_keys=ON;
|
|
42
|
+
PRAGMA defer_foreign_keys=OFF;
|
|
43
|
+
|
|
44
|
+
-- CreateIndex
|
|
45
|
+
CREATE UNIQUE INDEX "Proxy_name_key" ON "Proxy"("name");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Please do not edit this file manually
|
|
2
|
-
# It should be added in your version-control system (i.e. Git)
|
|
1
|
+
# Please do not edit this file manually
|
|
2
|
+
# It should be added in your version-control system (i.e. Git)
|
|
3
3
|
provider = "sqlite"
|
|
@@ -16,6 +16,22 @@ model Server {
|
|
|
16
16
|
bots Bot[]
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
model Proxy {
|
|
20
|
+
id Int @id @default(autoincrement())
|
|
21
|
+
name String @unique
|
|
22
|
+
type String @default("socks5") // "socks5" or "http"
|
|
23
|
+
host String
|
|
24
|
+
port Int
|
|
25
|
+
username String?
|
|
26
|
+
password String?
|
|
27
|
+
note String?
|
|
28
|
+
|
|
29
|
+
bots Bot[]
|
|
30
|
+
|
|
31
|
+
createdAt DateTime @default(now())
|
|
32
|
+
updatedAt DateTime @updatedAt
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
model Bot {
|
|
20
36
|
id Int @id @default(autoincrement())
|
|
21
37
|
username String @unique
|
|
@@ -28,6 +44,9 @@ model Bot {
|
|
|
28
44
|
server Server @relation(fields: [serverId], references: [id])
|
|
29
45
|
serverId Int
|
|
30
46
|
|
|
47
|
+
proxy Proxy? @relation(fields: [proxyId], references: [id])
|
|
48
|
+
proxyId Int?
|
|
49
|
+
|
|
31
50
|
proxyHost String?
|
|
32
51
|
proxyPort Int?
|
|
33
52
|
proxyUsername String?
|
|
@@ -44,6 +63,7 @@ model Bot {
|
|
|
44
63
|
panelUserAccess PanelUserBotAccess[]
|
|
45
64
|
apiKeys BotApiKey[]
|
|
46
65
|
apiConnectionLogs ApiConnectionLog[]
|
|
66
|
+
executionTraces ExecutionTrace[]
|
|
47
67
|
|
|
48
68
|
createdAt DateTime @default(now())
|
|
49
69
|
updatedAt DateTime @updatedAt
|
|
@@ -107,6 +127,7 @@ model EventGraph {
|
|
|
107
127
|
variables String? @default("[]")
|
|
108
128
|
|
|
109
129
|
triggers EventTrigger[]
|
|
130
|
+
executionTraces ExecutionTrace[]
|
|
110
131
|
|
|
111
132
|
createdAt DateTime @default(now())
|
|
112
133
|
updatedAt DateTime @updatedAt
|
|
@@ -201,7 +222,7 @@ model PanelUser {
|
|
|
201
222
|
id Int @id @default(autoincrement())
|
|
202
223
|
uuid String @unique @default(uuid())
|
|
203
224
|
username String @unique
|
|
204
|
-
passwordHash String
|
|
225
|
+
passwordHash String
|
|
205
226
|
role PanelRole @relation(fields: [roleId], references: [id])
|
|
206
227
|
roleId Int
|
|
207
228
|
createdAt DateTime @default(now())
|
|
@@ -209,6 +230,7 @@ model PanelUser {
|
|
|
209
230
|
allBots Boolean @default(true)
|
|
210
231
|
|
|
211
232
|
botAccess PanelUserBotAccess[]
|
|
233
|
+
apiKeys PanelApiKey[]
|
|
212
234
|
}
|
|
213
235
|
|
|
214
236
|
// Роли пользователей (Admin, Moderator, Viewer)
|
|
@@ -231,6 +253,31 @@ model PanelUserBotAccess {
|
|
|
231
253
|
@@id([userId, botId])
|
|
232
254
|
}
|
|
233
255
|
|
|
256
|
+
// API ключи для панели (для доступа к REST API и управления ботами)
|
|
257
|
+
model PanelApiKey {
|
|
258
|
+
id Int @id @default(autoincrement())
|
|
259
|
+
userId Int
|
|
260
|
+
user PanelUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
261
|
+
|
|
262
|
+
name String // "My Production Key", "Development Key"
|
|
263
|
+
keyHash String // bcrypt hash полного ключа
|
|
264
|
+
prefix String // "pk_abc123" для отображения в UI (первые 10 символов)
|
|
265
|
+
|
|
266
|
+
// Если NULL - наследует все права пользователя
|
|
267
|
+
// Если задано - ограниченный набор прав (JSON массив)
|
|
268
|
+
customScopes String?
|
|
269
|
+
|
|
270
|
+
lastUsedAt DateTime?
|
|
271
|
+
expiresAt DateTime? // Опционально: срок действия ключа
|
|
272
|
+
isActive Boolean @default(true)
|
|
273
|
+
|
|
274
|
+
createdAt DateTime @default(now())
|
|
275
|
+
updatedAt DateTime @updatedAt
|
|
276
|
+
|
|
277
|
+
@@index([userId])
|
|
278
|
+
@@index([keyHash])
|
|
279
|
+
}
|
|
280
|
+
|
|
234
281
|
model PluginDataStore {
|
|
235
282
|
id Int @id @default(autoincrement())
|
|
236
283
|
pluginName String
|
|
@@ -275,3 +322,25 @@ model ApiConnectionLog {
|
|
|
275
322
|
|
|
276
323
|
@@index([botId, createdAt])
|
|
277
324
|
}
|
|
325
|
+
|
|
326
|
+
model ExecutionTrace {
|
|
327
|
+
id String @id @default(uuid())
|
|
328
|
+
graphId Int
|
|
329
|
+
botId Int
|
|
330
|
+
eventType String
|
|
331
|
+
eventArgs String // JSON
|
|
332
|
+
startTime DateTime
|
|
333
|
+
endTime DateTime?
|
|
334
|
+
status String // running, completed, error
|
|
335
|
+
error String?
|
|
336
|
+
steps String // JSON array of ExecutionStep
|
|
337
|
+
|
|
338
|
+
bot Bot @relation(fields: [botId], references: [id], onDelete: Cascade)
|
|
339
|
+
graph EventGraph @relation(fields: [graphId], references: [id], onDelete: Cascade)
|
|
340
|
+
|
|
341
|
+
createdAt DateTime @default(now())
|
|
342
|
+
|
|
343
|
+
@@index([botId, graphId])
|
|
344
|
+
@@index([createdAt])
|
|
345
|
+
@@map("execution_traces")
|
|
346
|
+
}
|
|
@@ -10,11 +10,16 @@ jest.mock('../../core/utils/crypto', () => ({
|
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
12
|
// Mock Socket.IO
|
|
13
|
+
const mockIO = {
|
|
14
|
+
emit: jest.fn(),
|
|
15
|
+
to: jest.fn().mockReturnValue({ emit: jest.fn() })
|
|
16
|
+
};
|
|
17
|
+
|
|
13
18
|
jest.mock('../../real-time/socketHandler', () => ({
|
|
14
|
-
getIO: jest.fn()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
getIO: jest.fn(() => mockIO),
|
|
20
|
+
getIOSafe: jest.fn(() => mockIO),
|
|
21
|
+
addPluginLogToBuffer: jest.fn(),
|
|
22
|
+
broadcastToPanelNamespace: jest.fn()
|
|
18
23
|
}));
|
|
19
24
|
|
|
20
25
|
jest.mock('../../real-time/botApi', () => ({
|