vibrante-node 2.5.1__py3-none-any.whl

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 (487) hide show
  1. src/core/__init__.py +0 -0
  2. src/core/engine.py +484 -0
  3. src/core/events.py +32 -0
  4. src/core/graph.py +74 -0
  5. src/core/integrity.py +925 -0
  6. src/core/loader.py +56 -0
  7. src/core/manifest.py +910 -0
  8. src/core/models.py +59 -0
  9. src/core/persistence.py +27 -0
  10. src/core/python_to_workflow.py +182 -0
  11. src/core/registry.py +314 -0
  12. src/core/workflow_to_python.py +801 -0
  13. src/main.py +188 -0
  14. src/models/__init__.py +0 -0
  15. src/nodes/__init__.py +0 -0
  16. src/nodes/ai/__init__.py +1 -0
  17. src/nodes/base.py +174 -0
  18. src/nodes/builtins/__init__.py +0 -0
  19. src/nodes/builtins/group_node.py +210 -0
  20. src/nodes/builtins/nodes.py +452 -0
  21. src/nodes/print.py +19 -0
  22. src/nodes/test.py +19 -0
  23. src/ui/__init__.py +0 -0
  24. src/ui/canvas/__init__.py +0 -0
  25. src/ui/canvas/backdrop.py +223 -0
  26. src/ui/canvas/canvas_search_bar.py +222 -0
  27. src/ui/canvas/edge.py +98 -0
  28. src/ui/canvas/mini_map.py +138 -0
  29. src/ui/canvas/node_search_popup.py +270 -0
  30. src/ui/canvas/scene.py +1149 -0
  31. src/ui/canvas/sticky_note.py +123 -0
  32. src/ui/canvas/view.py +285 -0
  33. src/ui/code_editor.py +435 -0
  34. src/ui/export_python_dialog.py +490 -0
  35. src/ui/gemini_api_dialog.py +41 -0
  36. src/ui/gemini_chat.py +370 -0
  37. src/ui/import_python_dialog.py +122 -0
  38. src/ui/library_panel.py +246 -0
  39. src/ui/log_panel.py +315 -0
  40. src/ui/node_builder.py +841 -0
  41. src/ui/node_widget.py +1009 -0
  42. src/ui/port_widget.py +116 -0
  43. src/ui/script_editor.py +53 -0
  44. src/ui/scripting_console.py +270 -0
  45. src/ui/settings_window.py +575 -0
  46. src/ui/window.py +2012 -0
  47. src/utils/color_manager.py +50 -0
  48. src/utils/config_manager.py +71 -0
  49. src/utils/env_manager.py +232 -0
  50. src/utils/highlighter.py +110 -0
  51. src/utils/paths.py +30 -0
  52. src/utils/prism_config.py +300 -0
  53. src/utils/prism_core.py +80 -0
  54. src/utils/qt_compat.py +159 -0
  55. src/utils/runtime.py +80 -0
  56. vibrante_node/CLA.md +96 -0
  57. vibrante_node/COMMERCIAL_LICENSE.md +170 -0
  58. vibrante_node/LICENSE +178 -0
  59. vibrante_node/LICENSES/AGPL-3.0.txt +661 -0
  60. vibrante_node/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
  61. vibrante_node/LICENSES/CC-BY-4.0.txt +396 -0
  62. vibrante_node/LICENSES/GPL-3.0.txt +674 -0
  63. vibrante_node/LICENSES/LGPL-3.0.txt +165 -0
  64. vibrante_node/LICENSES/README.md +65 -0
  65. vibrante_node/THIRD_PARTY_NOTICES.txt +3277 -0
  66. vibrante_node/__init__.py +2 -0
  67. vibrante_node/app.py +60 -0
  68. vibrante_node/docs/AUTOMATION_API.html +785 -0
  69. vibrante_node/docs/DEVELOPER.html +891 -0
  70. vibrante_node/docs/DOCUMENTATION.html +2761 -0
  71. vibrante_node/docs/LICENSE.txt +35 -0
  72. vibrante_node/docs/NODE_BUILDER_API.html +1155 -0
  73. vibrante_node/docs/RELEASE_v1.0.5.html +140 -0
  74. vibrante_node/docs/RELEASE_v1.1.0.html +163 -0
  75. vibrante_node/docs/RELEASE_v1.1.5.html +286 -0
  76. vibrante_node/docs/RELEASE_v1.2.0.html +175 -0
  77. vibrante_node/docs/RELEASE_v1.3.0.html +168 -0
  78. vibrante_node/docs/RELEASE_v1.4.0.html +160 -0
  79. vibrante_node/docs/RELEASE_v1.5.0.html +432 -0
  80. vibrante_node/docs/RELEASE_v1.6.0.html +293 -0
  81. vibrante_node/docs/RELEASE_v1.6.1.html +171 -0
  82. vibrante_node/docs/RELEASE_v1.7.0.html +270 -0
  83. vibrante_node/docs/RELEASE_v1.8.0.html +201 -0
  84. vibrante_node/docs/RELEASE_v1.8.1.html +124 -0
  85. vibrante_node/docs/RELEASE_v1.8.2.html +119 -0
  86. vibrante_node/docs/RELEASE_v1.8.3.html +125 -0
  87. vibrante_node/docs/RELEASE_v1.8.4.html +210 -0
  88. vibrante_node/docs/RELEASE_v1.8.5.html +223 -0
  89. vibrante_node/docs/RELEASE_v2.0.0.html +284 -0
  90. vibrante_node/docs/RELEASE_v2.1.0.html +259 -0
  91. vibrante_node/docs/RELEASE_v2.1.1.html +156 -0
  92. vibrante_node/docs/RELEASE_v2.2.0.html +369 -0
  93. vibrante_node/docs/RELEASE_v2.2.1.html +168 -0
  94. vibrante_node/docs/RELEASE_v2.3.0.html +185 -0
  95. vibrante_node/docs/RELEASE_v2.4.0.html +446 -0
  96. vibrante_node/docs/RELEASE_v2.5.0.html +478 -0
  97. vibrante_node/docs/RELEASE_v2.5.1.html +190 -0
  98. vibrante_node/docs/USER_GUIDE.html +1407 -0
  99. vibrante_node/docs/index.html +103 -0
  100. vibrante_node/docs/portal/01_introduction.html +1177 -0
  101. vibrante_node/docs/portal/02_getting_started.html +1267 -0
  102. vibrante_node/docs/portal/03_user_guide.html +1736 -0
  103. vibrante_node/docs/portal/04_workflow_tutorials.html +1473 -0
  104. vibrante_node/docs/portal/05_node_development.html +1562 -0
  105. vibrante_node/docs/portal/06_backend_architecture.html +1373 -0
  106. vibrante_node/docs/portal/07_frontend_architecture.html +1588 -0
  107. vibrante_node/docs/portal/08_api_reference.html +2336 -0
  108. vibrante_node/docs/portal/09_advanced_topics.html +1664 -0
  109. vibrante_node/docs/portal/10_contribution_guide.html +1263 -0
  110. vibrante_node/docs/portal/11_troubleshooting.html +1108 -0
  111. vibrante_node/docs/portal/12_examples_library.html +1498 -0
  112. vibrante_node/docs/portal/13_general_purpose_automation.html +1472 -0
  113. vibrante_node/docs/portal/14_custom_nodes_api.html +1960 -0
  114. vibrante_node/docs/portal/index.html +605 -0
  115. vibrante_node/docs/portal/integrations_blender.html +605 -0
  116. vibrante_node/docs/portal/integrations_deadline.html +536 -0
  117. vibrante_node/docs/portal/integrations_houdini.html +787 -0
  118. vibrante_node/docs/portal/integrations_maya.html +675 -0
  119. vibrante_node/docs/portal/integrations_prism.html +628 -0
  120. vibrante_node/docs/portal/search.json +1 -0
  121. vibrante_node/docs/validation.json +333 -0
  122. vibrante_node/examples/arnold_lighting/orchestration_notes.md +45 -0
  123. vibrante_node/examples/arnold_lighting/prompt.md +47 -0
  124. vibrante_node/examples/automation/01_linear_chain.py +10 -0
  125. vibrante_node/examples/automation/02_batch_update_prefix.py +8 -0
  126. vibrante_node/examples/automation/03_reset_scene.py +5 -0
  127. vibrante_node/examples/automation/04_batch_execution.py +9 -0
  128. vibrante_node/examples/automation/05_git_backup.py +6 -0
  129. vibrante_node/examples/automation/06_reset_math_nodes.py +12 -0
  130. vibrante_node/examples/automation/07_stress_test_grid.py +8 -0
  131. vibrante_node/examples/automation/08_scene_summary.py +8 -0
  132. vibrante_node/examples/automation/09_toggle_bools.py +8 -0
  133. vibrante_node/examples/automation/10_session_report.py +7 -0
  134. vibrante_node/examples/automation/11_simple_math_node.py +7 -0
  135. vibrante_node/examples/cinematic_camera/orchestration_notes.md +56 -0
  136. vibrante_node/examples/cinematic_camera/prompt.md +50 -0
  137. vibrante_node/examples/cinematic_explosion/orchestration_notes.md +76 -0
  138. vibrante_node/examples/cinematic_explosion/prompt.md +47 -0
  139. vibrante_node/examples/cinematic_explosion/review.md +75 -0
  140. vibrante_node/examples/dust_wave/orchestration_notes.md +43 -0
  141. vibrante_node/examples/dust_wave/prompt.md +40 -0
  142. vibrante_node/examples/nodes/async_delay.py +21 -0
  143. vibrante_node/examples/nodes/connection_logger.py +25 -0
  144. vibrante_node/examples/nodes/data_filter.py +19 -0
  145. vibrante_node/examples/nodes/dict_merge.py +20 -0
  146. vibrante_node/examples/nodes/dict_summary.py +21 -0
  147. vibrante_node/examples/nodes/dropdown_selector.py +29 -0
  148. vibrante_node/examples/nodes/env_reader.py +18 -0
  149. vibrante_node/examples/nodes/list_item_picker.py +85 -0
  150. vibrante_node/examples/nodes/list_stats.py +27 -0
  151. vibrante_node/examples/nodes/logic_threshold.py +23 -0
  152. vibrante_node/examples/nodes/math_square.py +30 -0
  153. vibrante_node/examples/nodes/random_list.py +18 -0
  154. vibrante_node/examples/nodes/reactive_config.py +24 -0
  155. vibrante_node/examples/nodes/safety_reset.py +31 -0
  156. vibrante_node/examples/nodes/string_reverse.py +16 -0
  157. vibrante_node/icons/210429_DeadlineFreeOn10RenderMachines.jpg +0 -0
  158. vibrante_node/icons/README.md +39 -0
  159. vibrante_node/icons/blender_icon.png +0 -0
  160. vibrante_node/icons/braces.png +0 -0
  161. vibrante_node/icons/braces.svg +1 -0
  162. vibrante_node/icons/builder.png +0 -0
  163. vibrante_node/icons/check.png +0 -0
  164. vibrante_node/icons/check.svg +1 -0
  165. vibrante_node/icons/chevron-right.svg +3 -0
  166. vibrante_node/icons/code.png +0 -0
  167. vibrante_node/icons/code.svg +4 -0
  168. vibrante_node/icons/computer-window.png +0 -0
  169. vibrante_node/icons/data.png +0 -0
  170. vibrante_node/icons/data.svg +5 -0
  171. vibrante_node/icons/database-search.png +0 -0
  172. vibrante_node/icons/database-search.svg +5 -0
  173. vibrante_node/icons/database-zap.png +0 -0
  174. vibrante_node/icons/database-zap.svg +5 -0
  175. vibrante_node/icons/database.png +0 -0
  176. vibrante_node/icons/database.svg +5 -0
  177. vibrante_node/icons/dice.png +0 -0
  178. vibrante_node/icons/dice.svg +1 -0
  179. vibrante_node/icons/divide.svg +5 -0
  180. vibrante_node/icons/file-input.svg +6 -0
  181. vibrante_node/icons/file-plus.png +0 -0
  182. vibrante_node/icons/file-plus.svg +6 -0
  183. vibrante_node/icons/file-text.png +0 -0
  184. vibrante_node/icons/file-text.svg +7 -0
  185. vibrante_node/icons/folder-plus.png +0 -0
  186. vibrante_node/icons/folder-plus.svg +5 -0
  187. vibrante_node/icons/folder.png +0 -0
  188. vibrante_node/icons/folder.svg +3 -0
  189. vibrante_node/icons/gear.png +0 -0
  190. vibrante_node/icons/gear.svg +1 -0
  191. vibrante_node/icons/git-branch.svg +6 -0
  192. vibrante_node/icons/hash.png +0 -0
  193. vibrante_node/icons/hash.svg +1 -0
  194. vibrante_node/icons/houdini.svg +4 -0
  195. vibrante_node/icons/houdini_icon.png +0 -0
  196. vibrante_node/icons/http.png +0 -0
  197. vibrante_node/icons/list-check.png +0 -0
  198. vibrante_node/icons/list-check.svg +7 -0
  199. vibrante_node/icons/list-plus.svg +10 -0
  200. vibrante_node/icons/list.png +0 -0
  201. vibrante_node/icons/list.svg +8 -0
  202. vibrante_node/icons/logic.png +0 -0
  203. vibrante_node/icons/logic.svg +7 -0
  204. vibrante_node/icons/math.png +0 -0
  205. vibrante_node/icons/math.svg +4 -0
  206. vibrante_node/icons/maya_icon.jpg +0 -0
  207. vibrante_node/icons/message.png +0 -0
  208. vibrante_node/icons/message.svg +3 -0
  209. vibrante_node/icons/minus.svg +3 -0
  210. vibrante_node/icons/multiply.png +0 -0
  211. vibrante_node/icons/multiply.svg +1 -0
  212. vibrante_node/icons/online-library.png +0 -0
  213. vibrante_node/icons/percentage.svg +5 -0
  214. vibrante_node/icons/plus.png +0 -0
  215. vibrante_node/icons/plus.svg +1 -0
  216. vibrante_node/icons/print.png +0 -0
  217. vibrante_node/icons/print.svg +5 -0
  218. vibrante_node/icons/prism_icon.png +0 -0
  219. vibrante_node/icons/refresh.svg +6 -0
  220. vibrante_node/icons/repeat.svg +6 -0
  221. vibrante_node/icons/scales.png +0 -0
  222. vibrante_node/icons/scales.svg +1 -0
  223. vibrante_node/icons/shuffle.svg +7 -0
  224. vibrante_node/icons/string.png +0 -0
  225. vibrante_node/icons/string.svg +5 -0
  226. vibrante_node/icons/terminal.png +0 -0
  227. vibrante_node/icons/terminal.svg +1 -0
  228. vibrante_node/icons/timer.png +0 -0
  229. vibrante_node/icons/timer.svg +4 -0
  230. vibrante_node/icons/toggle-switch.svg +5 -0
  231. vibrante_node/icons/uppercase.png +0 -0
  232. vibrante_node/icons/uppercase.svg +1 -0
  233. vibrante_node/icons/variable-get.svg +4 -0
  234. vibrante_node/icons/variable-set.svg +6 -0
  235. vibrante_node/icons/variable.png +0 -0
  236. vibrante_node/icons/variable.svg +5 -0
  237. vibrante_node/icons/vibrante-node-icon.png +0 -0
  238. vibrante_node/icons/vibrante-node-logo.png +0 -0
  239. vibrante_node/icons/vibrante-node-main_logo.png +0 -0
  240. vibrante_node/icons/vibrante-node-resize_main_logo.png +0 -0
  241. vibrante_node/logo.png +0 -0
  242. vibrante_node/mcp_cli.py +36 -0
  243. vibrante_node/node_examples/Split_String.json +35 -0
  244. vibrante_node/node_examples/async_delay.json +32 -0
  245. vibrante_node/node_examples/delay_timer.json +29 -0
  246. vibrante_node/node_examples/file_reader.json +29 -0
  247. vibrante_node/node_examples/fruit_selector.json +37 -0
  248. vibrante_node/node_examples/json_parser.json +29 -0
  249. vibrante_node/node_examples/line_counter.json +29 -0
  250. vibrante_node/node_examples/list_append.json +32 -0
  251. vibrante_node/node_examples/list_images_recursive.json +55 -0
  252. vibrante_node/node_examples/logic_and.json +34 -0
  253. vibrante_node/node_examples/logic_compare.json +36 -0
  254. vibrante_node/node_examples/math_abs.json +29 -0
  255. vibrante_node/node_examples/math_add.json +32 -0
  256. vibrante_node/node_examples/reactive_config.json +28 -0
  257. vibrante_node/node_examples/string_uppercase.json +29 -0
  258. vibrante_node/nodes/Dropdown_Selector.json +27 -0
  259. vibrante_node/nodes/add_integers.json +34 -0
  260. vibrante_node/nodes/blender_action_bake_animation.json +23 -0
  261. vibrante_node/nodes/blender_action_custom.json +21 -0
  262. vibrante_node/nodes/blender_action_export_alembic.json +22 -0
  263. vibrante_node/nodes/blender_action_export_fbx.json +23 -0
  264. vibrante_node/nodes/blender_action_export_gltf.json +21 -0
  265. vibrante_node/nodes/blender_action_export_obj.json +19 -0
  266. vibrante_node/nodes/blender_action_export_usd.json +23 -0
  267. vibrante_node/nodes/blender_action_import_alembic.json +18 -0
  268. vibrante_node/nodes/blender_action_import_fbx.json +18 -0
  269. vibrante_node/nodes/blender_action_import_gltf.json +18 -0
  270. vibrante_node/nodes/blender_action_import_obj.json +18 -0
  271. vibrante_node/nodes/blender_action_new_blend.json +18 -0
  272. vibrante_node/nodes/blender_action_open_blend.json +18 -0
  273. vibrante_node/nodes/blender_action_render.json +23 -0
  274. vibrante_node/nodes/blender_action_save_blend.json +18 -0
  275. vibrante_node/nodes/blender_action_scene_info.json +17 -0
  276. vibrante_node/nodes/blender_action_set_frame_range.json +20 -0
  277. vibrante_node/nodes/blender_action_set_render_settings.json +27 -0
  278. vibrante_node/nodes/blender_get_action_result.json +22 -0
  279. vibrante_node/nodes/blender_headless.json +86 -0
  280. vibrante_node/nodes/compare.json +48 -0
  281. vibrante_node/nodes/console_print.json +29 -0
  282. vibrante_node/nodes/create_dictionary.json +18 -0
  283. vibrante_node/nodes/create_folder.json +17 -0
  284. vibrante_node/nodes/create_list.json +18 -0
  285. vibrante_node/nodes/deadline_blender_submit.json +38 -0
  286. vibrante_node/nodes/deadline_houdini_submit.json +38 -0
  287. vibrante_node/nodes/deadline_job_status.json +28 -0
  288. vibrante_node/nodes/deadline_maya_submit.json +40 -0
  289. vibrante_node/nodes/delay_timer.json +26 -0
  290. vibrante_node/nodes/example_random_float.json +35 -0
  291. vibrante_node/nodes/file_append.json +18 -0
  292. vibrante_node/nodes/file_write.json +18 -0
  293. vibrante_node/nodes/for_loop.json +46 -0
  294. vibrante_node/nodes/get_dict_value.json +19 -0
  295. vibrante_node/nodes/get_list_item.json +19 -0
  296. vibrante_node/nodes/houdini_action_bake_animation.json +20 -0
  297. vibrante_node/nodes/houdini_action_custom.json +20 -0
  298. vibrante_node/nodes/houdini_action_export_alembic.json +20 -0
  299. vibrante_node/nodes/houdini_action_export_camera_alembic.json +20 -0
  300. vibrante_node/nodes/houdini_action_export_fbx.json +18 -0
  301. vibrante_node/nodes/houdini_action_import_alembic.json +18 -0
  302. vibrante_node/nodes/houdini_action_import_camera.json +17 -0
  303. vibrante_node/nodes/houdini_action_import_fbx.json +18 -0
  304. vibrante_node/nodes/houdini_action_import_obj.json +18 -0
  305. vibrante_node/nodes/houdini_action_new_hip.json +16 -0
  306. vibrante_node/nodes/houdini_action_open_hip.json +17 -0
  307. vibrante_node/nodes/houdini_action_save_hip.json +17 -0
  308. vibrante_node/nodes/houdini_action_scene_info.json +16 -0
  309. vibrante_node/nodes/houdini_action_set_frame_range.json +18 -0
  310. vibrante_node/nodes/houdini_get_action_result.json +21 -0
  311. vibrante_node/nodes/houdini_headless.json +85 -0
  312. vibrante_node/nodes/houdini_scene_snapshot.json +41 -0
  313. vibrante_node/nodes/http_request.json +76 -0
  314. vibrante_node/nodes/if_condition.json +45 -0
  315. vibrante_node/nodes/list_directory.json +17 -0
  316. vibrante_node/nodes/list_images_recursive.json +41 -0
  317. vibrante_node/nodes/list_item_picker.json +41 -0
  318. vibrante_node/nodes/list_length.json +17 -0
  319. vibrante_node/nodes/logical_gate.json +45 -0
  320. vibrante_node/nodes/loop_body.json +62 -0
  321. vibrante_node/nodes/math_add.json +17 -0
  322. vibrante_node/nodes/math_divide.json +17 -0
  323. vibrante_node/nodes/math_modulo.json +17 -0
  324. vibrante_node/nodes/math_multiply.json +36 -0
  325. vibrante_node/nodes/math_subtract.json +17 -0
  326. vibrante_node/nodes/maya_action_assign_material.json +18 -0
  327. vibrante_node/nodes/maya_action_bake_animation.json +21 -0
  328. vibrante_node/nodes/maya_action_create_render_layer.json +19 -0
  329. vibrante_node/nodes/maya_action_custom.json +20 -0
  330. vibrante_node/nodes/maya_action_export_alembic.json +22 -0
  331. vibrante_node/nodes/maya_action_export_camera_alembic.json +20 -0
  332. vibrante_node/nodes/maya_action_export_fbx.json +18 -0
  333. vibrante_node/nodes/maya_action_import_alembic.json +17 -0
  334. vibrante_node/nodes/maya_action_import_camera.json +17 -0
  335. vibrante_node/nodes/maya_action_import_fbx.json +17 -0
  336. vibrante_node/nodes/maya_action_import_obj.json +17 -0
  337. vibrante_node/nodes/maya_action_list_references.json +16 -0
  338. vibrante_node/nodes/maya_action_new_scene.json +16 -0
  339. vibrante_node/nodes/maya_action_open_scene.json +18 -0
  340. vibrante_node/nodes/maya_action_playblast.json +22 -0
  341. vibrante_node/nodes/maya_action_reference_alembic.json +18 -0
  342. vibrante_node/nodes/maya_action_reference_scene.json +18 -0
  343. vibrante_node/nodes/maya_action_save_scene.json +18 -0
  344. vibrante_node/nodes/maya_action_scene_info.json +16 -0
  345. vibrante_node/nodes/maya_action_set_aovs.json +18 -0
  346. vibrante_node/nodes/maya_action_set_frame_range.json +18 -0
  347. vibrante_node/nodes/maya_action_set_render_settings.json +23 -0
  348. vibrante_node/nodes/maya_get_action_result.json +21 -0
  349. vibrante_node/nodes/maya_headless.json +27 -0
  350. vibrante_node/nodes/mcp_call_tool.json +19 -0
  351. vibrante_node/nodes/mcp_list_tools.json +18 -0
  352. vibrante_node/nodes/mcp_server_init.json +23 -0
  353. vibrante_node/nodes/message_node.json +32 -0
  354. vibrante_node/nodes/prism_add_integration.json +49 -0
  355. vibrante_node/nodes/prism_build_entity.json +45 -0
  356. vibrante_node/nodes/prism_change_project.json +37 -0
  357. vibrante_node/nodes/prism_core_info.json +37 -0
  358. vibrante_node/nodes/prism_core_init.json +46 -0
  359. vibrante_node/nodes/prism_create_category.json +44 -0
  360. vibrante_node/nodes/prism_create_entity.json +60 -0
  361. vibrante_node/nodes/prism_create_playblast.json +56 -0
  362. vibrante_node/nodes/prism_create_product_version.json +64 -0
  363. vibrante_node/nodes/prism_create_project.json +50 -0
  364. vibrante_node/nodes/prism_create_scene_from_preset.json +59 -0
  365. vibrante_node/nodes/prism_eval.json +42 -0
  366. vibrante_node/nodes/prism_get_aovs.json +29 -0
  367. vibrante_node/nodes/prism_get_asset_by_name.json +69 -0
  368. vibrante_node/nodes/prism_get_asset_type_by_name.json +62 -0
  369. vibrante_node/nodes/prism_get_asset_types_by_project.json +55 -0
  370. vibrante_node/nodes/prism_get_assets_by_project.json +41 -0
  371. vibrante_node/nodes/prism_get_assets_by_type.json +69 -0
  372. vibrante_node/nodes/prism_get_config.json +48 -0
  373. vibrante_node/nodes/prism_get_current_scene.json +37 -0
  374. vibrante_node/nodes/prism_get_departments.json +37 -0
  375. vibrante_node/nodes/prism_get_entity_info.json +69 -0
  376. vibrante_node/nodes/prism_get_entity_path.json +69 -0
  377. vibrante_node/nodes/prism_get_export_path.json +26 -0
  378. vibrante_node/nodes/prism_get_latest_product_path.json +34 -0
  379. vibrante_node/nodes/prism_get_media.json +29 -0
  380. vibrante_node/nodes/prism_get_media_versions.json +33 -0
  381. vibrante_node/nodes/prism_get_plugin.json +35 -0
  382. vibrante_node/nodes/prism_get_preset_scenes.json +35 -0
  383. vibrante_node/nodes/prism_get_product_versions.json +33 -0
  384. vibrante_node/nodes/prism_get_products.json +29 -0
  385. vibrante_node/nodes/prism_get_project_by_name.json +55 -0
  386. vibrante_node/nodes/prism_get_project_config_path.json +26 -0
  387. vibrante_node/nodes/prism_get_scene_files.json +45 -0
  388. vibrante_node/nodes/prism_get_scene_path.json +23 -0
  389. vibrante_node/nodes/prism_get_sequence_by_project.json +48 -0
  390. vibrante_node/nodes/prism_get_sequences_by_project.json +41 -0
  391. vibrante_node/nodes/prism_get_shot_by_name.json +62 -0
  392. vibrante_node/nodes/prism_get_shot_by_sequence.json +55 -0
  393. vibrante_node/nodes/prism_get_shot_info.json +69 -0
  394. vibrante_node/nodes/prism_get_shots.json +29 -0
  395. vibrante_node/nodes/prism_get_shots_by_project_sequence.json +48 -0
  396. vibrante_node/nodes/prism_get_shots_by_sequence.json +48 -0
  397. vibrante_node/nodes/prism_get_tasks.json +39 -0
  398. vibrante_node/nodes/prism_import_product.json +37 -0
  399. vibrante_node/nodes/prism_list_plugins.json +25 -0
  400. vibrante_node/nodes/prism_list_projects.json +25 -0
  401. vibrante_node/nodes/prism_login_token.json +33 -0
  402. vibrante_node/nodes/prism_monkey_patch.json +46 -0
  403. vibrante_node/nodes/prism_open_scene.json +33 -0
  404. vibrante_node/nodes/prism_popup.json +40 -0
  405. vibrante_node/nodes/prism_register_callback.json +58 -0
  406. vibrante_node/nodes/prism_save_scene_version.json +90 -0
  407. vibrante_node/nodes/prism_send_cmd.json +54 -0
  408. vibrante_node/nodes/prism_set_config.json +55 -0
  409. vibrante_node/nodes/prism_studio_assign_project.json +43 -0
  410. vibrante_node/nodes/prism_trigger_callback.json +42 -0
  411. vibrante_node/nodes/prism_usd_department_layer_path.json +35 -0
  412. vibrante_node/nodes/prism_usd_entity_path.json +29 -0
  413. vibrante_node/nodes/prism_usd_sublayer_path.json +41 -0
  414. vibrante_node/nodes/prism_usd_update_department_layer.json +33 -0
  415. vibrante_node/nodes/prism_usd_update_sublayer.json +33 -0
  416. vibrante_node/nodes/python_script.json +17 -0
  417. vibrante_node/nodes/scene_intent_extractor.json +25 -0
  418. vibrante_node/nodes/set_dict_value.json +20 -0
  419. vibrante_node/nodes/string_concat.json +47 -0
  420. vibrante_node/nodes/string_length.json +16 -0
  421. vibrante_node/nodes/string_lowercase.json +16 -0
  422. vibrante_node/nodes/string_replace.json +18 -0
  423. vibrante_node/nodes/string_split.json +17 -0
  424. vibrante_node/nodes/string_uppercase.json +16 -0
  425. vibrante_node/nodes/variable_node.json +42 -0
  426. vibrante_node/nodes/while_loop.json +18 -0
  427. vibrante_node/splash.png +0 -0
  428. vibrante_node/vfx_workflows/01_prism_project_overview.json +492 -0
  429. vibrante_node/vfx_workflows/02_maya_asset_publish.json +776 -0
  430. vibrante_node/vfx_workflows/03_multi_shot_alembic_export.json +856 -0
  431. vibrante_node/vfx_workflows/04_deadline_render_pipeline.json +994 -0
  432. vibrante_node/vfx_workflows/05_houdini_fx_pipeline.json +1056 -0
  433. vibrante_node/vfx_workflows/06_blender_multi_format_export.json +1206 -0
  434. vibrante_node/website_examples/database_query.json +69 -0
  435. vibrante_node/website_examples/email_notification.json +104 -0
  436. vibrante_node/website_examples/file_batch_processor.json +62 -0
  437. vibrante_node/website_examples/folder_monitor.json +55 -0
  438. vibrante_node/website_examples/hou_sop_chain.json +69 -0
  439. vibrante_node/website_examples/http_request.json +90 -0
  440. vibrante_node/website_examples/image_resizer.json +90 -0
  441. vibrante_node/website_examples/llm_text_generation.json +90 -0
  442. vibrante_node/website_examples/prism_multi_asset_publisher.json +76 -0
  443. vibrante_node/website_examples/regex_replace.json +69 -0
  444. vibrante_node/workflows/If_condition.json +134 -0
  445. vibrante_node/workflows/Maya_WorkFlow.json +464 -0
  446. vibrante_node/workflows/asset_intelligence_pipeline.json +259 -0
  447. vibrante_node/workflows/concat_string_with_loop.json +262 -0
  448. vibrante_node/workflows/delay_time.json +74 -0
  449. vibrante_node/workflows/example_workflow_maya_prism_demo.json +503 -0
  450. vibrante_node/workflows/example_workflow_prism_demo.json +276 -0
  451. vibrante_node/workflows/example_workflow_prism_demo_02.json +221 -0
  452. vibrante_node/workflows/extract_FPS_from_maya_scene.json +265 -0
  453. vibrante_node/workflows/for_each.json +260 -0
  454. vibrante_node/workflows/get_list_item.json +151 -0
  455. vibrante_node/workflows/hou_mcp_scene_context_demo.json +67 -0
  456. vibrante_node/workflows/list_recursive_images.json +103 -0
  457. vibrante_node/workflows/logic_if_example.json +262 -0
  458. vibrante_node/workflows/logic_if_with_variables.json +210 -0
  459. vibrante_node/workflows/loop_break_example.json +197 -0
  460. vibrante_node/workflows/loop_operation_example.json +382 -0
  461. vibrante_node/workflows/mcp_list_tools_demo.json +90 -0
  462. vibrante_node/workflows/prism_assets_workflow.json +131 -0
  463. vibrante_node/workflows/python_script_node.json +89 -0
  464. vibrante_node/workflows/run_in_sequence.json +158 -0
  465. vibrante_node/workflows/scene_intent_pipeline.json +134 -0
  466. vibrante_node/workflows/scene_planning_pipeline.json +258 -0
  467. vibrante_node/workflows/semantic_scene_intent.json +96 -0
  468. vibrante_node/workflows/setup_maya_scene.json +352 -0
  469. vibrante_node/workflows/tutorial_maya_headless_prism_pipeline.json +593 -0
  470. vibrante_node/workflows/two_way_switch.json +341 -0
  471. vibrante_node/workflows/while_loop_class_example.json +192 -0
  472. vibrante_node/workflows/while_loop_example.json +184 -0
  473. vibrante_node/workflows/while_loop_retry_example.json +276 -0
  474. vibrante_node-2.5.1.dist-info/METADATA +715 -0
  475. vibrante_node-2.5.1.dist-info/RECORD +487 -0
  476. vibrante_node-2.5.1.dist-info/WHEEL +5 -0
  477. vibrante_node-2.5.1.dist-info/entry_points.txt +3 -0
  478. vibrante_node-2.5.1.dist-info/licenses/CLA.md +96 -0
  479. vibrante_node-2.5.1.dist-info/licenses/COMMERCIAL_LICENSE.md +170 -0
  480. vibrante_node-2.5.1.dist-info/licenses/LICENSE +178 -0
  481. vibrante_node-2.5.1.dist-info/licenses/LICENSES/AGPL-3.0.txt +661 -0
  482. vibrante_node-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
  483. vibrante_node-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
  484. vibrante_node-2.5.1.dist-info/licenses/LICENSES/GPL-3.0.txt +674 -0
  485. vibrante_node-2.5.1.dist-info/licenses/LICENSES/LGPL-3.0.txt +165 -0
  486. vibrante_node-2.5.1.dist-info/licenses/LICENSES/README.md +65 -0
  487. vibrante_node-2.5.1.dist-info/top_level.txt +2 -0
