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.
Files changed (438) hide show
  1. package/.env.example +26 -0
  2. package/.env.production +38 -7
  3. package/.eslintrc.json +0 -54
  4. package/.eslintrc.override.json +8 -0
  5. package/.github/ISSUE_TEMPLATE/bug_report.yml +94 -0
  6. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  7. package/.github/ISSUE_TEMPLATE/feature_request.yml +56 -0
  8. package/.github/copilot-instructions.md +478 -45
  9. package/.github/dependabot.yml +19 -0
  10. package/.github/labeler.yml +24 -0
  11. package/.github/labels.yml +70 -0
  12. package/.github/pull_request_template.md +42 -0
  13. package/.github/release-drafter.yml +148 -0
  14. package/.github/workflows/auto-merge.yml +38 -0
  15. package/.github/workflows/ci.yml +38 -0
  16. package/.github/workflows/dependency-review.yml +17 -0
  17. package/.github/workflows/gemini-issue-triage.yml +172 -0
  18. package/.github/workflows/greetings.yml +23 -0
  19. package/.github/workflows/labeler.yml +16 -0
  20. package/.github/workflows/links.yml +80 -0
  21. package/.github/workflows/pr-size-labeler.yml +137 -0
  22. package/.github/workflows/publish-mcp.yml +12 -7
  23. package/.github/workflows/release-drafter.yml +23 -0
  24. package/.github/workflows/release.yml +112 -0
  25. package/.github/workflows/semantic-pull-request.yml +35 -0
  26. package/.github/workflows/smoke-test.yml +36 -0
  27. package/.github/workflows/stale.yml +28 -0
  28. package/CHANGELOG.md +269 -22
  29. package/CONTRIBUTING.md +140 -0
  30. package/README.md +166 -72
  31. package/claude_desktop_config_example.json +7 -6
  32. package/dist/automation/bridge.d.ts +50 -0
  33. package/dist/automation/bridge.js +452 -0
  34. package/dist/automation/connection-manager.d.ts +23 -0
  35. package/dist/automation/connection-manager.js +107 -0
  36. package/dist/automation/handshake.d.ts +11 -0
  37. package/dist/automation/handshake.js +89 -0
  38. package/dist/automation/index.d.ts +3 -0
  39. package/dist/automation/index.js +3 -0
  40. package/dist/automation/message-handler.d.ts +12 -0
  41. package/dist/automation/message-handler.js +149 -0
  42. package/dist/automation/request-tracker.d.ts +25 -0
  43. package/dist/automation/request-tracker.js +98 -0
  44. package/dist/automation/types.d.ts +130 -0
  45. package/dist/automation/types.js +2 -0
  46. package/dist/cli.js +32 -5
  47. package/dist/config.d.ts +27 -0
  48. package/dist/config.js +60 -0
  49. package/dist/constants.d.ts +12 -0
  50. package/dist/constants.js +12 -0
  51. package/dist/graphql/resolvers.d.ts +268 -0
  52. package/dist/graphql/resolvers.js +743 -0
  53. package/dist/graphql/schema.d.ts +5 -0
  54. package/dist/graphql/schema.js +437 -0
  55. package/dist/graphql/server.d.ts +26 -0
  56. package/dist/graphql/server.js +115 -0
  57. package/dist/graphql/types.d.ts +7 -0
  58. package/dist/graphql/types.js +2 -0
  59. package/dist/handlers/resource-handlers.d.ts +20 -0
  60. package/dist/handlers/resource-handlers.js +180 -0
  61. package/dist/index.d.ts +31 -18
  62. package/dist/index.js +119 -604
  63. package/dist/prompts/index.js +4 -4
  64. package/dist/resources/actors.d.ts +17 -12
  65. package/dist/resources/actors.js +56 -76
  66. package/dist/resources/assets.d.ts +6 -14
  67. package/dist/resources/assets.js +115 -147
  68. package/dist/resources/levels.d.ts +13 -13
  69. package/dist/resources/levels.js +25 -34
  70. package/dist/server/resource-registry.d.ts +20 -0
  71. package/dist/server/resource-registry.js +37 -0
  72. package/dist/server/tool-registry.d.ts +23 -0
  73. package/dist/server/tool-registry.js +322 -0
  74. package/dist/server-setup.d.ts +21 -0
  75. package/dist/server-setup.js +111 -0
  76. package/dist/services/health-monitor.d.ts +34 -0
  77. package/dist/services/health-monitor.js +105 -0
  78. package/dist/services/metrics-server.d.ts +11 -0
  79. package/dist/services/metrics-server.js +105 -0
  80. package/dist/tools/actors.d.ts +147 -9
  81. package/dist/tools/actors.js +350 -311
  82. package/dist/tools/animation.d.ts +135 -4
  83. package/dist/tools/animation.js +510 -411
  84. package/dist/tools/assets.d.ts +117 -19
  85. package/dist/tools/assets.js +259 -284
  86. package/dist/tools/audio.d.ts +102 -42
  87. package/dist/tools/audio.js +272 -685
  88. package/dist/tools/base-tool.d.ts +17 -0
  89. package/dist/tools/base-tool.js +46 -0
  90. package/dist/tools/behavior-tree.d.ts +94 -0
  91. package/dist/tools/behavior-tree.js +39 -0
  92. package/dist/tools/blueprint/helpers.d.ts +29 -0
  93. package/dist/tools/blueprint/helpers.js +182 -0
  94. package/dist/tools/blueprint.d.ts +228 -118
  95. package/dist/tools/blueprint.js +685 -832
  96. package/dist/tools/consolidated-tool-definitions.d.ts +5475 -1627
  97. package/dist/tools/consolidated-tool-definitions.js +829 -482
  98. package/dist/tools/consolidated-tool-handlers.d.ts +2 -1
  99. package/dist/tools/consolidated-tool-handlers.js +211 -1009
  100. package/dist/tools/debug.d.ts +143 -85
  101. package/dist/tools/debug.js +234 -180
  102. package/dist/tools/dynamic-handler-registry.d.ts +11 -0
  103. package/dist/tools/dynamic-handler-registry.js +101 -0
  104. package/dist/tools/editor.d.ts +139 -18
  105. package/dist/tools/editor.js +239 -244
  106. package/dist/tools/engine.d.ts +10 -4
  107. package/dist/tools/engine.js +13 -5
  108. package/dist/tools/environment.d.ts +36 -0
  109. package/dist/tools/environment.js +267 -0
  110. package/dist/tools/foliage.d.ts +105 -14
  111. package/dist/tools/foliage.js +219 -331
  112. package/dist/tools/handlers/actor-handlers.d.ts +3 -0
  113. package/dist/tools/handlers/actor-handlers.js +232 -0
  114. package/dist/tools/handlers/animation-handlers.d.ts +3 -0
  115. package/dist/tools/handlers/animation-handlers.js +185 -0
  116. package/dist/tools/handlers/argument-helper.d.ts +16 -0
  117. package/dist/tools/handlers/argument-helper.js +80 -0
  118. package/dist/tools/handlers/asset-handlers.d.ts +3 -0
  119. package/dist/tools/handlers/asset-handlers.js +496 -0
  120. package/dist/tools/handlers/audio-handlers.d.ts +3 -0
  121. package/dist/tools/handlers/audio-handlers.js +166 -0
  122. package/dist/tools/handlers/blueprint-handlers.d.ts +4 -0
  123. package/dist/tools/handlers/blueprint-handlers.js +358 -0
  124. package/dist/tools/handlers/common-handlers.d.ts +14 -0
  125. package/dist/tools/handlers/common-handlers.js +56 -0
  126. package/dist/tools/handlers/editor-handlers.d.ts +3 -0
  127. package/dist/tools/handlers/editor-handlers.js +119 -0
  128. package/dist/tools/handlers/effect-handlers.d.ts +3 -0
  129. package/dist/tools/handlers/effect-handlers.js +171 -0
  130. package/dist/tools/handlers/environment-handlers.d.ts +3 -0
  131. package/dist/tools/handlers/environment-handlers.js +170 -0
  132. package/dist/tools/handlers/graph-handlers.d.ts +3 -0
  133. package/dist/tools/handlers/graph-handlers.js +90 -0
  134. package/dist/tools/handlers/input-handlers.d.ts +3 -0
  135. package/dist/tools/handlers/input-handlers.js +21 -0
  136. package/dist/tools/handlers/inspect-handlers.d.ts +3 -0
  137. package/dist/tools/handlers/inspect-handlers.js +383 -0
  138. package/dist/tools/handlers/level-handlers.d.ts +3 -0
  139. package/dist/tools/handlers/level-handlers.js +237 -0
  140. package/dist/tools/handlers/lighting-handlers.d.ts +3 -0
  141. package/dist/tools/handlers/lighting-handlers.js +144 -0
  142. package/dist/tools/handlers/performance-handlers.d.ts +3 -0
  143. package/dist/tools/handlers/performance-handlers.js +130 -0
  144. package/dist/tools/handlers/pipeline-handlers.d.ts +3 -0
  145. package/dist/tools/handlers/pipeline-handlers.js +110 -0
  146. package/dist/tools/handlers/sequence-handlers.d.ts +3 -0
  147. package/dist/tools/handlers/sequence-handlers.js +376 -0
  148. package/dist/tools/handlers/system-handlers.d.ts +4 -0
  149. package/dist/tools/handlers/system-handlers.js +506 -0
  150. package/dist/tools/input.d.ts +19 -0
  151. package/dist/tools/input.js +89 -0
  152. package/dist/tools/introspection.d.ts +103 -40
  153. package/dist/tools/introspection.js +425 -568
  154. package/dist/tools/landscape.d.ts +97 -36
  155. package/dist/tools/landscape.js +280 -409
  156. package/dist/tools/level.d.ts +130 -10
  157. package/dist/tools/level.js +639 -675
  158. package/dist/tools/lighting.d.ts +77 -38
  159. package/dist/tools/lighting.js +441 -943
  160. package/dist/tools/logs.d.ts +45 -0
  161. package/dist/tools/logs.js +210 -0
  162. package/dist/tools/materials.d.ts +91 -24
  163. package/dist/tools/materials.js +190 -118
  164. package/dist/tools/niagara.d.ts +149 -39
  165. package/dist/tools/niagara.js +232 -182
  166. package/dist/tools/performance.d.ts +27 -12
  167. package/dist/tools/performance.js +204 -122
  168. package/dist/tools/physics.d.ts +32 -77
  169. package/dist/tools/physics.js +171 -582
  170. package/dist/tools/property-dictionary.d.ts +13 -0
  171. package/dist/tools/property-dictionary.js +82 -0
  172. package/dist/tools/sequence.d.ts +73 -48
  173. package/dist/tools/sequence.js +196 -748
  174. package/dist/tools/tool-definition-utils.d.ts +59 -0
  175. package/dist/tools/tool-definition-utils.js +35 -0
  176. package/dist/tools/ui.d.ts +66 -34
  177. package/dist/tools/ui.js +134 -214
  178. package/dist/types/env.d.ts +0 -3
  179. package/dist/types/env.js +0 -7
  180. package/dist/types/tool-interfaces.d.ts +898 -0
  181. package/dist/types/tool-interfaces.js +2 -0
  182. package/dist/types/tool-types.d.ts +195 -11
  183. package/dist/types/tool-types.js +0 -4
  184. package/dist/unreal-bridge.d.ts +24 -131
  185. package/dist/unreal-bridge.js +364 -1506
  186. package/dist/utils/command-validator.d.ts +9 -0
  187. package/dist/utils/command-validator.js +67 -0
  188. package/dist/utils/elicitation.d.ts +1 -1
  189. package/dist/utils/elicitation.js +12 -15
  190. package/dist/utils/error-handler.d.ts +2 -51
  191. package/dist/utils/error-handler.js +11 -87
  192. package/dist/utils/ini-reader.d.ts +3 -0
  193. package/dist/utils/ini-reader.js +69 -0
  194. package/dist/utils/logger.js +9 -6
  195. package/dist/utils/normalize.d.ts +3 -0
  196. package/dist/utils/normalize.js +56 -0
  197. package/dist/utils/response-factory.d.ts +7 -0
  198. package/dist/utils/response-factory.js +33 -0
  199. package/dist/utils/response-validator.d.ts +3 -24
  200. package/dist/utils/response-validator.js +130 -81
  201. package/dist/utils/result-helpers.d.ts +4 -5
  202. package/dist/utils/result-helpers.js +15 -16
  203. package/dist/utils/safe-json.js +5 -11
  204. package/dist/utils/unreal-command-queue.d.ts +24 -0
  205. package/dist/utils/unreal-command-queue.js +120 -0
  206. package/dist/utils/validation.d.ts +0 -40
  207. package/dist/utils/validation.js +1 -78
  208. package/dist/wasm/index.d.ts +70 -0
  209. package/dist/wasm/index.js +535 -0
  210. package/docs/GraphQL-API.md +888 -0
  211. package/docs/Migration-Guide-v0.5.0.md +692 -0
  212. package/docs/Roadmap.md +53 -0
  213. package/docs/WebAssembly-Integration.md +628 -0
  214. package/docs/editor-plugin-extension.md +370 -0
  215. package/docs/handler-mapping.md +242 -0
  216. package/docs/native-automation-progress.md +128 -0
  217. package/docs/testing-guide.md +423 -0
  218. package/mcp-config-example.json +6 -6
  219. package/package.json +60 -27
  220. package/plugins/McpAutomationBridge/Config/FilterPlugin.ini +8 -0
  221. package/plugins/McpAutomationBridge/McpAutomationBridge.uplugin +64 -0
  222. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/McpAutomationBridge.Build.cs +189 -0
  223. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.cpp +22 -0
  224. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeGlobals.h +30 -0
  225. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeHelpers.h +1983 -0
  226. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeModule.cpp +72 -0
  227. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSettings.cpp +46 -0
  228. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridgeSubsystem.cpp +581 -0
  229. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AnimationHandlers.cpp +2394 -0
  230. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetQueryHandlers.cpp +300 -0
  231. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AssetWorkflowHandlers.cpp +2807 -0
  232. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_AudioHandlers.cpp +1087 -0
  233. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BehaviorTreeHandlers.cpp +488 -0
  234. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.cpp +643 -0
  235. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintCreationHandlers.h +31 -0
  236. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintGraphHandlers.cpp +1184 -0
  237. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers.cpp +5652 -0
  238. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_BlueprintHandlers_List.cpp +152 -0
  239. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ControlHandlers.cpp +2614 -0
  240. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_DebugHandlers.cpp +42 -0
  241. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EditorFunctionHandlers.cpp +1237 -0
  242. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EffectHandlers.cpp +1701 -0
  243. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_EnvironmentHandlers.cpp +2145 -0
  244. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_FoliageHandlers.cpp +954 -0
  245. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InputHandlers.cpp +209 -0
  246. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_InsightsHandlers.cpp +41 -0
  247. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LandscapeHandlers.cpp +1164 -0
  248. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LevelHandlers.cpp +762 -0
  249. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LightingHandlers.cpp +634 -0
  250. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_LogHandlers.cpp +136 -0
  251. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_MaterialGraphHandlers.cpp +494 -0
  252. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraGraphHandlers.cpp +278 -0
  253. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_NiagaraHandlers.cpp +625 -0
  254. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PerformanceHandlers.cpp +401 -0
  255. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PipelineHandlers.cpp +67 -0
  256. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_ProcessRequest.cpp +735 -0
  257. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_PropertyHandlers.cpp +2634 -0
  258. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_RenderHandlers.cpp +189 -0
  259. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.cpp +917 -0
  260. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SCSHandlers.h +39 -0
  261. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequenceHandlers.cpp +2670 -0
  262. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_SequencerHandlers.cpp +519 -0
  263. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_TestHandlers.cpp +38 -0
  264. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_UiHandlers.cpp +668 -0
  265. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpAutomationBridge_WorldPartitionHandlers.cpp +346 -0
  266. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.cpp +1330 -0
  267. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpBridgeWebSocket.h +149 -0
  268. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/McpConnectionManager.cpp +783 -0
  269. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSettings.h +115 -0
  270. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSubsystem.h +796 -0
  271. package/plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpConnectionManager.h +117 -0
  272. package/scripts/check-unreal-connection.mjs +19 -0
  273. package/scripts/clean-tmp.js +23 -0
  274. package/scripts/patch-wasm.js +26 -0
  275. package/scripts/run-all-tests.mjs +131 -0
  276. package/scripts/smoke-test.ts +94 -0
  277. package/scripts/sync-mcp-plugin.js +143 -0
  278. package/scripts/test-no-plugin-alternates.mjs +113 -0
  279. package/scripts/validate-server.js +46 -0
  280. package/scripts/verify-automation-bridge.js +200 -0
  281. package/server.json +57 -21
  282. package/src/automation/bridge.ts +558 -0
  283. package/src/automation/connection-manager.ts +130 -0
  284. package/src/automation/handshake.ts +99 -0
  285. package/src/automation/index.ts +2 -0
  286. package/src/automation/message-handler.ts +167 -0
  287. package/src/automation/request-tracker.ts +123 -0
  288. package/src/automation/types.ts +107 -0
  289. package/src/cli.ts +33 -6
  290. package/src/config.ts +73 -0
  291. package/src/constants.ts +12 -0
  292. package/src/graphql/resolvers.ts +1010 -0
  293. package/src/graphql/schema.ts +452 -0
  294. package/src/graphql/server.ts +154 -0
  295. package/src/graphql/types.ts +7 -0
  296. package/src/handlers/resource-handlers.ts +186 -0
  297. package/src/index.ts +152 -649
  298. package/src/prompts/index.ts +4 -4
  299. package/src/resources/actors.ts +58 -76
  300. package/src/resources/assets.ts +147 -134
  301. package/src/resources/levels.ts +28 -33
  302. package/src/server/resource-registry.ts +47 -0
  303. package/src/server/tool-registry.ts +354 -0
  304. package/src/server-setup.ts +148 -0
  305. package/src/services/health-monitor.ts +132 -0
  306. package/src/services/metrics-server.ts +142 -0
  307. package/src/tools/actors.ts +417 -322
  308. package/src/tools/animation.ts +671 -461
  309. package/src/tools/assets.ts +353 -289
  310. package/src/tools/audio.ts +323 -766
  311. package/src/tools/base-tool.ts +52 -0
  312. package/src/tools/behavior-tree.ts +45 -0
  313. package/src/tools/blueprint/helpers.ts +189 -0
  314. package/src/tools/blueprint.ts +787 -965
  315. package/src/tools/consolidated-tool-definitions.ts +993 -500
  316. package/src/tools/consolidated-tool-handlers.ts +272 -1122
  317. package/src/tools/debug.ts +292 -187
  318. package/src/tools/dynamic-handler-registry.ts +151 -0
  319. package/src/tools/editor.ts +309 -246
  320. package/src/tools/engine.ts +14 -3
  321. package/src/tools/environment.ts +287 -0
  322. package/src/tools/foliage.ts +314 -379
  323. package/src/tools/handlers/actor-handlers.ts +271 -0
  324. package/src/tools/handlers/animation-handlers.ts +237 -0
  325. package/src/tools/handlers/argument-helper.ts +142 -0
  326. package/src/tools/handlers/asset-handlers.ts +532 -0
  327. package/src/tools/handlers/audio-handlers.ts +194 -0
  328. package/src/tools/handlers/blueprint-handlers.ts +380 -0
  329. package/src/tools/handlers/common-handlers.ts +87 -0
  330. package/src/tools/handlers/editor-handlers.ts +123 -0
  331. package/src/tools/handlers/effect-handlers.ts +220 -0
  332. package/src/tools/handlers/environment-handlers.ts +183 -0
  333. package/src/tools/handlers/graph-handlers.ts +116 -0
  334. package/src/tools/handlers/input-handlers.ts +28 -0
  335. package/src/tools/handlers/inspect-handlers.ts +450 -0
  336. package/src/tools/handlers/level-handlers.ts +252 -0
  337. package/src/tools/handlers/lighting-handlers.ts +147 -0
  338. package/src/tools/handlers/performance-handlers.ts +132 -0
  339. package/src/tools/handlers/pipeline-handlers.ts +127 -0
  340. package/src/tools/handlers/sequence-handlers.ts +415 -0
  341. package/src/tools/handlers/system-handlers.ts +564 -0
  342. package/src/tools/input.ts +101 -0
  343. package/src/tools/introspection.ts +493 -584
  344. package/src/tools/landscape.ts +394 -489
  345. package/src/tools/level.ts +752 -694
  346. package/src/tools/lighting.ts +583 -984
  347. package/src/tools/logs.ts +219 -0
  348. package/src/tools/materials.ts +231 -121
  349. package/src/tools/niagara.ts +293 -168
  350. package/src/tools/performance.ts +320 -168
  351. package/src/tools/physics.ts +268 -613
  352. package/src/tools/property-dictionary.ts +98 -0
  353. package/src/tools/sequence.ts +255 -815
  354. package/src/tools/tool-definition-utils.ts +35 -0
  355. package/src/tools/ui.ts +207 -283
  356. package/src/types/env.ts +0 -10
  357. package/src/types/tool-interfaces.ts +250 -0
  358. package/src/types/tool-types.ts +250 -13
  359. package/src/unreal-bridge.ts +460 -1550
  360. package/src/utils/command-validator.ts +75 -0
  361. package/src/utils/elicitation.ts +10 -7
  362. package/src/utils/error-handler.ts +14 -90
  363. package/src/utils/ini-reader.ts +86 -0
  364. package/src/utils/logger.ts +8 -3
  365. package/src/utils/normalize.ts +60 -0
  366. package/src/utils/response-factory.ts +39 -0
  367. package/src/utils/response-validator.ts +176 -56
  368. package/src/utils/result-helpers.ts +21 -19
  369. package/src/utils/safe-json.ts +14 -11
  370. package/src/utils/unreal-command-queue.ts +152 -0
  371. package/src/utils/validation.ts +4 -1
  372. package/src/wasm/index.ts +838 -0
  373. package/test-server.mjs +100 -0
  374. package/tests/run-unreal-tool-tests.mjs +242 -14
  375. package/tests/test-animation.mjs +44 -0
  376. package/tests/test-asset-advanced.mjs +82 -0
  377. package/tests/test-asset-errors.mjs +35 -0
  378. package/tests/test-audio.mjs +219 -0
  379. package/tests/test-automation-timeouts.mjs +98 -0
  380. package/tests/test-behavior-tree.mjs +261 -0
  381. package/tests/test-blueprint-events.mjs +35 -0
  382. package/tests/test-blueprint-graph.mjs +79 -0
  383. package/tests/test-blueprint.mjs +577 -0
  384. package/tests/test-client-mode.mjs +86 -0
  385. package/tests/test-console-command.mjs +56 -0
  386. package/tests/test-control-actor.mjs +425 -0
  387. package/tests/test-control-editor.mjs +80 -0
  388. package/tests/test-extra-tools.mjs +38 -0
  389. package/tests/test-graphql.mjs +322 -0
  390. package/tests/test-inspect.mjs +72 -0
  391. package/tests/test-landscape.mjs +60 -0
  392. package/tests/test-manage-asset.mjs +438 -0
  393. package/tests/test-manage-level.mjs +70 -0
  394. package/tests/test-materials.mjs +356 -0
  395. package/tests/test-niagara.mjs +185 -0
  396. package/tests/test-no-inline-python.mjs +122 -0
  397. package/tests/test-plugin-handshake.mjs +82 -0
  398. package/tests/test-render.mjs +33 -0
  399. package/tests/test-runner.mjs +933 -0
  400. package/tests/test-search-assets.mjs +66 -0
  401. package/tests/test-sequence.mjs +68 -0
  402. package/tests/test-system.mjs +57 -0
  403. package/tests/test-wasm.mjs +193 -0
  404. package/tests/test-world-partition.mjs +215 -0
  405. package/tsconfig.json +3 -3
  406. package/wasm/Cargo.lock +363 -0
  407. package/wasm/Cargo.toml +42 -0
  408. package/wasm/LICENSE +21 -0
  409. package/wasm/README.md +253 -0
  410. package/wasm/src/dependency_resolver.rs +377 -0
  411. package/wasm/src/lib.rs +153 -0
  412. package/wasm/src/property_parser.rs +271 -0
  413. package/wasm/src/transform_math.rs +396 -0
  414. package/wasm/tests/integration.rs +109 -0
  415. package/.github/workflows/smithery-build.yml +0 -29
  416. package/dist/tools/build_environment_advanced.d.ts +0 -65
  417. package/dist/tools/build_environment_advanced.js +0 -633
  418. package/dist/tools/rc.d.ts +0 -110
  419. package/dist/tools/rc.js +0 -437
  420. package/dist/tools/visual.d.ts +0 -40
  421. package/dist/tools/visual.js +0 -282
  422. package/dist/utils/http.d.ts +0 -6
  423. package/dist/utils/http.js +0 -151
  424. package/dist/utils/python-output.d.ts +0 -18
  425. package/dist/utils/python-output.js +0 -290
  426. package/dist/utils/python.d.ts +0 -2
  427. package/dist/utils/python.js +0 -4
  428. package/dist/utils/stdio-redirect.d.ts +0 -2
  429. package/dist/utils/stdio-redirect.js +0 -20
  430. package/docs/unreal-tool-test-cases.md +0 -572
  431. package/smithery.yaml +0 -29
  432. package/src/tools/build_environment_advanced.ts +0 -732
  433. package/src/tools/rc.ts +0 -515
  434. package/src/tools/visual.ts +0 -281
  435. package/src/utils/http.ts +0 -187
  436. package/src/utils/python-output.ts +0 -351
  437. package/src/utils/python.ts +0 -3
  438. package/src/utils/stdio-redirect.ts +0 -18
