blockmine 1.24.0 → 1.27.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/CHANGELOG.md +76 -1
- package/README.en.md +427 -0
- package/README.md +40 -0
- package/backend/package.json +2 -2
- package/backend/prisma/migrations/20260328173000_add_plugin_source_ref/migration.sql +2 -0
- package/backend/prisma/migrations/migration_lock.toml +2 -2
- package/backend/prisma/schema.prisma +2 -0
- package/backend/src/ai/plugin-assistant-system-prompt.md +664 -5
- package/backend/src/api/routes/apiKeys.js +8 -0
- package/backend/src/api/routes/bots.js +271 -9
- package/backend/src/api/routes/eventGraphs.js +151 -1
- package/backend/src/api/routes/health.js +38 -0
- package/backend/src/api/routes/nodeRegistry.js +63 -0
- package/backend/src/api/routes/plugins.js +254 -29
- package/backend/src/api/routes/servers.js +14 -2
- package/backend/src/container.js +11 -8
- package/backend/src/core/BotCommandLoader.js +161 -0
- package/backend/src/core/BotConnection.js +125 -0
- package/backend/src/core/BotEventHandlers.js +234 -0
- package/backend/src/core/BotIPCHandler.js +445 -0
- package/backend/src/core/BotManager.js +15 -7
- package/backend/src/core/BotProcess.js +169 -140
- package/backend/src/core/EventGraphManager.js +7 -3
- package/backend/src/core/GraphDebugHandler.js +229 -0
- package/backend/src/core/GraphDebugIPC.js +117 -0
- package/backend/src/core/GraphExecutionEngine.js +545 -978
- package/backend/src/core/GraphTraversal.js +80 -0
- package/backend/src/core/GraphValidation.js +73 -0
- package/backend/src/core/NodeDefinition.js +138 -0
- package/backend/src/core/NodeRegistry.js +153 -141
- package/backend/src/core/PluginLoader.js +83 -3
- package/backend/src/core/PluginManager.js +346 -35
- package/backend/src/core/RewindSignal.js +9 -0
- package/backend/src/core/config/ConfigValidator.js +72 -0
- package/backend/src/core/config/FeatureFlags.js +52 -0
- package/backend/src/core/config/__tests__/ConfigValidator.test.js +232 -0
- package/backend/src/core/domain/entities/Bot.js +39 -0
- package/backend/src/core/domain/entities/Command.js +41 -0
- package/backend/src/core/domain/entities/EventGraph.js +39 -0
- package/backend/src/core/domain/entities/Plugin.js +45 -0
- package/backend/src/core/domain/entities/User.js +40 -0
- package/backend/src/core/domain/services/DependencyResolver.js +168 -0
- package/backend/src/core/domain/services/GraphValidator.js +117 -0
- package/backend/src/core/domain/services/PermissionChecker.js +34 -0
- package/backend/src/core/domain/services/__tests__/DependencyResolver.test.js +126 -0
- package/backend/src/core/domain/valueObjects/BotConfig.js +27 -0
- package/backend/src/core/domain/valueObjects/DependencyGraph.js +86 -0
- package/backend/src/core/domain/valueObjects/PluginManifest.js +36 -0
- package/backend/src/core/errors/BaseError.js +29 -0
- package/backend/src/core/errors/ErrorHandler.js +81 -0
- package/backend/src/core/errors/__tests__/ErrorHandler.test.js +188 -0
- package/backend/src/core/errors/index.js +68 -0
- package/backend/src/core/infrastructure/BatchingUtility.js +66 -0
- package/backend/src/core/infrastructure/CircuitBreaker.js +103 -0
- package/backend/src/core/infrastructure/ConnectionPool.js +81 -0
- package/backend/src/core/infrastructure/RateLimiter.js +64 -0
- package/backend/src/core/infrastructure/__tests__/BatchingUtility.test.js +86 -0
- package/backend/src/core/infrastructure/__tests__/CircuitBreaker.test.js +156 -0
- package/backend/src/core/infrastructure/__tests__/ConnectionPool.test.js +146 -0
- package/backend/src/core/infrastructure/__tests__/RateLimiter.test.js +171 -0
- package/backend/src/core/ipc/botApiFactory.js +72 -0
- package/backend/src/core/ipc/ipcMessageTypes.js +115 -0
- package/backend/src/core/logging/AuditLogger.js +61 -0
- package/backend/src/core/logging/StructuredLogger.js +80 -0
- package/backend/src/core/logging/__tests__/StructuredLogger.test.js +213 -0
- package/backend/src/core/logging/index.js +7 -0
- package/backend/src/core/metrics/MetricsCollector.js +104 -0
- package/backend/src/core/metrics/__tests__/MetricsCollector.test.js +131 -0
- package/backend/src/core/node-registries/actionsNodes.js +191 -0
- package/backend/src/core/node-registries/arraysNodes.js +152 -0
- package/backend/src/core/node-registries/botNodes.js +48 -0
- package/backend/src/core/node-registries/containerNodes.js +141 -0
- package/backend/src/core/node-registries/dataNodes.js +284 -0
- package/backend/src/core/node-registries/debugNodes.js +23 -0
- package/backend/src/core/node-registries/eventsNodes.js +223 -0
- package/backend/src/core/node-registries/flowNodes.js +151 -0
- package/backend/src/core/node-registries/furnaceNodes.js +123 -0
- package/backend/src/core/node-registries/index.js +108 -0
- package/backend/src/core/node-registries/inventory.js +102 -106
- package/backend/src/core/node-registries/logicNodes.js +54 -0
- package/backend/src/core/node-registries/mathNodes.js +38 -0
- package/backend/src/core/node-registries/navigationNodes.js +109 -0
- package/backend/src/core/node-registries/objectsNodes.js +90 -0
- package/backend/src/core/node-registries/stringsNodes.js +165 -0
- package/backend/src/core/node-registries/timeNodes.js +105 -0
- package/backend/src/core/node-registries/typeNodes.js +22 -0
- package/backend/src/core/node-registries/usersNodes.js +126 -0
- package/backend/src/core/nodes/arrays/shuffle.js +14 -0
- package/backend/src/core/nodes/bot/get_name.js +8 -0
- package/backend/src/core/nodes/bot/stop_bot.js +5 -0
- package/backend/src/core/nodes/container/open.js +101 -111
- package/backend/src/core/nodes/data/store_read.js +26 -0
- package/backend/src/core/nodes/data/store_write.js +23 -0
- package/backend/src/core/nodes/event/call_event.js +31 -0
- package/backend/src/core/nodes/event/custom_event.js +8 -0
- package/backend/src/core/nodes/flow/timer.js +35 -0
- package/backend/src/core/nodes/inventory/drop.js +73 -65
- package/backend/src/core/nodes/inventory/equip.js +54 -45
- package/backend/src/core/nodes/inventory/select_slot.js +48 -46
- package/backend/src/core/nodes/navigation/follow.js +54 -51
- package/backend/src/core/nodes/navigation/go_to.js +41 -53
- package/backend/src/core/nodes/navigation/go_to_entity.js +65 -69
- package/backend/src/core/nodes/navigation/go_to_player.js +65 -70
- package/backend/src/core/nodes/navigation/stop.js +17 -26
- package/backend/src/core/nodes/users/add_to_group.js +24 -0
- package/backend/src/core/nodes/users/check_permission.js +26 -0
- package/backend/src/core/nodes/users/remove_from_group.js +24 -0
- package/backend/src/core/services/BotIPCMessageRouter.js +337 -0
- package/backend/src/core/services/BotLifecycleService.js +43 -450
- package/backend/src/core/services/CacheManager.js +83 -23
- package/backend/src/core/services/CrashRestartManager.js +42 -0
- package/backend/src/core/services/DebugSessionManager.js +114 -12
- package/backend/src/core/services/EventGraphService.js +69 -0
- package/backend/src/core/services/MinecraftBotManager.js +9 -1
- package/backend/src/core/services/PluginManagementService.js +84 -0
- package/backend/src/core/services/TestModeContext.js +65 -0
- package/backend/src/core/services/__tests__/CacheManager.test.js +168 -0
- package/backend/src/core/services.js +1 -11
- package/backend/src/core/validation/InputValidator.js +167 -0
- package/backend/src/core/validation/__tests__/InputValidator.test.js +296 -0
- package/backend/src/real-time/botApi/index.js +1 -1
- package/backend/src/real-time/socketHandler.js +26 -0
- package/backend/src/server.js +21 -6
- package/frontend/dist/assets/browser-ponyfill-D8y0Ty7C.js +2 -0
- package/frontend/dist/assets/index-CFJLS0dk.css +32 -0
- package/frontend/dist/assets/index-D91UGNMG.js +11260 -0
- package/frontend/dist/flags/en.svg +32 -0
- package/frontend/dist/flags/ru.svg +5 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/locales/en/admin.json +100 -0
- package/frontend/dist/locales/en/api-keys.json +58 -0
- package/frontend/dist/locales/en/bots.json +113 -0
- package/frontend/dist/locales/en/common.json +53 -0
- package/frontend/dist/locales/en/configuration.json +22 -0
- package/frontend/dist/locales/en/console.json +10 -0
- package/frontend/dist/locales/en/dashboard.json +85 -0
- package/frontend/dist/locales/en/dialogs.json +70 -0
- package/frontend/dist/locales/en/event-graphs.json +50 -0
- package/frontend/dist/locales/en/graph-store.json +70 -0
- package/frontend/dist/locales/en/login.json +36 -0
- package/frontend/dist/locales/en/management.json +192 -0
- package/frontend/dist/locales/en/minecraft-viewer.json +27 -0
- package/frontend/dist/locales/en/nodes.json +1132 -0
- package/frontend/dist/locales/en/permissions.json +50 -0
- package/frontend/dist/locales/en/plugin-detail.json +69 -0
- package/frontend/dist/locales/en/plugins.json +329 -0
- package/frontend/dist/locales/en/proxies.json +81 -0
- package/frontend/dist/locales/en/servers.json +39 -0
- package/frontend/dist/locales/en/setup.json +19 -0
- package/frontend/dist/locales/en/sidebar.json +195 -0
- package/frontend/dist/locales/en/tasks.json +62 -0
- package/frontend/dist/locales/en/visual-editor.json +418 -0
- package/frontend/dist/locales/en/websocket.json +86 -0
- package/frontend/dist/locales/ru/admin.json +100 -0
- package/frontend/dist/locales/ru/api-keys.json +58 -0
- package/frontend/dist/locales/ru/bots.json +113 -0
- package/frontend/dist/locales/ru/common.json +49 -0
- package/frontend/dist/locales/ru/configuration.json +22 -0
- package/frontend/dist/locales/ru/console.json +10 -0
- package/frontend/dist/locales/ru/dashboard.json +85 -0
- package/frontend/dist/locales/ru/dialogs.json +70 -0
- package/frontend/dist/locales/ru/event-graphs.json +50 -0
- package/frontend/dist/locales/ru/graph-store.json +70 -0
- package/frontend/dist/locales/ru/login.json +36 -0
- package/frontend/dist/locales/ru/management.json +192 -0
- package/frontend/dist/locales/ru/minecraft-viewer.json +30 -0
- package/frontend/dist/locales/ru/nodes.json +1131 -0
- package/frontend/dist/locales/ru/permissions.json +50 -0
- package/frontend/dist/locales/ru/plugin-detail.json +49 -0
- package/frontend/dist/locales/ru/plugins.json +209 -0
- package/frontend/dist/locales/ru/proxies.json +81 -0
- package/frontend/dist/locales/ru/servers.json +39 -0
- package/frontend/dist/locales/ru/setup.json +19 -0
- package/frontend/dist/locales/ru/sidebar.json +195 -0
- package/frontend/dist/locales/ru/tasks.json +62 -0
- package/frontend/dist/locales/ru/visual-editor.json +420 -0
- package/frontend/dist/locales/ru/websocket.json +86 -0
- package/frontend/dist/monacoeditorwork/css.worker.bundle.js +7 -7
- package/frontend/dist/monacoeditorwork/html.worker.bundle.js +7 -7
- package/frontend/dist/monacoeditorwork/json.worker.bundle.js +7 -7
- package/frontend/dist/monacoeditorwork/ts.worker.bundle.js +3 -3
- package/frontend/package.json +6 -0
- package/nul +12 -0
- package/package.json +3 -3
- package/screen/3dviewer.png +0 -0
- 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/language_selector.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/.claude/agents/README.md +0 -469
- package/.claude/agents/auth-route-debugger.md +0 -118
- package/.claude/agents/auth-route-tester.md +0 -93
- package/.claude/agents/auto-error-resolver.md +0 -97
- package/.claude/agents/build-optimizer.md +0 -236
- package/.claude/agents/code-architect.md +0 -34
- package/.claude/agents/code-architecture-reviewer.md +0 -83
- package/.claude/agents/code-explorer.md +0 -51
- package/.claude/agents/code-refactor-master.md +0 -94
- package/.claude/agents/code-reviewer.md +0 -46
- package/.claude/agents/cost-optimizer.md +0 -134
- package/.claude/agents/deployment-orchestrator.md +0 -113
- package/.claude/agents/documentation-architect.md +0 -82
- package/.claude/agents/frontend-error-fixer.md +0 -77
- package/.claude/agents/iac-code-generator.md +0 -71
- package/.claude/agents/incident-responder.md +0 -346
- package/.claude/agents/infrastructure-architect.md +0 -31
- package/.claude/agents/kubernetes-specialist.md +0 -56
- package/.claude/agents/migration-planner.md +0 -181
- package/.claude/agents/network-architect.md +0 -196
- package/.claude/agents/plan-reviewer.md +0 -52
- package/.claude/agents/refactor-planner.md +0 -63
- package/.claude/agents/security-scanner.md +0 -102
- package/.claude/agents/web-research-specialist.md +0 -78
- package/.claude/commands/cost-analysis.md +0 -315
- package/.claude/commands/dev-docs-update.md +0 -55
- package/.claude/commands/dev-docs.md +0 -51
- package/.claude/commands/feature-dev.md +0 -125
- package/.claude/commands/incident-debug.md +0 -247
- package/.claude/commands/infra-plan.md +0 -81
- package/.claude/commands/migration-plan.md +0 -478
- package/.claude/commands/route-research-for-testing.md +0 -37
- package/.claude/commands/security-review.md +0 -66
- package/.claude/hooks/CONFIG.md +0 -448
- package/.claude/hooks/README.md +0 -163
- package/.claude/hooks/SKILL_ACTIVATION_COMPLETE.md +0 -226
- package/.claude/hooks/WINDOWS_HOOKS_README.md +0 -151
- package/.claude/hooks/add-skill-activation-banners.ts +0 -132
- package/.claude/hooks/comprehensive-skill-test.ts +0 -1315
- package/.claude/hooks/error-handling-reminder.sh +0 -12
- package/.claude/hooks/error-handling-reminder.ts +0 -222
- package/.claude/hooks/k8s-manifest-validator.sh +0 -56
- package/.claude/hooks/package-lock.json +0 -556
- package/.claude/hooks/package.json +0 -16
- package/.claude/hooks/post-tool-use-tracker.ps1 +0 -174
- package/.claude/hooks/post-tool-use-tracker.sh +0 -183
- package/.claude/hooks/security-policy-check.sh +0 -247
- package/.claude/hooks/skill-activation-prompt.ps1 +0 -10
- package/.claude/hooks/skill-activation-prompt.sh +0 -10
- package/.claude/hooks/skill-activation-prompt.ts +0 -141
- package/.claude/hooks/stop-build-check-enhanced.sh +0 -130
- package/.claude/hooks/terraform-validator.sh +0 -53
- package/.claude/hooks/test-input.json +0 -7
- package/.claude/hooks/test-skill-activation.ts +0 -427
- package/.claude/hooks/trigger-build-resolver.sh +0 -79
- package/.claude/hooks/tsc-check.sh +0 -173
- package/.claude/hooks/tsconfig.json +0 -19
- package/.claude/settings.json +0 -59
- package/.claude/settings.local.json +0 -67
- package/.claude/skills/README.md +0 -507
- package/.claude/skills/api-engineering/SKILL.md +0 -63
- package/.claude/skills/api-engineering/resources/api-versioning.md +0 -88
- package/.claude/skills/api-engineering/resources/graphql-patterns.md +0 -106
- package/.claude/skills/api-engineering/resources/rate-limiting.md +0 -118
- package/.claude/skills/api-engineering/resources/rest-api-design.md +0 -105
- package/.claude/skills/backend-dev-guidelines/SKILL.md +0 -306
- package/.claude/skills/backend-dev-guidelines/resources/architecture-overview.md +0 -451
- package/.claude/skills/backend-dev-guidelines/resources/async-and-errors.md +0 -307
- package/.claude/skills/backend-dev-guidelines/resources/complete-examples.md +0 -638
- package/.claude/skills/backend-dev-guidelines/resources/configuration.md +0 -275
- package/.claude/skills/backend-dev-guidelines/resources/database-patterns.md +0 -224
- package/.claude/skills/backend-dev-guidelines/resources/middleware-guide.md +0 -213
- package/.claude/skills/backend-dev-guidelines/resources/routing-and-controllers.md +0 -756
- package/.claude/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +0 -336
- package/.claude/skills/backend-dev-guidelines/resources/services-and-repositories.md +0 -789
- package/.claude/skills/backend-dev-guidelines/resources/testing-guide.md +0 -235
- package/.claude/skills/backend-dev-guidelines/resources/validation-patterns.md +0 -754
- package/.claude/skills/budget-and-cost-management/SKILL.md +0 -850
- package/.claude/skills/build-engineering/SKILL.md +0 -431
- package/.claude/skills/build-engineering/resources/artifact-repositories.md +0 -72
- package/.claude/skills/build-engineering/resources/build-caching.md +0 -96
- package/.claude/skills/build-engineering/resources/build-pipelines.md +0 -105
- package/.claude/skills/build-engineering/resources/build-security.md +0 -95
- package/.claude/skills/build-engineering/resources/build-systems.md +0 -389
- package/.claude/skills/build-engineering/resources/compilation-optimization.md +0 -201
- package/.claude/skills/build-engineering/resources/dependency-management.md +0 -73
- package/.claude/skills/build-engineering/resources/monorepo-builds.md +0 -110
- package/.claude/skills/build-engineering/resources/performance-optimization.md +0 -113
- package/.claude/skills/build-engineering/resources/reproducible-builds.md +0 -82
- package/.claude/skills/cloud-engineering/SKILL.md +0 -675
- package/.claude/skills/cloud-engineering/resources/aws-patterns.md +0 -742
- package/.claude/skills/cloud-engineering/resources/azure-patterns.md +0 -714
- package/.claude/skills/cloud-engineering/resources/cleared-cloud-environments.md +0 -987
- package/.claude/skills/cloud-engineering/resources/cloud-cost-optimization.md +0 -757
- package/.claude/skills/cloud-engineering/resources/cloud-networking.md +0 -1058
- package/.claude/skills/cloud-engineering/resources/cloud-security-tools.md +0 -1530
- package/.claude/skills/cloud-engineering/resources/cloud-security.md +0 -990
- package/.claude/skills/cloud-engineering/resources/gcp-patterns.md +0 -758
- package/.claude/skills/cloud-engineering/resources/migration-strategies.md +0 -820
- package/.claude/skills/cloud-engineering/resources/multi-cloud-strategies.md +0 -670
- package/.claude/skills/cloud-engineering/resources/oci-patterns.md +0 -1198
- package/.claude/skills/cloud-engineering/resources/serverless-patterns.md +0 -795
- package/.claude/skills/cloud-engineering/resources/well-architected-frameworks.md +0 -966
- package/.claude/skills/cybersecurity/SKILL.md +0 -409
- package/.claude/skills/cybersecurity/resources/security-architecture.md +0 -266
- package/.claude/skills/database-engineering/SKILL.md +0 -61
- package/.claude/skills/database-engineering/resources/backup-and-recovery.md +0 -72
- package/.claude/skills/database-engineering/resources/database-replication.md +0 -63
- package/.claude/skills/database-engineering/resources/postgresql-fundamentals.md +0 -70
- package/.claude/skills/database-engineering/resources/query-optimization.md +0 -68
- package/.claude/skills/devsecops/SKILL.md +0 -374
- package/.claude/skills/devsecops/resources/ci-cd-security.md +0 -204
- package/.claude/skills/devsecops/resources/compliance-automation.md +0 -530
- package/.claude/skills/devsecops/resources/compliance-frameworks.md +0 -2322
- package/.claude/skills/devsecops/resources/container-security.md +0 -915
- package/.claude/skills/devsecops/resources/cspm-integration.md +0 -1440
- package/.claude/skills/devsecops/resources/policy-enforcement.md +0 -619
- package/.claude/skills/devsecops/resources/secrets-management.md +0 -755
- package/.claude/skills/devsecops/resources/security-monitoring.md +0 -146
- package/.claude/skills/devsecops/resources/security-scanning.md +0 -887
- package/.claude/skills/devsecops/resources/security-testing.md +0 -203
- package/.claude/skills/devsecops/resources/supply-chain-security.md +0 -518
- package/.claude/skills/devsecops/resources/vulnerability-management.md +0 -481
- package/.claude/skills/devsecops/resources/zero-trust-architecture.md +0 -177
- package/.claude/skills/documentation-as-code/SKILL.md +0 -323
- package/.claude/skills/documentation-as-code/resources/api-documentation.md +0 -90
- package/.claude/skills/documentation-as-code/resources/changelog-management.md +0 -79
- package/.claude/skills/documentation-as-code/resources/diagram-generation.md +0 -44
- package/.claude/skills/documentation-as-code/resources/docs-as-code-workflow.md +0 -99
- package/.claude/skills/documentation-as-code/resources/documentation-automation.md +0 -68
- package/.claude/skills/documentation-as-code/resources/documentation-sites.md +0 -79
- package/.claude/skills/documentation-as-code/resources/markdown-best-practices.md +0 -162
- package/.claude/skills/documentation-as-code/resources/openapi-specification.md +0 -77
- package/.claude/skills/documentation-as-code/resources/readme-engineering.md +0 -60
- package/.claude/skills/documentation-as-code/resources/technical-writing-guide.md +0 -202
- package/.claude/skills/engineering-management/SKILL.md +0 -356
- package/.claude/skills/engineering-management/resources/career-ladders.md +0 -609
- package/.claude/skills/engineering-management/resources/hiring-and-assessment.md +0 -555
- package/.claude/skills/engineering-management/resources/one-on-one-guides.md +0 -609
- package/.claude/skills/engineering-management/resources/resource-planning.md +0 -557
- package/.claude/skills/engineering-management/resources/team-organization-patterns.md +0 -491
- package/.claude/skills/engineering-management/resources/technical-interviews.md +0 -474
- package/.claude/skills/engineering-operations-management/SKILL.md +0 -817
- package/.claude/skills/error-tracking/SKILL.md +0 -379
- package/.claude/skills/frontend-design/SKILL.md +0 -42
- package/.claude/skills/frontend-dev-guidelines/SKILL.md +0 -403
- package/.claude/skills/frontend-dev-guidelines/resources/common-patterns.md +0 -331
- package/.claude/skills/frontend-dev-guidelines/resources/complete-examples.md +0 -872
- package/.claude/skills/frontend-dev-guidelines/resources/component-patterns.md +0 -502
- package/.claude/skills/frontend-dev-guidelines/resources/data-fetching.md +0 -767
- package/.claude/skills/frontend-dev-guidelines/resources/file-organization.md +0 -502
- package/.claude/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +0 -501
- package/.claude/skills/frontend-dev-guidelines/resources/performance.md +0 -406
- package/.claude/skills/frontend-dev-guidelines/resources/routing-guide.md +0 -364
- package/.claude/skills/frontend-dev-guidelines/resources/styling-guide.md +0 -428
- package/.claude/skills/frontend-dev-guidelines/resources/typescript-standards.md +0 -418
- package/.claude/skills/general-it-engineering/SKILL.md +0 -393
- package/.claude/skills/general-it-engineering/resources/asset-management.md +0 -712
- package/.claude/skills/general-it-engineering/resources/automation-orchestration.md +0 -817
- package/.claude/skills/general-it-engineering/resources/business-continuity.md +0 -786
- package/.claude/skills/general-it-engineering/resources/change-management.md +0 -715
- package/.claude/skills/general-it-engineering/resources/enterprise-monitoring.md +0 -729
- package/.claude/skills/general-it-engineering/resources/help-desk-operations.md +0 -738
- package/.claude/skills/general-it-engineering/resources/incident-service-management.md +0 -834
- package/.claude/skills/general-it-engineering/resources/it-governance.md +0 -753
- package/.claude/skills/general-it-engineering/resources/itil-framework.md +0 -503
- package/.claude/skills/general-it-engineering/resources/service-management.md +0 -669
- package/.claude/skills/infrastructure-architecture/SKILL.md +0 -328
- package/.claude/skills/infrastructure-architecture/resources/architecture-decision-records.md +0 -505
- package/.claude/skills/infrastructure-architecture/resources/architecture-patterns.md +0 -528
- package/.claude/skills/infrastructure-architecture/resources/capacity-planning.md +0 -453
- package/.claude/skills/infrastructure-architecture/resources/cleared-environment-architecture.md +0 -773
- package/.claude/skills/infrastructure-architecture/resources/cost-architecture.md +0 -499
- package/.claude/skills/infrastructure-architecture/resources/data-architecture.md +0 -501
- package/.claude/skills/infrastructure-architecture/resources/disaster-recovery.md +0 -535
- package/.claude/skills/infrastructure-architecture/resources/migration-architecture.md +0 -512
- package/.claude/skills/infrastructure-architecture/resources/multi-region-design.md +0 -608
- package/.claude/skills/infrastructure-architecture/resources/reference-architectures.md +0 -562
- package/.claude/skills/infrastructure-architecture/resources/security-architecture.md +0 -538
- package/.claude/skills/infrastructure-architecture/resources/system-design-principles.md +0 -489
- package/.claude/skills/infrastructure-architecture/resources/workload-classification.md +0 -1000
- package/.claude/skills/infrastructure-strategy/SKILL.md +0 -924
- package/.claude/skills/network-engineering/SKILL.md +0 -385
- package/.claude/skills/network-engineering/resources/dns-management.md +0 -738
- package/.claude/skills/network-engineering/resources/load-balancing.md +0 -820
- package/.claude/skills/network-engineering/resources/network-architecture.md +0 -546
- package/.claude/skills/network-engineering/resources/network-security.md +0 -921
- package/.claude/skills/network-engineering/resources/network-troubleshooting.md +0 -749
- package/.claude/skills/network-engineering/resources/routing-switching.md +0 -373
- package/.claude/skills/network-engineering/resources/sdn-networking.md +0 -695
- package/.claude/skills/network-engineering/resources/service-mesh-networking.md +0 -777
- package/.claude/skills/network-engineering/resources/tcp-ip-protocols.md +0 -444
- package/.claude/skills/network-engineering/resources/vpn-connectivity.md +0 -672
- package/.claude/skills/node-development/SKILL.md +0 -317
- package/.claude/skills/observability-engineering/SKILL.md +0 -101
- package/.claude/skills/observability-engineering/resources/apm-tools.md +0 -97
- package/.claude/skills/observability-engineering/resources/correlation-strategies.md +0 -87
- package/.claude/skills/observability-engineering/resources/distributed-tracing.md +0 -98
- package/.claude/skills/observability-engineering/resources/logs-aggregation.md +0 -118
- package/.claude/skills/observability-engineering/resources/observability-cost-optimization.md +0 -141
- package/.claude/skills/observability-engineering/resources/opentelemetry.md +0 -110
- package/.claude/skills/platform-engineering/SKILL.md +0 -555
- package/.claude/skills/platform-engineering/resources/architecture-overview.md +0 -600
- package/.claude/skills/platform-engineering/resources/container-orchestration.md +0 -916
- package/.claude/skills/platform-engineering/resources/cost-optimization.md +0 -634
- package/.claude/skills/platform-engineering/resources/developer-platforms.md +0 -670
- package/.claude/skills/platform-engineering/resources/gitops-automation.md +0 -650
- package/.claude/skills/platform-engineering/resources/infrastructure-as-code.md +0 -778
- package/.claude/skills/platform-engineering/resources/infrastructure-standards.md +0 -708
- package/.claude/skills/platform-engineering/resources/multi-tenancy.md +0 -602
- package/.claude/skills/platform-engineering/resources/platform-security.md +0 -711
- package/.claude/skills/platform-engineering/resources/resource-management.md +0 -592
- package/.claude/skills/platform-engineering/resources/service-mesh.md +0 -628
- package/.claude/skills/release-engineering/SKILL.md +0 -393
- package/.claude/skills/release-engineering/resources/artifact-management.md +0 -108
- package/.claude/skills/release-engineering/resources/build-optimization.md +0 -84
- package/.claude/skills/release-engineering/resources/ci-cd-pipelines.md +0 -411
- package/.claude/skills/release-engineering/resources/deployment-strategies.md +0 -197
- package/.claude/skills/release-engineering/resources/pipeline-security.md +0 -62
- package/.claude/skills/release-engineering/resources/progressive-delivery.md +0 -83
- package/.claude/skills/release-engineering/resources/release-automation.md +0 -68
- package/.claude/skills/release-engineering/resources/release-orchestration.md +0 -77
- package/.claude/skills/release-engineering/resources/rollback-strategies.md +0 -66
- package/.claude/skills/release-engineering/resources/versioning-strategies.md +0 -59
- package/.claude/skills/route-tester/SKILL.md +0 -392
- package/.claude/skills/skill-developer/ADVANCED.md +0 -197
- package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
- package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
- package/.claude/skills/skill-developer/SKILL.md +0 -430
- package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
- package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
- package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
- package/.claude/skills/skill-rules.json +0 -2989
- package/.claude/skills/sre/SKILL.md +0 -464
- package/.claude/skills/sre/resources/alerting-best-practices.md +0 -282
- package/.claude/skills/sre/resources/capacity-planning.md +0 -226
- package/.claude/skills/sre/resources/chaos-engineering.md +0 -193
- package/.claude/skills/sre/resources/disaster-recovery.md +0 -232
- package/.claude/skills/sre/resources/incident-management.md +0 -436
- package/.claude/skills/sre/resources/observability-stack.md +0 -240
- package/.claude/skills/sre/resources/on-call-runbooks.md +0 -167
- package/.claude/skills/sre/resources/performance-optimization.md +0 -108
- package/.claude/skills/sre/resources/reliability-patterns.md +0 -183
- package/.claude/skills/sre/resources/slo-sli-sla.md +0 -464
- package/.claude/skills/sre/resources/toil-reduction.md +0 -145
- package/.claude/skills/systems-engineering/SKILL.md +0 -648
- package/.claude/skills/systems-engineering/resources/automation-patterns.md +0 -771
- package/.claude/skills/systems-engineering/resources/configuration-management.md +0 -998
- package/.claude/skills/systems-engineering/resources/linux-administration.md +0 -672
- package/.claude/skills/systems-engineering/resources/networking-fundamentals.md +0 -982
- package/.claude/skills/systems-engineering/resources/performance-tuning.md +0 -871
- package/.claude/skills/systems-engineering/resources/powershell-scripting.md +0 -482
- package/.claude/skills/systems-engineering/resources/security-hardening.md +0 -739
- package/.claude/skills/systems-engineering/resources/shell-scripting.md +0 -915
- package/.claude/skills/systems-engineering/resources/storage-management.md +0 -628
- package/.claude/skills/systems-engineering/resources/system-monitoring.md +0 -787
- package/.claude/skills/systems-engineering/resources/troubleshooting-guide.md +0 -753
- package/.claude/skills/systems-engineering/resources/windows-administration.md +0 -738
- package/.claude/skills/technical-leadership/SKILL.md +0 -728
- package/backend/docs/SECRETS_DOCUMENTATION.md +0 -327
- package/backend/package-lock.json +0 -6801
- package/backend/src/core/node-registries/actions.js +0 -202
- package/backend/src/core/node-registries/arrays.js +0 -155
- package/backend/src/core/node-registries/bot.js +0 -23
- package/backend/src/core/node-registries/container.js +0 -162
- package/backend/src/core/node-registries/data.js +0 -290
- package/backend/src/core/node-registries/debug.js +0 -26
- package/backend/src/core/node-registries/events.js +0 -201
- package/backend/src/core/node-registries/flow.js +0 -139
- package/backend/src/core/node-registries/furnace.js +0 -143
- package/backend/src/core/node-registries/logic.js +0 -62
- package/backend/src/core/node-registries/math.js +0 -42
- package/backend/src/core/node-registries/navigation.js +0 -111
- package/backend/src/core/node-registries/objects.js +0 -98
- package/backend/src/core/node-registries/strings.js +0 -187
- package/backend/src/core/node-registries/time.js +0 -113
- package/backend/src/core/node-registries/type.js +0 -25
- package/backend/src/core/node-registries/users.js +0 -79
- package/frontend/dist/assets/index-BC-NbKXi.css +0 -32
- package/frontend/dist/assets/index-DqJXZMHY.js +0 -11266
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
const { MessageTypes } = require('./ipc/ipcMessageTypes');
|
|
2
|
+
const { Vec3 } = require('vec3');
|
|
3
|
+
const { v4: uuidv4 } = require('uuid');
|
|
4
|
+
const { parseArguments } = require('./system/parseArguments');
|
|
5
|
+
const { getRuntimeCommandRegistry } = require('./system/RuntimeCommandRegistry');
|
|
6
|
+
const Transport = require('./system/Transport');
|
|
7
|
+
const CommandContext = require('./system/CommandContext');
|
|
8
|
+
const UserService = require('./UserService');
|
|
9
|
+
const GraphExecutionEngine = require('./GraphExecutionEngine');
|
|
10
|
+
const NodeRegistry = require('./NodeRegistry');
|
|
11
|
+
const Command = require('./system/Command');
|
|
12
|
+
|
|
13
|
+
let viewerRenderDistance = 24;
|
|
14
|
+
|
|
15
|
+
function createSendLog() {
|
|
16
|
+
return process.send
|
|
17
|
+
? (content) => process.send({ type: MessageTypes.BOT.LOG, content })
|
|
18
|
+
: (content) => console.log(`[ChildProcess Log] ${content}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function handleIncomingCommand(bot, type, username, message, sendLog) {
|
|
22
|
+
const log = sendLog || createSendLog();
|
|
23
|
+
|
|
24
|
+
if (!message.startsWith(bot.config.prefix || '@')) return;
|
|
25
|
+
|
|
26
|
+
const rawMessage = message.slice((bot.config.prefix || '@').length).trim();
|
|
27
|
+
const commandParts = rawMessage.split(/ +/);
|
|
28
|
+
const commandName = commandParts.shift().toLowerCase();
|
|
29
|
+
const restOfMessage = commandParts.join(' ');
|
|
30
|
+
|
|
31
|
+
let commandInstance = bot.commands.get(commandName) ||
|
|
32
|
+
Array.from(bot.commands.values()).find(cmd => cmd.aliases.includes(commandName));
|
|
33
|
+
|
|
34
|
+
if (!commandInstance) {
|
|
35
|
+
const runtimeRegistry = getRuntimeCommandRegistry();
|
|
36
|
+
commandInstance = runtimeRegistry.get(bot.config.id, commandName);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!commandInstance) return;
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const processedArgs = {};
|
|
43
|
+
const parsedArgs = parseArguments(restOfMessage);
|
|
44
|
+
let currentArgIndex = 0;
|
|
45
|
+
|
|
46
|
+
const argsDef = commandInstance.isVisual && commandInstance.args ? commandInstance.args : (commandInstance.args || []);
|
|
47
|
+
for (const argDef of argsDef) {
|
|
48
|
+
if (argDef.type === 'greedy_string') {
|
|
49
|
+
if (currentArgIndex < parsedArgs.length) {
|
|
50
|
+
processedArgs[argDef.name] = parsedArgs.slice(currentArgIndex).join(' ');
|
|
51
|
+
currentArgIndex = parsedArgs.length;
|
|
52
|
+
}
|
|
53
|
+
} else if (currentArgIndex < parsedArgs.length) {
|
|
54
|
+
let value = parsedArgs[currentArgIndex];
|
|
55
|
+
if (argDef.type === 'number') {
|
|
56
|
+
const numValue = parseFloat(value);
|
|
57
|
+
if (isNaN(numValue)) {
|
|
58
|
+
bot.api.sendMessage(type, `Ошибка: Аргумент "${argDef.description}" должен быть числом.`, username);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
value = numValue;
|
|
62
|
+
}
|
|
63
|
+
processedArgs[argDef.name] = value;
|
|
64
|
+
currentArgIndex++;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (processedArgs[argDef.name] === undefined) {
|
|
68
|
+
if (argDef.default !== undefined) {
|
|
69
|
+
processedArgs[argDef.name] = argDef.default;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (process.send) {
|
|
75
|
+
process.send({
|
|
76
|
+
type: MessageTypes.COMMAND.VALIDATE_AND_RUN,
|
|
77
|
+
commandName: commandInstance.name,
|
|
78
|
+
username,
|
|
79
|
+
args: processedArgs,
|
|
80
|
+
typeChat: type,
|
|
81
|
+
commandArgs: argsDef
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
} catch (e) {
|
|
85
|
+
log(`[BotProcess] Ошибка парсинга аргументов: ${e.message}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function createBotIPCHandler(bot, prisma, pluginUiState, pendingRequests, sendLog, sendEvent, serializeEntity) {
|
|
90
|
+
const handlers = {};
|
|
91
|
+
|
|
92
|
+
handlers[MessageTypes.BOT.START] = async (message) => {
|
|
93
|
+
const config = message.config;
|
|
94
|
+
sendLog(`[System] Получена команда на запуск бота ${config.username}...`);
|
|
95
|
+
return { config };
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
handlers[MessageTypes.SYSTEM.GET_PLAYER_LIST] = (message) => {
|
|
99
|
+
const playerList = bot ? Object.keys(bot.players) : [];
|
|
100
|
+
return { requestId: message.requestId, players: playerList };
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
handlers[MessageTypes.SYSTEM.GET_NEARBY_ENTITIES] = (message) => {
|
|
104
|
+
const entities = [];
|
|
105
|
+
if (bot && bot.entities) {
|
|
106
|
+
const centerPos = message.payload?.position || bot.entity?.position;
|
|
107
|
+
const radius = message.payload?.radius || 32;
|
|
108
|
+
|
|
109
|
+
if (centerPos) {
|
|
110
|
+
for (const entity of Object.values(bot.entities)) {
|
|
111
|
+
if (entity && entity.position && entity.isValid) {
|
|
112
|
+
const dx = entity.position.x - centerPos.x;
|
|
113
|
+
const dy = entity.position.y - centerPos.y;
|
|
114
|
+
const dz = entity.position.z - centerPos.z;
|
|
115
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
116
|
+
|
|
117
|
+
if (distance <= radius) {
|
|
118
|
+
entities.push(serializeEntity(entity));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { requestId: message.requestId, entities };
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
handlers[MessageTypes.VIEWER.GET_STATE] = (message) => {
|
|
128
|
+
if (!bot || !process.send) return null;
|
|
129
|
+
|
|
130
|
+
let blocks = undefined;
|
|
131
|
+
if (message.includeBlocks && bot.entity?.position) {
|
|
132
|
+
blocks = [];
|
|
133
|
+
const pos = bot.entity.position;
|
|
134
|
+
|
|
135
|
+
for (let x = Math.floor(pos.x - viewerRenderDistance); x <= Math.floor(pos.x + viewerRenderDistance); x++) {
|
|
136
|
+
for (let y = Math.floor(pos.y - viewerRenderDistance / 2); y <= Math.floor(pos.y + viewerRenderDistance); y++) {
|
|
137
|
+
for (let z = Math.floor(pos.z - viewerRenderDistance); z <= Math.floor(pos.z + viewerRenderDistance); z++) {
|
|
138
|
+
const block = bot.blockAt(new Vec3(x, y, z));
|
|
139
|
+
if (block && block.type !== 0) {
|
|
140
|
+
blocks.push({ x, y, z, type: block.type, name: block.name });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
requestId: message.requestId,
|
|
149
|
+
state: {
|
|
150
|
+
status: bot._client ? 'online' : 'offline',
|
|
151
|
+
health: bot.health || 20,
|
|
152
|
+
food: bot.food || 20,
|
|
153
|
+
position: bot.entity?.position ? { x: bot.entity.position.x, y: bot.entity.position.y, z: bot.entity.position.z } : null,
|
|
154
|
+
yaw: bot.entity?.yaw || 0,
|
|
155
|
+
pitch: bot.entity?.pitch || 0,
|
|
156
|
+
gameMode: bot.game?.gameMode,
|
|
157
|
+
dimension: bot.game?.dimension,
|
|
158
|
+
blocks,
|
|
159
|
+
inventory: bot.inventory ? bot.inventory.items().map(item => ({ name: item.name, displayName: item.displayName, count: item.count, slot: item.slot })) : [],
|
|
160
|
+
nearbyPlayers: bot.entities ? Object.values(bot.entities).filter(e => e.type === 'player' && e.username !== bot.username).map(e => ({ username: e.username, position: { x: e.position.x, y: e.position.y, z: e.position.z }, yaw: e.yaw || 0, pitch: e.pitch || 0, distance: bot.entity ? bot.entity.position.distanceTo(e.position) : 0 })) : [],
|
|
161
|
+
nearbyMobs: bot.entities ? Object.values(bot.entities).filter(e => e.type === 'mob').map(e => ({ name: e.name || e.displayName, mobType: e.mobType, position: { x: e.position.x, y: e.position.y, z: e.position.z }, distance: bot.entity ? bot.entity.position.distanceTo(e.position) : 0 })) : []
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
handlers[MessageTypes.VIEWER.CONTROL] = (message) => {
|
|
167
|
+
if (!bot) return null;
|
|
168
|
+
const { command } = message;
|
|
169
|
+
|
|
170
|
+
switch (command.type) {
|
|
171
|
+
case 'move':
|
|
172
|
+
bot.setControlState(command.direction, command.active);
|
|
173
|
+
break;
|
|
174
|
+
case 'look':
|
|
175
|
+
if (command.yaw !== undefined) bot.entity.yaw = command.yaw;
|
|
176
|
+
if (command.pitch !== undefined) bot.entity.pitch = command.pitch;
|
|
177
|
+
break;
|
|
178
|
+
case 'chat':
|
|
179
|
+
bot.chat(command.message);
|
|
180
|
+
break;
|
|
181
|
+
case 'dig':
|
|
182
|
+
if (command.position) {
|
|
183
|
+
const block = bot.blockAt(new Vec3(command.position.x, command.position.y, command.position.z));
|
|
184
|
+
if (block) bot.dig(block).catch(err => sendLog(`[Viewer] Dig error: ${err.message}`));
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
case 'hotbar_slot':
|
|
188
|
+
if (command.slot !== undefined && command.slot >= 0 && command.slot <= 8) {
|
|
189
|
+
bot.setQuickBarSlot(command.slot);
|
|
190
|
+
sendLog(`[Viewer] Hotbar slot changed to ${command.slot}`);
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case 'place':
|
|
194
|
+
if (command.position && command.blockType) {
|
|
195
|
+
const referenceBlock = bot.blockAt(new Vec3(command.position.x, command.position.y, command.position.z));
|
|
196
|
+
if (referenceBlock) {
|
|
197
|
+
const itemToPlace = bot.inventory.items().find(item => item.name === command.blockType);
|
|
198
|
+
if (itemToPlace) {
|
|
199
|
+
bot.equip(itemToPlace, 'hand').then(() => bot.placeBlock(referenceBlock, new Vec3(0, 1, 0))).catch(err => sendLog(`[Viewer] Place error: ${err.message}`));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case 'set_render_distance':
|
|
205
|
+
if (command.distance && command.distance >= 8 && command.distance <= 64) {
|
|
206
|
+
viewerRenderDistance = command.distance;
|
|
207
|
+
sendLog(`[Viewer] Render distance set to ${viewerRenderDistance}`);
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
handlers[MessageTypes.GRAPH.EXECUTE_EVENT_GRAPH] = async (message) => {
|
|
215
|
+
const { graph, eventType, eventArgs } = message;
|
|
216
|
+
if (!graph || !graph.nodes || graph.nodes.length === 0) return null;
|
|
217
|
+
|
|
218
|
+
const config = bot?.config;
|
|
219
|
+
if (!config) {
|
|
220
|
+
sendLog('[ERROR] Bot config not available for event graph execution');
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const players = bot ? Object.keys(bot.players) : [];
|
|
225
|
+
|
|
226
|
+
const context = {
|
|
227
|
+
bot,
|
|
228
|
+
players,
|
|
229
|
+
botState: { health: bot?.health, food: bot?.food, position: bot?.entity?.position },
|
|
230
|
+
botEntity: bot && bot.entity ? serializeEntity(bot.entity) : null,
|
|
231
|
+
eventArgs,
|
|
232
|
+
botId: config.id,
|
|
233
|
+
graphId: graph.id,
|
|
234
|
+
eventType
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const engine = new GraphExecutionEngine(NodeRegistry, bot);
|
|
238
|
+
await engine.execute(graph, context, eventType);
|
|
239
|
+
|
|
240
|
+
return null;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
handlers[MessageTypes.USER.ACTION_RESPONSE] = (message) => {
|
|
244
|
+
if (pendingRequests.has(message.requestId)) {
|
|
245
|
+
const { resolve, reject } = pendingRequests.get(message.requestId);
|
|
246
|
+
if (message.error) reject(new Error(message.error));
|
|
247
|
+
else resolve(message.payload);
|
|
248
|
+
pendingRequests.delete(message.requestId);
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
handlers[MessageTypes.USER.CREDENTIALS_OPERATION_RESPONSE] = (message) => {
|
|
254
|
+
if (pendingRequests.has(message.requestId)) {
|
|
255
|
+
const { resolve, reject } = pendingRequests.get(message.requestId);
|
|
256
|
+
if (message.error) reject(new Error(message.error));
|
|
257
|
+
else resolve(message.payload);
|
|
258
|
+
pendingRequests.delete(message.requestId);
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
handlers[MessageTypes.COMMAND.EXECUTE_HANDLER] = (message) => {
|
|
264
|
+
const { commandName, username, args, typeChat } = message;
|
|
265
|
+
const commandInstance = bot.commands.get(commandName);
|
|
266
|
+
if (commandInstance) {
|
|
267
|
+
(async () => {
|
|
268
|
+
try {
|
|
269
|
+
const user = await UserService.getUser(username, bot.config.id, bot.config);
|
|
270
|
+
const handlerParamCount = commandInstance.handler.length;
|
|
271
|
+
|
|
272
|
+
if (handlerParamCount === 1) {
|
|
273
|
+
const transport = new Transport(typeChat, bot);
|
|
274
|
+
const context = new CommandContext(bot, user, args, transport);
|
|
275
|
+
await commandInstance.handler(context);
|
|
276
|
+
} else {
|
|
277
|
+
await commandInstance.handler(bot, typeChat, user, args);
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
sendLog(`[Handler Error] ${commandName}: ${e.message}`);
|
|
281
|
+
}
|
|
282
|
+
})();
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
handlers[MessageTypes.COMMAND.EXECUTE_COMMAND_REQUEST] = (message) => {
|
|
288
|
+
const { requestId, payload } = message;
|
|
289
|
+
const { commandName, args, username, typeChat } = payload;
|
|
290
|
+
|
|
291
|
+
(async () => {
|
|
292
|
+
try {
|
|
293
|
+
const commandInstance = bot.commands.get(commandName);
|
|
294
|
+
if (!commandInstance) throw new Error(`Command '${commandName}' not found.`);
|
|
295
|
+
|
|
296
|
+
const user = await UserService.getUser(username, bot.config.id, bot.config);
|
|
297
|
+
const handlerParamCount = commandInstance.handler.length;
|
|
298
|
+
|
|
299
|
+
let result;
|
|
300
|
+
if (handlerParamCount === 1) {
|
|
301
|
+
const transport = new Transport(typeChat, bot);
|
|
302
|
+
const context = new CommandContext(bot, user, args, transport);
|
|
303
|
+
|
|
304
|
+
if (typeChat === 'websocket') {
|
|
305
|
+
result = await commandInstance.handler(context);
|
|
306
|
+
if (process.send) process.send({ type: MessageTypes.GRAPH.EXECUTE_COMMAND_RESPONSE, requestId, result });
|
|
307
|
+
} else {
|
|
308
|
+
commandInstance.handler(context).catch(e => sendLog(`[Handler Error] ${commandName}: ${e.message}`));
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
if (typeChat === 'websocket') {
|
|
312
|
+
const originalSendMessage = bot.sendMessage;
|
|
313
|
+
let resultFromSendMessage = null;
|
|
314
|
+
let sendMessageCalled = false;
|
|
315
|
+
|
|
316
|
+
bot.sendMessage = (type, msg, user) => {
|
|
317
|
+
if (type === 'websocket') {
|
|
318
|
+
resultFromSendMessage = msg;
|
|
319
|
+
sendMessageCalled = true;
|
|
320
|
+
} else {
|
|
321
|
+
originalSendMessage.call(bot, type, msg, user);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
try {
|
|
326
|
+
const returnValue = await commandInstance.handler(bot, typeChat, user, args);
|
|
327
|
+
result = sendMessageCalled ? resultFromSendMessage : returnValue;
|
|
328
|
+
if (process.send) process.send({ type: MessageTypes.GRAPH.EXECUTE_COMMAND_RESPONSE, requestId, result });
|
|
329
|
+
} finally {
|
|
330
|
+
bot.sendMessage = originalSendMessage;
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
commandInstance.handler(bot, typeChat, user, args).catch(e => sendLog(`[Handler Error] ${commandName}: ${e.message}`));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (process.send) process.send({ type: MessageTypes.GRAPH.EXECUTE_COMMAND_RESPONSE, requestId, error: error.message });
|
|
338
|
+
}
|
|
339
|
+
})();
|
|
340
|
+
return null;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
handlers[MessageTypes.COMMAND.HANDLE_PERMISSION_ERROR] = (message) => {
|
|
344
|
+
const { commandName, username, typeChat } = message;
|
|
345
|
+
const commandInstance = bot.commands.get(commandName);
|
|
346
|
+
if (commandInstance) {
|
|
347
|
+
if (commandInstance.onInsufficientPermissions !== Command.prototype.onInsufficientPermissions) {
|
|
348
|
+
commandInstance.onInsufficientPermissions(bot, typeChat, { username });
|
|
349
|
+
} else {
|
|
350
|
+
bot.api.sendMessage(typeChat, `У вас нет прав для выполнения команды ${commandName}.`, username);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return null;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
handlers[MessageTypes.COMMAND.HANDLE_WRONG_CHAT] = (message) => {
|
|
357
|
+
const { commandName, username, typeChat } = message;
|
|
358
|
+
const commandInstance = bot.commands.get(commandName);
|
|
359
|
+
if (commandInstance) {
|
|
360
|
+
if (commandInstance.onWrongChatType !== Command.prototype.onWrongChatType) {
|
|
361
|
+
commandInstance.onWrongChatType(bot, typeChat, { username });
|
|
362
|
+
} else {
|
|
363
|
+
bot.api.sendMessage('private', `Команду ${commandName} нельзя использовать в этом типе чата - ${typeChat}.`, username);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
handlers[MessageTypes.COMMAND.HANDLE_COOLDOWN] = (message) => {
|
|
370
|
+
const { commandName, username, typeChat, timeLeft } = message;
|
|
371
|
+
const commandInstance = bot.commands.get(commandName);
|
|
372
|
+
if (commandInstance) {
|
|
373
|
+
if (commandInstance.onCooldown !== Command.prototype.onCooldown) {
|
|
374
|
+
commandInstance.onCooldown(bot, typeChat, { username }, timeLeft);
|
|
375
|
+
} else {
|
|
376
|
+
bot.api.sendMessage(typeChat, `Команду ${commandName} можно будет использовать через ${timeLeft} сек.`, username);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return null;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
handlers[MessageTypes.COMMAND.HANDLE_BLACKLIST] = (message) => {
|
|
383
|
+
const { commandName, username, typeChat } = message;
|
|
384
|
+
const commandInstance = bot.commands.get(commandName);
|
|
385
|
+
if (commandInstance && commandInstance.onBlacklisted !== Command.prototype.onBlacklisted) {
|
|
386
|
+
commandInstance.onBlacklisted(bot, typeChat, { username });
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
handlers[MessageTypes.CHAT.SEND_MESSAGE] = (message) => {
|
|
392
|
+
const { typeChat, message: msg, username } = message;
|
|
393
|
+
if (bot && bot.api) {
|
|
394
|
+
bot.api.sendMessage(typeChat, msg, username);
|
|
395
|
+
}
|
|
396
|
+
return null;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
handlers[MessageTypes.PLUGINS.RELOAD] = async () => {
|
|
400
|
+
sendLog('[System] Получена команда на перезагрузку плагинов...');
|
|
401
|
+
return { shouldReload: true };
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
handlers[MessageTypes.SERVER.COMMAND] = (message) => {
|
|
405
|
+
if (bot && bot.messageQueue && message.payload?.command) {
|
|
406
|
+
bot.messageQueue.enqueue('command', message.payload.command);
|
|
407
|
+
}
|
|
408
|
+
return null;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
handlers[MessageTypes.USER.INVALIDATE_USER_CACHE] = (message) => {
|
|
412
|
+
if (message.username && bot && bot.config) {
|
|
413
|
+
UserService.clearCache(message.username, bot.config.id);
|
|
414
|
+
}
|
|
415
|
+
return null;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
handlers[MessageTypes.USER.INVALIDATE_ALL_USER_CACHE] = () => {
|
|
419
|
+
if (bot && bot.config) {
|
|
420
|
+
for (const [cacheKey] of UserService.cache.entries()) {
|
|
421
|
+
if (cacheKey.startsWith(`${bot.config.id}:`)) {
|
|
422
|
+
UserService.cache.delete(cacheKey);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
sendLog(`[BotProcess] Кэш пользователей очищен для бота ${bot.config.id}`);
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
return handlers;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function sendLog(content) {
|
|
434
|
+
if (process.send) {
|
|
435
|
+
process.send({ type: MessageTypes.BOT.LOG, content });
|
|
436
|
+
} else {
|
|
437
|
+
console.log(`[ChildProcess Log] ${content}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
module.exports = {
|
|
442
|
+
handleIncomingCommand,
|
|
443
|
+
createBotIPCHandler,
|
|
444
|
+
sendLog
|
|
445
|
+
};
|
|
@@ -22,11 +22,10 @@ class BotManager {
|
|
|
22
22
|
this.eventGraphManager = eventGraphManager;
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
|
|
25
|
-
// Геттеры для обратной совместимости
|
|
26
25
|
this.bots = this.processManager.getAllProcesses();
|
|
27
26
|
this.nodeRegistry = require('./NodeRegistry');
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
this._cleanupRegistry = new Map();
|
|
30
29
|
this.intervals = [];
|
|
31
30
|
|
|
32
31
|
this._startBackgroundTasks();
|
|
@@ -36,18 +35,27 @@ class BotManager {
|
|
|
36
35
|
this.resourceMonitor.startMonitoring(5000);
|
|
37
36
|
this.telemetry.startHeartbeat(5 * 60 * 1000);
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const usageInterval = setInterval(() => this.updateAllResourceUsage(), 5000);
|
|
39
|
+
const syncInterval = setInterval(() => this.syncBotStatuses(), 10000);
|
|
40
|
+
|
|
41
|
+
this.intervals.push(usageInterval, syncInterval);
|
|
42
|
+
this._cleanupRegistry.set('usageInterval', () => clearInterval(usageInterval));
|
|
43
|
+
this._cleanupRegistry.set('syncInterval', () => clearInterval(syncInterval));
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
/**
|
|
44
|
-
* Очистка интервалов при завершении работы
|
|
45
|
-
*/
|
|
46
46
|
cleanup() {
|
|
47
|
+
for (const fn of this._cleanupRegistry.values()) {
|
|
48
|
+
try { fn(); } catch {}
|
|
49
|
+
}
|
|
50
|
+
this._cleanupRegistry.clear();
|
|
47
51
|
this.intervals.forEach(interval => clearInterval(interval));
|
|
48
52
|
this.intervals = [];
|
|
49
53
|
}
|
|
50
54
|
|
|
55
|
+
registerCleanup(key, fn) {
|
|
56
|
+
this._cleanupRegistry.set(key, fn);
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
initialize() {
|
|
52
60
|
if (!this.lifecycleService.eventGraphManager) {
|
|
53
61
|
this.lifecycleService.eventGraphManager = this.eventGraphManager;
|