src/ui/canvas/scene.py ADDED
@@ -0,0 +1,1149 @@
1
+ from src.utils.qt_compat import QtWidgets, QtCore, QtGui, exec_dialog, Signal
2
+ import asyncio
3
+
4
+ QGraphicsScene = QtWidgets.QGraphicsScene
5
+ QGraphicsItem = QtWidgets.QGraphicsItem
6
+ QMenu = QtWidgets.QMenu
7
+ QAction = QtWidgets.QAction
8
+ Qt = QtCore.Qt
9
+ QPointF = QtCore.QPointF
10
+ QColor = QtGui.QColor
11
+ QPen = QtGui.QPen
12
+ from src.core.registry import NodeRegistry
13
+ from src.ui.node_widget import NodeWidget
14
+ from src.ui.canvas.edge import Edge
15
+ from src.ui.port_widget import PortWidget
16
+ from src.core.models import WorkflowModel, NodeInstanceModel, ConnectionModel, StickyNoteModel, BackdropModel
17
+ from src.utils.runtime import AsyncRuntime
18
+ from src.ui.canvas.sticky_note import StickyNote
19
+ from src.ui.canvas.backdrop import Backdrop
20
+ from uuid import uuid4, UUID
21
+
22
+ # Simple global clipboard for cross-tab copy/paste
23
+ global_clipboard = {"nodes": None}
24
+
25
+ class NodeScene(QGraphicsScene):
26
+ dirty_changed = Signal(bool) # emitted when unsaved-state changes
27
+
28
+ def __init__(self, parent=None):
29
+ super().__init__(parent)
30
+ self.setBackgroundBrush(QColor(40, 40, 40)) # Darker background
31
+ self.setSceneRect(-5000, -5000, 10000, 10000)
32
+
33
+ self.nodes = [] # List of NodeWidget
34
+ self.edges = []
35
+ self.sticky_notes = []
36
+ self.backdrops = []
37
+ self.active_edge = None
38
+ self.file_path = None
39
+
40
+ # Snap target state
41
+ self._snapped_port = None
42
+
43
+ self.history = []
44
+ self.redo_stack = []
45
+ self._undoing = False
46
+ self._dirty = False
47
+ self._sync_callback = None # Set by MainWindow when this scene is a subgraph tab
48
+
49
+ self.grid_size = 20
50
+ self.grid_pen = QPen(QColor("#555555"), 0.5)
51
+
52
+ def push_history(self):
53
+ if self._undoing: return
54
+ snapshot = self.to_workflow_model().model_dump()
55
+ self.history.append(snapshot)
56
+ self.redo_stack.clear()
57
+ if len(self.history) > 50: # Limit history
58
+ self.history.pop(0)
59
+ if not self._dirty:
60
+ self._dirty = True
61
+ self.dirty_changed.emit(True)
62
+ if self._sync_callback:
63
+ self._sync_callback(snapshot)
64
+
65
+ def mark_clean(self):
66
+ if self._dirty:
67
+ self._dirty = False
68
+ self.dirty_changed.emit(False)
69
+
70
+ def undo(self):
71
+ if not self.history: return
72
+ self._undoing = True
73
+ current = self.to_workflow_model().model_dump()
74
+ self.redo_stack.append(current)
75
+
76
+ last_state = self.history.pop()
77
+ model = WorkflowModel.model_validate(last_state)
78
+ self.from_workflow_model(model)
79
+ self._undoing = False
80
+ if self._sync_callback:
81
+ self._sync_callback(last_state)
82
+
83
+ def redo(self):
84
+ if not self.redo_stack: return
85
+ self._undoing = True
86
+ current = self.to_workflow_model().model_dump()
87
+ self.history.append(current)
88
+
89
+ next_state = self.redo_stack.pop()
90
+ model = WorkflowModel.model_validate(next_state)
91
+ self.from_workflow_model(model)
92
+ self._undoing = False
93
+ if self._sync_callback:
94
+ self._sync_callback(next_state)
95
+
96
+ def _safe_async_call(self, coro):
97
+ """Helper to call async methods from the UI thread using a background loop."""
98
+ AsyncRuntime.run_coroutine(coro)
99
+
100
+ def _get_port_data_type(self, port):
101
+ """Returns the data type string for a port widget."""
102
+ pd = port.port_definition
103
+ if hasattr(pd, "type"):
104
+ return pd.type.lower()
105
+ if hasattr(pd, "data_type"):
106
+ return pd.data_type.lower()
107
+ return "any"
108
+
109
+ def _trigger_unplug(self, from_port, to_port):
110
+ """Triggers sync and async unplug events."""
111
+ if not from_port or not to_port: return
112
+ fn_widget = from_port.parentItem()
113
+ tn_widget = to_port.parentItem()
114
+ fn = fn_widget.node_definition
115
+ tn = tn_widget.node_definition
116
+
117
+ try:
118
+ fn.on_unplug_sync(from_port.port_definition.name, False)
119
+ except Exception as e:
120
+ print(f"Error in {fn.name} on_unplug_sync: {e}")
121
+
122
+ try:
123
+ tn.on_unplug_sync(to_port.port_definition.name, True)
124
+ except Exception as e:
125
+ print(f"Error in {tn.name} on_unplug_sync: {e}")
126
+
127
+ fn_widget._refresh_widget_states()
128
+ tn_widget._refresh_widget_states()
129
+
130
+ self._safe_async_call(fn.on_unplug(from_port.port_definition.name, False))
131
+ self._safe_async_call(tn.on_unplug(to_port.port_definition.name, True))
132
+
133
+ def _trigger_plug(self, from_port, to_port):
134
+ """Triggers sync and async plug events."""
135
+ if not from_port or not to_port: return
136
+ fn_widget = from_port.parentItem()
137
+ tn_widget = to_port.parentItem()
138
+ fn = fn_widget.node_definition
139
+ tn = tn_widget.node_definition
140
+
141
+ source_val = fn.get_parameter(from_port.port_definition.name)
142
+ if source_val is not None:
143
+ tn_widget.set_parameter(to_port.port_definition.name, source_val)
144
+
145
+ try:
146
+ fn.on_plug_sync(from_port.port_definition.name, False, tn, to_port.port_definition.name)
147
+ except Exception as e:
148
+ print(f"Error in {fn.name} on_plug_sync: {e}")
149
+
150
+ try:
151
+ tn.on_plug_sync(to_port.port_definition.name, True, fn, from_port.port_definition.name)
152
+ except Exception as e:
153
+ print(f"Error in {tn.name} on_plug_sync: {e}")
154
+
155
+ fn_widget._refresh_widget_states()
156
+ tn_widget._refresh_widget_states()
157
+
158
+ self._safe_async_call(fn.on_plug(from_port.port_definition.name, False, tn, to_port.port_definition.name))
159
+ self._safe_async_call(tn.on_plug(to_port.port_definition.name, True, fn, from_port.port_definition.name))
160
+
161
+ def drawBackground(self, painter, rect):
162
+ super().drawBackground(painter, rect)
163
+ left = int(rect.left())
164
+ right = int(rect.right())
165
+ top = int(rect.top())
166
+ bottom = int(rect.bottom())
167
+ first_left = left - (left % self.grid_size)
168
+ first_top = top - (top % self.grid_size)
169
+ painter.setPen(self.grid_pen)
170
+ for x in range(first_left, right, self.grid_size):
171
+ painter.drawLine(x, top, x, bottom)
172
+ for y in range(first_top, bottom, self.grid_size):
173
+ painter.drawLine(left, y, right, y)
174
+
175
+ def copy_selection(self):
176
+ selected_items = self.selectedItems()
177
+ if not selected_items:
178
+ return None
179
+
180
+ # Serialize only selected nodes, notes, backdrops and internal connections
181
+ model = WorkflowModel()
182
+ node_ids = set()
183
+
184
+ for item in selected_items:
185
+ if isinstance(item, NodeWidget):
186
+ node_ids.add(item.instance_id)
187
+ node_model = NodeInstanceModel(
188
+ instance_id=item.instance_id,
189
+ node_id=getattr(item.node_definition, 'node_id', item.node_definition.name),
190
+ position=(item.pos().x(), item.pos().y()),
191
+ parameters=item.node_definition.parameters.copy()
192
+ )
193
+ model.nodes.append(node_model)
194
+ elif isinstance(item, StickyNote):
195
+ model.sticky_notes.append(StickyNoteModel(
196
+ id=item.instance_id,
197
+ position=(item.pos().x(), item.pos().y()),
198
+ size=(item.rect().width(), item.rect().height()),
199
+ text=item.get_text(),
200
+ color=item.bg_color.name()
201
+ ))
202
+ elif isinstance(item, Backdrop):
203
+ model.backdrops.append(BackdropModel(
204
+ id=item.instance_id,
205
+ position=(item.pos().x(), item.pos().y()),
206
+ size=(item.rect().width(), item.rect().height()),
207
+ title=item.title_item.toPlainText(),
208
+ color=item.bg_color.name()
209
+ ))
210
+
211
+ for edge in self.edges:
212
+ if edge.from_port and edge.to_port:
213
+ f_id = edge.from_port.parentItem().instance_id
214
+ t_id = edge.to_port.parentItem().instance_id
215
+ if f_id in node_ids and t_id in node_ids:
216
+ conn_model = ConnectionModel(
217
+ from_node=f_id,
218
+ from_port=edge.from_port.port_definition.name,
219
+ to_node=t_id,
220
+ to_port=edge.to_port.port_definition.name
221
+ )
222
+ model.connections.append(conn_model)
223
+
224
+ global_clipboard["nodes"] = model.model_dump()
225
+ return global_clipboard["nodes"]
226
+
227
+ def paste_selection(self, target_pos: QPointF = None, pos_offset: QPointF = None):
228
+ data = global_clipboard.get("nodes")
229
+ if not data:
230
+ return
231
+
232
+ model = WorkflowModel.model_validate(data)
233
+
234
+ # Calculate offset if target_pos is provided
235
+ if target_pos is not None:
236
+ # Find the top-left of the copied group as reference
237
+ all_positions = []
238
+ for n in model.nodes: all_positions.append(n.position)
239
+ for n in model.sticky_notes: all_positions.append(n.position)
240
+ for n in model.backdrops: all_positions.append(n.position)
241
+
242
+ if all_positions:
243
+ min_x = min(p[0] for p in all_positions)
244
+ min_y = min(p[1] for p in all_positions)
245
+ pos_offset = target_pos - QPointF(min_x, min_y)
246
+
247
+ # Default offset if neither target_pos nor pos_offset is provided
248
+ if pos_offset is None:
249
+ pos_offset = QPointF(30, 30)
250
+
251
+ # Map old IDs to new IDs to maintain connections
252
+ import uuid
253
+ id_map = {}
254
+ new_items = []
255
+
256
+ self.clearSelection()
257
+
258
+ # Paste Nodes
259
+ for node_model in model.nodes:
260
+ new_pos = QPointF(node_model.position[0], node_model.position[1]) + pos_offset
261
+ widget = self.add_node_by_name(node_model.node_id, new_pos)
262
+ if widget:
263
+ new_id = str(uuid.uuid4())
264
+ id_map[node_model.instance_id] = new_id
265
+ widget.instance_id = new_id
266
+ for p_name, p_val in node_model.parameters.items():
267
+ widget.set_parameter(p_name, p_val, propagate=False)
268
+ widget.setSelected(True)
269
+ new_items.append(widget)
270
+
271
+ # Paste Connections
272
+ for conn in model.connections:
273
+ from_id = id_map.get(conn.from_node)
274
+ to_id = id_map.get(conn.to_node)
275
+ if from_id and to_id:
276
+ from_w = next((n for n in self.nodes if n.instance_id == from_id), None)
277
+ to_w = next((n for n in self.nodes if n.instance_id == to_id), None)
278
+ if from_w and to_w:
279
+ self.connect_nodes(from_w, conn.from_port, to_w, conn.to_port)
280
+
281
+ # Paste Sticky Notes
282
+ for note_model in model.sticky_notes:
283
+ new_pos = QPointF(note_model.position[0], note_model.position[1]) + pos_offset
284
+ note = self.add_sticky_note(note_model.text, (new_pos.x(), new_pos.y()),
285
+ note_model.size, note_model.color)
286
+ note.setSelected(True)
287
+ new_items.append(note)
288
+
289
+ # Paste Backdrops
290
+ for bd_model in model.backdrops:
291
+ new_pos = QPointF(bd_model.position[0], bd_model.position[1]) + pos_offset
292
+ box = self.add_backdrop(bd_model.title, (new_pos.x(), new_pos.y()),
293
+ bd_model.size, bd_model.color)
294
+ box.setSelected(True)
295
+ new_items.append(box)
296
+
297
+ return new_items
298
+
299
+ def duplicate_selection(self):
300
+ """Duplicate selected items in place at a +20 px offset. Leaves duplicates selected."""
301
+ if not self.copy_selection():
302
+ return
303
+ self.paste_selection(pos_offset=QPointF(20, 20))
304
+
305
+ def group_selection(self):
306
+ """Collapse selected nodes into a single GroupNode with an embedded sub-workflow.
307
+
308
+ Boundary data connections are analysed automatically:
309
+ - External → internal becomes a group input port + group_in node inside.
310
+ - Internal → external becomes a group output port + group_out node inside.
311
+ Exec connections crossing the boundary are rewired to the GroupNode's
312
+ exec_in / exec_out pins.
313
+ """
314
+ selected = [i for i in self.selectedItems() if isinstance(i, NodeWidget)]
315
+ if not selected:
316
+ return
317
+
318
+ selected_str_ids = {str(w.instance_id) for w in selected}
319
+
320
+ # Capture current workflow (parameters already serializable)
321
+ workflow = self.to_workflow_model()
322
+ conn_list = workflow.connections
323
+
324
+ boundary_in = [] # data: external → internal
325
+ boundary_out = [] # data: internal → external
326
+ boundary_exec_in = [] # exec: external → internal
327
+ boundary_exec_out = [] # exec: internal → external
328
+ internal_conns = [] # connections fully inside the selection
329
+
330
+ for conn in conn_list:
331
+ fi = str(conn.from_node) in selected_str_ids
332
+ ti = str(conn.to_node) in selected_str_ids
333
+ if fi and ti:
334
+ internal_conns.append(conn)
335
+ elif not fi and ti:
336
+ (boundary_exec_in if conn.is_exec else boundary_in).append(conn)
337
+ elif fi and not ti:
338
+ (boundary_exec_out if conn.is_exec else boundary_out).append(conn)
339
+
340
+ # Build group input port list (deduplicated by target port name)
341
+ group_inputs = [] # [(group_port_name, conn), ...]
342
+ seen_in = set()
343
+ in_port_map = {} # conn → group_port_name
344
+
345
+ for conn in boundary_in:
346
+ base = conn.to_port
347
+ name = base
348
+ idx = 1
349
+ while name in seen_in:
350
+ name = f"{base}_{idx}"
351
+ idx += 1
352
+ seen_in.add(name)
353
+ group_inputs.append((name, conn))
354
+ in_port_map[id(conn)] = name
355
+
356
+ # Build group output port list (deduplicated by source port name)
357
+ group_outputs = [] # [(group_port_name, conn), ...]
358
+ seen_out = set()
359
+ out_port_map = {} # conn → group_port_name
360
+
361
+ for conn in boundary_out:
362
+ base = conn.from_port
363
+ name = base
364
+ idx = 1
365
+ while name in seen_out:
366
+ name = f"{base}_{idx}"
367
+ idx += 1
368
+ seen_out.add(name)
369
+ group_outputs.append((name, conn))
370
+ out_port_map[id(conn)] = name
371
+
372
+ # --- Build internal WorkflowModel ---
373
+ from src.core.models import WorkflowModel, NodeInstanceModel, ConnectionModel
374
+ from uuid import uuid4
375
+
376
+ selected_models = [
377
+ m for m in workflow.nodes
378
+ if str(m.instance_id) in selected_str_ids
379
+ ]
380
+
381
+ internal_nodes = list(selected_models)
382
+ internal_conns_list = list(internal_conns)
383
+
384
+ # Compute bounding rect for positioning boundary nodes
385
+ min_x = min(w.pos().x() for w in selected)
386
+ max_x = max(w.pos().x() for w in selected)
387
+ avg_y = sum(w.pos().y() for w in selected) / len(selected)
388
+
389
+ # Add group_in nodes (left of selection)
390
+ gin_id_map = {} # group_port_name → internal UUID
391
+ for i, (port_name, conn) in enumerate(group_inputs):
392
+ gin_id = uuid4()
393
+ gin_id_map[port_name] = gin_id
394
+ internal_nodes.append(NodeInstanceModel(
395
+ instance_id=gin_id,
396
+ node_id="group_in",
397
+ position=(min_x - 250, avg_y + i * 80),
398
+ parameters={"port_name": port_name, "value": None}
399
+ ))
400
+ # Wire group_in.value → original target node's port
401
+ internal_conns_list.append(ConnectionModel(
402
+ from_node=gin_id,
403
+ from_port="value",
404
+ to_node=conn.to_node,
405
+ to_port=conn.to_port,
406
+ is_exec=False
407
+ ))
408
+
409
+ # Add group_out nodes (right of selection)
410
+ gout_id_map = {} # group_port_name → internal UUID
411
+ for i, (port_name, conn) in enumerate(group_outputs):
412
+ gout_id = uuid4()
413
+ gout_id_map[port_name] = gout_id
414
+ internal_nodes.append(NodeInstanceModel(
415
+ instance_id=gout_id,
416
+ node_id="group_out",
417
+ position=(max_x + 250, avg_y + i * 80),
418
+ parameters={"port_name": port_name, "value": None}
419
+ ))
420
+ # Wire original source node's port → group_out.value
421
+ internal_conns_list.append(ConnectionModel(
422
+ from_node=conn.from_node,
423
+ from_port=conn.from_port,
424
+ to_node=gout_id,
425
+ to_port="value",
426
+ is_exec=False
427
+ ))
428
+
429
+ internal_workflow = WorkflowModel(
430
+ nodes=internal_nodes,
431
+ connections=internal_conns_list
432
+ )
433
+
434
+ # --- Port definitions for serialization / restore ---
435
+ port_defs = []
436
+ for port_name, _ in group_inputs:
437
+ port_defs.append({"name": port_name, "type": "any", "is_input": True})
438
+ for port_name, _ in group_outputs:
439
+ port_defs.append({"name": port_name, "type": "any", "is_input": False})
440
+
441
+ self.push_history()
442
+
443
+ # --- Remove selected nodes and their edges from the scene ---
444
+ for edge in list(self.edges):
445
+ fp = edge.from_port.parentItem() if edge.from_port else None
446
+ tp = edge.to_port.parentItem() if edge.to_port else None
447
+ if fp in selected or tp in selected:
448
+ self.removeItem(edge)
449
+ self.edges.remove(edge)
450
+ for widget in selected:
451
+ self.removeItem(widget)
452
+ if widget in self.nodes:
453
+ self.nodes.remove(widget)
454
+
455
+ # --- Create GroupNode on canvas ---
456
+ center_x = sum(w.pos().x() for w in selected) / len(selected)
457
+ center_y = avg_y
458
+ group_widget = self.add_node_by_name("group_node", QPointF(center_x, center_y))
459
+ if not group_widget:
460
+ return
461
+
462
+ # Store embedded workflow and port definitions
463
+ group_widget.node_definition.parameters["__workflow__"] = internal_workflow.model_dump(mode='json')
464
+ group_widget.node_definition.parameters["__port_defs__"] = port_defs
465
+ group_widget.node_definition.parameters["__name__"] = "Group"
466
+
467
+ # Add dynamic ports to the node definition, then rebuild the widget
468
+ for pd in port_defs:
469
+ if pd["is_input"]:
470
+ group_widget.node_definition.add_input(pd["name"], pd["type"])
471
+ else:
472
+ group_widget.node_definition.add_output(pd["name"], pd["type"])
473
+ group_widget.rebuild_ports()
474
+
475
+ # --- Reconnect external connections to the GroupNode ---
476
+ for port_name, conn in group_inputs:
477
+ from_w = next((n for n in self.nodes if str(n.instance_id) == str(conn.from_node)), None)
478
+ if from_w:
479
+ self.connect_nodes(from_w, conn.from_port, group_widget, port_name)
480
+
481
+ for port_name, conn in group_outputs:
482
+ to_w = next((n for n in self.nodes if str(n.instance_id) == str(conn.to_node)), None)
483
+ if to_w:
484
+ self.connect_nodes(group_widget, port_name, to_w, conn.to_port)
485
+
486
+ # Reconnect exec boundary connections to the GroupNode's exec pins
487
+ for conn in boundary_exec_in:
488
+ from_w = next((n for n in self.nodes if str(n.instance_id) == str(conn.from_node)), None)
489
+ if from_w:
490
+ self.connect_nodes(from_w, conn.from_port, group_widget, "exec_in")
491
+
492
+ for conn in boundary_exec_out:
493
+ to_w = next((n for n in self.nodes if str(n.instance_id) == str(conn.to_node)), None)
494
+ if to_w:
495
+ self.connect_nodes(group_widget, "exec_out", to_w, conn.to_port)
496
+
497
+ self.clearSelection()
498
+ group_widget.setSelected(True)
499
+
500
+ @staticmethod
501
+ def _serializable_params(params: dict) -> dict:
502
+ import json
503
+ from pydantic import TypeAdapter
504
+ from typing import Any as _AnyType
505
+
506
+ # R10-1 (silent-loss fix): JSON-native values take the fast path unchanged.
507
+ # Any other value is converted via Pydantic JSON-mode serialization (same
508
+ # semantics as the subgraph-sync callback, window.py:1987) so supported
509
+ # values — e.g. UUID objects inside GroupNode.__workflow__ — are preserved
510
+ # instead of silently dropped from saved workflows.
511
+ # Values Pydantic also cannot render keep the pre-existing documented
512
+ # out-of-contract drop rather than failing the save (scene.py:501-508).
513
+ _any_adapter = TypeAdapter(_AnyType)
514
+
515
+ result = {}
516
+ for k, v in params.items():
517
+ try:
518
+ json.dumps(v)
519
+ result[k] = v
520
+ continue
521
+ except (TypeError, ValueError, RecursionError):
522
+ pass
523
+ try:
524
+ converted = _any_adapter.dump_python(v, mode="json")
525
+ json.dumps(converted) # retain only genuinely JSON-safe output
526
+ except (TypeError, ValueError, RecursionError):
527
+ continue # no JSON representation — preserved drop boundary
528
+ result[k] = converted
529
+ return result
530
+
531
+ def to_workflow_model(self) -> WorkflowModel:
532
+ model = WorkflowModel()
533
+ for node_widget in self.nodes:
534
+ # SYNC: Ensure the latest parameters from the UI are captured
535
+ # Many parameters might have changed via widgets without triggering a full sync
536
+
537
+ node_model = NodeInstanceModel(
538
+ instance_id=node_widget.instance_id,
539
+ node_id=getattr(node_widget.node_definition, 'node_id', node_widget.node_definition.name),
540
+ position=(node_widget.pos().x(), node_widget.pos().y()),
541
+ parameters=self._serializable_params(node_widget.node_definition.parameters),
542
+ bypassed=node_widget.bypassed,
543
+ init_priority=node_widget.init_priority
544
+ )
545
+ model.nodes.append(node_model)
546
+ for edge in self.edges:
547
+ if edge.from_port and edge.to_port:
548
+ f_parent = edge.from_port.parentItem()
549
+ t_parent = edge.to_port.parentItem()
550
+
551
+ if not f_parent or not t_parent:
552
+ continue # Skip partially detached edges
553
+
554
+ conn_model = ConnectionModel(
555
+ from_node=f_parent.instance_id,
556
+ from_port=edge.from_port.port_definition.name,
557
+ to_node=t_parent.instance_id,
558
+ to_port=edge.to_port.port_definition.name,
559
+ is_exec=edge.from_port.port_type == "exec"
560
+ )
561
+ model.connections.append(conn_model)
562
+ for note in self.sticky_notes:
563
+ model.sticky_notes.append(StickyNoteModel(
564
+ id=note.instance_id,
565
+ position=(note.pos().x(), note.pos().y()),
566
+ size=(note.rect().width(), note.rect().height()),
567
+ text=note.get_text(),
568
+ color=note.bg_color.name()
569
+ ))
570
+ for box in self.backdrops:
571
+ model.backdrops.append(BackdropModel(
572
+ id=box.instance_id,
573
+ position=(box.pos().x(), box.pos().y()),
574
+ size=(box.rect().width(), box.rect().height()),
575
+ title=box.title_item.toPlainText(),
576
+ color=box.bg_color.name()
577
+ ))
578
+ return model
579
+
580
+ def from_workflow_model(self, model: WorkflowModel):
581
+ _prev_undoing = self._undoing
582
+ self._undoing = True # suppress push_history (and dirty marking) during load
583
+ self.clear()
584
+ self.nodes = []
585
+ self.edges = []
586
+ self.sticky_notes = []
587
+ self.backdrops = []
588
+ id_to_widget = {}
589
+
590
+ # Sort nodes so init-first nodes (init_priority > 0) are created BEFORE
591
+ # any other node. Higher init_priority is created earlier so the very
592
+ # first thing on the canvas is the highest-priority init node.
593
+ # This ensures init nodes (e.g. "connect to server", "auth login") are
594
+ # present in the scene before any downstream node tries to render or
595
+ # request data from them.
596
+ ordered_nodes = sorted(
597
+ model.nodes,
598
+ key=lambda n: -getattr(n, 'init_priority', 0),
599
+ )
600
+
601
+ for node_model in ordered_nodes:
602
+ widget = self.add_node_by_name(node_model.node_id, QPointF(node_model.position[0], node_model.position[1]))
603
+ if widget:
604
+ widget.instance_id = node_model.instance_id
605
+ widget.set_bypassed(node_model.bypassed)
606
+ widget.set_init_priority(getattr(node_model, 'init_priority', 0))
607
+ # SYNC: Apply parameters to UI widgets and node definition
608
+ for p_name, p_val in node_model.parameters.items():
609
+ widget.set_parameter(p_name, p_val, propagate=False)
610
+
611
+ # Restore dynamic ports from saved parameters (e.g. GroupNode data
612
+ # ports, Sequencer step ports). Mirrors what the engine does before
613
+ # each execution — without this, dynamic ports are lost on reload.
614
+ widget.node_definition.restore_from_parameters(node_model.parameters)
615
+ widget.rebuild_ports()
616
+
617
+ id_to_widget[node_model.instance_id] = widget
618
+
619
+ # Create connections involving init-first nodes BEFORE all others so
620
+ # the init nodes are fully wired up before any non-init connection
621
+ # is established.
622
+ init_ids = {n.instance_id for n in model.nodes if getattr(n, 'init_priority', 0) > 0}
623
+ ordered_conns = sorted(
624
+ model.connections,
625
+ key=lambda c: 0 if (c.from_node in init_ids or c.to_node in init_ids) else 1,
626
+ )
627
+
628
+ for conn in ordered_conns:
629
+ from_widget = id_to_widget.get(conn.from_node)
630
+ to_widget = id_to_widget.get(conn.to_node)
631
+ if from_widget and to_widget:
632
+ self.connect_nodes(from_widget, conn.from_port, to_widget, conn.to_port)
633
+
634
+ for note_model in model.sticky_notes:
635
+ self.add_sticky_note(note_model.text, note_model.position, note_model.size, note_model.color, note_model.id)
636
+
637
+ for bd_model in model.backdrops:
638
+ self.add_backdrop(bd_model.title, bd_model.position, bd_model.size, bd_model.color, bd_model.id)
639
+
640
+ self._undoing = _prev_undoing
641
+
642
+ def add_sticky_note(self, text="New Note", pos=(0, 0), size=(200, 150), color="#ffffcc", instance_id=None):
643
+ self.push_history()
644
+ note = StickyNote(text, pos, size, color, instance_id)
645
+ self.addItem(note)
646
+ self.sticky_notes.append(note)
647
+ return note
648
+
649
+ def add_backdrop(self, title="Network Box", pos=(0, 0), size=(400, 300), color="#444444", instance_id=None):
650
+ self.push_history()
651
+ box = Backdrop(title, pos, size, color, instance_id)
652
+ self.addItem(box)
653
+ self.backdrops.append(box)
654
+ return box
655
+
656
+ def mousePressEvent(self, event):
657
+ # Snap history before potential move or connection change
658
+ if event.button() == Qt.LeftButton:
659
+ self.push_history()
660
+
661
+ view = self.views()[0] if self.views() else None
662
+ transform = view.transform() if view else None
663
+ item = self.itemAt(event.scenePos(), transform) if transform else self.itemAt(event.scenePos())
664
+ is_dark = self.backgroundBrush().color().lightness() < 128
665
+ if event.button() == Qt.LeftButton:
666
+ if isinstance(item, PortWidget):
667
+ if item.is_input:
668
+ existing_edge = next((e for e in self.edges if e.to_port == item), None)
669
+ if existing_edge:
670
+ from_p = existing_edge.from_port
671
+ to_p = existing_edge.to_port
672
+ self.edges.remove(existing_edge)
673
+ self.active_edge = existing_edge
674
+ self.active_edge.to_port = None
675
+ self._trigger_unplug(from_p, to_p)
676
+ else:
677
+ self.active_edge = Edge(item)
678
+ self.active_edge.apply_theme(is_dark)
679
+ self.addItem(self.active_edge)
680
+ else:
681
+ self.active_edge = Edge(item)
682
+ self.active_edge.apply_theme(is_dark)
683
+ self.addItem(self.active_edge)
684
+ self.active_edge.set_end_pos(event.scenePos())
685
+ event.accept()
686
+ return
687
+ elif isinstance(item, Edge):
688
+ item.setSelected(True)
689
+ super().mousePressEvent(event)
690
+ return
691
+ super().mousePressEvent(event)
692
+
693
+ def mouseMoveEvent(self, event):
694
+ if self.active_edge:
695
+ pos = event.scenePos()
696
+
697
+ # SNAP LOGIC
698
+ snap_radius = 35
699
+ nearest_port = None
700
+ min_dist = snap_radius
701
+
702
+ # Find nearest compatible port
703
+ for item in self.items(QtCore.QRectF(pos.x() - snap_radius, pos.y() - snap_radius, snap_radius*2, snap_radius*2)):
704
+ if isinstance(item, PortWidget):
705
+ # Compatibility check
706
+ if item.parentItem() != self.active_edge.from_port.parentItem() and \
707
+ item.is_input != self.active_edge.from_port.is_input:
708
+
709
+ dist = (item.scenePos() - pos).manhattanLength()
710
+ if dist < min_dist:
711
+ min_dist = dist
712
+ nearest_port = item
713
+
714
+ if nearest_port:
715
+ # Snap to port center
716
+ self.active_edge.set_end_pos(nearest_port.scenePos())
717
+
718
+ # Trigger animation on the target port
719
+ if self._snapped_port != nearest_port:
720
+ if self._snapped_port:
721
+ self._snapped_port.hoverLeaveEvent(None)
722
+ self._snapped_port = nearest_port
723
+ self._snapped_port.hoverEnterEvent(None)
724
+ else:
725
+ # No snap, follow mouse
726
+ self.active_edge.set_end_pos(pos)
727
+ if self._snapped_port:
728
+ self._snapped_port.hoverLeaveEvent(None)
729
+ self._snapped_port = None
730
+
731
+ event.accept()
732
+ else:
733
+ super().mouseMoveEvent(event)
734
+
735
+ def mouseReleaseEvent(self, event):
736
+ if self.active_edge and event.button() == Qt.LeftButton:
737
+ view = self.views()[0] if self.views() else None
738
+ transform = view.transform() if view else None
739
+
740
+ # Use the snapped port if it exists, otherwise check under mouse
741
+ item = self._snapped_port
742
+ if not item:
743
+ item = self.itemAt(event.scenePos(), transform) if transform else self.itemAt(event.scenePos())
744
+
745
+ if isinstance(item, PortWidget):
746
+ if item != self.active_edge.from_port and \
747
+ item.parentItem() != self.active_edge.from_port.parentItem() and \
748
+ item.is_input != self.active_edge.from_port.is_input:
749
+ target_input = item if item.is_input else self.active_edge.from_port
750
+ target_output = item if not item.is_input else self.active_edge.from_port
751
+
752
+ old_edge = next((e for e in self.edges if e.to_port == target_input), None)
753
+ if old_edge:
754
+ from_p = old_edge.from_port
755
+ to_p = old_edge.to_port
756
+ self.removeItem(old_edge)
757
+ self.edges.remove(old_edge)
758
+ self._trigger_unplug(from_p, to_p)
759
+
760
+ self.active_edge.from_port = target_output
761
+ self.active_edge.to_port = target_input
762
+ self.active_edge.update_path()
763
+ if self.active_edge not in self.edges:
764
+ self.edges.append(self.active_edge)
765
+ self._trigger_plug(target_output, target_input)
766
+
767
+ out_type = self._get_port_data_type(target_output)
768
+ in_type = self._get_port_data_type(target_input)
769
+ if out_type != "any" and in_type != "any" and out_type != in_type:
770
+ from_name = target_output.parentItem().node_definition.name
771
+ to_name = target_input.parentItem().node_definition.name
772
+ msg = (
773
+ f"Type mismatch: '{from_name}.{target_output.port_definition.name}' "
774
+ f"({out_type}) → '{to_name}.{target_input.port_definition.name}' ({in_type})"
775
+ )
776
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
777
+ self.parent().log_panel.log(msg, "warning")
778
+
779
+ self.active_edge = None
780
+ else:
781
+ self.removeItem(self.active_edge)
782
+ self.active_edge = None
783
+ else:
784
+ self.removeItem(self.active_edge)
785
+ self.active_edge = None
786
+
787
+ # Reset snapped state
788
+ if self._snapped_port:
789
+ self._snapped_port.hoverLeaveEvent(None)
790
+ self._snapped_port = None
791
+
792
+ event.accept()
793
+ else:
794
+ super().mouseReleaseEvent(event)
795
+
796
+ def mouseDoubleClickEvent(self, event):
797
+ for item in self.items(event.scenePos()):
798
+ target = item
799
+ while target is not None and not isinstance(target, NodeWidget):
800
+ target = target.parentItem()
801
+ if isinstance(target, NodeWidget) and getattr(target.node_definition, 'node_id', '') == 'group_node':
802
+ parent = self.parent()
803
+ if parent and hasattr(parent, '_open_subgraph_tab'):
804
+ parent._open_subgraph_tab(target)
805
+ event.accept()
806
+ return
807
+ super().mouseDoubleClickEvent(event)
808
+
809
+ def keyPressEvent(self, event):
810
+ from PyQt5.QtWidgets import QApplication, QLineEdit, QTextEdit, QPlainTextEdit
811
+ focus_widget = QApplication.focusWidget()
812
+ if isinstance(focus_widget, (QLineEdit, QTextEdit, QPlainTextEdit)):
813
+ super().keyPressEvent(event)
814
+ return
815
+ if event.key() == Qt.Key_Delete:
816
+ self.push_history()
817
+ for item in self.selectedItems():
818
+ if isinstance(item, Edge):
819
+ if item in self.edges:
820
+ from_p = item.from_port
821
+ to_p = item.to_port
822
+ self.edges.remove(item)
823
+ self._trigger_unplug(from_p, to_p)
824
+ self.removeItem(item)
825
+ elif isinstance(item, NodeWidget):
826
+ self._remove_node_widget(item)
827
+ elif isinstance(item, StickyNote):
828
+ if item in self.sticky_notes: self.sticky_notes.remove(item)
829
+ self.removeItem(item)
830
+ elif isinstance(item, Backdrop):
831
+ if item in self.backdrops: self.backdrops.remove(item)
832
+ self.removeItem(item)
833
+ super().keyPressEvent(event)
834
+
835
+ def _remove_node_widget(self, node_widget):
836
+ edges_to_remove = [e for e in self.edges if e.from_port.parentItem() == node_widget or e.to_port.parentItem() == node_widget]
837
+ for e in edges_to_remove:
838
+ from_p = e.from_port
839
+ to_p = e.to_port
840
+ self.edges.remove(e)
841
+ self.removeItem(e)
842
+ self._trigger_unplug(from_p, to_p)
843
+ if node_widget in self.nodes:
844
+ self.nodes.remove(node_widget)
845
+ self.removeItem(node_widget)
846
+
847
+ def contextMenuEvent(self, event):
848
+ # Delegate to item-level context menus first
849
+ for item in self.items(event.scenePos()):
850
+ if isinstance(item, (StickyNote, Backdrop)):
851
+ item.contextMenuEvent(event)
852
+ return
853
+
854
+ menu = QMenu()
855
+ pos = event.scenePos()
856
+
857
+ selected_items = self.selectedItems()
858
+ selected_nodes = [i for i in selected_items if isinstance(i, NodeWidget)]
859
+
860
+ # 1. Option to wrap selection in Backdrop
861
+ if selected_nodes:
862
+ # EDIT NODE (open Node Builder for the first selected node's definition)
863
+ editable_ids = [
864
+ n.node_definition.node_id
865
+ for n in selected_nodes
866
+ if NodeRegistry.get_source_path(getattr(n.node_definition, 'node_id', '')) is not None
867
+ ]
868
+ if editable_ids:
869
+ first_id = editable_ids[0]
870
+ edit_label = f"Edit Node ('{first_id}')" if len(editable_ids) == 1 else f"Edit Node ('{first_id}')..."
871
+ edit_act = QAction(edit_label, self.parent())
872
+ def do_edit(_checked=False, nid=first_id):
873
+ parent = self.parent()
874
+ if parent and hasattr(parent, '_on_edit_requested'):
875
+ parent._on_edit_requested(nid)
876
+ edit_act.triggered.connect(do_edit)
877
+ menu.addAction(edit_act)
878
+ menu.addSeparator()
879
+
880
+ copy_act = QAction(f"Copy {len(selected_nodes)} Nodes", self.parent())
881
+ copy_act.triggered.connect(self.copy_selection)
882
+ menu.addAction(copy_act)
883
+
884
+ # BYPASS Options
885
+ any_bypassed = any(n.bypassed for n in selected_nodes)
886
+ any_not_bypassed = any(not n.bypassed for n in selected_nodes)
887
+
888
+ if any_not_bypassed:
889
+ bypass_act = QAction("Bypass Selected Nodes", self.parent())
890
+ def do_bypass():
891
+ self.push_history()
892
+ for n in selected_nodes: n.set_bypassed(True)
893
+ bypass_act.triggered.connect(do_bypass)
894
+ menu.addAction(bypass_act)
895
+
896
+ if any_bypassed:
897
+ unbypass_act = QAction("Unbypass Selected Nodes", self.parent())
898
+ def do_unbypass():
899
+ self.push_history()
900
+ for n in selected_nodes: n.set_bypassed(False)
901
+ unbypass_act.triggered.connect(do_unbypass)
902
+ menu.addAction(unbypass_act)
903
+
904
+ any_init = any(n.init_priority > 0 for n in selected_nodes)
905
+ any_not_init = any(n.init_priority == 0 for n in selected_nodes)
906
+
907
+ if any_not_init:
908
+ init_act = QAction("Mark as Init Node (runs first)", self.parent())
909
+ def do_mark_init():
910
+ self.push_history()
911
+ for n in selected_nodes: n.set_init_priority(1)
912
+ init_act.triggered.connect(do_mark_init)
913
+ menu.addAction(init_act)
914
+
915
+ if any_init:
916
+ uninit_act = QAction("Remove Init Priority", self.parent())
917
+ def do_remove_init():
918
+ self.push_history()
919
+ for n in selected_nodes: n.set_init_priority(0)
920
+ uninit_act.triggered.connect(do_remove_init)
921
+ menu.addAction(uninit_act)
922
+
923
+ # RELOAD node from disk — refresh ports / code without re-adding
924
+ reloadable_ids = sorted({
925
+ n.node_definition.node_id
926
+ for n in selected_nodes
927
+ if NodeRegistry.get_source_path(getattr(n.node_definition, 'node_id', '')) is not None
928
+ })
929
+ if reloadable_ids:
930
+ if len(reloadable_ids) == 1:
931
+ reload_act = QAction(f"Reload Node ('{reloadable_ids[0]}')", self.parent())
932
+ else:
933
+ reload_act = QAction(f"Reload {len(reloadable_ids)} Node Types from Disk", self.parent())
934
+ def do_reload(_checked=False, ids=reloadable_ids):
935
+ self.push_history()
936
+ for nid in ids:
937
+ self.reload_node_type(nid)
938
+ reload_act.triggered.connect(do_reload)
939
+ menu.addAction(reload_act)
940
+
941
+ menu.addSeparator()
942
+
943
+ wrap_act = QAction(f"Wrap {len(selected_nodes)} Nodes in Box", self.parent())
944
+ def wrap_selection():
945
+ self.push_history()
946
+ # Calculate bounding rect of all selected nodes
947
+ rect = selected_nodes[0].sceneBoundingRect()
948
+ for node in selected_nodes[1:]:
949
+ rect = rect.united(node.sceneBoundingRect())
950
+
951
+ # Add padding
952
+ padding = 40
953
+ box_pos = (rect.x() - padding, rect.y() - padding - 20) # Extra top for title
954
+ box_size = (rect.width() + padding*2, rect.height() + padding*2 + 20)
955
+
956
+ self.add_backdrop(title="Grouped Nodes", pos=box_pos, size=box_size)
957
+
958
+ wrap_act.triggered.connect(wrap_selection)
959
+ menu.addAction(wrap_act)
960
+ menu.addSeparator()
961
+
962
+ if global_clipboard.get("nodes"):
963
+ paste_act = QAction("Paste Nodes", self.parent())
964
+ paste_act.triggered.connect(lambda: self.paste_selection(target_pos=pos))
965
+ menu.addAction(paste_act)
966
+ menu.addSeparator()
967
+
968
+ # Core Items
969
+ add_note_act = QAction("Add Sticky Note", self.parent())
970
+ add_note_act.triggered.connect(lambda: self.add_sticky_note(pos=(pos.x(), pos.y())))
971
+ menu.addAction(add_note_act)
972
+
973
+ add_bd_act = QAction("Add Network Box (Backdrop)", self.parent())
974
+ add_bd_act.triggered.connect(lambda: self.add_backdrop(pos=(pos.x(), pos.y())))
975
+ menu.addAction(add_bd_act)
976
+
977
+ menu.addSeparator()
978
+
979
+ # Search Nodes option (Tab shortcut)
980
+ search_act = QAction("Search Nodes... (Tab)", self.parent())
981
+ def show_search():
982
+ view = self.views()[0] if self.views() else None
983
+ if view and hasattr(view, 'show_node_search_popup'):
984
+ view.show_node_search_popup(pos)
985
+ search_act.triggered.connect(show_search)
986
+ menu.addAction(search_act)
987
+
988
+ # Nodes Submenu
989
+ node_menu = menu.addMenu("Add Node")
990
+ for node_id in NodeRegistry.list_node_ids():
991
+ action = QAction(f"{node_id}", self.parent())
992
+ def spawn_node(nid=node_id, p=pos):
993
+ result = self.add_node_by_name(nid, p)
994
+ if result:
995
+ self.push_history()
996
+ action.triggered.connect(spawn_node)
997
+ node_menu.addAction(action)
998
+
999
+ if not menu.isEmpty(): exec_dialog(menu, event.screenPos())
1000
+ else: super().contextMenuEvent(event)
1001
+
1002
+ def add_node_by_name(self, node_id, pos):
1003
+ if isinstance(pos, tuple): pos = QPointF(pos[0], pos[1])
1004
+ node_class = NodeRegistry.get_class(node_id)
1005
+ if node_class:
1006
+ try:
1007
+ node_definition = node_class()
1008
+ except Exception as e:
1009
+ msg = f"Failed to create node '{node_id}': {e}"
1010
+ print(msg)
1011
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
1012
+ self.parent().log_panel.log(msg, "error")
1013
+ return None
1014
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
1015
+ lp = self.parent().log_panel
1016
+ node_definition._on_log = lambda msg, level: lp.log(f"[{node_definition.name}] {msg}", level)
1017
+ node_widget = NodeWidget(node_definition)
1018
+ node_definition._on_ports_changed = node_widget.rebuild_ports
1019
+ node_definition._is_port_connected = node_widget.is_port_connected
1020
+ node_definition._on_dropdown_options_changed = node_widget.update_dropdown_options
1021
+ node_widget.setPos(pos)
1022
+ self.addItem(node_widget)
1023
+ self.nodes.append(node_widget)
1024
+
1025
+ # Inherit theme
1026
+ is_dark = self.backgroundBrush().color().lightness() < 128
1027
+ node_widget.apply_theme(is_dark)
1028
+
1029
+ # Ensure states are initialized correctly (all enabled)
1030
+ node_widget._refresh_widget_states()
1031
+
1032
+ # Honor class-level init_first flag from the node builder
1033
+ if getattr(node_definition, 'init_first', False) or getattr(node_class, 'init_first', False):
1034
+ node_widget.set_init_priority(1)
1035
+ return node_widget
1036
+ return None
1037
+
1038
+ def find_node_by_name(self, name: str):
1039
+ for node in self.nodes:
1040
+ if node.node_definition.name == name: return node
1041
+ return None
1042
+
1043
+ def reload_node_type(self, node_id: str) -> int:
1044
+ """Re-read this node's JSON definition from disk and refresh every
1045
+ live instance of it in the scene.
1046
+
1047
+ Existing connections are preserved where the port name still exists
1048
+ on the new definition; connections to removed ports are dropped.
1049
+ Saved parameter values are re-applied where the port still exists.
1050
+
1051
+ Returns the number of widgets that were refreshed.
1052
+ """
1053
+ ok = NodeRegistry.reload_node_definition(node_id)
1054
+ if not ok:
1055
+ err = NodeRegistry.last_error or f"Reload failed for '{node_id}'"
1056
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
1057
+ self.parent().log_panel.log(err, "error")
1058
+ return 0
1059
+
1060
+ node_class = NodeRegistry.get_class(node_id)
1061
+ if not node_class:
1062
+ return 0
1063
+
1064
+ refreshed = 0
1065
+ for node_widget in list(self.nodes):
1066
+ inst_id = getattr(node_widget.node_definition, 'node_id', None)
1067
+ if inst_id != node_id:
1068
+ continue
1069
+ try:
1070
+ new_definition = node_class()
1071
+ except Exception as e:
1072
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
1073
+ self.parent().log_panel.log(
1074
+ f"Reload: failed to instantiate '{node_id}': {e}", "error"
1075
+ )
1076
+ continue
1077
+
1078
+ # Re-wire engine/UI hooks so the rebuilt instance behaves like a
1079
+ # freshly added node.
1080
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
1081
+ lp = self.parent().log_panel
1082
+ new_definition._on_log = lambda msg, level, name=new_definition.name: lp.log(
1083
+ f"[{name}] {msg}", level
1084
+ )
1085
+ new_definition._on_ports_changed = node_widget.rebuild_ports
1086
+ new_definition._is_port_connected = node_widget.is_port_connected
1087
+ new_definition._on_dropdown_options_changed = node_widget.update_dropdown_options
1088
+
1089
+ node_widget.reload_definition(new_definition)
1090
+ refreshed += 1
1091
+
1092
+ if self.parent() and hasattr(self.parent(), 'log_panel'):
1093
+ self.parent().log_panel.log(
1094
+ f"Reloaded '{node_id}' — {refreshed} instance(s) updated.", "success"
1095
+ )
1096
+ return refreshed
1097
+
1098
+ def connect_nodes(self, from_node, from_port_name, to_node, to_port_name):
1099
+ self.push_history()
1100
+ if isinstance(from_node, str): from_node = self.find_node_by_name(from_node)
1101
+ if isinstance(to_node, str): to_node = self.find_node_by_name(to_node)
1102
+ if not from_node or not to_node: return None
1103
+ from_port = next((p for p in from_node.output_widgets if p.port_definition.name == from_port_name), None)
1104
+ to_port = next((p for p in to_node.input_widgets if p.port_definition.name == to_port_name), None)
1105
+ if from_port and to_port:
1106
+ old_edge = next((e for e in self.edges if e.to_port == to_port), None)
1107
+ if old_edge:
1108
+ from_p = old_edge.from_port
1109
+ to_p = old_edge.to_port
1110
+ self.removeItem(old_edge)
1111
+ self.edges.remove(old_edge)
1112
+ self._trigger_unplug(from_p, to_p)
1113
+ edge = Edge(from_port, to_port)
1114
+ is_dark = self.backgroundBrush().color().lightness() < 128
1115
+ edge.apply_theme(is_dark)
1116
+ self.addItem(edge)
1117
+ self.edges.append(edge)
1118
+ edge.update_path()
1119
+ self._trigger_plug(from_port, to_port)
1120
+ return edge
1121
+ return None
1122
+
1123
+ def update_edge_value(self, node_widget, port_name, value):
1124
+ """Push a live execution value to every edge leaving node_widget's port_name."""
1125
+ for edge in self.edges:
1126
+ if (edge.from_port is not None
1127
+ and edge.to_port is not None
1128
+ and edge.from_port.parentItem() is node_widget
1129
+ and edge.from_port.port_definition.name == port_name):
1130
+ edge.set_live_value(value)
1131
+
1132
+ def clear_edge_values(self):
1133
+ """Clear all live value tooltips from every edge (call at execution start)."""
1134
+ for edge in self.edges:
1135
+ edge.clear_live_value()
1136
+
1137
+ def apply_theme(self, is_dark=True):
1138
+ if is_dark:
1139
+ self.setBackgroundBrush(QColor(40, 40, 40))
1140
+ self.grid_pen = QPen(QColor("#555555"), 0.5)
1141
+ else:
1142
+ self.setBackgroundBrush(QColor(255, 255, 255))
1143
+ self.grid_pen = QPen(QColor("#d0d0d0"), 0.5)
1144
+
1145
+ for node in self.nodes:
1146
+ node.apply_theme(is_dark)
1147
+ for edge in self.edges:
1148
+ edge.apply_theme(is_dark)
1149
+ self.update()