@@ -1,1036 +1,238 @@
1
- // Consolidated tool handlers - maps 13 tools to all 36 operations
2
1
  import { cleanObject } from '../utils/safe-json.js';
3
2
  import { Logger } from '../utils/logger.js';
4
- const log = new Logger('ConsolidatedToolHandler');
5
- const ACTION_REQUIRED_ERROR = 'Missing required parameter: action';
6
- function ensureArgsPresent(args) {
7
- if (args === null || args === undefined) {
8
- throw new Error('Invalid arguments: null or undefined');
9
- }
3
+ import { ResponseFactory } from '../utils/response-factory.js';
4
+ import { executeAutomationRequest, requireAction } from './handlers/common-handlers.js';
5
+ import { handleAssetTools } from './handlers/asset-handlers.js';
6
+ import { handleActorTools } from './handlers/actor-handlers.js';
7
+ import { handleEditorTools } from './handlers/editor-handlers.js';
8
+ import { handleLevelTools } from './handlers/level-handlers.js';
9
+ import { handleBlueprintTools, handleBlueprintGet } from './handlers/blueprint-handlers.js';
10
+ import { handleSequenceTools } from './handlers/sequence-handlers.js';
11
+ import { handleAnimationTools } from './handlers/animation-handlers.js';
12
+ import { handleEffectTools } from './handlers/effect-handlers.js';
13
+ import { handleEnvironmentTools } from './handlers/environment-handlers.js';
14
+ import { handleSystemTools, handleConsoleCommand } from './handlers/system-handlers.js';
15
+ import { handleInspectTools } from './handlers/inspect-handlers.js';
16
+ import { handlePipelineTools } from './handlers/pipeline-handlers.js';
17
+ import { handleGraphTools } from './handlers/graph-handlers.js';
18
+ import { handleAudioTools } from './handlers/audio-handlers.js';
19
+ import { handleLightingTools } from './handlers/lighting-handlers.js';
20
+ import { handlePerformanceTools } from './handlers/performance-handlers.js';
21
+ import { handleInputTools } from './handlers/input-handlers.js';
22
+ import { getDynamicHandlerForTool } from './dynamic-handler-registry.js';
23
+ import { consolidatedToolDefinitions } from './consolidated-tool-definitions.js';
24
+ const MATERIAL_GRAPH_ACTION_MAP = {
25
+ add_material_node: 'add_node',
26
+ connect_material_pins: 'connect_pins',
27
+ remove_material_node: 'remove_node',
28
+ break_material_connections: 'break_connections',
29
+ get_material_node_details: 'get_node_details',
30
+ };
31
+ const BEHAVIOR_TREE_ACTION_MAP = {
32
+ add_bt_node: 'add_node',
33
+ connect_bt_nodes: 'connect_nodes',
34
+ remove_bt_node: 'remove_node',
35
+ break_bt_connections: 'break_connections',
36
+ set_bt_node_properties: 'set_node_properties'
37
+ };
38
+ const NIAGARA_GRAPH_ACTION_MAP = {
39
+ add_niagara_module: 'add_module',
40
+ connect_niagara_pins: 'connect_pins',
41
+ remove_niagara_node: 'remove_node',
42
+ set_niagara_parameter: 'set_parameter'
43
+ };
44
+ function isMaterialGraphAction(action) {
45
+ return (Object.prototype.hasOwnProperty.call(MATERIAL_GRAPH_ACTION_MAP, action) ||
46
+ action.includes('material_node') ||
47
+ action.includes('material_pins') ||
48
+ action.includes('material_connections'));
10
49
  }
11
- function requireAction(args) {
12
- ensureArgsPresent(args);
13
- const action = args.action;
14
- if (typeof action !== 'string' || action.trim() === '') {
15
- throw new Error(ACTION_REQUIRED_ERROR);
16
- }
17
- return action;
50
+ function isBehaviorTreeGraphAction(action) {
51
+ return (Object.prototype.hasOwnProperty.call(BEHAVIOR_TREE_ACTION_MAP, action) ||
52
+ action.includes('_bt_') ||
53
+ action.includes('behavior_tree'));
18
54
  }
19
- function requireNonEmptyString(value, field, message) {
20
- if (typeof value !== 'string' || value.trim() === '') {
21
- throw new Error(message ?? `Invalid ${field}: must be a non-empty string`);
22
- }
23
- return value;
55
+ function isNiagaraGraphAction(action) {
56
+ return (Object.prototype.hasOwnProperty.call(NIAGARA_GRAPH_ACTION_MAP, action) ||
57
+ action.includes('niagara_module') ||
58
+ action.includes('niagara_pins') ||
59
+ action.includes('niagara_node') ||
60
+ action.includes('niagara_parameter'));
24
61
  }
25
- function requirePositiveNumber(value, field, message) {
26
- if (typeof value !== 'number' || !isFinite(value) || value <= 0) {
27
- throw new Error(message ?? `Invalid ${field}: must be a positive number`);
62
+ function normalizeToolCall(name, args) {
63
+ let normalizedName = name;
64
+ let action;
65
+ if (args && typeof args.action === 'string') {
66
+ action = args.action;
28
67
  }
29
- return value;
30
- }
31
- function requireVector3Components(vector, message) {
32
- if (!vector ||
33
- typeof vector.x !== 'number' ||
34
- typeof vector.y !== 'number' ||
35
- typeof vector.z !== 'number') {
36
- throw new Error(message);
68
+ else if (normalizedName === 'console_command') {
69
+ normalizedName = 'system_control';
70
+ action = 'console_command';
37
71
  }
38
- return [vector.x, vector.y, vector.z];
39
- }
40
- function getElicitationTimeoutMs(tools) {
41
- if (!tools)
42
- return undefined;
43
- const direct = tools.elicitationTimeoutMs;
44
- if (typeof direct === 'number' && Number.isFinite(direct)) {
45
- return direct;
72
+ else {
73
+ action = requireAction(args);
46
74
  }
47
- if (typeof tools.getElicitationTimeoutMs === 'function') {
48
- const value = tools.getElicitationTimeoutMs();
49
- if (typeof value === 'number' && Number.isFinite(value)) {
50
- return value;
51
- }
75
+ if (normalizedName === 'create_effect')
76
+ normalizedName = 'manage_effect';
77
+ if (normalizedName === 'console_command') {
78
+ normalizedName = 'system_control';
79
+ action = 'console_command';
52
80
  }
53
- return undefined;
54
- }
55
- async function elicitMissingPrimitiveArgs(tools, args, prompt, fieldSchemas) {
56
- if (!tools ||
57
- typeof tools.supportsElicitation !== 'function' ||
58
- !tools.supportsElicitation() ||
59
- typeof tools.elicit !== 'function') {
60
- return;
81
+ if (normalizedName === 'manage_pipeline') {
82
+ normalizedName = 'system_control';
83
+ action = 'run_ubt';
61
84
  }
62
- const properties = {};
63
- const required = [];
64
- for (const [key, schema] of Object.entries(fieldSchemas)) {
65
- const value = args?.[key];
66
- const missing = value === undefined ||
67
- value === null ||
68
- (typeof value === 'string' && value.trim() === '');
69
- if (missing) {
70
- properties[key] = schema;
71
- required.push(key);
72
- }
85
+ if (normalizedName === 'manage_tests') {
86
+ normalizedName = 'system_control';
87
+ action = 'run_tests';
73
88
  }
74
- if (required.length === 0)
75
- return;
76
- const timeoutMs = getElicitationTimeoutMs(tools);
77
- const options = {
78
- fallback: async () => ({ ok: false, error: 'missing-params' })
89
+ return {
90
+ name: normalizedName,
91
+ action,
92
+ args
79
93
  };
80
- if (typeof timeoutMs === 'number') {
81
- options.timeoutMs = timeoutMs;
82
- }
83
- try {
84
- const elicited = await tools.elicit(prompt, { type: 'object', properties, required }, options);
85
- if (elicited?.ok && elicited.value) {
86
- for (const key of required) {
87
- const value = elicited.value[key];
88
- if (value === undefined || value === null)
89
- continue;
90
- args[key] = typeof value === 'string' ? value.trim() : value;
94
+ }
95
+ async function invokeNamedTool(name, action, args, tools) {
96
+ switch (name) {
97
+ case 'manage_asset': {
98
+ if (['create_render_target', 'nanite_rebuild_mesh'].includes(action)) {
99
+ const payload = { ...args, subAction: action };
100
+ return cleanObject(await executeAutomationRequest(tools, 'manage_render', payload, `Automation bridge not available for ${action}`));
101
+ }
102
+ if (isMaterialGraphAction(action)) {
103
+ const subAction = MATERIAL_GRAPH_ACTION_MAP[action] || action;
104
+ return await handleGraphTools('manage_material_graph', subAction, args, tools);
91
105
  }
106
+ if (isBehaviorTreeGraphAction(action)) {
107
+ const subAction = BEHAVIOR_TREE_ACTION_MAP[action] || action;
108
+ return await handleGraphTools('manage_behavior_tree', subAction, args, tools);
109
+ }
110
+ return await handleAssetTools(action, args, tools);
92
111
  }
93
- }
94
- catch (err) {
95
- log.debug('Special elicitation fallback skipped', {
96
- prompt,
97
- err: err?.message || String(err)
98
- });
112
+ case 'manage_blueprint': {
113
+ if (action === 'get_blueprint') {
114
+ return await handleBlueprintGet(args, tools);
115
+ }
116
+ const graphActions = ['create_node', 'delete_node', 'connect_pins', 'break_pin_links', 'set_node_property', 'create_reroute_node', 'get_node_details', 'get_graph_details', 'get_pin_details'];
117
+ if (graphActions.includes(action)) {
118
+ return await handleGraphTools('manage_blueprint_graph', action, args, tools);
119
+ }
120
+ return await handleBlueprintTools(action, args, tools);
121
+ }
122
+ case 'control_actor':
123
+ return await handleActorTools(action, args, tools);
124
+ case 'control_editor': {
125
+ if (action === 'simulate_input') {
126
+ const payload = { ...args, subAction: action };
127
+ return cleanObject(await executeAutomationRequest(tools, 'manage_ui', payload, 'Automation bridge not available'));
128
+ }
129
+ return await handleEditorTools(action, args, tools);
130
+ }
131
+ case 'manage_level': {
132
+ if (['load_cells', 'set_datalayer'].includes(action)) {
133
+ const payload = { ...args, subAction: action };
134
+ return cleanObject(await executeAutomationRequest(tools, 'manage_world_partition', payload, 'Automation bridge not available'));
135
+ }
136
+ return await handleLevelTools(action, args, tools);
137
+ }
138
+ case 'animation_physics':
139
+ return await handleAnimationTools(action, args, tools);
140
+ case 'manage_effect': {
141
+ if (isNiagaraGraphAction(action)) {
142
+ const isInstanceOp = action === 'set_niagara_parameter' && (args.actorName || (args.systemName && !args.assetPath && !args.systemPath));
143
+ if (isInstanceOp) {
144
+ return await handleEffectTools(action, args, tools);
145
+ }
146
+ const subAction = NIAGARA_GRAPH_ACTION_MAP[action] || action;
147
+ return await handleGraphTools('manage_niagara_graph', subAction, args, tools);
148
+ }
149
+ return await handleEffectTools(action, args, tools);
150
+ }
151
+ case 'build_environment':
152
+ return await handleEnvironmentTools(action, args, tools);
153
+ case 'system_control': {
154
+ if (action === 'console_command')
155
+ return await handleConsoleCommand(args, tools);
156
+ if (action === 'run_ubt')
157
+ return await handlePipelineTools(action, args, tools);
158
+ if (action === 'run_tests')
159
+ return cleanObject(await executeAutomationRequest(tools, 'manage_tests', { ...args, subAction: action }, 'Bridge unavailable'));
160
+ if (action === 'subscribe' || action === 'unsubscribe')
161
+ return cleanObject(await executeAutomationRequest(tools, 'manage_logs', { ...args, subAction: action }, 'Bridge unavailable'));
162
+ if (action === 'spawn_category')
163
+ return cleanObject(await executeAutomationRequest(tools, 'manage_debug', { ...args, subAction: action }, 'Bridge unavailable'));
164
+ if (action === 'start_session')
165
+ return cleanObject(await executeAutomationRequest(tools, 'manage_insights', { ...args, subAction: action }, 'Bridge unavailable'));
166
+ if (action === 'lumen_update_scene')
167
+ return cleanObject(await executeAutomationRequest(tools, 'manage_render', { ...args, subAction: action }, 'Bridge unavailable'));
168
+ return await handleSystemTools(action, args, tools);
169
+ }
170
+ case 'manage_sequence':
171
+ return await handleSequenceTools(action, args, tools);
172
+ case 'inspect':
173
+ return await handleInspectTools(action, args, tools);
174
+ case 'manage_audio':
175
+ return await handleAudioTools(action, args, tools);
176
+ case 'manage_behavior_tree':
177
+ return await handleGraphTools('manage_behavior_tree', action, args, tools);
178
+ case 'manage_blueprint_graph':
179
+ return await handleGraphTools('manage_blueprint_graph', action, args, tools);
180
+ case 'manage_render':
181
+ return cleanObject(await executeAutomationRequest(tools, 'manage_render', { ...args, subAction: action }, 'Bridge unavailable'));
182
+ case 'manage_world_partition':
183
+ return cleanObject(await executeAutomationRequest(tools, 'manage_world_partition', { ...args, subAction: action }, 'Bridge unavailable'));
184
+ case 'manage_lighting':
185
+ return await handleLightingTools(action, args, tools);
186
+ case 'manage_performance':
187
+ return await handlePerformanceTools(action, args, tools);
188
+ case 'manage_input':
189
+ return await handleInputTools(action, args, tools);
190
+ default:
191
+ return cleanObject({ success: false, error: 'UNKNOWN_TOOL', message: `Unknown consolidated tool: ${name}` });
99
192
  }
100
193
  }
101
194
  export async function handleConsolidatedToolCall(name, args, tools) {
195
+ const logger = new Logger('ConsolidatedToolHandler');
102
196
  const startTime = Date.now();
103
- // Use scoped logger (stderr) to avoid polluting stdout JSON
104
- log.debug(`Starting execution of ${name} at ${new Date().toISOString()}`);
197
+ logger.info(`Starting execution of ${name} at ${new Date().toISOString()}`);
105
198
  try {
106
- ensureArgsPresent(args);
107
- switch (name) {
108
- // 1. ASSET MANAGER
109
- case 'manage_asset':
110
- switch (requireAction(args)) {
111
- case 'list': {
112
- if (args.directory !== undefined && args.directory !== null && typeof args.directory !== 'string') {
113
- throw new Error('Invalid directory: must be a string');
114
- }
115
- const res = await tools.assetResources.list(args.directory || '/Game', false);
116
- return cleanObject({ success: true, ...res });
117
- }
118
- case 'import': {
119
- let sourcePath = typeof args.sourcePath === 'string' ? args.sourcePath.trim() : '';
120
- let destinationPath = typeof args.destinationPath === 'string' ? args.destinationPath.trim() : '';
121
- if ((!sourcePath || !destinationPath) && typeof tools.supportsElicitation === 'function' && tools.supportsElicitation() && typeof tools.elicit === 'function') {
122
- const schemaProps = {};
123
- const required = [];
124
- if (!sourcePath) {
125
- schemaProps.sourcePath = {
126
- type: 'string',
127
- title: 'Source File Path',
128
- description: 'Full path to the asset file on disk to import'
129
- };
130
- required.push('sourcePath');
131
- }
132
- if (!destinationPath) {
133
- schemaProps.destinationPath = {
134
- type: 'string',
135
- title: 'Destination Path',
136
- description: 'Unreal content path where the asset should be imported (e.g., /Game/MCP/Assets)'
137
- };
138
- required.push('destinationPath');
139
- }
140
- if (required.length > 0) {
141
- const timeoutMs = getElicitationTimeoutMs(tools);
142
- const options = { fallback: async () => ({ ok: false, error: 'missing-import-params' }) };
143
- if (typeof timeoutMs === 'number') {
144
- options.timeoutMs = timeoutMs;
145
- }
146
- const elicited = await tools.elicit('Provide the missing import parameters for manage_asset.import', { type: 'object', properties: schemaProps, required }, options);
147
- if (elicited?.ok && elicited.value) {
148
- if (typeof elicited.value.sourcePath === 'string') {
149
- sourcePath = elicited.value.sourcePath.trim();
150
- }
151
- if (typeof elicited.value.destinationPath === 'string') {
152
- destinationPath = elicited.value.destinationPath.trim();
153
- }
154
- }
155
- }
156
- }
157
- const sourcePathValidated = requireNonEmptyString(sourcePath || args.sourcePath, 'sourcePath', 'Invalid sourcePath');
158
- const destinationPathValidated = requireNonEmptyString(destinationPath || args.destinationPath, 'destinationPath', 'Invalid destinationPath');
159
- const res = await tools.assetTools.importAsset(sourcePathValidated, destinationPathValidated);
160
- return cleanObject(res);
161
- }
162
- case 'create_material': {
163
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the material details for manage_asset.create_material', {
164
- name: {
165
- type: 'string',
166
- title: 'Material Name',
167
- description: 'Name for the new material asset'
168
- },
169
- path: {
170
- type: 'string',
171
- title: 'Save Path',
172
- description: 'Optional Unreal content path where the material should be saved'
173
- }
174
- });
175
- const sanitizedName = typeof args.name === 'string' ? args.name.trim() : args.name;
176
- const sanitizedPath = typeof args.path === 'string' ? args.path.trim() : args.path;
177
- const name = requireNonEmptyString(sanitizedName, 'name', 'Invalid name: must be a non-empty string');
178
- const res = await tools.materialTools.createMaterial(name, sanitizedPath || '/Game/Materials');
179
- return cleanObject(res);
180
- }
181
- default:
182
- throw new Error(`Unknown asset action: ${args.action}`);
183
- }
184
- // 2. ACTOR CONTROL
185
- case 'control_actor':
186
- switch (requireAction(args)) {
187
- case 'spawn': {
188
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the spawn parameters for control_actor.spawn', {
189
- classPath: {
190
- type: 'string',
191
- title: 'Actor Class or Asset Path',
192
- description: 'Class name (e.g., StaticMeshActor) or asset path (e.g., /Engine/BasicShapes/Cube) to spawn'
193
- }
194
- });
195
- const classPathInput = typeof args.classPath === 'string' ? args.classPath.trim() : args.classPath;
196
- const classPath = requireNonEmptyString(classPathInput, 'classPath', 'Invalid classPath: must be a non-empty string');
197
- const actorNameInput = typeof args.actorName === 'string' && args.actorName.trim() !== ''
198
- ? args.actorName
199
- : (typeof args.name === 'string' ? args.name : undefined);
200
- const res = await tools.actorTools.spawn({
201
- classPath,
202
- location: args.location,
203
- rotation: args.rotation,
204
- actorName: actorNameInput
205
- });
206
- return cleanObject(res);
207
- }
208
- case 'delete': {
209
- await elicitMissingPrimitiveArgs(tools, args, 'Which actor should control_actor.delete remove?', {
210
- actorName: {
211
- type: 'string',
212
- title: 'Actor Name',
213
- description: 'Exact label of the actor to delete'
214
- }
215
- });
216
- const actorNameArg = typeof args.actorName === 'string' && args.actorName.trim() !== ''
217
- ? args.actorName
218
- : (typeof args.name === 'string' ? args.name : undefined);
219
- const actorName = requireNonEmptyString(actorNameArg, 'actorName', 'Invalid actorName');
220
- const res = await tools.bridge.executeEditorFunction('DELETE_ACTOR', { actor_name: actorName });
221
- return cleanObject(res);
222
- }
223
- case 'apply_force': {
224
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the target actor for control_actor.apply_force', {
225
- actorName: {
226
- type: 'string',
227
- title: 'Actor Name',
228
- description: 'Physics-enabled actor that should receive the force'
229
- }
230
- });
231
- const actorName = requireNonEmptyString(args.actorName, 'actorName', 'Invalid actorName');
232
- const vector = requireVector3Components(args.force, 'Invalid force: must have numeric x,y,z');
233
- const res = await tools.physicsTools.applyForce({
234
- actorName,
235
- forceType: 'Force',
236
- vector
237
- });
238
- return cleanObject(res);
239
- }
240
- default:
241
- throw new Error(`Unknown actor action: ${args.action}`);
242
- }
243
- // 3. EDITOR CONTROL
244
- case 'control_editor':
245
- switch (requireAction(args)) {
246
- case 'play': {
247
- const res = await tools.editorTools.playInEditor();
248
- return cleanObject(res);
249
- }
250
- case 'stop': {
251
- const res = await tools.editorTools.stopPlayInEditor();
252
- return cleanObject(res);
253
- }
254
- case 'pause': {
255
- const res = await tools.editorTools.pausePlayInEditor();
256
- return cleanObject(res);
257
- }
258
- case 'set_game_speed': {
259
- const speed = requirePositiveNumber(args.speed, 'speed', 'Invalid speed: must be a positive number');
260
- // Use console command via bridge
261
- const res = await tools.bridge.executeConsoleCommand(`slomo ${speed}`);
262
- return cleanObject(res);
263
- }
264
- case 'eject': {
265
- const res = await tools.bridge.executeConsoleCommand('eject');
266
- return cleanObject(res);
267
- }
268
- case 'possess': {
269
- const res = await tools.bridge.executeConsoleCommand('viewself');
270
- return cleanObject(res);
271
- }
272
- case 'set_camera': {
273
- const res = await tools.editorTools.setViewportCamera(args.location, args.rotation);
274
- return cleanObject(res);
275
- }
276
- case 'set_view_mode': {
277
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the view mode for control_editor.set_view_mode', {
278
- viewMode: {
279
- type: 'string',
280
- title: 'View Mode',
281
- description: 'Viewport view mode (e.g., Lit, Unlit, Wireframe)'
282
- }
283
- });
284
- const viewMode = requireNonEmptyString(args.viewMode, 'viewMode', 'Missing required parameter: viewMode');
285
- const res = await tools.bridge.setSafeViewMode(viewMode);
286
- return cleanObject(res);
287
- }
288
- default:
289
- throw new Error(`Unknown editor action: ${args.action}`);
290
- }
291
- // 4. LEVEL MANAGER
292
- case 'manage_level':
293
- switch (requireAction(args)) {
294
- case 'load': {
295
- await elicitMissingPrimitiveArgs(tools, args, 'Select the level to load for manage_level.load', {
296
- levelPath: {
297
- type: 'string',
298
- title: 'Level Path',
299
- description: 'Content path of the level asset to load (e.g., /Game/Maps/MyLevel)'
300
- }
301
- });
302
- const levelPath = requireNonEmptyString(args.levelPath, 'levelPath', 'Missing required parameter: levelPath');
303
- const res = await tools.levelTools.loadLevel({ levelPath, streaming: !!args.streaming });
304
- return cleanObject(res);
305
- }
306
- case 'save': {
307
- const res = await tools.levelTools.saveLevel({ levelName: args.levelName, savePath: args.savePath });
308
- return cleanObject(res);
309
- }
310
- case 'stream': {
311
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the streaming level name for manage_level.stream', {
312
- levelName: {
313
- type: 'string',
314
- title: 'Level Name',
315
- description: 'Streaming level name to toggle'
316
- }
317
- });
318
- const levelName = requireNonEmptyString(args.levelName, 'levelName', 'Missing required parameter: levelName');
319
- const res = await tools.levelTools.streamLevel({ levelName, shouldBeLoaded: !!args.shouldBeLoaded, shouldBeVisible: !!args.shouldBeVisible });
320
- return cleanObject(res);
321
- }
322
- case 'create_light': {
323
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the light details for manage_level.create_light', {
324
- lightType: {
325
- type: 'string',
326
- title: 'Light Type',
327
- description: 'Directional, Point, Spot, Rect, or Sky'
328
- },
329
- name: {
330
- type: 'string',
331
- title: 'Light Name',
332
- description: 'Name for the new light actor'
333
- }
334
- });
335
- const lightType = requireNonEmptyString(args.lightType, 'lightType', 'Missing required parameter: lightType');
336
- const name = requireNonEmptyString(args.name, 'name', 'Invalid name');
337
- const typeKey = lightType.toLowerCase();
338
- const toVector = (value, fallback) => {
339
- if (Array.isArray(value) && value.length === 3) {
340
- return [Number(value[0]) || 0, Number(value[1]) || 0, Number(value[2]) || 0];
341
- }
342
- if (value && typeof value === 'object') {
343
- return [Number(value.x) || 0, Number(value.y) || 0, Number(value.z) || 0];
344
- }
345
- return fallback;
346
- };
347
- const toRotator = (value, fallback) => {
348
- if (Array.isArray(value) && value.length === 3) {
349
- return [Number(value[0]) || 0, Number(value[1]) || 0, Number(value[2]) || 0];
350
- }
351
- if (value && typeof value === 'object') {
352
- return [Number(value.pitch) || 0, Number(value.yaw) || 0, Number(value.roll) || 0];
353
- }
354
- return fallback;
355
- };
356
- const toColor = (value) => {
357
- if (Array.isArray(value) && value.length === 3) {
358
- return [Number(value[0]) || 0, Number(value[1]) || 0, Number(value[2]) || 0];
359
- }
360
- if (value && typeof value === 'object') {
361
- return [Number(value.r) || 0, Number(value.g) || 0, Number(value.b) || 0];
362
- }
363
- return undefined;
364
- };
365
- const location = toVector(args.location, [0, 0, typeKey === 'directional' ? 500 : 0]);
366
- const rotation = toRotator(args.rotation, [0, 0, 0]);
367
- const color = toColor(args.color);
368
- const castShadows = typeof args.castShadows === 'boolean' ? args.castShadows : undefined;
369
- if (typeKey === 'directional') {
370
- return cleanObject(await tools.lightingTools.createDirectionalLight({
371
- name,
372
- intensity: args.intensity,
373
- color,
374
- rotation,
375
- castShadows,
376
- temperature: args.temperature
377
- }));
378
- }
379
- if (typeKey === 'point') {
380
- return cleanObject(await tools.lightingTools.createPointLight({
381
- name,
382
- location,
383
- intensity: args.intensity,
384
- radius: args.radius,
385
- color,
386
- falloffExponent: args.falloffExponent,
387
- castShadows
388
- }));
389
- }
390
- if (typeKey === 'spot') {
391
- const innerCone = typeof args.innerCone === 'number' ? args.innerCone : undefined;
392
- const outerCone = typeof args.outerCone === 'number' ? args.outerCone : undefined;
393
- if (innerCone !== undefined && outerCone !== undefined && innerCone >= outerCone) {
394
- throw new Error('innerCone must be less than outerCone');
395
- }
396
- return cleanObject(await tools.lightingTools.createSpotLight({
397
- name,
398
- location,
399
- rotation,
400
- intensity: args.intensity,
401
- innerCone: args.innerCone,
402
- outerCone: args.outerCone,
403
- radius: args.radius,
404
- color,
405
- castShadows
406
- }));
407
- }
408
- if (typeKey === 'rect') {
409
- return cleanObject(await tools.lightingTools.createRectLight({
410
- name,
411
- location,
412
- rotation,
413
- intensity: args.intensity,
414
- width: args.width,
415
- height: args.height,
416
- color
417
- }));
418
- }
419
- if (typeKey === 'sky' || typeKey === 'skylight') {
420
- return cleanObject(await tools.lightingTools.createSkyLight({
421
- name,
422
- sourceType: args.sourceType,
423
- cubemapPath: args.cubemapPath,
424
- intensity: args.intensity,
425
- recapture: args.recapture
426
- }));
427
- }
428
- throw new Error(`Unknown light type: ${lightType}`);
429
- }
430
- case 'build_lighting': {
431
- const res = await tools.lightingTools.buildLighting({ quality: args.quality || 'High', buildReflectionCaptures: true });
432
- return cleanObject(res);
433
- }
434
- default:
435
- throw new Error(`Unknown level action: ${args.action}`);
436
- }
437
- // 5. ANIMATION & PHYSICS
438
- case 'animation_physics':
439
- switch (requireAction(args)) {
440
- case 'create_animation_bp': {
441
- await elicitMissingPrimitiveArgs(tools, args, 'Provide details for animation_physics.create_animation_bp', {
442
- name: {
443
- type: 'string',
444
- title: 'Blueprint Name',
445
- description: 'Name of the Animation Blueprint to create'
446
- },
447
- skeletonPath: {
448
- type: 'string',
449
- title: 'Skeleton Path',
450
- description: 'Content path of the skeleton asset to bind'
451
- }
452
- });
453
- const name = requireNonEmptyString(args.name, 'name', 'Invalid name');
454
- const skeletonPath = requireNonEmptyString(args.skeletonPath, 'skeletonPath', 'Invalid skeletonPath');
455
- const res = await tools.animationTools.createAnimationBlueprint({ name, skeletonPath, savePath: args.savePath });
456
- return cleanObject(res);
457
- }
458
- case 'play_montage': {
459
- await elicitMissingPrimitiveArgs(tools, args, 'Provide playback details for animation_physics.play_montage', {
460
- actorName: {
461
- type: 'string',
462
- title: 'Actor Name',
463
- description: 'Actor that should play the montage'
464
- },
465
- montagePath: {
466
- type: 'string',
467
- title: 'Montage Path',
468
- description: 'Montage or animation asset path to play'
469
- }
470
- });
471
- const actorName = requireNonEmptyString(args.actorName, 'actorName', 'Invalid actorName');
472
- const montagePath = args.montagePath || args.animationPath;
473
- const validatedMontage = requireNonEmptyString(montagePath, 'montagePath', 'Invalid montagePath');
474
- const res = await tools.animationTools.playAnimation({ actorName, animationType: 'Montage', animationPath: validatedMontage, playRate: args.playRate });
475
- return cleanObject(res);
476
- }
477
- case 'setup_ragdoll': {
478
- await elicitMissingPrimitiveArgs(tools, args, 'Provide setup details for animation_physics.setup_ragdoll', {
479
- skeletonPath: {
480
- type: 'string',
481
- title: 'Skeleton Path',
482
- description: 'Content path for the skeleton asset'
483
- },
484
- physicsAssetName: {
485
- type: 'string',
486
- title: 'Physics Asset Name',
487
- description: 'Name of the physics asset to apply'
488
- }
489
- });
490
- const skeletonPath = requireNonEmptyString(args.skeletonPath, 'skeletonPath', 'Invalid skeletonPath');
491
- const physicsAssetName = requireNonEmptyString(args.physicsAssetName, 'physicsAssetName', 'Invalid physicsAssetName');
492
- const res = await tools.physicsTools.setupRagdoll({ skeletonPath, physicsAssetName, blendWeight: args.blendWeight, savePath: args.savePath });
493
- return cleanObject(res);
494
- }
495
- default:
496
- throw new Error(`Unknown animation/physics action: ${args.action}`);
497
- }
498
- // 6. EFFECTS SYSTEM
499
- case 'create_effect':
500
- switch (requireAction(args)) {
501
- case 'particle': {
502
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the particle effect details for create_effect.particle', {
503
- effectType: {
504
- type: 'string',
505
- title: 'Effect Type',
506
- description: 'Preset effect type to spawn (e.g., Fire, Smoke)'
507
- }
508
- });
509
- const res = await tools.niagaraTools.createEffect({ effectType: args.effectType, name: args.name, location: args.location, scale: args.scale, customParameters: args.customParameters });
510
- return cleanObject(res);
511
- }
512
- case 'niagara': {
513
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the Niagara system path for create_effect.niagara', {
514
- systemPath: {
515
- type: 'string',
516
- title: 'Niagara System Path',
517
- description: 'Asset path of the Niagara system to spawn'
518
- }
519
- });
520
- const systemPath = requireNonEmptyString(args.systemPath, 'systemPath', 'Invalid systemPath');
521
- const verifyResult = await tools.bridge.executePythonWithResult(`
522
- import unreal, json
523
- path = r"${systemPath}"
524
- exists = unreal.EditorAssetLibrary.does_asset_exist(path)
525
- print('RESULT:' + json.dumps({'success': exists, 'exists': exists, 'path': path}))
526
- `.trim());
527
- if (!verifyResult?.exists) {
528
- return cleanObject({ success: false, error: `Niagara system not found at ${systemPath}` });
529
- }
530
- const loc = Array.isArray(args.location)
531
- ? { x: args.location[0], y: args.location[1], z: args.location[2] }
532
- : args.location || { x: 0, y: 0, z: 0 };
533
- const res = await tools.niagaraTools.spawnEffect({
534
- systemPath,
535
- location: [loc.x ?? 0, loc.y ?? 0, loc.z ?? 0],
536
- rotation: Array.isArray(args.rotation) ? args.rotation : undefined,
537
- scale: args.scale
538
- });
539
- return cleanObject(res);
540
- }
541
- case 'debug_shape': {
542
- const shapeInput = args.shape ?? 'Sphere';
543
- const shape = String(shapeInput).trim().toLowerCase();
544
- const originalShapeLabel = String(shapeInput).trim() || 'shape';
545
- const loc = args.location || { x: 0, y: 0, z: 0 };
546
- const size = args.size || 100;
547
- const color = args.color || [255, 0, 0, 255];
548
- const duration = args.duration || 5;
549
- if (shape === 'line') {
550
- const end = args.end || { x: loc.x + size, y: loc.y, z: loc.z };
551
- return cleanObject(await tools.debugTools.drawDebugLine({ start: [loc.x, loc.y, loc.z], end: [end.x, end.y, end.z], color, duration }));
552
- }
553
- else if (shape === 'box') {
554
- const extent = [size, size, size];
555
- return cleanObject(await tools.debugTools.drawDebugBox({ center: [loc.x, loc.y, loc.z], extent, color, duration }));
556
- }
557
- else if (shape === 'sphere') {
558
- return cleanObject(await tools.debugTools.drawDebugSphere({ center: [loc.x, loc.y, loc.z], radius: size, color, duration }));
559
- }
560
- else if (shape === 'capsule') {
561
- return cleanObject(await tools.debugTools.drawDebugCapsule({ center: [loc.x, loc.y, loc.z], halfHeight: size, radius: Math.max(10, size / 3), color, duration }));
562
- }
563
- else if (shape === 'cone') {
564
- return cleanObject(await tools.debugTools.drawDebugCone({ origin: [loc.x, loc.y, loc.z], direction: [0, 0, 1], length: size, angleWidth: 0.5, angleHeight: 0.5, color, duration }));
565
- }
566
- else if (shape === 'arrow') {
567
- const end = args.end || { x: loc.x + size, y: loc.y, z: loc.z };
568
- return cleanObject(await tools.debugTools.drawDebugArrow({ start: [loc.x, loc.y, loc.z], end: [end.x, end.y, end.z], color, duration }));
569
- }
570
- else if (shape === 'point') {
571
- return cleanObject(await tools.debugTools.drawDebugPoint({ location: [loc.x, loc.y, loc.z], size, color, duration }));
572
- }
573
- else if (shape === 'text' || shape === 'string') {
574
- const text = args.text || 'Debug';
575
- return cleanObject(await tools.debugTools.drawDebugString({ location: [loc.x, loc.y, loc.z], text, color, duration }));
576
- }
577
- // Default fallback
578
- return cleanObject({ success: false, error: `Unsupported debug shape: ${originalShapeLabel}` });
579
- }
580
- default:
581
- throw new Error(`Unknown effect action: ${args.action}`);
582
- }
583
- // 7. BLUEPRINT MANAGER
584
- case 'manage_blueprint':
585
- switch (requireAction(args)) {
586
- case 'create': {
587
- await elicitMissingPrimitiveArgs(tools, args, 'Provide details for manage_blueprint.create', {
588
- name: {
589
- type: 'string',
590
- title: 'Blueprint Name',
591
- description: 'Name for the new Blueprint asset'
592
- },
593
- blueprintType: {
594
- type: 'string',
595
- title: 'Blueprint Type',
596
- description: 'Base type such as Actor, Pawn, Character, etc.'
597
- }
598
- });
599
- const res = await tools.blueprintTools.createBlueprint({
600
- name: args.name,
601
- blueprintType: args.blueprintType || 'Actor',
602
- savePath: args.savePath,
603
- parentClass: args.parentClass
604
- });
605
- return cleanObject(res);
606
- }
607
- case 'add_component': {
608
- await elicitMissingPrimitiveArgs(tools, args, 'Provide details for manage_blueprint.add_component', {
609
- name: {
610
- type: 'string',
611
- title: 'Blueprint Name',
612
- description: 'Blueprint asset to modify'
613
- },
614
- componentType: {
615
- type: 'string',
616
- title: 'Component Type',
617
- description: 'Component class to add (e.g., StaticMeshComponent)'
618
- },
619
- componentName: {
620
- type: 'string',
621
- title: 'Component Name',
622
- description: 'Name for the new component'
623
- }
624
- });
625
- const res = await tools.blueprintTools.addComponent({ blueprintName: args.name, componentType: args.componentType, componentName: args.componentName });
626
- return cleanObject(res);
627
- }
628
- default:
629
- throw new Error(`Unknown blueprint action: ${args.action}`);
630
- }
631
- // 8. ENVIRONMENT BUILDER
632
- case 'build_environment':
633
- switch (requireAction(args)) {
634
- case 'create_landscape': {
635
- const res = await tools.landscapeTools.createLandscape({ name: args.name, sizeX: args.sizeX, sizeY: args.sizeY, materialPath: args.materialPath });
636
- return cleanObject(res);
637
- }
638
- case 'sculpt': {
639
- const res = await tools.landscapeTools.sculptLandscape({ landscapeName: args.name, tool: args.tool, brushSize: args.brushSize, strength: args.strength });
640
- return cleanObject(res);
641
- }
642
- case 'add_foliage': {
643
- const res = await tools.foliageTools.addFoliageType({ name: args.name, meshPath: args.meshPath, density: args.density });
644
- return cleanObject(res);
645
- }
646
- case 'paint_foliage': {
647
- const pos = args.position ? [args.position.x || 0, args.position.y || 0, args.position.z || 0] : [0, 0, 0];
648
- const res = await tools.foliageTools.paintFoliage({ foliageType: args.foliageType, position: pos, brushSize: args.brushSize, paintDensity: args.paintDensity, eraseMode: args.eraseMode });
649
- return cleanObject(res);
650
- }
651
- case 'create_procedural_terrain': {
652
- const loc = args.location ? [args.location.x || 0, args.location.y || 0, args.location.z || 0] : [0, 0, 0];
653
- const res = await tools.buildEnvAdvanced.createProceduralTerrain({
654
- name: args.name || 'ProceduralTerrain',
655
- location: loc,
656
- sizeX: args.sizeX,
657
- sizeY: args.sizeY,
658
- subdivisions: args.subdivisions,
659
- heightFunction: args.heightFunction,
660
- material: args.materialPath
661
- });
662
- return cleanObject(res);
663
- }
664
- case 'create_procedural_foliage': {
665
- if (!args.bounds || !args.bounds.location || !args.bounds.size)
666
- throw new Error('bounds.location and bounds.size are required');
667
- const bounds = {
668
- location: [args.bounds.location.x || 0, args.bounds.location.y || 0, args.bounds.location.z || 0],
669
- size: [args.bounds.size.x || 1000, args.bounds.size.y || 1000, args.bounds.size.z || 100]
670
- };
671
- const res = await tools.buildEnvAdvanced.createProceduralFoliage({
672
- name: args.name || 'ProceduralFoliage',
673
- bounds,
674
- foliageTypes: args.foliageTypes || [],
675
- seed: args.seed
676
- });
677
- return cleanObject(res);
678
- }
679
- case 'add_foliage_instances': {
680
- if (!args.foliageType)
681
- throw new Error('foliageType is required');
682
- if (!Array.isArray(args.transforms))
683
- throw new Error('transforms array is required');
684
- const transforms = args.transforms.map(t => ({
685
- location: [t.location?.x || 0, t.location?.y || 0, t.location?.z || 0],
686
- rotation: t.rotation ? [t.rotation.pitch || 0, t.rotation.yaw || 0, t.rotation.roll || 0] : undefined,
687
- scale: t.scale ? [t.scale.x || 1, t.scale.y || 1, t.scale.z || 1] : undefined
688
- }));
689
- const res = await tools.buildEnvAdvanced.addFoliageInstances({ foliageType: args.foliageType, transforms });
690
- return cleanObject(res);
691
- }
692
- case 'create_landscape_grass_type': {
693
- const res = await tools.buildEnvAdvanced.createLandscapeGrassType({
694
- name: args.name || 'GrassType',
695
- meshPath: args.meshPath,
696
- density: args.density,
697
- minScale: args.minScale,
698
- maxScale: args.maxScale
699
- });
700
- return cleanObject(res);
701
- }
702
- default:
703
- throw new Error(`Unknown environment action: ${args.action}`);
704
- }
705
- // 9. SYSTEM CONTROL
706
- case 'system_control':
707
- switch (requireAction(args)) {
708
- case 'profile': {
709
- const res = await tools.performanceTools.startProfiling({ type: args.profileType, duration: args.duration });
710
- return cleanObject(res);
711
- }
712
- case 'show_fps': {
713
- const res = await tools.performanceTools.showFPS({ enabled: !!args.enabled, verbose: !!args.verbose });
714
- return cleanObject(res);
715
- }
716
- case 'set_quality': {
717
- const res = await tools.performanceTools.setScalability({ category: args.category, level: args.level });
718
- return cleanObject(res);
719
- }
720
- case 'play_sound': {
721
- await elicitMissingPrimitiveArgs(tools, args, 'Provide the audio asset for system_control.play_sound', {
722
- soundPath: {
723
- type: 'string',
724
- title: 'Sound Asset Path',
725
- description: 'Asset path of the sound to play'
726
- }
727
- });
728
- const soundPath = requireNonEmptyString(args.soundPath, 'soundPath', 'Missing required parameter: soundPath');
729
- if (args.location && typeof args.location === 'object') {
730
- const loc = [args.location.x || 0, args.location.y || 0, args.location.z || 0];
731
- const res = await tools.audioTools.playSoundAtLocation({ soundPath, location: loc, volume: args.volume, pitch: args.pitch, startTime: args.startTime });
732
- return cleanObject(res);
733
- }
734
- const res = await tools.audioTools.playSound2D({ soundPath, volume: args.volume, pitch: args.pitch, startTime: args.startTime });
735
- return cleanObject(res);
736
- }
737
- case 'create_widget': {
738
- await elicitMissingPrimitiveArgs(tools, args, 'Provide details for system_control.create_widget', {
739
- widgetName: {
740
- type: 'string',
741
- title: 'Widget Name',
742
- description: 'Name for the new UI widget asset'
743
- },
744
- widgetType: {
745
- type: 'string',
746
- title: 'Widget Type',
747
- description: 'Widget type such as HUD, Menu, Overlay, etc.'
748
- }
749
- });
750
- const widgetName = requireNonEmptyString(args.widgetName ?? args.name, 'widgetName', 'Missing required parameter: widgetName');
751
- const widgetType = requireNonEmptyString(args.widgetType, 'widgetType', 'Missing required parameter: widgetType');
752
- const res = await tools.uiTools.createWidget({ name: widgetName, type: widgetType, savePath: args.savePath });
753
- return cleanObject(res);
754
- }
755
- case 'show_widget': {
756
- const res = await tools.uiTools.setWidgetVisibility({ widgetName: args.widgetName, visible: args.visible !== false });
757
- return cleanObject(res);
758
- }
759
- case 'screenshot': {
760
- const res = await tools.visualTools.takeScreenshot({ resolution: args.resolution });
761
- return cleanObject(res);
762
- }
763
- case 'engine_start': {
764
- const res = await tools.engineTools.launchEditor({ editorExe: args.editorExe, projectPath: args.projectPath });
765
- return cleanObject(res);
766
- }
767
- case 'engine_quit': {
768
- const res = await tools.engineTools.quitEditor();
769
- return cleanObject(res);
770
- }
771
- default:
772
- throw new Error(`Unknown system action: ${args.action}`);
773
- }
774
- // 10. CONSOLE COMMAND - handle validation here
775
- case 'console_command':
776
- if (!args.command || typeof args.command !== 'string' || args.command.trim() === '') {
777
- return { success: true, message: 'Empty command' };
778
- }
779
- // Basic safety filter
780
- const cmd = String(args.command).trim();
781
- const blocked = [/\bquit\b/i, /\bexit\b/i, /debugcrash/i];
782
- if (blocked.some(r => r.test(cmd))) {
783
- return { success: false, error: 'Command blocked for safety' };
784
- }
785
- try {
786
- const raw = await tools.bridge.executeConsoleCommand(cmd);
787
- const summary = tools.bridge.summarizeConsoleCommand(cmd, raw);
788
- const output = summary.output || '';
789
- const looksInvalid = /unknown|invalid/i.test(output);
790
- return cleanObject({
791
- success: summary.returnValue !== false && !looksInvalid,
792
- command: summary.command,
793
- output: output || undefined,
794
- logLines: summary.logLines?.length ? summary.logLines : undefined,
795
- returnValue: summary.returnValue,
796
- message: !looksInvalid
797
- ? (output || 'Command executed')
798
- : undefined,
799
- error: looksInvalid ? output : undefined,
800
- raw: summary.raw
801
- });
802
- }
803
- catch (e) {
804
- return cleanObject({ success: false, command: cmd, error: e?.message || String(e) });
805
- }
806
- // 11. REMOTE CONTROL PRESETS - Direct implementation
807
- case 'manage_rc':
808
- // Handle RC operations directly through RcTools
809
- let rcResult;
810
- const rcAction = requireAction(args);
811
- switch (rcAction) {
812
- // Support both 'create_preset' and 'create' for compatibility
813
- case 'create_preset':
814
- case 'create':
815
- // Support both 'name' and 'presetName' parameter names
816
- const presetName = args.name || args.presetName;
817
- if (!presetName)
818
- throw new Error('Missing required parameter: name or presetName');
819
- rcResult = await tools.rcTools.createPreset({
820
- name: presetName,
821
- path: args.path
822
- });
823
- // Return consistent output with presetId for tests
824
- if (rcResult.success) {
825
- rcResult.message = `Remote Control preset created: ${presetName}`;
826
- // Ensure presetId is set (for test compatibility)
827
- if (rcResult.presetPath && !rcResult.presetId) {
828
- rcResult.presetId = rcResult.presetPath;
829
- }
830
- }
831
- break;
832
- case 'list':
833
- // List all presets - implement via RcTools
834
- rcResult = await tools.rcTools.listPresets();
835
- break;
836
- case 'delete':
837
- case 'delete_preset':
838
- const presetIdentifier = args.presetId || args.presetPath;
839
- if (!presetIdentifier)
840
- throw new Error('Missing required parameter: presetId');
841
- rcResult = await tools.rcTools.deletePreset(presetIdentifier);
842
- if (rcResult.success) {
843
- rcResult.message = 'Preset deleted successfully';
844
- }
845
- break;
846
- case 'expose_actor':
847
- if (!args.presetPath)
848
- throw new Error('Missing required parameter: presetPath');
849
- if (!args.actorName)
850
- throw new Error('Missing required parameter: actorName');
851
- rcResult = await tools.rcTools.exposeActor({
852
- presetPath: args.presetPath,
853
- actorName: args.actorName
854
- });
855
- if (rcResult.success) {
856
- rcResult.message = `Actor '${args.actorName}' exposed to preset`;
857
- }
858
- break;
859
- case 'expose_property':
860
- case 'expose': // Support simplified name from tests
861
- // Support both presetPath and presetId
862
- const presetPathExp = args.presetPath || args.presetId;
863
- if (!presetPathExp)
864
- throw new Error('Missing required parameter: presetPath or presetId');
865
- if (!args.objectPath)
866
- throw new Error('Missing required parameter: objectPath');
867
- if (!args.propertyName)
868
- throw new Error('Missing required parameter: propertyName');
869
- rcResult = await tools.rcTools.exposeProperty({
870
- presetPath: presetPathExp,
871
- objectPath: args.objectPath,
872
- propertyName: args.propertyName
873
- });
874
- if (rcResult.success) {
875
- rcResult.message = `Property '${args.propertyName}' exposed to preset`;
876
- }
877
- break;
878
- case 'list_fields':
879
- case 'get_exposed': // Support test naming
880
- const presetPathList = args.presetPath || args.presetId;
881
- if (!presetPathList)
882
- throw new Error('Missing required parameter: presetPath or presetId');
883
- rcResult = await tools.rcTools.listFields({
884
- presetPath: presetPathList
885
- });
886
- // Map 'fields' to 'exposedProperties' for test compatibility
887
- if (rcResult.success && rcResult.fields) {
888
- rcResult.exposedProperties = rcResult.fields;
889
- }
890
- break;
891
- case 'set_property':
892
- case 'set_value': // Support test naming
893
- // Support both patterns
894
- const objPathSet = args.objectPath || args.presetId;
895
- const propNameSet = args.propertyName || args.propertyLabel;
896
- if (!objPathSet)
897
- throw new Error('Missing required parameter: objectPath or presetId');
898
- if (!propNameSet)
899
- throw new Error('Missing required parameter: propertyName or propertyLabel');
900
- if (args.value === undefined)
901
- throw new Error('Missing required parameter: value');
902
- rcResult = await tools.rcTools.setProperty({
903
- objectPath: objPathSet,
904
- propertyName: propNameSet,
905
- value: args.value
906
- });
907
- if (rcResult.success) {
908
- rcResult.message = `Property '${propNameSet}' value updated`;
909
- }
910
- break;
911
- case 'get_property':
912
- case 'get_value': // Support test naming
913
- const objPathGet = args.objectPath || args.presetId;
914
- const propNameGet = args.propertyName || args.propertyLabel;
915
- if (!objPathGet)
916
- throw new Error('Missing required parameter: objectPath or presetId');
917
- if (!propNameGet)
918
- throw new Error('Missing required parameter: propertyName or propertyLabel');
919
- rcResult = await tools.rcTools.getProperty({
920
- objectPath: objPathGet,
921
- propertyName: propNameGet
922
- });
923
- break;
924
- case 'call_function':
925
- if (!args.presetId)
926
- throw new Error('Missing required parameter: presetId');
927
- if (!args.functionLabel)
928
- throw new Error('Missing required parameter: functionLabel');
929
- // For now, return not implemented
930
- rcResult = {
931
- success: false,
932
- error: 'Function calls not yet implemented'
933
- };
934
- break;
935
- default:
936
- throw new Error(`Unknown RC action: ${rcAction}. Valid actions are: create_preset, expose_actor, expose_property, list_fields, set_property, get_property, or their simplified versions: create, list, delete, expose, get_exposed, set_value, get_value, call_function`);
937
- }
938
- // Return result directly - MCP formatting will be handled by response validator
939
- // Clean to prevent circular references
940
- return cleanObject(rcResult);
941
- // 12. SEQUENCER / CINEMATICS
942
- case 'manage_sequence':
943
- // Direct handling for sequence operations
944
- const seqResult = await (async () => {
945
- const sequenceTools = tools.sequenceTools;
946
- if (!sequenceTools)
947
- throw new Error('Sequence tools not available');
948
- const action = requireAction(args);
949
- switch (action) {
950
- case 'create':
951
- return await sequenceTools.create({ name: args.name, path: args.path });
952
- case 'open':
953
- return await sequenceTools.open({ path: args.path });
954
- case 'add_camera':
955
- return await sequenceTools.addCamera({ spawnable: args.spawnable !== false });
956
- case 'add_actor':
957
- return await sequenceTools.addActor({ actorName: args.actorName });
958
- case 'add_actors':
959
- if (!args.actorNames)
960
- throw new Error('Missing required parameter: actorNames');
961
- return await sequenceTools.addActors({ actorNames: args.actorNames });
962
- case 'remove_actors':
963
- if (!args.actorNames)
964
- throw new Error('Missing required parameter: actorNames');
965
- return await sequenceTools.removeActors({ actorNames: args.actorNames });
966
- case 'get_bindings':
967
- return await sequenceTools.getBindings({ path: args.path });
968
- case 'add_spawnable_from_class':
969
- if (!args.className)
970
- throw new Error('Missing required parameter: className');
971
- return await sequenceTools.addSpawnableFromClass({ className: args.className, path: args.path });
972
- case 'play':
973
- return await sequenceTools.play({ loopMode: args.loopMode });
974
- case 'pause':
975
- return await sequenceTools.pause();
976
- case 'stop':
977
- return await sequenceTools.stop();
978
- case 'set_properties':
979
- return await sequenceTools.setSequenceProperties({
980
- path: args.path,
981
- frameRate: args.frameRate,
982
- lengthInFrames: args.lengthInFrames,
983
- playbackStart: args.playbackStart,
984
- playbackEnd: args.playbackEnd
985
- });
986
- case 'get_properties':
987
- return await sequenceTools.getSequenceProperties({ path: args.path });
988
- case 'set_playback_speed':
989
- if (args.speed === undefined)
990
- throw new Error('Missing required parameter: speed');
991
- return await sequenceTools.setPlaybackSpeed({ speed: args.speed });
992
- default:
993
- throw new Error(`Unknown sequence action: ${action}`);
994
- }
995
- })();
996
- // Return result directly - MCP formatting will be handled by response validator
997
- // Clean to prevent circular references
998
- return cleanObject(seqResult);
999
- // 13. INTROSPECTION
1000
- case 'inspect':
1001
- const inspectAction = requireAction(args);
1002
- switch (inspectAction) {
1003
- case 'inspect_object': {
1004
- const res = await tools.introspectionTools.inspectObject({ objectPath: args.objectPath, detailed: args.detailed });
1005
- return cleanObject(res);
1006
- }
1007
- case 'set_property': {
1008
- const res = await tools.introspectionTools.setProperty({ objectPath: args.objectPath, propertyName: args.propertyName, value: args.value });
1009
- return cleanObject(res);
1010
- }
1011
- default:
1012
- throw new Error(`Unknown inspect action: ${inspectAction}`);
1013
- }
1014
- default:
1015
- throw new Error(`Unknown consolidated tool: ${name}`);
199
+ const normalized = normalizeToolCall(name, args);
200
+ const normalizedName = normalized.name;
201
+ const action = normalized.action;
202
+ const normalizedArgs = normalized.args;
203
+ const toolDef = consolidatedToolDefinitions.find(t => t.name === normalizedName);
204
+ const dynamicHandler = await getDynamicHandlerForTool(normalizedName, action);
205
+ if (!dynamicHandler && toolDef && toolDef.inputSchema && toolDef.inputSchema.properties && toolDef.inputSchema.properties.action) {
206
+ const actionProp = toolDef.inputSchema.properties.action;
207
+ const allowed = Array.isArray(actionProp.enum) ? actionProp.enum : undefined;
208
+ if (allowed && !allowed.includes(action)) {
209
+ return cleanObject({
210
+ success: false,
211
+ error: 'UNKNOWN_ACTION',
212
+ message: `Unknown action '${action}' for consolidated tool '${normalizedName}'.`
213
+ });
214
+ }
215
+ }
216
+ const defaultHandler = async () => invokeNamedTool(normalizedName, action, normalizedArgs, tools);
217
+ if (dynamicHandler) {
218
+ return await dynamicHandler({ name: normalizedName, action, args: normalizedArgs, tools, defaultHandler });
1016
219
  }
1017
- // All cases return (or throw) above; this is a type guard for exhaustiveness.
220
+ return await defaultHandler();
1018
221
  }
