unreal-engine-mcp-server 0.4.6 → 0.5.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/.env.example +26 -0
- package/.env.production +38 -7
- package/.eslintrc.json +0 -54
- package/.eslintrc.override.json +8 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +94 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +56 -0
- package/.github/copilot-instructions.md +478 -45
- package/.github/dependabot.yml +19 -0
- package/.github/labeler.yml +24 -0
- package/.github/labels.yml +70 -0
- package/.github/pull_request_template.md +42 -0
- package/.github/release-drafter.yml +148 -0
- package/.github/workflows/auto-merge.yml +38 -0
- package/.github/workflows/ci.yml +38 -0
- package/.github/workflows/dependency-review.yml +17 -0
- package/.github/workflows/gemini-issue-triage.yml +172 -0
- package/.github/workflows/greetings.yml +23 -0
- package/.github/workflows/labeler.yml +16 -0
- package/.github/workflows/links.yml +80 -0
- package/.github/workflows/pr-size-labeler.yml +137 -0
- package/.github/workflows/publish-mcp.yml +12 -7
- package/.github/workflows/release-drafter.yml +23 -0
- package/.github/workflows/release.yml +112 -0
- package/.github/workflows/semantic-pull-request.yml +35 -0
- package/.github/workflows/smoke-test.yml +36 -0
- package/.github/workflows/stale.yml +28 -0
- package/CHANGELOG.md +269 -22
- package/CONTRIBUTING.md +140 -0
- package/README.md +166 -72
- package/claude_desktop_config_example.json +7 -6
- package/dist/automation/bridge.d.ts +50 -0
- package/dist/automation/bridge.js +452 -0
- package/dist/automation/connection-manager.d.ts +23 -0
- package/dist/automation/connection-manager.js +107 -0
- package/dist/automation/handshake.d.ts +11 -0
- package/dist/automation/handshake.js +89 -0
- package/dist/automation/index.d.ts +3 -0
- package/dist/automation/index.js +3 -0
- package/dist/automation/message-handler.d.ts +12 -0
- package/dist/automation/message-handler.js +149 -0
- package/dist/automation/request-tracker.d.ts +25 -0
- package/dist/automation/request-tracker.js +98 -0
- package/dist/automation/types.d.ts +130 -0
- package/dist/automation/types.js +2 -0
- package/dist/cli.js +32 -5
- package/dist/config.d.ts +27 -0
- package/dist/config.js +60 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +12 -0
- package/dist/graphql/resolvers.d.ts +268 -0
- package/dist/graphql/resolvers.js +743 -0
- package/dist/graphql/schema.d.ts +5 -0
- package/dist/graphql/schema.js +437 -0
- package/dist/graphql/server.d.ts +26 -0
- package/dist/graphql/server.js +115 -0
- package/dist/graphql/types.d.ts +7 -0
- package/dist/graphql/types.js +2 -0
- package/dist/handlers/resource-handlers.d.ts +20 -0
- package/dist/handlers/resource-handlers.js +180 -0
- package/dist/index.d.ts +31 -18
- package/dist/index.js +119 -604
- package/dist/prompts/index.js +4 -4
- package/dist/resources/actors.d.ts +17 -12
- package/dist/resources/actors.js +56 -76
- package/dist/resources/assets.d.ts +6 -14
- package/dist/resources/assets.js +115 -147
- package/dist/resources/levels.d.ts +13 -13
- package/dist/resources/levels.js +25 -34
- package/dist/server/resource-registry.d.ts +20 -0
- package/dist/server/resource-registry.js +37 -0
- package/dist/server/tool-registry.d.ts +23 -0
- package/dist/server/tool-registry.js +322 -0
- package/dist/server-setup.d.ts +21 -0
- package/dist/server-setup.js +111 -0
- package/dist/services/health-monitor.d.ts +34 -0
- package/dist/services/health-monitor.js +105 -0
- package/dist/services/metrics-server.d.ts +11 -0
- package/dist/services/metrics-server.js +105 -0
- package/dist/tools/actors.d.ts +147 -9
- package/dist/tools/actors.js +350 -311
- package/dist/tools/animation.d.ts +135 -4
- package/dist/tools/animation.js +510 -411
- package/dist/tools/assets.d.ts +117 -19
- package/dist/tools/assets.js +259 -284
- package/dist/tools/audio.d.ts +102 -42
- package/dist/tools/audio.js +272 -685
- package/dist/tools/base-tool.d.ts +17 -0
- package/dist/tools/base-tool.js +46 -0
- package/dist/tools/behavior-tree.d.ts +94 -0
- package/dist/tools/behavior-tree.js +39 -0
- package/dist/tools/blueprint/helpers.d.ts +29 -0
- package/dist/tools/blueprint/helpers.js +182 -0
- package/dist/tools/blueprint.d.ts +228 -118
- package/dist/tools/blueprint.js +685 -832
- package/dist/tools/consolidated-tool-definitions.d.ts +5475 -1627
- package/dist/tools/consolidated-tool-definitions.js +829 -482
- package/dist/tools/consolidated-tool-handlers.d.ts +2 -1
- package/dist/tools/consolidated-tool-handlers.js +211 -1009
- package/dist/tools/debug.d.ts +143 -85
- package/dist/tools/debug.js +234 -180
- package/dist/tools/dynamic-handler-registry.d.ts +11 -0
- package/dist/tools/dynamic-handler-registry.js +101 -0
- package/dist/tools/editor.d.ts +139 -18
- package/dist/tools/editor.js +239 -244
- package/dist/tools/engine.d.ts +10 -4
- package/dist/tools/engine.js +13 -5
- package/dist/tools/environment.d.ts +36 -0
- package/dist/tools/environment.js +267 -0
- package/dist/tools/foliage.d.ts +105 -14
- package/dist/tools/foliage.js +219 -331
- package/dist/tools/handlers/actor-handlers.d.ts +3 -0
- package/dist/tools/handlers/actor-handlers.js +232 -0
- package/dist/tools/handlers/animation-handlers.d.ts +3 -0
- package/dist/tools/handlers/animation-handlers.js +185 -0
- package/dist/tools/handlers/argument-helper.d.ts +16 -0
- package/dist/tools/handlers/argument-helper.js +80 -0
- package/dist/tools/handlers/asset-handlers.d.ts +3 -0
- package/dist/tools/handlers/asset-handlers.js +496 -0
- package/dist/tools/handlers/audio-handlers.d.ts +3 -0
- package/dist/tools/handlers/audio-handlers.js +166 -0
- package/dist/tools/handlers/blueprint-handlers.d.ts +4 -0
- package/dist/tools/handlers/blueprint-handlers.js +358 -0
- package/dist/tools/handlers/common-handlers.d.ts +14 -0
- package/dist/tools/handlers/common-handlers.js +56 -0
- package/dist/tools/handlers/editor-handlers.d.ts +3 -0
- package/dist/tools/handlers/editor-handlers.js +119 -0
- package/dist/tools/handlers/effect-handlers.d.ts +3 -0
- package/dist/tools/handlers/effect-handlers.js +171 -0
- package/dist/tools/handlers/environment-handlers.d.ts +3 -0
- package/dist/tools/handlers/environment-handlers.js +170 -0
- package/dist/tools/handlers/graph-handlers.d.ts +3 -0
- package/dist/tools/handlers/graph-handlers.js +90 -0
- package/dist/tools/handlers/input-handlers.d.ts +3 -0
- package/dist/tools/handlers/input-handlers.js +21 -0
- package/dist/tools/handlers/inspect-handlers.d.ts +3 -0
- package/dist/tools/handlers/inspect-handlers.js +383 -0
- package/dist/tools/handlers/level-handlers.d.ts +3 -0
- package/dist/tools/handlers/level-handlers.js +237 -0
- package/dist/tools/handlers/lighting-handlers.d.ts +3 -0
- package/dist/tools/handlers/lighting-handlers.js +144 -0
- package/dist/tools/handlers/performance-handlers.d.ts +3 -0
- package/dist/tools/handlers/performance-handlers.js +130 -0
- package/dist/tools/handlers/pipeline-handlers.d.ts +3 -0
- package/dist/tools/handlers/pipeline-handlers.js +110 -0
- package/dist/tools/handlers/sequence-handlers.d.ts +3 -0
- package/dist/tools/handlers/sequence-handlers.js +376 -0
- package/dist/tools/handlers/system-handlers.d.ts +4 -0
- package/dist/tools/handlers/system-handlers.js +506 -0
- package/dist/tools/input.d.ts +19 -0
- package/dist/tools/input.js +89 -0
- package/dist/tools/introspection.d.ts +103 -40
- package/dist/tools/introspection.js +425 -568
- package/dist/tools/landscape.d.ts +97 -36
- package/dist/tools/landscape.js +280 -409
- package/dist/tools/level.d.ts +130 -10
- package/dist/tools/level.js +639 -675
- package/dist/tools/lighting.d.ts +77 -38
- package/dist/tools/lighting.js +441 -943
- package/dist/tools/logs.d.ts +45 -0
- package/dist/tools/logs.js +210 -0
- package/dist/tools/materials.d.ts +91 -24
- package/dist/tools/materials.js +190 -118
- package/dist/tools/niagara.d.ts +149 -39
- package/dist/tools/niagara.js +232 -182
- package/dist/tools/performance.d.ts +27 -12
- package/dist/tools/performance.js +204 -122
- package/dist/tools/physics.d.ts +32 -77
- package/dist/tools/physics.js +171 -582
- package/dist/tools/property-dictionary.d.ts +13 -0
- package/dist/tools/property-dictionary.js +82 -0
- package/dist/tools/sequence.d.ts +73 -48
- package/dist/tools/sequence.js +196 -748
- package/dist/tools/tool-definition-utils.d.ts +59 -0
- package/dist/tools/tool-definition-utils.js +35 -0
- package/dist/tools/ui.d.ts +66 -34
- package/dist/tools/ui.js +134 -214
- package/dist/types/env.d.ts +0 -3
- package/dist/types/env.js +0 -7
- package/dist/types/tool-interfaces.d.ts +898 -0
- package/dist/types/tool-interfaces.js +2 -0
- package/dist/types/tool-types.d.ts +195 -11
- package/dist/types/tool-types.js +0 -4
- package/dist/unreal-bridge.d.ts +24 -131
- package/dist/unreal-bridge.js +364 -1506
- package/dist/utils/command-validator.d.ts +9 -0
- package/dist/utils/command-validator.js +67 -0
- package/dist/utils/elicitation.d.ts +1 -1
- package/dist/utils/elicitation.js +12 -15
- package/dist/utils/error-handler.d.ts +2 -51
- package/dist/utils/error-handler.js +11 -87
- package/dist/utils/ini-reader.d.ts +3 -0
- package/dist/utils/ini-reader.js +69 -0
- package/dist/utils/logger.js +9 -6
- package/dist/utils/normalize.d.ts +3 -0
- package/dist/utils/normalize.js +56 -0
- package/dist/utils/response-factory.d.ts +7 -0
- package/dist/utils/response-factory.js +33 -0
- package/dist/utils/response-validator.d.ts +3 -24
- package/dist/utils/response-validator.js +130 -81
- package/dist/utils/result-helpers.d.ts +4 -5
- package/dist/utils/result-helpers.js +15 -16
- package/dist/utils/safe-json.js +5 -11
- package/dist/utils/unreal-command-queue.d.ts +24 -0
- package/dist/utils/unreal-command-queue.js +120 -0
- package/dist/utils/validation.d.ts +0 -40
- package/dist/utils/validation.js +1 -78
- package/dist/wasm/index.d.ts +70 -0
- package/dist/wasm/index.js +535 -0
- package/docs/GraphQL-API.md +888 -0
- package/docs/Migration-Guide-v0.5.0.md +692 -0
- package/docs/Roadmap.md +53 -0
- package/docs/WebAssembly-Integration.md +628 -0
- package/docs/editor-plugin-extension.md +370 -0
- package/docs/handler-mapping.md +242 -0
- package/docs/native-automation-progress.md +128 -0
- package/docs/testing-guide.md +423 -0
- package/mcp-config-example.json +6 -6
- package/package.json +60 -27
- package/plugins/McpAutomationBridge/Config/FilterPlugin.ini +8 -0
- package/plugins/McpAutomationBridge/McpAutomationBridge.uplugin +64 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/McpAutomationBridge.Build.cs +189 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.cpp +22 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.h +30 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeHelpers.h +1983 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeModule.cpp +72 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSettings.cpp +46 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSubsystem.cpp +581 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AnimationHandlers.cpp +2394 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetQueryHandlers.cpp +300 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetWorkflowHandlers.cpp +2807 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AudioHandlers.cpp +1087 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BehaviorTreeHandlers.cpp +488 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.cpp +643 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.h +31 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintGraphHandlers.cpp +1184 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers.cpp +5652 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers_List.cpp +152 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ControlHandlers.cpp +2614 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_DebugHandlers.cpp +42 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EditorFunctionHandlers.cpp +1237 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EffectHandlers.cpp +1701 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EnvironmentHandlers.cpp +2145 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_FoliageHandlers.cpp +954 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InputHandlers.cpp +209 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InsightsHandlers.cpp +41 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LandscapeHandlers.cpp +1164 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LevelHandlers.cpp +762 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LightingHandlers.cpp +634 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LogHandlers.cpp +136 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_MaterialGraphHandlers.cpp +494 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraGraphHandlers.cpp +278 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraHandlers.cpp +625 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PerformanceHandlers.cpp +401 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PipelineHandlers.cpp +67 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ProcessRequest.cpp +735 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cpp +2634 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_RenderHandlers.cpp +189 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.cpp +917 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.h +39 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequenceHandlers.cpp +2670 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequencerHandlers.cpp +519 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_TestHandlers.cpp +38 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_UiHandlers.cpp +668 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_WorldPartitionHandlers.cpp +346 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.cpp +1330 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.h +149 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpConnectionManager.cpp +783 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSettings.h +115 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSubsystem.h +796 -0
- package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpConnectionManager.h +117 -0
- package/scripts/check-unreal-connection.mjs +19 -0
- package/scripts/clean-tmp.js +23 -0
- package/scripts/patch-wasm.js +26 -0
- package/scripts/run-all-tests.mjs +131 -0
- package/scripts/smoke-test.ts +94 -0
- package/scripts/sync-mcp-plugin.js +143 -0
- package/scripts/test-no-plugin-alternates.mjs +113 -0
- package/scripts/validate-server.js +46 -0
- package/scripts/verify-automation-bridge.js +200 -0
- package/server.json +57 -21
- package/src/automation/bridge.ts +558 -0
- package/src/automation/connection-manager.ts +130 -0
- package/src/automation/handshake.ts +99 -0
- package/src/automation/index.ts +2 -0
- package/src/automation/message-handler.ts +167 -0
- package/src/automation/request-tracker.ts +123 -0
- package/src/automation/types.ts +107 -0
- package/src/cli.ts +33 -6
- package/src/config.ts +73 -0
- package/src/constants.ts +12 -0
- package/src/graphql/resolvers.ts +1010 -0
- package/src/graphql/schema.ts +452 -0
- package/src/graphql/server.ts +154 -0
- package/src/graphql/types.ts +7 -0
- package/src/handlers/resource-handlers.ts +186 -0
- package/src/index.ts +152 -649
- package/src/prompts/index.ts +4 -4
- package/src/resources/actors.ts +58 -76
- package/src/resources/assets.ts +147 -134
- package/src/resources/levels.ts +28 -33
- package/src/server/resource-registry.ts +47 -0
- package/src/server/tool-registry.ts +354 -0
- package/src/server-setup.ts +148 -0
- package/src/services/health-monitor.ts +132 -0
- package/src/services/metrics-server.ts +142 -0
- package/src/tools/actors.ts +417 -322
- package/src/tools/animation.ts +671 -461
- package/src/tools/assets.ts +353 -289
- package/src/tools/audio.ts +323 -766
- package/src/tools/base-tool.ts +52 -0
- package/src/tools/behavior-tree.ts +45 -0
- package/src/tools/blueprint/helpers.ts +189 -0
- package/src/tools/blueprint.ts +787 -965
- package/src/tools/consolidated-tool-definitions.ts +993 -500
- package/src/tools/consolidated-tool-handlers.ts +272 -1122
- package/src/tools/debug.ts +292 -187
- package/src/tools/dynamic-handler-registry.ts +151 -0
- package/src/tools/editor.ts +309 -246
- package/src/tools/engine.ts +14 -3
- package/src/tools/environment.ts +287 -0
- package/src/tools/foliage.ts +314 -379
- package/src/tools/handlers/actor-handlers.ts +271 -0
- package/src/tools/handlers/animation-handlers.ts +237 -0
- package/src/tools/handlers/argument-helper.ts +142 -0
- package/src/tools/handlers/asset-handlers.ts +532 -0
- package/src/tools/handlers/audio-handlers.ts +194 -0
- package/src/tools/handlers/blueprint-handlers.ts +380 -0
- package/src/tools/handlers/common-handlers.ts +87 -0
- package/src/tools/handlers/editor-handlers.ts +123 -0
- package/src/tools/handlers/effect-handlers.ts +220 -0
- package/src/tools/handlers/environment-handlers.ts +183 -0
- package/src/tools/handlers/graph-handlers.ts +116 -0
- package/src/tools/handlers/input-handlers.ts +28 -0
- package/src/tools/handlers/inspect-handlers.ts +450 -0
- package/src/tools/handlers/level-handlers.ts +252 -0
- package/src/tools/handlers/lighting-handlers.ts +147 -0
- package/src/tools/handlers/performance-handlers.ts +132 -0
- package/src/tools/handlers/pipeline-handlers.ts +127 -0
- package/src/tools/handlers/sequence-handlers.ts +415 -0
- package/src/tools/handlers/system-handlers.ts +564 -0
- package/src/tools/input.ts +101 -0
- package/src/tools/introspection.ts +493 -584
- package/src/tools/landscape.ts +394 -489
- package/src/tools/level.ts +752 -694
- package/src/tools/lighting.ts +583 -984
- package/src/tools/logs.ts +219 -0
- package/src/tools/materials.ts +231 -121
- package/src/tools/niagara.ts +293 -168
- package/src/tools/performance.ts +320 -168
- package/src/tools/physics.ts +268 -613
- package/src/tools/property-dictionary.ts +98 -0
- package/src/tools/sequence.ts +255 -815
- package/src/tools/tool-definition-utils.ts +35 -0
- package/src/tools/ui.ts +207 -283
- package/src/types/env.ts +0 -10
- package/src/types/tool-interfaces.ts +250 -0
- package/src/types/tool-types.ts +250 -13
- package/src/unreal-bridge.ts +460 -1550
- package/src/utils/command-validator.ts +75 -0
- package/src/utils/elicitation.ts +10 -7
- package/src/utils/error-handler.ts +14 -90
- package/src/utils/ini-reader.ts +86 -0
- package/src/utils/logger.ts +8 -3
- package/src/utils/normalize.ts +60 -0
- package/src/utils/response-factory.ts +39 -0
- package/src/utils/response-validator.ts +176 -56
- package/src/utils/result-helpers.ts +21 -19
- package/src/utils/safe-json.ts +14 -11
- package/src/utils/unreal-command-queue.ts +152 -0
- package/src/utils/validation.ts +4 -1
- package/src/wasm/index.ts +838 -0
- package/test-server.mjs +100 -0
- package/tests/run-unreal-tool-tests.mjs +242 -14
- package/tests/test-animation.mjs +44 -0
- package/tests/test-asset-advanced.mjs +82 -0
- package/tests/test-asset-errors.mjs +35 -0
- package/tests/test-audio.mjs +219 -0
- package/tests/test-automation-timeouts.mjs +98 -0
- package/tests/test-behavior-tree.mjs +261 -0
- package/tests/test-blueprint-events.mjs +35 -0
- package/tests/test-blueprint-graph.mjs +79 -0
- package/tests/test-blueprint.mjs +577 -0
- package/tests/test-client-mode.mjs +86 -0
- package/tests/test-console-command.mjs +56 -0
- package/tests/test-control-actor.mjs +425 -0
- package/tests/test-control-editor.mjs +80 -0
- package/tests/test-extra-tools.mjs +38 -0
- package/tests/test-graphql.mjs +322 -0
- package/tests/test-inspect.mjs +72 -0
- package/tests/test-landscape.mjs +60 -0
- package/tests/test-manage-asset.mjs +438 -0
- package/tests/test-manage-level.mjs +70 -0
- package/tests/test-materials.mjs +356 -0
- package/tests/test-niagara.mjs +185 -0
- package/tests/test-no-inline-python.mjs +122 -0
- package/tests/test-plugin-handshake.mjs +82 -0
- package/tests/test-render.mjs +33 -0
- package/tests/test-runner.mjs +933 -0
- package/tests/test-search-assets.mjs +66 -0
- package/tests/test-sequence.mjs +68 -0
- package/tests/test-system.mjs +57 -0
- package/tests/test-wasm.mjs +193 -0
- package/tests/test-world-partition.mjs +215 -0
- package/tsconfig.json +3 -3
- package/wasm/Cargo.lock +363 -0
- package/wasm/Cargo.toml +42 -0
- package/wasm/LICENSE +21 -0
- package/wasm/README.md +253 -0
- package/wasm/src/dependency_resolver.rs +377 -0
- package/wasm/src/lib.rs +153 -0
- package/wasm/src/property_parser.rs +271 -0
- package/wasm/src/transform_math.rs +396 -0
- package/wasm/tests/integration.rs +109 -0
- package/.github/workflows/smithery-build.yml +0 -29
- package/dist/tools/build_environment_advanced.d.ts +0 -65
- package/dist/tools/build_environment_advanced.js +0 -633
- package/dist/tools/rc.d.ts +0 -110
- package/dist/tools/rc.js +0 -437
- package/dist/tools/visual.d.ts +0 -40
- package/dist/tools/visual.js +0 -282
- package/dist/utils/http.d.ts +0 -6
- package/dist/utils/http.js +0 -151
- package/dist/utils/python-output.d.ts +0 -18
- package/dist/utils/python-output.js +0 -290
- package/dist/utils/python.d.ts +0 -2
- package/dist/utils/python.js +0 -4
- package/dist/utils/stdio-redirect.d.ts +0 -2
- package/dist/utils/stdio-redirect.js +0 -20
- package/docs/unreal-tool-test-cases.md +0 -572
- package/smithery.yaml +0 -29
- package/src/tools/build_environment_advanced.ts +0 -732
- package/src/tools/rc.ts +0 -515
- package/src/tools/visual.ts +0 -281
- package/src/utils/http.ts +0 -187
- package/src/utils/python-output.ts +0 -351
- package/src/utils/python.ts +0 -3
- package/src/utils/stdio-redirect.ts +0 -18
|
@@ -0,0 +1,1237 @@
|
|
|
1
|
+
#include "McpAutomationBridgeGlobals.h"
|
|
2
|
+
#include "McpAutomationBridgeHelpers.h"
|
|
3
|
+
#include "McpAutomationBridgeSubsystem.h"
|
|
4
|
+
#if WITH_EDITOR
|
|
5
|
+
#if __has_include("Subsystems/EditorActorSubsystem.h")
|
|
6
|
+
#include "Subsystems/EditorActorSubsystem.h"
|
|
7
|
+
#elif __has_include("EditorActorSubsystem.h")
|
|
8
|
+
#include "EditorActorSubsystem.h"
|
|
9
|
+
#endif
|
|
10
|
+
#if __has_include("Subsystems/UnrealEditorSubsystem.h")
|
|
11
|
+
#include "Subsystems/UnrealEditorSubsystem.h"
|
|
12
|
+
#elif __has_include("UnrealEditorSubsystem.h")
|
|
13
|
+
#include "UnrealEditorSubsystem.h"
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include("Subsystems/LevelEditorSubsystem.h")
|
|
16
|
+
#include "Subsystems/LevelEditorSubsystem.h"
|
|
17
|
+
#elif __has_include("LevelEditorSubsystem.h")
|
|
18
|
+
#include "LevelEditorSubsystem.h"
|
|
19
|
+
#endif
|
|
20
|
+
#include "AssetToolsModule.h"
|
|
21
|
+
#include "EditorAssetLibrary.h"
|
|
22
|
+
#if __has_include("EditorLoadingAndSavingUtils.h")
|
|
23
|
+
#include "EditorLoadingAndSavingUtils.h"
|
|
24
|
+
#elif __has_include("FileHelpers.h")
|
|
25
|
+
#include "FileHelpers.h"
|
|
26
|
+
#endif
|
|
27
|
+
#include "Factories/Factory.h"
|
|
28
|
+
#include "Kismet/GameplayStatics.h"
|
|
29
|
+
#include "Misc/Base64.h"
|
|
30
|
+
#include "Sound/SoundBase.h"
|
|
31
|
+
#include "Sound/SoundCue.h"
|
|
32
|
+
#include "UObject/SoftObjectPath.h"
|
|
33
|
+
#if __has_include("Blueprint/UserWidget.h")
|
|
34
|
+
#include "Blueprint/UserWidget.h"
|
|
35
|
+
#endif
|
|
36
|
+
#if __has_include("GameFramework/PlayerController.h")
|
|
37
|
+
#include "GameFramework/PlayerController.h"
|
|
38
|
+
#endif
|
|
39
|
+
#include "EngineUtils.h"
|
|
40
|
+
#include "GameFramework/WorldSettings.h"
|
|
41
|
+
#include "Misc/OutputDeviceNull.h"
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
bool UMcpAutomationBridgeSubsystem::HandleExecuteEditorFunction(
|
|
45
|
+
const FString &RequestId, const FString &Action,
|
|
46
|
+
const TSharedPtr<FJsonObject> &Payload,
|
|
47
|
+
TSharedPtr<FMcpBridgeWebSocket> RequestingSocket) {
|
|
48
|
+
const FString Lower = Action.ToLower();
|
|
49
|
+
// Accept either the generic execute_editor_function action or the
|
|
50
|
+
// more specific execute_console_command action. This allows the
|
|
51
|
+
// server to use native console commands for health checks and diagnostics.
|
|
52
|
+
if (!Lower.Equals(TEXT("execute_editor_function"), ESearchCase::IgnoreCase) &&
|
|
53
|
+
!Lower.Contains(TEXT("execute_editor_function")) &&
|
|
54
|
+
!Lower.Equals(TEXT("execute_console_command")) &&
|
|
55
|
+
!Lower.Contains(TEXT("execute_console_command")))
|
|
56
|
+
return false;
|
|
57
|
+
|
|
58
|
+
if (!Payload.IsValid()) {
|
|
59
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
60
|
+
TEXT("execute_editor_function payload missing."),
|
|
61
|
+
TEXT("INVALID_PAYLOAD"));
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Handle native console command action first — console commands
|
|
66
|
+
// carry a top-level `command` (or params.command) and should not
|
|
67
|
+
// be treated as a generic execute_editor_function requiring a
|
|
68
|
+
// functionName field.
|
|
69
|
+
if (Lower.Equals(TEXT("execute_console_command")) ||
|
|
70
|
+
Lower.Contains(TEXT("execute_console_command"))) {
|
|
71
|
+
// Accept either a top-level 'command' string or nested params.command
|
|
72
|
+
FString Cmd;
|
|
73
|
+
if (!Payload->TryGetStringField(TEXT("command"), Cmd)) {
|
|
74
|
+
const TSharedPtr<FJsonObject> *ParamsPtr = nullptr;
|
|
75
|
+
if (Payload->TryGetObjectField(TEXT("params"), ParamsPtr) && ParamsPtr &&
|
|
76
|
+
(*ParamsPtr).IsValid()) {
|
|
77
|
+
(*ParamsPtr)->TryGetStringField(TEXT("command"), Cmd);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (Cmd.IsEmpty()) {
|
|
81
|
+
SendAutomationError(RequestingSocket, RequestId, TEXT("command required"),
|
|
82
|
+
TEXT("INVALID_ARGUMENT"));
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!GEditor) {
|
|
87
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
88
|
+
TEXT("Editor not available"), nullptr,
|
|
89
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
bool bExecCalled = false;
|
|
94
|
+
bool bOk = false;
|
|
95
|
+
|
|
96
|
+
// Prefer executing with a valid editor world context where possible to
|
|
97
|
+
// avoid assertions inside engine helpers that require a proper world
|
|
98
|
+
// (e.g. when running Open/Map commands).
|
|
99
|
+
UWorld *TargetWorld = nullptr;
|
|
100
|
+
#if WITH_EDITOR
|
|
101
|
+
if (GEditor) {
|
|
102
|
+
if (UUnrealEditorSubsystem *UES =
|
|
103
|
+
GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()) {
|
|
104
|
+
TargetWorld = UES->GetEditorWorld();
|
|
105
|
+
}
|
|
106
|
+
if (!TargetWorld) {
|
|
107
|
+
TargetWorld = GEditor->GetEditorWorldContext().World();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
#endif
|
|
111
|
+
|
|
112
|
+
if (GEditor && TargetWorld) {
|
|
113
|
+
bOk = GEditor->Exec(TargetWorld, *Cmd);
|
|
114
|
+
bExecCalled = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Fallback: try all known engine world contexts if the editor world
|
|
118
|
+
// did not handle the command successfully.
|
|
119
|
+
if (!bOk && GEngine) {
|
|
120
|
+
for (const FWorldContext &Ctx : GEngine->GetWorldContexts()) {
|
|
121
|
+
UWorld *World = Ctx.World();
|
|
122
|
+
if (!World)
|
|
123
|
+
continue;
|
|
124
|
+
const bool bWorldOk = GEngine->Exec(World, *Cmd);
|
|
125
|
+
bExecCalled = bExecCalled || bWorldOk;
|
|
126
|
+
if (bWorldOk) {
|
|
127
|
+
bOk = true;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// If we could not find any valid world to execute against, avoid
|
|
134
|
+
// invoking the engine command path entirely and return a structured
|
|
135
|
+
// error instead of risking an assertion.
|
|
136
|
+
if (!bExecCalled && !TargetWorld) {
|
|
137
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
138
|
+
Out->SetStringField(TEXT("command"), Cmd);
|
|
139
|
+
Out->SetBoolField(TEXT("success"), false);
|
|
140
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
141
|
+
TEXT("Editor world not available for command"),
|
|
142
|
+
Out, TEXT("EDITOR_WORLD_NOT_AVAILABLE"));
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
147
|
+
Out->SetStringField(TEXT("command"), Cmd);
|
|
148
|
+
Out->SetBoolField(TEXT("success"), bOk);
|
|
149
|
+
SendAutomationResponse(RequestingSocket, RequestId, bOk,
|
|
150
|
+
bOk ? TEXT("Command executed")
|
|
151
|
+
: TEXT("Command not executed"),
|
|
152
|
+
Out, bOk ? FString() : TEXT("EXEC_FAILED"));
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// For other execute_editor_function cases require functionName
|
|
157
|
+
FString FunctionName;
|
|
158
|
+
Payload->TryGetStringField(TEXT("functionName"), FunctionName);
|
|
159
|
+
if (FunctionName.IsEmpty()) {
|
|
160
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
161
|
+
TEXT("functionName required"),
|
|
162
|
+
TEXT("INVALID_ARGUMENT"));
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const FString FN = FunctionName.ToUpper();
|
|
167
|
+
// Accept either a top-level 'command' string or nested params.command
|
|
168
|
+
FString Cmd;
|
|
169
|
+
if (!Payload->TryGetStringField(TEXT("command"), Cmd)) {
|
|
170
|
+
const TSharedPtr<FJsonObject> *ParamsPtr = nullptr;
|
|
171
|
+
if (Payload->TryGetObjectField(TEXT("params"), ParamsPtr) && ParamsPtr &&
|
|
172
|
+
(*ParamsPtr).IsValid()) {
|
|
173
|
+
(*ParamsPtr)->TryGetStringField(TEXT("command"), Cmd);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// (Console handling moved earlier)
|
|
177
|
+
|
|
178
|
+
#if WITH_EDITOR
|
|
179
|
+
// Dispatch a handful of well-known functions to native handlers
|
|
180
|
+
if (FN == TEXT("GET_ALL_ACTORS") || FN == TEXT("GET_ALL_ACTORS_SIMPLE")) {
|
|
181
|
+
if (!GEditor) {
|
|
182
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
183
|
+
TEXT("Editor not available"), nullptr,
|
|
184
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
UEditorActorSubsystem *ActorSS =
|
|
188
|
+
GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
|
|
189
|
+
if (!ActorSS) {
|
|
190
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
191
|
+
TEXT("EditorActorSubsystem not available"),
|
|
192
|
+
nullptr, TEXT("EDITOR_ACTOR_SUBSYSTEM_MISSING"));
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
TArray<AActor *> Actors = ActorSS->GetAllLevelActors();
|
|
196
|
+
TArray<TSharedPtr<FJsonValue>> Arr;
|
|
197
|
+
Arr.Reserve(Actors.Num());
|
|
198
|
+
for (AActor *A : Actors) {
|
|
199
|
+
if (!A)
|
|
200
|
+
continue;
|
|
201
|
+
TSharedPtr<FJsonObject> E = MakeShared<FJsonObject>();
|
|
202
|
+
E->SetStringField(TEXT("name"), A->GetName());
|
|
203
|
+
E->SetStringField(TEXT("label"), A->GetActorLabel());
|
|
204
|
+
E->SetStringField(TEXT("path"), A->GetPathName());
|
|
205
|
+
E->SetStringField(TEXT("class"), A->GetClass()
|
|
206
|
+
? A->GetClass()->GetPathName()
|
|
207
|
+
: TEXT(""));
|
|
208
|
+
Arr.Add(MakeShared<FJsonValueObject>(E));
|
|
209
|
+
}
|
|
210
|
+
TSharedPtr<FJsonObject> Result = MakeShared<FJsonObject>();
|
|
211
|
+
Result->SetArrayField(TEXT("actors"), Arr);
|
|
212
|
+
Result->SetNumberField(TEXT("count"), Arr.Num());
|
|
213
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
214
|
+
TEXT("Actor list"), Result, FString());
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (FN == TEXT("SPAWN_ACTOR") || FN == TEXT("SPAWN_ACTOR_AT_LOCATION")) {
|
|
219
|
+
FString ClassPath;
|
|
220
|
+
Payload->TryGetStringField(TEXT("class_path"), ClassPath);
|
|
221
|
+
if (ClassPath.IsEmpty())
|
|
222
|
+
Payload->TryGetStringField(TEXT("classPath"), ClassPath);
|
|
223
|
+
const TSharedPtr<FJsonObject> *LocObj = nullptr;
|
|
224
|
+
FVector Loc(0, 0, 0);
|
|
225
|
+
FRotator Rot(0, 0, 0);
|
|
226
|
+
if (Payload->TryGetObjectField(TEXT("params"), LocObj) && LocObj &&
|
|
227
|
+
(*LocObj).IsValid()) {
|
|
228
|
+
const TSharedPtr<FJsonObject> &P = *LocObj;
|
|
229
|
+
ReadVectorField(P, TEXT("location"), Loc, Loc);
|
|
230
|
+
ReadRotatorField(P, TEXT("rotation"), Rot, Rot);
|
|
231
|
+
} else {
|
|
232
|
+
if (const TSharedPtr<FJsonValue> LocVal =
|
|
233
|
+
Payload->TryGetField(TEXT("location"))) {
|
|
234
|
+
if (LocVal->Type == EJson::Array) {
|
|
235
|
+
const TArray<TSharedPtr<FJsonValue>> &A = LocVal->AsArray();
|
|
236
|
+
if (A.Num() >= 3)
|
|
237
|
+
Loc = FVector((float)A[0]->AsNumber(), (float)A[1]->AsNumber(),
|
|
238
|
+
(float)A[2]->AsNumber());
|
|
239
|
+
} else if (LocVal->Type == EJson::Object) {
|
|
240
|
+
const TSharedPtr<FJsonObject> LocObject = LocVal->AsObject();
|
|
241
|
+
if (LocObject.IsValid())
|
|
242
|
+
ReadVectorField(LocObject, TEXT("location"), Loc, Loc);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (!GEditor) {
|
|
248
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
249
|
+
TEXT("Editor not available"), nullptr,
|
|
250
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
UEditorActorSubsystem *ActorSS =
|
|
254
|
+
GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
|
|
255
|
+
if (!ActorSS) {
|
|
256
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
257
|
+
TEXT("EditorActorSubsystem not available"),
|
|
258
|
+
nullptr, TEXT("EDITOR_ACTOR_SUBSYSTEM_MISSING"));
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
UClass *Resolved = nullptr;
|
|
262
|
+
if (!ClassPath.IsEmpty()) {
|
|
263
|
+
Resolved = ResolveClassByName(ClassPath);
|
|
264
|
+
}
|
|
265
|
+
if (!Resolved) {
|
|
266
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
267
|
+
Err->SetStringField(TEXT("error"), TEXT("Class not found"));
|
|
268
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
269
|
+
TEXT("Class not found"), Err,
|
|
270
|
+
TEXT("CLASS_NOT_FOUND"));
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
AActor *Spawned = SpawnActorInActiveWorld<AActor>(Resolved, Loc, Rot);
|
|
274
|
+
if (!Spawned) {
|
|
275
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
276
|
+
Err->SetStringField(TEXT("error"), TEXT("Spawn failed"));
|
|
277
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
278
|
+
TEXT("Spawn failed"), Err, TEXT("SPAWN_FAILED"));
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
282
|
+
Out->SetStringField(TEXT("actorName"), Spawned->GetActorLabel());
|
|
283
|
+
Out->SetStringField(TEXT("actorPath"), Spawned->GetPathName());
|
|
284
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
285
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
286
|
+
TEXT("Actor spawned"), Out, FString());
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (FN == TEXT("DELETE_ACTOR") || FN == TEXT("DESTROY_ACTOR")) {
|
|
291
|
+
// ... (existing delete logic) ...
|
|
292
|
+
FString Target;
|
|
293
|
+
Payload->TryGetStringField(TEXT("actor_name"), Target);
|
|
294
|
+
if (Target.IsEmpty())
|
|
295
|
+
Payload->TryGetStringField(TEXT("actorName"), Target);
|
|
296
|
+
if (Target.IsEmpty()) {
|
|
297
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
298
|
+
TEXT("actor_name required"),
|
|
299
|
+
TEXT("INVALID_ARGUMENT"));
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
if (!GEditor) {
|
|
303
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
304
|
+
TEXT("Editor not available"), nullptr,
|
|
305
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
UEditorActorSubsystem *ActorSS =
|
|
309
|
+
GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
|
|
310
|
+
if (!ActorSS) {
|
|
311
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
312
|
+
TEXT("EditorActorSubsystem not available"),
|
|
313
|
+
nullptr, TEXT("EDITOR_ACTOR_SUBSYSTEM_MISSING"));
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
AActor *Found = nullptr;
|
|
317
|
+
for (AActor *A : ActorSS->GetAllLevelActors()) {
|
|
318
|
+
if (!A)
|
|
319
|
+
continue;
|
|
320
|
+
if (A->GetActorLabel().Equals(Target, ESearchCase::IgnoreCase) ||
|
|
321
|
+
A->GetName().Equals(Target, ESearchCase::IgnoreCase) ||
|
|
322
|
+
A->GetPathName().Equals(Target, ESearchCase::IgnoreCase)) {
|
|
323
|
+
Found = A;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (!Found) {
|
|
328
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
329
|
+
Err->SetStringField(TEXT("error"), TEXT("Actor not found"));
|
|
330
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
331
|
+
TEXT("Actor not found"), Err,
|
|
332
|
+
TEXT("ACTOR_NOT_FOUND"));
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
const bool bDeleted = ActorSS->DestroyActor(Found);
|
|
336
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
337
|
+
Out->SetBoolField(TEXT("success"), bDeleted);
|
|
338
|
+
if (bDeleted) {
|
|
339
|
+
Out->SetStringField(TEXT("deleted"), Found->GetActorLabel());
|
|
340
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
341
|
+
TEXT("Actor deleted"), Out, FString());
|
|
342
|
+
} else {
|
|
343
|
+
Out->SetStringField(TEXT("error"), TEXT("Delete failed"));
|
|
344
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
345
|
+
TEXT("Delete failed"), Out, TEXT("DELETE_FAILED"));
|
|
346
|
+
}
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (FN == TEXT("POSSESS")) {
|
|
351
|
+
FString TargetName;
|
|
352
|
+
Payload->TryGetStringField(TEXT("actor_name"), TargetName);
|
|
353
|
+
if (TargetName.IsEmpty())
|
|
354
|
+
Payload->TryGetStringField(TEXT("actorName"), TargetName);
|
|
355
|
+
if (TargetName.IsEmpty()) {
|
|
356
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
357
|
+
TEXT("actorName required"), TEXT("INVALID_ARGUMENT"));
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (!GEditor || !GEditor->IsPlaySessionInProgress()) {
|
|
362
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
363
|
+
TEXT("Possess only available during PIE session"),
|
|
364
|
+
nullptr, TEXT("NOT_IN_PIE"));
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
UWorld *PlayWorld = GEditor->PlayWorld;
|
|
369
|
+
if (!PlayWorld) {
|
|
370
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
371
|
+
TEXT("PIE World not found"), nullptr,
|
|
372
|
+
TEXT("WORLD_NOT_FOUND"));
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
APawn *FoundPawn = nullptr;
|
|
377
|
+
for (TActorIterator<APawn> It(PlayWorld); It; ++It) {
|
|
378
|
+
APawn *P = *It;
|
|
379
|
+
if (!P)
|
|
380
|
+
continue;
|
|
381
|
+
if (P->GetActorLabel().Equals(TargetName, ESearchCase::IgnoreCase) ||
|
|
382
|
+
P->GetName().Equals(TargetName, ESearchCase::IgnoreCase)) {
|
|
383
|
+
FoundPawn = P;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (!FoundPawn) {
|
|
389
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
390
|
+
TEXT("Pawn not found in PIE world"), nullptr,
|
|
391
|
+
TEXT("PAWN_NOT_FOUND"));
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
APlayerController *PC = PlayWorld->GetFirstPlayerController();
|
|
396
|
+
if (!PC) {
|
|
397
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
398
|
+
TEXT("No PlayerController found in PIE"), nullptr,
|
|
399
|
+
TEXT("PC_NOT_FOUND"));
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
PC->Possess(FoundPawn);
|
|
404
|
+
|
|
405
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
406
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
407
|
+
Out->SetStringField(TEXT("possessed"), FoundPawn->GetActorLabel());
|
|
408
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
409
|
+
TEXT("Possessed pawn"), Out, FString());
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (FN == TEXT("ASSET_EXISTS") || FN == TEXT("ASSET_EXISTS_SIMPLE")) {
|
|
414
|
+
FString PathToCheck;
|
|
415
|
+
// Accept either top-level 'path' or nested params.path
|
|
416
|
+
if (!Payload->TryGetStringField(TEXT("path"), PathToCheck)) {
|
|
417
|
+
const TSharedPtr<FJsonObject> *ParamsPtr = nullptr;
|
|
418
|
+
if (Payload->TryGetObjectField(TEXT("params"), ParamsPtr) && ParamsPtr &&
|
|
419
|
+
(*ParamsPtr).IsValid()) {
|
|
420
|
+
(*ParamsPtr)->TryGetStringField(TEXT("path"), PathToCheck);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (PathToCheck.IsEmpty()) {
|
|
424
|
+
SendAutomationError(RequestingSocket, RequestId, TEXT("path required"),
|
|
425
|
+
TEXT("INVALID_ARGUMENT"));
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Perform check on game thread
|
|
430
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
431
|
+
const bool bExists = UEditorAssetLibrary::DoesAssetExist(PathToCheck);
|
|
432
|
+
Out->SetBoolField(TEXT("exists"), bExists);
|
|
433
|
+
Out->SetStringField(TEXT("path"), PathToCheck);
|
|
434
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
435
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
436
|
+
bExists ? TEXT("Asset exists")
|
|
437
|
+
: TEXT("Asset not found"),
|
|
438
|
+
Out, bExists ? FString() : TEXT("NOT_FOUND"));
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (FN == TEXT("SET_VIEWPORT_CAMERA") ||
|
|
443
|
+
FN == TEXT("SET_VIEWPORT_CAMERA_INFO") ||
|
|
444
|
+
FN == TEXT("SET_CAMERA_POSITION")) {
|
|
445
|
+
const TSharedPtr<FJsonObject> *Params = nullptr;
|
|
446
|
+
FVector Loc(0, 0, 0);
|
|
447
|
+
FRotator Rot(0, 0, 0);
|
|
448
|
+
if (Payload->TryGetObjectField(TEXT("params"), Params) && Params &&
|
|
449
|
+
(*Params).IsValid()) {
|
|
450
|
+
ReadVectorField(*Params, TEXT("location"), Loc, Loc);
|
|
451
|
+
ReadRotatorField(*Params, TEXT("rotation"), Rot, Rot);
|
|
452
|
+
} else {
|
|
453
|
+
ReadVectorField(Payload, TEXT("location"), Loc, Loc);
|
|
454
|
+
ReadRotatorField(Payload, TEXT("rotation"), Rot, Rot);
|
|
455
|
+
}
|
|
456
|
+
if (!GEditor) {
|
|
457
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
458
|
+
TEXT("Editor not available"), nullptr,
|
|
459
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (UUnrealEditorSubsystem *UES =
|
|
464
|
+
GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()) {
|
|
465
|
+
UES->SetLevelViewportCameraInfo(Loc, Rot);
|
|
466
|
+
if (ULevelEditorSubsystem *LES =
|
|
467
|
+
GEditor->GetEditorSubsystem<ULevelEditorSubsystem>()) {
|
|
468
|
+
LES->EditorInvalidateViewports();
|
|
469
|
+
}
|
|
470
|
+
TSharedPtr<FJsonObject> R = MakeShared<FJsonObject>();
|
|
471
|
+
R->SetBoolField(TEXT("success"), true);
|
|
472
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
473
|
+
TEXT("Camera set"), R, FString());
|
|
474
|
+
} else {
|
|
475
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
476
|
+
TEXT("UnrealEditorSubsystem not available"),
|
|
477
|
+
nullptr, TEXT("SUBSYSTEM_NOT_FOUND"));
|
|
478
|
+
}
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (FN == TEXT("BUILD_LIGHTING")) {
|
|
483
|
+
FString Quality;
|
|
484
|
+
Payload->TryGetStringField(TEXT("quality"), Quality);
|
|
485
|
+
if (!GEditor) {
|
|
486
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
487
|
+
TEXT("Editor not available"), nullptr,
|
|
488
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Guard against missing editor world; building lighting when there is
|
|
493
|
+
// no active editor world can trigger engine assertions. If the world
|
|
494
|
+
// is not available, report a structured error instead of proceeding.
|
|
495
|
+
UWorld *CurrentWorld = nullptr;
|
|
496
|
+
if (GEditor) {
|
|
497
|
+
CurrentWorld = GEditor->GetEditorWorldContext().World();
|
|
498
|
+
}
|
|
499
|
+
if (!CurrentWorld) {
|
|
500
|
+
SendAutomationResponse(
|
|
501
|
+
RequestingSocket, RequestId, false,
|
|
502
|
+
TEXT("Editor world not available for build lighting"), nullptr,
|
|
503
|
+
TEXT("EDITOR_WORLD_NOT_AVAILABLE"));
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (ULevelEditorSubsystem *LES =
|
|
508
|
+
GEditor->GetEditorSubsystem<ULevelEditorSubsystem>()) {
|
|
509
|
+
ELightingBuildQuality QualityEnum =
|
|
510
|
+
ELightingBuildQuality::Quality_Production;
|
|
511
|
+
if (!Quality.IsEmpty()) {
|
|
512
|
+
const FString LowerQuality = Quality.ToLower();
|
|
513
|
+
if (LowerQuality == TEXT("preview")) {
|
|
514
|
+
QualityEnum = ELightingBuildQuality::Quality_Preview;
|
|
515
|
+
} else if (LowerQuality == TEXT("medium")) {
|
|
516
|
+
QualityEnum = ELightingBuildQuality::Quality_Medium;
|
|
517
|
+
} else if (LowerQuality == TEXT("high")) {
|
|
518
|
+
QualityEnum = ELightingBuildQuality::Quality_High;
|
|
519
|
+
} else {
|
|
520
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
521
|
+
Err->SetBoolField(TEXT("success"), false);
|
|
522
|
+
Err->SetStringField(TEXT("error"), TEXT("unknown_quality"));
|
|
523
|
+
Err->SetStringField(TEXT("quality"), Quality);
|
|
524
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
525
|
+
TEXT("Unknown lighting quality"), Err,
|
|
526
|
+
TEXT("UNKNOWN_QUALITY"));
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (AWorldSettings *WS = CurrentWorld->GetWorldSettings()) {
|
|
531
|
+
if (WS->bForceNoPrecomputedLighting) {
|
|
532
|
+
TSharedPtr<FJsonObject> R = MakeShared<FJsonObject>();
|
|
533
|
+
R->SetBoolField(TEXT("skipped"), true);
|
|
534
|
+
R->SetStringField(TEXT("reason"),
|
|
535
|
+
TEXT("bForceNoPrecomputedLighting is true"));
|
|
536
|
+
SendAutomationResponse(
|
|
537
|
+
RequestingSocket, RequestId, true,
|
|
538
|
+
TEXT("Lighting build skipped (precomputed lighting disabled)"), R,
|
|
539
|
+
FString());
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
LES->BuildLightMaps(QualityEnum, /*bWithReflectionCaptures*/ false);
|
|
545
|
+
TSharedPtr<FJsonObject> R = MakeShared<FJsonObject>();
|
|
546
|
+
R->SetBoolField(TEXT("requested"), true);
|
|
547
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
548
|
+
TEXT("Build lighting requested"), R, FString());
|
|
549
|
+
} else {
|
|
550
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
551
|
+
TEXT("LevelEditorSubsystem not available"),
|
|
552
|
+
nullptr, TEXT("SUBSYSTEM_NOT_FOUND"));
|
|
553
|
+
}
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (FN == TEXT("SAVE_CURRENT_LEVEL")) {
|
|
558
|
+
if (!GEditor) {
|
|
559
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
560
|
+
TEXT("Editor not available"), nullptr,
|
|
561
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
562
|
+
return true;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
bool bSaved = false;
|
|
566
|
+
#if __has_include("EditorLoadingAndSavingUtils.h")
|
|
567
|
+
bSaved = UEditorLoadingAndSavingUtils::SaveCurrentLevel();
|
|
568
|
+
#elif __has_include("FileHelpers.h")
|
|
569
|
+
bSaved = FEditorFileUtils::SaveCurrentLevel();
|
|
570
|
+
#endif
|
|
571
|
+
|
|
572
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
573
|
+
Out->SetBoolField(TEXT("success"), bSaved);
|
|
574
|
+
SendAutomationResponse(RequestingSocket, RequestId, bSaved,
|
|
575
|
+
bSaved ? TEXT("Level saved")
|
|
576
|
+
: TEXT("Failed to save level"),
|
|
577
|
+
Out, bSaved ? FString() : TEXT("SAVE_FAILED"));
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// RESOLVE_OBJECT: return basic object/asset discovery info
|
|
582
|
+
if (FN == TEXT("RESOLVE_OBJECT")) {
|
|
583
|
+
FString Path;
|
|
584
|
+
Payload->TryGetStringField(TEXT("path"), Path);
|
|
585
|
+
if (Path.IsEmpty()) {
|
|
586
|
+
SendAutomationError(RequestingSocket, RequestId, TEXT("path required"),
|
|
587
|
+
TEXT("INVALID_ARGUMENT"));
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
591
|
+
bool bExists = false;
|
|
592
|
+
FString ClassName;
|
|
593
|
+
if (UEditorAssetLibrary::DoesAssetExist(Path)) {
|
|
594
|
+
bExists = true;
|
|
595
|
+
if (UObject *Obj = UEditorAssetLibrary::LoadAsset(Path)) {
|
|
596
|
+
if (UClass *Cls = Obj->GetClass()) {
|
|
597
|
+
ClassName = Cls->GetPathName();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
} else if (UObject *Obj = FindObject<UObject>(nullptr, *Path)) {
|
|
601
|
+
bExists = true;
|
|
602
|
+
if (UClass *Cls = Obj->GetClass()) {
|
|
603
|
+
ClassName = Cls->GetPathName();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
Out->SetBoolField(TEXT("exists"), bExists);
|
|
607
|
+
Out->SetStringField(TEXT("path"), Path);
|
|
608
|
+
Out->SetStringField(TEXT("class"), ClassName);
|
|
609
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
610
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
611
|
+
bExists ? TEXT("Object resolved")
|
|
612
|
+
: TEXT("Object not found"),
|
|
613
|
+
Out, bExists ? FString() : TEXT("NOT_FOUND"));
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// LIST_ACTOR_COMPONENTS: provide a simple listing of components for a given
|
|
618
|
+
// editor actor
|
|
619
|
+
if (FN == TEXT("LIST_ACTOR_COMPONENTS")) {
|
|
620
|
+
FString ActorPath;
|
|
621
|
+
Payload->TryGetStringField(TEXT("actorPath"), ActorPath);
|
|
622
|
+
if (ActorPath.IsEmpty()) {
|
|
623
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
624
|
+
TEXT("actorPath required"), TEXT("INVALID_ARGUMENT"));
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
if (!GEditor) {
|
|
628
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
629
|
+
TEXT("Editor not available"), nullptr,
|
|
630
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
UEditorActorSubsystem *ActorSS =
|
|
634
|
+
GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
|
|
635
|
+
if (!ActorSS) {
|
|
636
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
637
|
+
TEXT("EditorActorSubsystem not available"),
|
|
638
|
+
nullptr, TEXT("EDITOR_ACTOR_SUBSYSTEM_MISSING"));
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
AActor *Found = nullptr;
|
|
642
|
+
for (AActor *A : ActorSS->GetAllLevelActors()) {
|
|
643
|
+
if (!A)
|
|
644
|
+
continue;
|
|
645
|
+
if (A->GetActorLabel().Equals(ActorPath, ESearchCase::IgnoreCase) ||
|
|
646
|
+
A->GetName().Equals(ActorPath, ESearchCase::IgnoreCase) ||
|
|
647
|
+
A->GetPathName().Equals(ActorPath, ESearchCase::IgnoreCase)) {
|
|
648
|
+
Found = A;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
if (!Found) {
|
|
653
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
654
|
+
Err->SetStringField(TEXT("error"), TEXT("Actor not found"));
|
|
655
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
656
|
+
TEXT("Actor not found"), Err,
|
|
657
|
+
TEXT("ACTOR_NOT_FOUND"));
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
TArray<UActorComponent *> Comps;
|
|
661
|
+
Found->GetComponents(Comps);
|
|
662
|
+
TArray<TSharedPtr<FJsonValue>> Arr;
|
|
663
|
+
for (UActorComponent *C : Comps) {
|
|
664
|
+
if (!C)
|
|
665
|
+
continue;
|
|
666
|
+
TSharedPtr<FJsonObject> R = MakeShared<FJsonObject>();
|
|
667
|
+
R->SetStringField(TEXT("name"), C->GetName());
|
|
668
|
+
R->SetStringField(TEXT("class"), C->GetClass()
|
|
669
|
+
? C->GetClass()->GetPathName()
|
|
670
|
+
: TEXT(""));
|
|
671
|
+
R->SetStringField(TEXT("path"), C->GetPathName());
|
|
672
|
+
Arr.Add(MakeShared<FJsonValueObject>(R));
|
|
673
|
+
}
|
|
674
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
675
|
+
Out->SetArrayField(TEXT("components"), Arr);
|
|
676
|
+
Out->SetNumberField(TEXT("count"), Arr.Num());
|
|
677
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
678
|
+
TEXT("Components listed"), Out, FString());
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// GET_BLUEPRINT_CDO: best-effort CDO/class info for a Blueprint asset
|
|
683
|
+
if (FN == TEXT("GET_BLUEPRINT_CDO")) {
|
|
684
|
+
FString BlueprintPath;
|
|
685
|
+
Payload->TryGetStringField(TEXT("blueprintPath"), BlueprintPath);
|
|
686
|
+
if (BlueprintPath.IsEmpty()) {
|
|
687
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
688
|
+
TEXT("blueprintPath required"),
|
|
689
|
+
TEXT("INVALID_ARGUMENT"));
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
if (!UEditorAssetLibrary::DoesAssetExist(BlueprintPath)) {
|
|
694
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
695
|
+
TEXT("Blueprint not found"), nullptr,
|
|
696
|
+
TEXT("NOT_FOUND"));
|
|
697
|
+
return true;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
701
|
+
UObject *Obj = UEditorAssetLibrary::LoadAsset(BlueprintPath);
|
|
702
|
+
if (!Obj) {
|
|
703
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
704
|
+
TEXT("Blueprint not found"), nullptr,
|
|
705
|
+
TEXT("NOT_FOUND"));
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if (UBlueprint *BP = Cast<UBlueprint>(Obj)) {
|
|
710
|
+
if (BP->GeneratedClass) {
|
|
711
|
+
UClass *Gen = BP->GeneratedClass;
|
|
712
|
+
Out->SetStringField(TEXT("blueprintPath"), BlueprintPath);
|
|
713
|
+
Out->SetStringField(TEXT("classPath"), Gen->GetPathName());
|
|
714
|
+
Out->SetStringField(TEXT("className"), Gen->GetName());
|
|
715
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
716
|
+
TEXT("Blueprint CDO info"), Out, FString());
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
719
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
720
|
+
TEXT("Blueprint/GeneratedClass not available"),
|
|
721
|
+
nullptr, TEXT("INVALID_BLUEPRINT"));
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (UClass *C = Cast<UClass>(Obj)) {
|
|
726
|
+
Out->SetStringField(TEXT("classPath"), C->GetPathName());
|
|
727
|
+
Out->SetStringField(TEXT("className"), C->GetName());
|
|
728
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
729
|
+
TEXT("Class info"), Out, FString());
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
734
|
+
TEXT("Blueprint/GeneratedClass not available"),
|
|
735
|
+
nullptr, TEXT("INVALID_BLUEPRINT"));
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (FN == TEXT("BLUEPRINT_ADD_COMPONENT")) {
|
|
740
|
+
const TSharedPtr<FJsonObject> *Params = nullptr;
|
|
741
|
+
TSharedPtr<FJsonObject> LocalParams = MakeShared<FJsonObject>();
|
|
742
|
+
if (Payload->TryGetObjectField(TEXT("params"), Params) && Params &&
|
|
743
|
+
(*Params).IsValid()) {
|
|
744
|
+
LocalParams = *Params;
|
|
745
|
+
} else if (Payload->HasField(TEXT("payloadBase64"))) {
|
|
746
|
+
FString Enc;
|
|
747
|
+
Payload->TryGetStringField(TEXT("payloadBase64"), Enc);
|
|
748
|
+
if (!Enc.IsEmpty()) {
|
|
749
|
+
TArray<uint8> DecodedBytes;
|
|
750
|
+
if (FBase64::Decode(Enc, DecodedBytes) && DecodedBytes.Num() > 0) {
|
|
751
|
+
DecodedBytes.Add(0);
|
|
752
|
+
const ANSICHAR *Utf8 =
|
|
753
|
+
reinterpret_cast<const ANSICHAR *>(DecodedBytes.GetData());
|
|
754
|
+
FString Decoded = FString(UTF8_TO_TCHAR(Utf8));
|
|
755
|
+
TSharedPtr<FJsonObject> Parsed = MakeShared<FJsonObject>();
|
|
756
|
+
TSharedRef<TJsonReader<>> Reader =
|
|
757
|
+
TJsonReaderFactory<>::Create(Decoded);
|
|
758
|
+
if (FJsonSerializer::Deserialize(Reader, Parsed) &&
|
|
759
|
+
Parsed.IsValid()) {
|
|
760
|
+
LocalParams = Parsed;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
FString TargetBP;
|
|
767
|
+
LocalParams->TryGetStringField(TEXT("blueprintPath"), TargetBP);
|
|
768
|
+
if (TargetBP.IsEmpty()) {
|
|
769
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
770
|
+
TEXT("blueprintPath required"),
|
|
771
|
+
TEXT("INVALID_ARGUMENT"));
|
|
772
|
+
return true;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
TSharedPtr<FJsonObject> SCSPayload = MakeShared<FJsonObject>();
|
|
776
|
+
SCSPayload->SetStringField(TEXT("blueprintPath"), TargetBP);
|
|
777
|
+
|
|
778
|
+
TArray<TSharedPtr<FJsonValue>> Ops;
|
|
779
|
+
TSharedPtr<FJsonObject> Op = MakeShared<FJsonObject>();
|
|
780
|
+
Op->SetStringField(TEXT("type"), TEXT("add_component"));
|
|
781
|
+
FString Name;
|
|
782
|
+
LocalParams->TryGetStringField(TEXT("componentName"), Name);
|
|
783
|
+
if (!Name.IsEmpty())
|
|
784
|
+
Op->SetStringField(TEXT("componentName"), Name);
|
|
785
|
+
FString Class;
|
|
786
|
+
LocalParams->TryGetStringField(TEXT("componentClass"), Class);
|
|
787
|
+
if (!Class.IsEmpty())
|
|
788
|
+
Op->SetStringField(TEXT("componentClass"), Class);
|
|
789
|
+
FString AttachTo;
|
|
790
|
+
LocalParams->TryGetStringField(TEXT("attachTo"), AttachTo);
|
|
791
|
+
if (!AttachTo.IsEmpty())
|
|
792
|
+
Op->SetStringField(TEXT("attachTo"), AttachTo);
|
|
793
|
+
Ops.Add(MakeShared<FJsonValueObject>(Op));
|
|
794
|
+
SCSPayload->SetArrayField(TEXT("operations"), Ops);
|
|
795
|
+
|
|
796
|
+
return HandleBlueprintAction(RequestId, TEXT("blueprint_modify_scs"),
|
|
797
|
+
SCSPayload, RequestingSocket);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
if (FN == TEXT("CREATE_ASSET")) {
|
|
801
|
+
// Check if we have a nested "params" object, which is standard for
|
|
802
|
+
// ExecuteEditorFunction
|
|
803
|
+
const TSharedPtr<FJsonObject> *ParamsObj;
|
|
804
|
+
const TSharedPtr<FJsonObject> SourceObj =
|
|
805
|
+
(Payload->TryGetObjectField(TEXT("params"), ParamsObj)) ? *ParamsObj
|
|
806
|
+
: Payload;
|
|
807
|
+
|
|
808
|
+
FString AssetName;
|
|
809
|
+
SourceObj->TryGetStringField(TEXT("asset_name"), AssetName);
|
|
810
|
+
FString PackagePath;
|
|
811
|
+
SourceObj->TryGetStringField(TEXT("package_path"), PackagePath);
|
|
812
|
+
FString AssetClass;
|
|
813
|
+
SourceObj->TryGetStringField(TEXT("asset_class"), AssetClass);
|
|
814
|
+
FString FactoryClass;
|
|
815
|
+
SourceObj->TryGetStringField(TEXT("factory_class"), FactoryClass);
|
|
816
|
+
|
|
817
|
+
if (AssetName.IsEmpty() || PackagePath.IsEmpty() ||
|
|
818
|
+
FactoryClass.IsEmpty()) {
|
|
819
|
+
SendAutomationError(
|
|
820
|
+
RequestingSocket, RequestId,
|
|
821
|
+
TEXT("asset_name, package_path, and factory_class required"),
|
|
822
|
+
TEXT("INVALID_ARGUMENT"));
|
|
823
|
+
return true;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
if (!GEditor) {
|
|
827
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
828
|
+
TEXT("Editor not available"), nullptr,
|
|
829
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
830
|
+
return true;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
IAssetTools &AssetTools =
|
|
834
|
+
FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools")
|
|
835
|
+
.Get();
|
|
836
|
+
|
|
837
|
+
// Resolve factory
|
|
838
|
+
UClass *FactoryUClass = ResolveClassByName(FactoryClass);
|
|
839
|
+
if (!FactoryUClass) {
|
|
840
|
+
// Try finding by short name or full path
|
|
841
|
+
FactoryUClass = UClass::TryFindTypeSlow<UClass>(FactoryClass);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// Quick factory lookup by short name if full resolution failed
|
|
845
|
+
if (!FactoryUClass) {
|
|
846
|
+
for (TObjectIterator<UClass> It; It; ++It) {
|
|
847
|
+
if (It->GetName().Equals(FactoryClass) ||
|
|
848
|
+
It->GetName().Equals(FactoryClass + TEXT("Factory"))) {
|
|
849
|
+
if (It->IsChildOf(UFactory::StaticClass())) {
|
|
850
|
+
FactoryUClass = *It;
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
if (!FactoryUClass) {
|
|
858
|
+
SendAutomationResponse(
|
|
859
|
+
RequestingSocket, RequestId, false,
|
|
860
|
+
FString::Printf(TEXT("Factory class '%s' not found"), *FactoryClass),
|
|
861
|
+
nullptr, TEXT("FACTORY_NOT_FOUND"));
|
|
862
|
+
return true;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
UFactory *Factory =
|
|
866
|
+
NewObject<UFactory>(GetTransientPackage(), FactoryUClass);
|
|
867
|
+
if (!Factory) {
|
|
868
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
869
|
+
TEXT("Failed to instantiate factory"), nullptr,
|
|
870
|
+
TEXT("FACTORY_CREATION_FAILED"));
|
|
871
|
+
return true;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// Attempt creation
|
|
875
|
+
UObject *NewAsset =
|
|
876
|
+
AssetTools.CreateAsset(AssetName, PackagePath, nullptr, Factory);
|
|
877
|
+
if (NewAsset) {
|
|
878
|
+
// Force save
|
|
879
|
+
TArray<UPackage *> PackagesToSave;
|
|
880
|
+
PackagesToSave.Add(NewAsset->GetOutermost());
|
|
881
|
+
FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, false, false);
|
|
882
|
+
|
|
883
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
884
|
+
Out->SetStringField(TEXT("name"), NewAsset->GetName());
|
|
885
|
+
Out->SetStringField(TEXT("path"), NewAsset->GetPathName());
|
|
886
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
887
|
+
|
|
888
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
889
|
+
TEXT("Asset created"), Out, FString());
|
|
890
|
+
} else {
|
|
891
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
892
|
+
TEXT("Failed to create asset via AssetTools"),
|
|
893
|
+
nullptr, TEXT("ASSET_CREATION_FAILED"));
|
|
894
|
+
}
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// PLAY_SOUND helpers
|
|
899
|
+
if (FN == TEXT("PLAY_SOUND_AT_LOCATION") || FN == TEXT("PLAY_SOUND_2D")) {
|
|
900
|
+
const TSharedPtr<FJsonObject> *Params = nullptr;
|
|
901
|
+
if (!Payload->TryGetObjectField(TEXT("params"), Params) ||
|
|
902
|
+
!(*Params).IsValid()) { /* allow top-level path fields */
|
|
903
|
+
}
|
|
904
|
+
FString SoundPath;
|
|
905
|
+
if (!Payload->TryGetStringField(TEXT("path"), SoundPath))
|
|
906
|
+
Payload->TryGetStringField(TEXT("soundPath"), SoundPath);
|
|
907
|
+
if (SoundPath.IsEmpty()) {
|
|
908
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
909
|
+
TEXT("soundPath or path required"),
|
|
910
|
+
TEXT("INVALID_ARGUMENT"));
|
|
911
|
+
return true;
|
|
912
|
+
}
|
|
913
|
+
if (!GEditor) {
|
|
914
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
915
|
+
TEXT("Editor world not available"), nullptr,
|
|
916
|
+
TEXT("EDITOR_WORLD_NOT_AVAILABLE"));
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
919
|
+
UWorld *World = nullptr;
|
|
920
|
+
if (UUnrealEditorSubsystem *UES =
|
|
921
|
+
GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()) {
|
|
922
|
+
World = UES->GetEditorWorld();
|
|
923
|
+
}
|
|
924
|
+
if (!World) {
|
|
925
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
926
|
+
TEXT("Editor world not available"), nullptr,
|
|
927
|
+
TEXT("EDITOR_WORLD_NOT_AVAILABLE"));
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
if (!UEditorAssetLibrary::DoesAssetExist(SoundPath)) {
|
|
932
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
933
|
+
Err->SetStringField(TEXT("error"), TEXT("Sound asset not found"));
|
|
934
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
935
|
+
TEXT("Sound not found"), Err, TEXT("NOT_FOUND"));
|
|
936
|
+
return true;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
USoundBase *Snd =
|
|
940
|
+
Cast<USoundBase>(UEditorAssetLibrary::LoadAsset(SoundPath));
|
|
941
|
+
if (!Snd) {
|
|
942
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
943
|
+
Err->SetStringField(TEXT("error"), TEXT("Sound asset not found"));
|
|
944
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
945
|
+
TEXT("Sound not found"), Err, TEXT("NOT_FOUND"));
|
|
946
|
+
return true;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
if (FN == TEXT("PLAY_SOUND_AT_LOCATION")) {
|
|
950
|
+
float x = 0, y = 0, z = 0;
|
|
951
|
+
const TSharedPtr<FJsonObject> *LocObj = nullptr;
|
|
952
|
+
if (Payload->TryGetObjectField(TEXT("params"), LocObj) && LocObj &&
|
|
953
|
+
(*LocObj).IsValid()) {
|
|
954
|
+
(*LocObj)->TryGetNumberField(TEXT("x"), x);
|
|
955
|
+
(*LocObj)->TryGetNumberField(TEXT("y"), y);
|
|
956
|
+
(*LocObj)->TryGetNumberField(TEXT("z"), z);
|
|
957
|
+
}
|
|
958
|
+
FVector Loc(x, y, z);
|
|
959
|
+
UGameplayStatics::SpawnSoundAtLocation(World, Snd, Loc);
|
|
960
|
+
} else {
|
|
961
|
+
UGameplayStatics::SpawnSoundAtLocation(World, Snd, FVector::ZeroVector);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
965
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
966
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
967
|
+
TEXT("Sound played"), Out, FString());
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// ADD_WIDGET_TO_VIEWPORT: implemented with proper widget creation and
|
|
972
|
+
// viewport management
|
|
973
|
+
if (FN == TEXT("ADD_WIDGET_TO_VIEWPORT")) {
|
|
974
|
+
FString WidgetPath;
|
|
975
|
+
Payload->TryGetStringField(TEXT("widget_path"), WidgetPath);
|
|
976
|
+
if (WidgetPath.IsEmpty()) {
|
|
977
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
978
|
+
TEXT("widget_path required"),
|
|
979
|
+
TEXT("INVALID_ARGUMENT"));
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
int32 zOrder = 0;
|
|
984
|
+
Payload->TryGetNumberField(TEXT("z_order"), zOrder);
|
|
985
|
+
int32 playerIndex = 0;
|
|
986
|
+
Payload->TryGetNumberField(TEXT("player_index"), playerIndex);
|
|
987
|
+
|
|
988
|
+
if (!GEditor) {
|
|
989
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
990
|
+
TEXT("Editor not available for widget creation"),
|
|
991
|
+
nullptr, TEXT("EDITOR_NOT_AVAILABLE"));
|
|
992
|
+
return true;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// Load the widget blueprint class
|
|
996
|
+
UClass *WidgetClass = LoadClass<UUserWidget>(nullptr, *WidgetPath);
|
|
997
|
+
if (!WidgetClass) {
|
|
998
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
999
|
+
Err->SetStringField(TEXT("error"), TEXT("Widget class not found"));
|
|
1000
|
+
Err->SetStringField(TEXT("widget_path"), WidgetPath);
|
|
1001
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1002
|
+
TEXT("Widget class not found"), Err,
|
|
1003
|
+
TEXT("WIDGET_NOT_FOUND"));
|
|
1004
|
+
return true;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Get the current world and player controller
|
|
1008
|
+
UWorld *World = GEditor->GetEditorWorldContext().World();
|
|
1009
|
+
if (!World) {
|
|
1010
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1011
|
+
TEXT("No world available"), nullptr,
|
|
1012
|
+
TEXT("NO_WORLD"));
|
|
1013
|
+
return true;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
APlayerController *PlayerController =
|
|
1017
|
+
UGameplayStatics::GetPlayerController(World, playerIndex);
|
|
1018
|
+
if (!PlayerController) {
|
|
1019
|
+
// Try to get the first available player controller if the specified one
|
|
1020
|
+
// doesn't exist
|
|
1021
|
+
PlayerController = UGameplayStatics::GetPlayerController(World, 0);
|
|
1022
|
+
if (!PlayerController) {
|
|
1023
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
1024
|
+
Err->SetStringField(TEXT("error"),
|
|
1025
|
+
TEXT("Player controller not available"));
|
|
1026
|
+
Err->SetNumberField(TEXT("player_index"), playerIndex);
|
|
1027
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1028
|
+
TEXT("Player controller not available"), Err,
|
|
1029
|
+
TEXT("NO_PLAYER_CONTROLLER"));
|
|
1030
|
+
return true;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// Create and add the widget to viewport
|
|
1035
|
+
UUserWidget *Widget =
|
|
1036
|
+
CreateWidget<UUserWidget>(PlayerController, WidgetClass);
|
|
1037
|
+
if (!Widget) {
|
|
1038
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1039
|
+
TEXT("Failed to create widget instance"), nullptr,
|
|
1040
|
+
TEXT("WIDGET_CREATION_FAILED"));
|
|
1041
|
+
return true;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
Widget->AddToViewport(zOrder);
|
|
1045
|
+
|
|
1046
|
+
// Verify widget is in viewport
|
|
1047
|
+
const bool bIsInViewport = Widget->IsInViewport();
|
|
1048
|
+
|
|
1049
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
1050
|
+
Out->SetBoolField(TEXT("success"), bIsInViewport);
|
|
1051
|
+
Out->SetStringField(TEXT("widget_path"), WidgetPath);
|
|
1052
|
+
Out->SetStringField(TEXT("widget_class"), WidgetClass->GetPathName());
|
|
1053
|
+
Out->SetNumberField(TEXT("z_order"), zOrder);
|
|
1054
|
+
Out->SetNumberField(TEXT("player_index"),
|
|
1055
|
+
PlayerController ? playerIndex : 0);
|
|
1056
|
+
|
|
1057
|
+
if (!bIsInViewport) {
|
|
1058
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1059
|
+
TEXT("Failed to add widget to viewport"), Out,
|
|
1060
|
+
TEXT("ADD_TO_VIEWPORT_FAILED"));
|
|
1061
|
+
return true;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
1065
|
+
TEXT("Widget added to viewport"), Out, FString());
|
|
1066
|
+
return true;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
if (FN == TEXT("GENERATE_MEMORY_REPORT")) {
|
|
1070
|
+
FString OutputPath;
|
|
1071
|
+
Payload->TryGetStringField(TEXT("outputPath"), OutputPath);
|
|
1072
|
+
bool bDetailed = false;
|
|
1073
|
+
Payload->TryGetBoolField(TEXT("detailed"), bDetailed);
|
|
1074
|
+
|
|
1075
|
+
if (!GEditor) {
|
|
1076
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1077
|
+
TEXT("Editor not available"), nullptr,
|
|
1078
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
1079
|
+
return true;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
FString MemReportCmd =
|
|
1083
|
+
bDetailed ? TEXT("memreport -full") : TEXT("memreport");
|
|
1084
|
+
GEditor->Exec(nullptr, *MemReportCmd);
|
|
1085
|
+
|
|
1086
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
1087
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
1088
|
+
// Note: OutputPath is not fully supported by the native memreport command
|
|
1089
|
+
// (it auto-generates filenames), but we acknowledge the request.
|
|
1090
|
+
Out->SetStringField(
|
|
1091
|
+
TEXT("message"),
|
|
1092
|
+
TEXT("Memory report generated (check Saved/Profiling/MemReports)"));
|
|
1093
|
+
|
|
1094
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
1095
|
+
TEXT("Memory report generated"), Out, FString());
|
|
1096
|
+
return true;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// CALL_SUBSYSTEM: generic reflection-based subsystem call
|
|
1100
|
+
if (FN == TEXT("CALL_SUBSYSTEM")) {
|
|
1101
|
+
FString SubsystemName;
|
|
1102
|
+
Payload->TryGetStringField(TEXT("subsystem"), SubsystemName);
|
|
1103
|
+
FString TargetFuncName;
|
|
1104
|
+
Payload->TryGetStringField(TEXT("function"), TargetFuncName);
|
|
1105
|
+
const TSharedPtr<FJsonObject> *Args = nullptr;
|
|
1106
|
+
Payload->TryGetObjectField(TEXT("args"), Args);
|
|
1107
|
+
|
|
1108
|
+
if (SubsystemName.IsEmpty() || TargetFuncName.IsEmpty()) {
|
|
1109
|
+
SendAutomationError(RequestingSocket, RequestId,
|
|
1110
|
+
TEXT("subsystem and function required"),
|
|
1111
|
+
TEXT("INVALID_ARGUMENT"));
|
|
1112
|
+
return true;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
if (!GEditor) {
|
|
1116
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1117
|
+
TEXT("Editor not available"), nullptr,
|
|
1118
|
+
TEXT("EDITOR_NOT_AVAILABLE"));
|
|
1119
|
+
return true;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
UObject *TargetSubsystem = nullptr;
|
|
1123
|
+
|
|
1124
|
+
// 1. Try Editor Subsystems
|
|
1125
|
+
if (!TargetSubsystem) {
|
|
1126
|
+
// We can't iterate types easily without object iterator or known list.
|
|
1127
|
+
// Try resolving class first.
|
|
1128
|
+
UClass *SubsystemClass = ResolveClassByName(SubsystemName);
|
|
1129
|
+
if (SubsystemClass) {
|
|
1130
|
+
if (SubsystemClass->IsChildOf(UEditorSubsystem::StaticClass())) {
|
|
1131
|
+
TargetSubsystem = GEditor->GetEditorSubsystemBase(SubsystemClass);
|
|
1132
|
+
} else if (SubsystemClass->IsChildOf(UEngineSubsystem::StaticClass())) {
|
|
1133
|
+
TargetSubsystem = GEngine->GetEngineSubsystemBase(SubsystemClass);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// 2. Fallback: string-based lookup if class resolve failed or returns null
|
|
1139
|
+
// (though GetEditorSubsystemBase handles null class) Iterate known
|
|
1140
|
+
// subsystem collections if we really need to, but resolving class is best.
|
|
1141
|
+
|
|
1142
|
+
if (!TargetSubsystem) {
|
|
1143
|
+
TSharedPtr<FJsonObject> Err = MakeShared<FJsonObject>();
|
|
1144
|
+
Err->SetStringField(
|
|
1145
|
+
TEXT("error"),
|
|
1146
|
+
FString::Printf(TEXT("Subsystem '%s' not found or not initialized"),
|
|
1147
|
+
*SubsystemName));
|
|
1148
|
+
SendAutomationResponse(RequestingSocket, RequestId, false,
|
|
1149
|
+
TEXT("Subsystem not found"), Err,
|
|
1150
|
+
TEXT("SUBSYSTEM_NOT_FOUND"));
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// Build command string
|
|
1155
|
+
FString CmdString = TargetFuncName;
|
|
1156
|
+
if (Args && (*Args).IsValid()) {
|
|
1157
|
+
for (const auto &Pair : (*Args)->Values) {
|
|
1158
|
+
CmdString += TEXT(" ");
|
|
1159
|
+
CmdString += Pair.Key;
|
|
1160
|
+
CmdString += TEXT("=");
|
|
1161
|
+
|
|
1162
|
+
switch (Pair.Value->Type) {
|
|
1163
|
+
case EJson::String:
|
|
1164
|
+
CmdString += FString::Printf(TEXT("\"%s\""), *Pair.Value->AsString());
|
|
1165
|
+
break;
|
|
1166
|
+
case EJson::Number:
|
|
1167
|
+
CmdString += FString::Printf(TEXT("%f"), Pair.Value->AsNumber());
|
|
1168
|
+
break;
|
|
1169
|
+
case EJson::Boolean:
|
|
1170
|
+
CmdString += Pair.Value->AsBool() ? TEXT("True") : TEXT("False");
|
|
1171
|
+
break;
|
|
1172
|
+
default:
|
|
1173
|
+
// Object/Array support in command string is limited, pass
|
|
1174
|
+
// stringified? For now, skip complex types or rely on simple string
|
|
1175
|
+
// conversion
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
FOutputDeviceNull Ar;
|
|
1182
|
+
bool bResult = TargetSubsystem->CallFunctionByNameWithArguments(
|
|
1183
|
+
*CmdString, Ar, nullptr, true);
|
|
1184
|
+
|
|
1185
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
1186
|
+
Out->SetBoolField(TEXT("success"), bResult);
|
|
1187
|
+
Out->SetStringField(TEXT("subsystem"), SubsystemName);
|
|
1188
|
+
Out->SetStringField(TEXT("function"), TargetFuncName);
|
|
1189
|
+
|
|
1190
|
+
SendAutomationResponse(RequestingSocket, RequestId, bResult,
|
|
1191
|
+
bResult ? TEXT("Function called")
|
|
1192
|
+
: TEXT("Function call failed"),
|
|
1193
|
+
Out, bResult ? FString() : TEXT("CALL_FAILED"));
|
|
1194
|
+
return true;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
if (FN == TEXT("CONFIGURE_TEXTURE_STREAMING")) {
|
|
1198
|
+
bool bEnabled = true;
|
|
1199
|
+
if (Payload->HasField(TEXT("enabled")))
|
|
1200
|
+
Payload->TryGetBoolField(TEXT("enabled"), bEnabled);
|
|
1201
|
+
|
|
1202
|
+
double PoolSize = -1;
|
|
1203
|
+
if (Payload->HasField(TEXT("poolSize")))
|
|
1204
|
+
Payload->TryGetNumberField(TEXT("poolSize"), PoolSize);
|
|
1205
|
+
|
|
1206
|
+
bool bBoost = false;
|
|
1207
|
+
if (Payload->HasField(TEXT("boostPlayerLocation")))
|
|
1208
|
+
Payload->TryGetBoolField(TEXT("boostPlayerLocation"), bBoost);
|
|
1209
|
+
|
|
1210
|
+
if (IConsoleVariable *CVar = IConsoleManager::Get().FindConsoleVariable(
|
|
1211
|
+
TEXT("r.TextureStreaming"))) {
|
|
1212
|
+
CVar->Set(bEnabled ? 1 : 0, ECVF_SetByCode);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
if (PoolSize >= 0) {
|
|
1216
|
+
if (IConsoleVariable *CVar = IConsoleManager::Get().FindConsoleVariable(
|
|
1217
|
+
TEXT("r.Streaming.PoolSize"))) {
|
|
1218
|
+
CVar->Set((int32)PoolSize, ECVF_SetByCode);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// Boost logic would go here (e.g. forcing stream in for player view),
|
|
1223
|
+
// but basic CVar setting is the core requirement.
|
|
1224
|
+
|
|
1225
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
1226
|
+
Out->SetBoolField(TEXT("success"), true);
|
|
1227
|
+
Out->SetBoolField(TEXT("enabled"), bEnabled);
|
|
1228
|
+
SendAutomationResponse(RequestingSocket, RequestId, true,
|
|
1229
|
+
TEXT("Texture streaming configured"), Out,
|
|
1230
|
+
FString());
|
|
1231
|
+
return true;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
return false;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
#endif
|