1019
222
  catch (err) {
1020
223
  const duration = Date.now() - startTime;
1021
- console.log(`[ConsolidatedToolHandler] Failed execution of ${name} after ${duration}ms: ${err?.message || String(err)}`);
1022
- // Return consistent error structure matching regular tool handlers
224
+ logger.error(`Failed execution of ${name} after ${duration}ms: ${err?.message || String(err)}`);
1023
225
  const errorMessage = err?.message || String(err);
1024
- const isTimeout = errorMessage.includes('timeout');
1025
- return {
1026
- content: [{
1027
- type: 'text',
1028
- text: isTimeout
1029
- ? `Tool ${name} timed out. Please check Unreal Engine connection.`
1030
- : `Failed to execute ${name}: ${errorMessage}`
1031
- }],
1032
- isError: true
1033
- };
226
+ const lowerError = errorMessage.toString().toLowerCase();
227
+ const isTimeout = lowerError.includes('timeout');
228
+ let text;
229
+ if (isTimeout) {
230
+ text = `Tool ${name} timed out. Please check Unreal Engine connection.`;
231
+ }
232
+ else {
233
+ text = `Failed to execute ${name}: ${errorMessage}`;
234
+ }
235
+ return ResponseFactory.error(text);
1034
236
  }
1035
237
  }
1036
238
  //# sourceMappingURL=consolidated-tool-handlers.js.map