vibrante-node-runtime 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.
- src/__init__.py +1 -0
- src/runtime/__init__.py +187 -0
- src/runtime/agent_runtime.py +315 -0
- src/runtime/ai_planner.py +371 -0
- src/runtime/approval_pipeline.py +237 -0
- src/runtime/architectural_features/__init__.py +68 -0
- src/runtime/architectural_features/architectural_feature_realizer.py +279 -0
- src/runtime/architectural_features/architectural_plan.py +421 -0
- src/runtime/architectural_features/architectural_plan_builder.py +428 -0
- src/runtime/architectural_features/environment_architecture_review.py +398 -0
- src/runtime/asset_identity/__init__.py +103 -0
- src/runtime/asset_identity/asset_identity_auditor.py +532 -0
- src/runtime/asset_identity/identity_review.py +248 -0
- src/runtime/asset_identity/identity_serializer.py +76 -0
- src/runtime/asset_identity/identity_statistics.py +132 -0
- src/runtime/asset_identity/opaque_id_detector.py +167 -0
- src/runtime/asset_identity/role_engine_validator.py +134 -0
- src/runtime/asset_identity/role_geometry_validator.py +161 -0
- src/runtime/asset_knowledge_graph.py +505 -0
- src/runtime/asset_staging_manager.py +350 -0
- src/runtime/assets/__init__.py +310 -0
- src/runtime/assets/acquisition/__init__.py +109 -0
- src/runtime/assets/acquisition/acquisition_manager.py +431 -0
- src/runtime/assets/acquisition/download_registry.py +324 -0
- src/runtime/assets/acquisition/fab_library_scanner.py +384 -0
- src/runtime/assets/acquisition/library_index.py +379 -0
- src/runtime/assets/acquisition/library_watcher.py +362 -0
- src/runtime/assets/acquisition/megascans_scanner.py +551 -0
- src/runtime/assets/acquisition_online/__init__.py +211 -0
- src/runtime/assets/acquisition_online/acquisition_pipeline.py +279 -0
- src/runtime/assets/acquisition_online/asset_cache_manager.py +265 -0
- src/runtime/assets/acquisition_online/asset_fetcher.py +361 -0
- src/runtime/assets/acquisition_online/asset_provenance_tracker.py +231 -0
- src/runtime/assets/acquisition_online/download_queue.py +297 -0
- src/runtime/assets/acquisition_online/download_review.py +253 -0
- src/runtime/assets/acquisition_online/download_scheduler.py +188 -0
- src/runtime/assets/acquisition_online/download_serializer.py +116 -0
- src/runtime/assets/acquisition_online/download_statistics.py +145 -0
- src/runtime/assets/acquisition_online/fab_socket_receiver.py +449 -0
- src/runtime/assets/acquisition_online/megascans_auth.py +408 -0
- src/runtime/assets/acquisition_online/megascans_download.py +391 -0
- src/runtime/assets/acquisition_online/megascans_search.py +313 -0
- src/runtime/assets/acquisition_online/project_asset_staging.py +221 -0
- src/runtime/assets/acquisition_online/provider_session_manager.py +182 -0
- src/runtime/assets/acquisition_online/quixel_bridge_client.py +380 -0
- src/runtime/assets/assembly/__init__.py +288 -0
- src/runtime/assets/assembly/anchor_asset_engine.py +387 -0
- src/runtime/assets/assembly/architectural_templates.py +493 -0
- src/runtime/assets/assembly/asset_clustering_engine.py +343 -0
- src/runtime/assets/assembly/asset_placement_engine.py +553 -0
- src/runtime/assets/assembly/asset_scale_analyzer.py +278 -0
- src/runtime/assets/assembly/bounding_box_extractor.py +227 -0
- src/runtime/assets/assembly/clearance_validator.py +204 -0
- src/runtime/assets/assembly/collision_detector.py +208 -0
- src/runtime/assets/assembly/composition_constraints.py +291 -0
- src/runtime/assets/assembly/decorative_population_engine.py +419 -0
- src/runtime/assets/assembly/environment_blueprint.py +92 -0
- src/runtime/assets/assembly/environment_builder.py +401 -0
- src/runtime/assets/assembly/environment_completeness_review.py +500 -0
- src/runtime/assets/assembly/environment_review.py +454 -0
- src/runtime/assets/assembly/environment_scale_review.py +490 -0
- src/runtime/assets/assembly/environment_structure_builder.py +344 -0
- src/runtime/assets/assembly/environment_zones.py +332 -0
- src/runtime/assets/assembly/footprint_calculator.py +181 -0
- src/runtime/assets/assembly/layout_spacing_engine.py +350 -0
- src/runtime/assets/assembly/placement_optimizer.py +272 -0
- src/runtime/assets/assembly/placement_relationships.py +380 -0
- src/runtime/assets/assembly/placement_templates.py +1024 -0
- src/runtime/assets/assembly/scene_population_engine.py +351 -0
- src/runtime/assets/assembly/semantic_placement_rules.py +323 -0
- src/runtime/assets/assembly/spatial_metadata.py +118 -0
- src/runtime/assets/assembly/spatial_review.py +304 -0
- src/runtime/assets/assembly/storytelling_layout_engine.py +768 -0
- src/runtime/assets/assembly/unit_normalizer.py +192 -0
- src/runtime/assets/cache/__init__.py +39 -0
- src/runtime/assets/cache/asset_cache.py +330 -0
- src/runtime/assets/cache/asset_storage.py +234 -0
- src/runtime/assets/cache/asset_sync.py +280 -0
- src/runtime/assets/discovery/__init__.py +17 -0
- src/runtime/assets/discovery/asset_discovery_engine.py +223 -0
- src/runtime/assets/download/__init__.py +24 -0
- src/runtime/assets/download/asset_download_manager.py +275 -0
- src/runtime/assets/geometry/__init__.py +149 -0
- src/runtime/assets/geometry/asset_metrics.py +476 -0
- src/runtime/assets/geometry/bounding_box_extractor.py +478 -0
- src/runtime/assets/geometry/geometry_analyzer.py +251 -0
- src/runtime/assets/geometry/geometry_review.py +463 -0
- src/runtime/assets/geometry/geometry_serializer.py +121 -0
- src/runtime/assets/geometry/geometry_statistics.py +206 -0
- src/runtime/assets/geometry/ground_contact_detector.py +277 -0
- src/runtime/assets/geometry/pivot_detector.py +248 -0
- src/runtime/assets/geometry/support_surface_detector.py +299 -0
- src/runtime/assets/logging/__init__.py +17 -0
- src/runtime/assets/logging/asset_logger.py +153 -0
- src/runtime/assets/metadata/__init__.py +65 -0
- src/runtime/assets/metadata/asset_metadata_enricher.py +215 -0
- src/runtime/assets/metadata/asset_provenance.py +273 -0
- src/runtime/assets/metadata/asset_semantic_mapper.py +265 -0
- src/runtime/assets/metadata/provider_normalizer.py +364 -0
- src/runtime/assets/providers/__init__.py +38 -0
- src/runtime/assets/providers/base.py +218 -0
- src/runtime/assets/providers/local_library_provider.py +209 -0
- src/runtime/assets/providers/polyhaven_provider.py +268 -0
- src/runtime/assets/providers/provider_manager.py +229 -0
- src/runtime/assets/providers/quixel_provider.py +277 -0
- src/runtime/assets/providers/sketchfab_live_provider.py +515 -0
- src/runtime/assets/providers/sketchfab_provider.py +327 -0
- src/runtime/assets/providers/studio_library_provider.py +323 -0
- src/runtime/assets/providers/usd_library_provider.py +310 -0
- src/runtime/assets/ranking/__init__.py +17 -0
- src/runtime/assets/ranking/asset_ranking_engine.py +365 -0
- src/runtime/assets/real_world_scale.py +189 -0
- src/runtime/assets/realization/__init__.py +162 -0
- src/runtime/assets/realization/asset_converter.py +282 -0
- src/runtime/assets/realization/asset_dependency_resolver.py +285 -0
- src/runtime/assets/realization/asset_importer.py +298 -0
- src/runtime/assets/realization/asset_instancer.py +269 -0
- src/runtime/assets/realization/asset_material_mapper.py +337 -0
- src/runtime/assets/realization/asset_normalizer.py +319 -0
- src/runtime/assets/realization/asset_realization_review.py +416 -0
- src/runtime/assets/realization/asset_validation_pipeline.py +316 -0
- src/runtime/assets/realization/realization_serializer.py +172 -0
- src/runtime/assets/realization/realization_statistics.py +265 -0
- src/runtime/assets/realization/scene_asset_realizer.py +405 -0
- src/runtime/assets/realization/usd_builder.py +272 -0
- src/runtime/assets/recommendations/__init__.py +17 -0
- src/runtime/assets/recommendations/asset_recommendation_engine.py +260 -0
- src/runtime/assets/schema/__init__.py +38 -0
- src/runtime/assets/schema/asset_descriptor.py +484 -0
- src/runtime/assets/semantic/__init__.py +234 -0
- src/runtime/assets/semantic/asset_catalog.py +368 -0
- src/runtime/assets/semantic/asset_catalog_review.py +266 -0
- src/runtime/assets/semantic/asset_catalog_serializer.py +103 -0
- src/runtime/assets/semantic/asset_catalog_statistics.py +130 -0
- src/runtime/assets/semantic/asset_catalog_sync.py +248 -0
- src/runtime/assets/semantic/asset_cinematic_mapper.py +156 -0
- src/runtime/assets/semantic/asset_environment_mapper.py +459 -0
- src/runtime/assets/semantic/asset_knowledge_graph.py +257 -0
- src/runtime/assets/semantic/asset_lookdev_mapper.py +180 -0
- src/runtime/assets/semantic/asset_manifest_reader.py +236 -0
- src/runtime/assets/semantic/asset_metadata_extractor.py +167 -0
- src/runtime/assets/semantic/asset_metadata_provider.py +231 -0
- src/runtime/assets/semantic/asset_query_engine.py +240 -0
- src/runtime/assets/semantic/asset_role_classifier.py +193 -0
- src/runtime/assets/semantic/asset_storytelling_mapper.py +163 -0
- src/runtime/assets/semantic/megascans_metadata_client.py +345 -0
- src/runtime/assets/semantic/semantic_asset_enricher.py +232 -0
- src/runtime/assets/serialization/__init__.py +15 -0
- src/runtime/assets/serialization/asset_serializer.py +201 -0
- src/runtime/assets/suitability/__init__.py +115 -0
- src/runtime/assets/suitability/asset_suitability_engine.py +345 -0
- src/runtime/assets/suitability/asset_suitability_review.py +193 -0
- src/runtime/assets/suitability/asset_suitability_serializer.py +67 -0
- src/runtime/assets/suitability/asset_suitability_statistics.py +141 -0
- src/runtime/assets/suitability/environment_affinity.py +290 -0
- src/runtime/assets/suitability/material_affinity.py +247 -0
- src/runtime/assets/suitability/placement_affinity.py +153 -0
- src/runtime/assets/suitability/role_affinity.py +205 -0
- src/runtime/assets/suitability/scale_affinity.py +150 -0
- src/runtime/assets/suitability/story_affinity.py +235 -0
- src/runtime/assets/suitability/style_affinity.py +252 -0
- src/runtime/assets/validation/__init__.py +17 -0
- src/runtime/assets/validation/asset_validation_engine.py +281 -0
- src/runtime/assets/vector_search/__init__.py +193 -0
- src/runtime/assets/vector_search/asset_embedding_builder.py +132 -0
- src/runtime/assets/vector_search/asset_vector_store.py +264 -0
- src/runtime/assets/vector_search/catalog_vector_index_builder.py +155 -0
- src/runtime/assets/vector_search/embedding_provider.py +294 -0
- src/runtime/assets/vector_search/hybrid_ranking_engine.py +241 -0
- src/runtime/assets/vector_search/intent_embedding_engine.py +99 -0
- src/runtime/assets/vector_search/intent_parser.py +462 -0
- src/runtime/assets/vector_search/retrieval_pipeline.py +275 -0
- src/runtime/assets/vector_search/retrieval_review.py +281 -0
- src/runtime/assets/vector_search/retrieval_serializer.py +91 -0
- src/runtime/assets/vector_search/retrieval_statistics.py +133 -0
- src/runtime/assets/vector_search/semantic_similarity.py +116 -0
- src/runtime/assets/vector_search/vector_search_engine.py +246 -0
- src/runtime/atmosphere_orchestrator.py +412 -0
- src/runtime/audit_store.py +230 -0
- src/runtime/capability_catalog.py +2324 -0
- src/runtime/capability_registry.py +225 -0
- src/runtime/cinematic_camera_engine.py +497 -0
- src/runtime/cinematic_composition.py +399 -0
- src/runtime/cinematic_scene_review.py +539 -0
- src/runtime/contextual_reasoning.py +286 -0
- src/runtime/dependency_graph.py +205 -0
- src/runtime/distributed_runtime.py +348 -0
- src/runtime/environment/__init__.py +189 -0
- src/runtime/environment/anchor_asset_builder.py +389 -0
- src/runtime/environment/atmosphere_builder.py +307 -0
- src/runtime/environment/decorative_population.py +320 -0
- src/runtime/environment/environment_blueprint.py +107 -0
- src/runtime/environment/environment_completeness.py +234 -0
- src/runtime/environment/environment_requirements.py +224 -0
- src/runtime/environment/environment_review.py +320 -0
- src/runtime/environment/environment_serializer.py +100 -0
- src/runtime/environment/environment_statistics.py +149 -0
- src/runtime/environment/environment_structure_builder.py +391 -0
- src/runtime/environment/environment_template_library.py +388 -0
- src/runtime/environment/environment_zone_builder.py +334 -0
- src/runtime/environment/support_asset_builder.py +243 -0
- src/runtime/environment_realization/__init__.py +177 -0
- src/runtime/environment_realization/architectural_constraint_solver.py +230 -0
- src/runtime/environment_realization/beam_builder.py +221 -0
- src/runtime/environment_realization/ceiling_builder.py +186 -0
- src/runtime/environment_realization/environment_execution_engine.py +228 -0
- src/runtime/environment_realization/environment_realization_engine.py +119 -0
- src/runtime/environment_realization/environment_review.py +250 -0
- src/runtime/environment_realization/environment_serializer.py +77 -0
- src/runtime/environment_realization/environment_statistics.py +134 -0
- src/runtime/environment_realization/floor_builder.py +198 -0
- src/runtime/environment_realization/opening_builder.py +224 -0
- src/runtime/environment_realization/room_shell_builder.py +215 -0
- src/runtime/environment_realization/room_shell_completeness_validator.py +303 -0
- src/runtime/environment_realization/structural_attachment_enforcer.py +386 -0
- src/runtime/environment_realization/structural_builder.py +314 -0
- src/runtime/environment_realization/structural_elements.py +258 -0
- src/runtime/environment_realization/structural_routing_engine.py +390 -0
- src/runtime/environment_realization/wall_builder.py +199 -0
- src/runtime/environment_rules.py +239 -0
- src/runtime/environment_shell/__init__.py +187 -0
- src/runtime/environment_shell/environment_readiness_gate.py +187 -0
- src/runtime/environment_shell/environment_shell_audit.py +184 -0
- src/runtime/environment_shell/environment_shell_blueprint.py +267 -0
- src/runtime/environment_shell/environment_shell_builder.py +265 -0
- src/runtime/environment_shell/environment_shell_state.py +133 -0
- src/runtime/environment_shell/shell_ceiling_builder.py +114 -0
- src/runtime/environment_shell/shell_floor_builder.py +96 -0
- src/runtime/environment_shell/shell_phase_result.py +66 -0
- src/runtime/environment_shell/shell_review.py +241 -0
- src/runtime/environment_shell/shell_serializer.py +67 -0
- src/runtime/environment_shell/shell_statistics.py +141 -0
- src/runtime/environment_shell/shell_validator.py +138 -0
- src/runtime/environment_shell/shell_wall_builder.py +156 -0
- src/runtime/environment_shell/structural_anchor_generator.py +200 -0
- src/runtime/environment_shell/structural_element_placer.py +193 -0
- src/runtime/environments/__init__.py +67 -0
- src/runtime/environments/environment_registry.py +1139 -0
- src/runtime/environments/environment_statistics.py +219 -0
- src/runtime/execution_explainer.py +399 -0
- src/runtime/execution_quality.py +258 -0
- src/runtime/execution_review.py +221 -0
- src/runtime/execution_scheduler.py +263 -0
- src/runtime/failure_intelligence.py +341 -0
- src/runtime/goal_decomposer.py +532 -0
- src/runtime/houdini_asset_realizer.py +329 -0
- src/runtime/houdini_runtime.py +992 -0
- src/runtime/intent_parser.py +275 -0
- src/runtime/knowledge_graph.py +310 -0
- src/runtime/layout/__init__.py +172 -0
- src/runtime/layout/affordance_engine.py +384 -0
- src/runtime/layout/anchor_layout_engine.py +244 -0
- src/runtime/layout/decoration_layout_engine.py +325 -0
- src/runtime/layout/furniture_cluster_builder.py +381 -0
- src/runtime/layout/layout_review.py +265 -0
- src/runtime/layout/layout_serializer.py +77 -0
- src/runtime/layout/layout_statistics.py +123 -0
- src/runtime/layout/relationship_graph.py +165 -0
- src/runtime/layout/relationship_graph_builder.py +699 -0
- src/runtime/layout/relationship_layout_engine.py +1101 -0
- src/runtime/layout/relationship_realization_auditor.py +849 -0
- src/runtime/layout/semantic_layout_engine.py +327 -0
- src/runtime/layout/surface_placement_engine.py +270 -0
- src/runtime/layout/wall_attachment_engine.py +243 -0
- src/runtime/layout_realization/__init__.py +183 -0
- src/runtime/layout_realization/cluster_realizer.py +212 -0
- src/runtime/layout_realization/collision_solver.py +359 -0
- src/runtime/layout_realization/identity_metadata_writer.py +257 -0
- src/runtime/layout_realization/layout_application_engine.py +242 -0
- src/runtime/layout_realization/layout_realization_engine.py +293 -0
- src/runtime/layout_realization/layout_validator.py +315 -0
- src/runtime/layout_realization/metadata_application_engine.py +187 -0
- src/runtime/layout_realization/realization_review.py +268 -0
- src/runtime/layout_realization/realization_serializer.py +77 -0
- src/runtime/layout_realization/realization_statistics.py +151 -0
- src/runtime/layout_realization/relationship_metadata_writer.py +305 -0
- src/runtime/layout_realization/relationship_persistence_auditor.py +426 -0
- src/runtime/layout_realization/relationship_realizer.py +294 -0
- src/runtime/layout_realization/scene_constraint_solver.py +317 -0
- src/runtime/layout_realization/surface_realizer.py +195 -0
- src/runtime/layout_realization/transform_resolver.py +268 -0
- src/runtime/layout_realization/wall_attachment_realizer.py +182 -0
- src/runtime/layout_transform_engine.py +341 -0
- src/runtime/lighting/__init__.py +215 -0
- src/runtime/lighting/lighting_color_engine.py +252 -0
- src/runtime/lighting/lighting_environment_mapper.py +792 -0
- src/runtime/lighting/lighting_exposure_engine.py +213 -0
- src/runtime/lighting/lighting_hierarchy_engine.py +248 -0
- src/runtime/lighting/lighting_knowledge.py +342 -0
- src/runtime/lighting/lighting_language.py +239 -0
- src/runtime/lighting/lighting_mood_engine.py +230 -0
- src/runtime/lighting/lighting_patterns.py +522 -0
- src/runtime/lighting/lighting_plan_builder.py +320 -0
- src/runtime/lighting/lighting_readability_engine.py +273 -0
- src/runtime/lighting/lighting_recommendation_engine.py +205 -0
- src/runtime/lighting/lighting_review.py +370 -0
- src/runtime/lighting/lighting_serializer.py +71 -0
- src/runtime/lighting/lighting_statistics.py +142 -0
- src/runtime/lighting/lighting_strategy_engine.py +239 -0
- src/runtime/lighting/lighting_validation.py +183 -0
- src/runtime/llm_provider.py +340 -0
- src/runtime/lookdev/__init__.py +137 -0
- src/runtime/lookdev/lookdev_patterns.py +216 -0
- src/runtime/lookdev/lookdev_review.py +389 -0
- src/runtime/lookdev/lookdev_serializer.py +71 -0
- src/runtime/lookdev/lookdev_statistics.py +133 -0
- src/runtime/lookdev/lookdev_validation.py +203 -0
- src/runtime/lookdev/material_assignment_engine.py +331 -0
- src/runtime/lookdev/material_knowledge.py +244 -0
- src/runtime/lookdev/material_library.py +311 -0
- src/runtime/lookdev/material_recommendation.py +394 -0
- src/runtime/lookdev/renderer_profiles.py +281 -0
- src/runtime/mcp_runtime.py +357 -0
- src/runtime/mcp_server_runtime.py +386 -0
- src/runtime/mcp_session.py +261 -0
- src/runtime/mcp_tool_registry.py +2169 -0
- src/runtime/mcp_transport.py +206 -0
- src/runtime/multi_dcc_runtime.py +316 -0
- src/runtime/orchestration_heuristics.py +360 -0
- src/runtime/pattern_library.py +344 -0
- src/runtime/plan_validator.py +314 -0
- src/runtime/planning/__init__.py +103 -0
- src/runtime/planning/camera/__init__.py +1 -0
- src/runtime/planning/camera/camera_planner.py +179 -0
- src/runtime/planning/composition/__init__.py +1 -0
- src/runtime/planning/composition/composition_planner.py +223 -0
- src/runtime/planning/logging/__init__.py +1 -0
- src/runtime/planning/logging/planning_logger.py +109 -0
- src/runtime/planning/planners/__init__.py +1 -0
- src/runtime/planning/planners/asset_query_generator.py +265 -0
- src/runtime/planning/planners/scene_planner.py +199 -0
- src/runtime/planning/planners/zone_planner.py +271 -0
- src/runtime/planning/recommendations/__init__.py +1 -0
- src/runtime/planning/recommendations/scene_plan_recommendation_engine.py +228 -0
- src/runtime/planning/schema/__init__.py +23 -0
- src/runtime/planning/schema/scene_plan.py +569 -0
- src/runtime/planning/serialization/__init__.py +1 -0
- src/runtime/planning/serialization/plan_serializer.py +147 -0
- src/runtime/planning/validators/__init__.py +1 -0
- src/runtime/planning/validators/scene_plan_validator.py +210 -0
- src/runtime/planning_memory.py +242 -0
- src/runtime/predictive_execution.py +393 -0
- src/runtime/procedural_scene_assembler.py +415 -0
- src/runtime/production_memory.py +309 -0
- src/runtime/production_scoring.py +422 -0
- src/runtime/reality/__init__.py +197 -0
- src/runtime/reality/architectural_integrity_validator.py +220 -0
- src/runtime/reality/beam_connection_validator.py +205 -0
- src/runtime/reality/composition_engine.py +206 -0
- src/runtime/reality/correction_applier.py +159 -0
- src/runtime/reality/correction_pass_engine.py +253 -0
- src/runtime/reality/density_engine.py +145 -0
- src/runtime/reality/floating_object_detector.py +206 -0
- src/runtime/reality/functional_zone_builder.py +260 -0
- src/runtime/reality/geometry_inspector.py +229 -0
- src/runtime/reality/human_reasoning_engine.py +284 -0
- src/runtime/reality/reality_intelligence_engine.py +182 -0
- src/runtime/reality/reality_scene_model.py +351 -0
- src/runtime/reality/reality_serializer.py +75 -0
- src/runtime/reality/reality_statistics.py +145 -0
- src/runtime/reality/support_rule_engine.py +248 -0
- src/runtime/reality/visual_review_engine.py +217 -0
- src/runtime/recommendation_engine.py +358 -0
- src/runtime/render_preparation_engine.py +463 -0
- src/runtime/resource_estimator.py +256 -0
- src/runtime/resource_optimizer.py +343 -0
- src/runtime/review_engine.py +768 -0
- src/runtime/review_feedback.py +325 -0
- src/runtime/runtime_analytics.py +330 -0
- src/runtime/runtime_bootstrap.py +137 -0
- src/runtime/runtime_constraints.py +317 -0
- src/runtime/runtime_federation_api.py +297 -0
- src/runtime/runtime_identity.py +70 -0
- src/runtime/runtime_narration.py +493 -0
- src/runtime/runtime_prompt_context.py +682 -0
- src/runtime/scene_awareness.py +559 -0
- src/runtime/scene_cache.py +277 -0
- src/runtime/scene_hierarchy_builder.py +258 -0
- src/runtime/scene_layout_planner.py +292 -0
- src/runtime/scene_realization_review.py +452 -0
- src/runtime/scene_recommendation_engine.py +398 -0
- src/runtime/scene_validation/__init__.py +118 -0
- src/runtime/scene_validation/occupancy_validator.py +176 -0
- src/runtime/scene_validation/orphan_detector.py +205 -0
- src/runtime/scene_validation/plausibility_engine.py +236 -0
- src/runtime/scene_validation/relationship_validator.py +238 -0
- src/runtime/scene_validation/routing_audit.py +556 -0
- src/runtime/scene_validation/scene_reality_validator.py +229 -0
- src/runtime/scene_validation/support_surface_validator.py +155 -0
- src/runtime/scene_validation/validation_review.py +207 -0
- src/runtime/scene_validation/validation_serializer.py +74 -0
- src/runtime/scene_validation/validation_statistics.py +142 -0
- src/runtime/semantic/__init__.py +113 -0
- src/runtime/semantic/enrichers/__init__.py +12 -0
- src/runtime/semantic/enrichers/scene_intent_enricher.py +305 -0
- src/runtime/semantic/logging/__init__.py +18 -0
- src/runtime/semantic/logging/semantic_logger.py +298 -0
- src/runtime/semantic/prompts/__init__.py +12 -0
- src/runtime/semantic/prompts/intent_prompt_builder.py +317 -0
- src/runtime/semantic/recommendations/__init__.py +17 -0
- src/runtime/semantic/recommendations/intent_recommendation_engine.py +434 -0
- src/runtime/semantic/scene_intent_extractor.py +455 -0
- src/runtime/semantic/schema/__init__.py +40 -0
- src/runtime/semantic/schema/scene_intent_schema.py +349 -0
- src/runtime/semantic/serialization/__init__.py +16 -0
- src/runtime/semantic/serialization/intent_serializer.py +248 -0
- src/runtime/semantic/validators/__init__.py +14 -0
- src/runtime/semantic/validators/scene_intent_validator.py +284 -0
- src/runtime/semantic_execution.py +348 -0
- src/runtime/semantic_import_controller.py +408 -0
- src/runtime/semantic_lighting_engine.py +566 -0
- src/runtime/semantic_memory.py +257 -0
- src/runtime/semantic_registry.py +386 -0
- src/runtime/semantic_scene_templates.py +387 -0
- src/runtime/storage/__init__.py +18 -0
- src/runtime/storage/memory_backend.py +294 -0
- src/runtime/storage/serialization.py +211 -0
- src/runtime/storage/sqlite_backend.py +365 -0
- src/runtime/structure/__init__.py +135 -0
- src/runtime/structure/environment_structural_affinity.py +254 -0
- src/runtime/structure/geometry_role_detector.py +182 -0
- src/runtime/structure/metadata_role_classifier.py +279 -0
- src/runtime/structure/structural_asset_classifier.py +331 -0
- src/runtime/structure/structural_placement_rules.py +326 -0
- src/runtime/structure/structural_review.py +682 -0
- src/runtime/structure/structural_serializer.py +113 -0
- src/runtime/structure/structural_statistics.py +209 -0
- src/runtime/studio/__init__.py +71 -0
- src/runtime/studio/cross_project_learning.py +263 -0
- src/runtime/studio/knowledge_recommendation.py +324 -0
- src/runtime/studio/knowledge_serializer.py +154 -0
- src/runtime/studio/knowledge_statistics.py +107 -0
- src/runtime/studio/production_benchmark.py +240 -0
- src/runtime/studio/project_memory.py +250 -0
- src/runtime/studio/review_analytics.py +166 -0
- src/runtime/studio/studio_knowledge.py +284 -0
- src/runtime/studio/studio_metrics.py +155 -0
- src/runtime/studio/studio_standards.py +262 -0
- src/runtime/studio_knowledge.py +328 -0
- src/runtime/transaction_manager.py +367 -0
- src/runtime/validation_engine.py +234 -0
- src/runtime/visual_hierarchy_engine.py +452 -0
- src/runtime/worker_runtime.py +236 -0
- src/runtime/workflow_federation.py +316 -0
- src/runtime/workflow_optimizer.py +407 -0
- src/runtime/workflow_templates.py +421 -0
- src/runtime/workflows/__init__.py +129 -0
- src/runtime/workflows/workflow_blueprint.py +394 -0
- src/runtime/workflows/workflow_executor.py +344 -0
- src/runtime/workflows/workflow_pack.py +403 -0
- src/runtime/workflows/workflow_recommendation.py +353 -0
- src/runtime/workflows/workflow_registry.py +165 -0
- src/runtime/workflows/workflow_review.py +336 -0
- src/runtime/workflows/workflow_serializer.py +149 -0
- src/runtime/workflows/workflow_statistics.py +205 -0
- src/runtime/workflows/workflow_validator.py +272 -0
- src/utils/__init__.py +0 -0
- src/utils/hou_bridge.py +262 -0
- src/utils/vibrante_config.py +272 -0
- vibrante_node_runtime-2.5.1.dist-info/METADATA +47 -0
- vibrante_node_runtime-2.5.1.dist-info/RECORD +472 -0
- vibrante_node_runtime-2.5.1.dist-info/WHEEL +5 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/CLA.md +96 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/COMMERCIAL_LICENSE.md +170 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSE +178 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/AGPL-3.0.txt +661 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/GPL-3.0.txt +674 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/LGPL-3.0.txt +165 -0
- vibrante_node_runtime-2.5.1.dist-info/licenses/LICENSES/README.md +65 -0
- vibrante_node_runtime-2.5.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,2169 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MCP Tool Registry
|
|
3
|
+
=================
|
|
4
|
+
Bridges the semantic runtime, orchestration runtime, workflow templates,
|
|
5
|
+
AI planning tools, and review systems to the MCP protocol's tool surface.
|
|
6
|
+
|
|
7
|
+
ONLY semantic orchestration tools are registered.
|
|
8
|
+
Raw Houdini mutation APIs (create_node, set_parm, run_python …) are NEVER
|
|
9
|
+
exposed here. The semantic layer is the mandatory choke point.
|
|
10
|
+
|
|
11
|
+
Registered tools
|
|
12
|
+
----------------
|
|
13
|
+
|
|
14
|
+
RUNTIME:
|
|
15
|
+
initialize_runtime_context warm up runtime; return bootstrap data
|
|
16
|
+
query_runtime_state live runtime metrics and status
|
|
17
|
+
query_scene_context structured Houdini scene snapshot
|
|
18
|
+
|
|
19
|
+
KNOWLEDGE:
|
|
20
|
+
query_capabilities enumerate available capabilities
|
|
21
|
+
query_workflow_templates browse workflow templates
|
|
22
|
+
query_examples execution examples for an intent
|
|
23
|
+
|
|
24
|
+
PLANNING:
|
|
25
|
+
plan_scene NL intent → execution plan
|
|
26
|
+
preview_execution inspect ops + risk without executing
|
|
27
|
+
validate_execution_plan structural + constraint validation
|
|
28
|
+
|
|
29
|
+
SCENE BUILDING:
|
|
30
|
+
build_scene_from_assets REQUIRED FIRST STEP for scene intents — real assets, never primitives
|
|
31
|
+
|
|
32
|
+
EXECUTION:
|
|
33
|
+
execute_workflow_transaction run via the transaction system
|
|
34
|
+
review_execution post-execution intent-match review
|
|
35
|
+
|
|
36
|
+
Public API:
|
|
37
|
+
register_all_tools(transport=None) -> MCPToolRegistry
|
|
38
|
+
get_mcp_tool_registry() -> MCPToolRegistry (singleton)
|
|
39
|
+
reset_mcp_tool_registry_for_tests()
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
from __future__ import annotations
|
|
43
|
+
|
|
44
|
+
import json
|
|
45
|
+
import threading
|
|
46
|
+
from dataclasses import dataclass, field
|
|
47
|
+
from typing import Any, Awaitable, Callable, Dict, List, Optional
|
|
48
|
+
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
# Scene-building intent detection
|
|
51
|
+
# ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
_SCENE_BUILDING_VERBS = frozenset({
|
|
54
|
+
"build", "create", "make", "construct", "generate", "assemble",
|
|
55
|
+
"design", "set up", "setup", "populate", "fill",
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
_SCENE_ENVIRONMENT_KEYWORDS = frozenset({
|
|
59
|
+
"room", "scene", "environment", "interior", "exterior", "set",
|
|
60
|
+
"hangar", "corridor", "hallway", "tavern", "saloon", "office",
|
|
61
|
+
"dungeon", "castle", "building", "hall", "warehouse", "factory",
|
|
62
|
+
"lab", "laboratory", "kitchen", "bedroom", "bathroom", "cellar",
|
|
63
|
+
"western", "medieval", "sci-fi", "cyberpunk", "fantasy", "desert",
|
|
64
|
+
"apartment", "house", "hotel", "bar", "restaurant", "cafe",
|
|
65
|
+
"village", "town", "alley", "street", "courtyard", "arena",
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
_PRIMITIVE_NODE_TYPES = frozenset({
|
|
69
|
+
"box", "tube", "sphere", "grid", "line", "circle", "torus",
|
|
70
|
+
"platonic", "rubber_toy", "metaball",
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _is_scene_building_intent(intent: str) -> bool:
|
|
75
|
+
"""Return True if the intent is for building a scene/environment."""
|
|
76
|
+
low = intent.lower()
|
|
77
|
+
words = set(low.split())
|
|
78
|
+
has_verb = any(v in low for v in _SCENE_BUILDING_VERBS)
|
|
79
|
+
has_env = any(kw in low for kw in _SCENE_ENVIRONMENT_KEYWORDS)
|
|
80
|
+
return has_verb and has_env
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _plan_is_primitive_only(operations: List[Dict[str, Any]]) -> bool:
|
|
84
|
+
"""Return True if the plan is mostly create_node calls with primitive types."""
|
|
85
|
+
if not operations:
|
|
86
|
+
return False
|
|
87
|
+
prim_count = sum(
|
|
88
|
+
1 for op in operations
|
|
89
|
+
if str(op.get("node_type", op.get("params", {}).get("node_type", ""))).lower()
|
|
90
|
+
in _PRIMITIVE_NODE_TYPES
|
|
91
|
+
)
|
|
92
|
+
return prim_count / max(len(operations), 1) >= 0.4
|
|
93
|
+
|
|
94
|
+
# ---------------------------------------------------------------------------
|
|
95
|
+
# ToolDefinition
|
|
96
|
+
# ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
@dataclass
|
|
99
|
+
class ToolDefinition:
|
|
100
|
+
name: str
|
|
101
|
+
description: str
|
|
102
|
+
inputSchema: Dict[str, Any]
|
|
103
|
+
handler: Callable[[Dict[str, Any]], Awaitable[Dict[str, Any]]]
|
|
104
|
+
category: str = "general"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------------------------
|
|
108
|
+
# MCPToolRegistry
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
class MCPToolRegistry:
|
|
112
|
+
"""In-process registry of MCP-exposed semantic tools."""
|
|
113
|
+
|
|
114
|
+
def __init__(self) -> None:
|
|
115
|
+
self._tools: Dict[str, ToolDefinition] = {}
|
|
116
|
+
self._lock = threading.Lock()
|
|
117
|
+
|
|
118
|
+
def register_tool(self, defn: ToolDefinition) -> None:
|
|
119
|
+
with self._lock:
|
|
120
|
+
self._tools[defn.name] = defn
|
|
121
|
+
|
|
122
|
+
def get_tool(self, name: str) -> Optional[ToolDefinition]:
|
|
123
|
+
with self._lock:
|
|
124
|
+
return self._tools.get(name)
|
|
125
|
+
|
|
126
|
+
def list_tools(self) -> List[Dict[str, Any]]:
|
|
127
|
+
with self._lock:
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
"name": d.name,
|
|
131
|
+
"description": d.description,
|
|
132
|
+
"inputSchema": d.inputSchema,
|
|
133
|
+
"category": d.category,
|
|
134
|
+
}
|
|
135
|
+
for d in self._tools.values()
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
async def dispatch_tool(
|
|
139
|
+
self, name: str, arguments: Dict[str, Any]
|
|
140
|
+
) -> Dict[str, Any]:
|
|
141
|
+
tool = self.get_tool(name)
|
|
142
|
+
if tool is None:
|
|
143
|
+
return {"ok": False, "error": f"Unknown tool: {name!r}"}
|
|
144
|
+
try:
|
|
145
|
+
result = await tool.handler(arguments)
|
|
146
|
+
if not isinstance(result, dict):
|
|
147
|
+
result = {"result": result}
|
|
148
|
+
return result
|
|
149
|
+
except Exception as exc:
|
|
150
|
+
return {"ok": False, "error": str(exc), "tool": name}
|
|
151
|
+
|
|
152
|
+
def stats(self) -> Dict[str, Any]:
|
|
153
|
+
with self._lock:
|
|
154
|
+
by_cat: Dict[str, int] = {}
|
|
155
|
+
for d in self._tools.values():
|
|
156
|
+
by_cat[d.category] = by_cat.get(d.category, 0) + 1
|
|
157
|
+
return {
|
|
158
|
+
"tool_count": len(self._tools),
|
|
159
|
+
"by_category": by_cat,
|
|
160
|
+
"tools": sorted(self._tools.keys()),
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# ---------------------------------------------------------------------------
|
|
165
|
+
# Handlers — RUNTIME group
|
|
166
|
+
# ---------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
async def _handle_initialize_runtime_context(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
169
|
+
import os
|
|
170
|
+
from src.runtime.runtime_bootstrap import initialize_runtime, get_bootstrap_data
|
|
171
|
+
from src.utils.vibrante_config import apply_vibrante_config
|
|
172
|
+
|
|
173
|
+
# Read the packages file and push its values into the live Houdini session
|
|
174
|
+
# so the session always reflects what vibrante_node.json says, even when
|
|
175
|
+
# Houdini loaded an old state at startup (packages are not hot-reloaded).
|
|
176
|
+
from src.utils.vibrante_config import read_vibrante_config
|
|
177
|
+
try:
|
|
178
|
+
from src.utils.hou_bridge import get_bridge
|
|
179
|
+
file_vals = read_vibrante_config()
|
|
180
|
+
bridge = get_bridge()
|
|
181
|
+
for key, value in file_vals.items():
|
|
182
|
+
if value and not (value.startswith("<") and value.endswith(">")):
|
|
183
|
+
bridge.run_code(
|
|
184
|
+
f"import os\nos.environ[{key!r}] = {value!r}"
|
|
185
|
+
)
|
|
186
|
+
except Exception:
|
|
187
|
+
pass # bridge not available — fall back to file-only path
|
|
188
|
+
apply_vibrante_config(force=True)
|
|
189
|
+
|
|
190
|
+
client_id = str(args.get("client_id", ""))
|
|
191
|
+
init_status = initialize_runtime()
|
|
192
|
+
bootstrap = get_bootstrap_data()
|
|
193
|
+
|
|
194
|
+
# Include resolved asset paths so the agent never guesses or checks stale locations.
|
|
195
|
+
asset_paths = {
|
|
196
|
+
"megascans_library": os.environ.get("VIBRANTE_MEGASCANS_LIBRARY", "(not set)"),
|
|
197
|
+
"asset_cache": os.environ.get("VIBRANTE_ASSET_CACHE", "(not set)"),
|
|
198
|
+
"fab_library": os.environ.get("VIBRANTE_FAB_LIBRARY", "(not set)"),
|
|
199
|
+
"project_staging": os.environ.get("VIBRANTE_PROJECT_STAGING", "(not set)"),
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
# Start the Fab Plugin socket receiver in the background so the user can
|
|
203
|
+
# push assets from the Fab desktop app / Unreal Engine without restarting.
|
|
204
|
+
fab_receiver_info: Dict[str, Any] = {}
|
|
205
|
+
try:
|
|
206
|
+
from src.runtime.assets.acquisition_online.fab_socket_receiver import (
|
|
207
|
+
get_fab_socket_receiver,
|
|
208
|
+
)
|
|
209
|
+
receiver = get_fab_socket_receiver()
|
|
210
|
+
if not receiver.is_running():
|
|
211
|
+
receiver.start()
|
|
212
|
+
fab_receiver_info = {
|
|
213
|
+
"running": receiver.is_running(),
|
|
214
|
+
"port": receiver.port,
|
|
215
|
+
"message": (
|
|
216
|
+
f"Fab socket receiver listening on port {receiver.port}. "
|
|
217
|
+
"Export assets from the Fab desktop app / Unreal Engine → "
|
|
218
|
+
"they will be automatically picked up on the next build_scene_from_assets call."
|
|
219
|
+
) if receiver.is_running() else (
|
|
220
|
+
f"Fab socket receiver could not start on port {receiver.port} "
|
|
221
|
+
"(port may be in use). Manual download or local library scan still works."
|
|
222
|
+
),
|
|
223
|
+
}
|
|
224
|
+
except Exception as _fab_exc:
|
|
225
|
+
fab_receiver_info = {"running": False, "error": str(_fab_exc)}
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
"ok": True,
|
|
229
|
+
"status": init_status,
|
|
230
|
+
"bootstrap": bootstrap,
|
|
231
|
+
"asset_paths": asset_paths,
|
|
232
|
+
"fab_socket_receiver": fab_receiver_info,
|
|
233
|
+
"message": (
|
|
234
|
+
"Vibrante Runtime initialized. "
|
|
235
|
+
f"Megascans library: {asset_paths['megascans_library']}. "
|
|
236
|
+
"Review runtime_rules and recommended_execution_flow before issuing commands."
|
|
237
|
+
),
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
async def _handle_query_runtime_state(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
242
|
+
state: Dict[str, Any] = {"ok": True}
|
|
243
|
+
try:
|
|
244
|
+
from src.runtime.transaction_manager import get_transaction_manager
|
|
245
|
+
viz = get_transaction_manager().get_graph_visualization_data()
|
|
246
|
+
state["transaction_manager"] = viz
|
|
247
|
+
except Exception as exc:
|
|
248
|
+
state["transaction_manager_error"] = str(exc)
|
|
249
|
+
try:
|
|
250
|
+
from src.runtime.scene_cache import get_scene_cache
|
|
251
|
+
state["scene_cache"] = get_scene_cache().stats()
|
|
252
|
+
except Exception as exc:
|
|
253
|
+
state["scene_cache_error"] = str(exc)
|
|
254
|
+
try:
|
|
255
|
+
from src.runtime.execution_scheduler import get_execution_scheduler
|
|
256
|
+
sched = get_execution_scheduler()
|
|
257
|
+
state["scheduler"] = sched.stats()
|
|
258
|
+
except Exception as exc:
|
|
259
|
+
state["scheduler_error"] = str(exc)
|
|
260
|
+
try:
|
|
261
|
+
from src.runtime.audit_store import get_audit_store
|
|
262
|
+
state["audit_store"] = get_audit_store().stats()
|
|
263
|
+
except Exception as exc:
|
|
264
|
+
state["audit_store_error"] = str(exc)
|
|
265
|
+
return state
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
async def _handle_query_scene_context(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
269
|
+
force_refresh = bool(args.get("force_refresh", False))
|
|
270
|
+
try:
|
|
271
|
+
from src.runtime import houdini_runtime
|
|
272
|
+
context = await houdini_runtime.scene_context(force_refresh=force_refresh)
|
|
273
|
+
return {"ok": True, "scene_context": context}
|
|
274
|
+
except Exception as exc:
|
|
275
|
+
return {
|
|
276
|
+
"ok": False,
|
|
277
|
+
"error": str(exc),
|
|
278
|
+
"scene_context": None,
|
|
279
|
+
"message": (
|
|
280
|
+
"Houdini bridge not available. "
|
|
281
|
+
"Ensure Houdini is running with the Vibrante-Node plugin loaded."
|
|
282
|
+
),
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
# ---------------------------------------------------------------------------
|
|
287
|
+
# Handlers — KNOWLEDGE group
|
|
288
|
+
# ---------------------------------------------------------------------------
|
|
289
|
+
|
|
290
|
+
async def _handle_query_capabilities(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
291
|
+
cap_type: Optional[str] = args.get("cap_type") or None
|
|
292
|
+
try:
|
|
293
|
+
from src.runtime.capability_registry import get_capability_registry
|
|
294
|
+
reg = get_capability_registry()
|
|
295
|
+
caps = reg.query_capabilities(cap_type=cap_type) if cap_type else reg.query_capabilities()
|
|
296
|
+
return {"ok": True, "capabilities": caps, "count": len(caps)}
|
|
297
|
+
except Exception as exc:
|
|
298
|
+
return {"ok": False, "error": str(exc)}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
async def _handle_query_workflow_templates(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
302
|
+
tag: Optional[str] = args.get("tag") or None
|
|
303
|
+
try:
|
|
304
|
+
from src.runtime.workflow_templates import get_workflow_templates
|
|
305
|
+
wt = get_workflow_templates()
|
|
306
|
+
templates = wt.list_templates(tag=tag) if tag else wt.list_templates()
|
|
307
|
+
return {"ok": True, "templates": templates, "count": len(templates)}
|
|
308
|
+
except Exception as exc:
|
|
309
|
+
return {"ok": False, "error": str(exc)}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
async def _handle_query_examples(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
313
|
+
intent = str(args.get("intent", "")).strip()
|
|
314
|
+
if not intent:
|
|
315
|
+
return {"ok": False, "error": "intent is required"}
|
|
316
|
+
results: Dict[str, Any] = {"ok": True, "intent": intent}
|
|
317
|
+
|
|
318
|
+
# ── Scene-building / environment example ──────────────────────────────────
|
|
319
|
+
# build_scene_from_assets handles the full intent-to-scene pipeline.
|
|
320
|
+
# Return a concrete usage example so callers know the correct tool sequence.
|
|
321
|
+
if _is_scene_building_intent(intent):
|
|
322
|
+
t128 = _parse_intent_tier128(intent)
|
|
323
|
+
results["scene_building_example"] = {
|
|
324
|
+
"tool": "build_scene_from_assets",
|
|
325
|
+
"description": (
|
|
326
|
+
"Full intent-to-scene pipeline: intent → semantic keywords → "
|
|
327
|
+
"local catalog search → Megascans import → structural routing → "
|
|
328
|
+
"semantic layout → layout realization → Houdini transforms."
|
|
329
|
+
),
|
|
330
|
+
"sample_call": {
|
|
331
|
+
"intent": intent,
|
|
332
|
+
"top_k": 10,
|
|
333
|
+
"parent": "/obj",
|
|
334
|
+
"environment": t128.get("environment", "(auto-detected from intent)"),
|
|
335
|
+
"room_half_width": 5.0,
|
|
336
|
+
},
|
|
337
|
+
"pipeline_stages": [
|
|
338
|
+
"Phase 1: Intent parsing (Tier 12.8) — environment, keywords, role",
|
|
339
|
+
"Phase 1.5: Structural routing (Tier 10.3.5) — split structural vs furniture",
|
|
340
|
+
"Phase 2: SemanticLayout furniture only (Tier 9.8) — clusters, surfaces, walls",
|
|
341
|
+
"Phase 3: LayoutRealization (Tier 9.9) — world-space transforms",
|
|
342
|
+
"Phase 4: Collision resolution (Tier 9.4)",
|
|
343
|
+
"Phase 5: Scene constraint solving",
|
|
344
|
+
"Phase 6: Apply furniture transforms to Houdini",
|
|
345
|
+
"Phase 6b: Apply structural transforms (beam/door/column placement)",
|
|
346
|
+
],
|
|
347
|
+
"expected_output_fields": [
|
|
348
|
+
"ok", "asset_count", "environment", "source",
|
|
349
|
+
"layout_pipeline_report.routing_ok",
|
|
350
|
+
"layout_pipeline_report.structural_assets_routed",
|
|
351
|
+
"layout_pipeline_report.furniture_assets_to_layout",
|
|
352
|
+
"layout_pipeline_report.collision_count_after",
|
|
353
|
+
"layout_pipeline_report.production_ready",
|
|
354
|
+
"END_TO_END_LAYOUT_STATUS",
|
|
355
|
+
],
|
|
356
|
+
"usage": (
|
|
357
|
+
"Call build_scene_from_assets directly with the intent string. "
|
|
358
|
+
"Do NOT use plan_scene + execute_workflow_transaction for scene building — "
|
|
359
|
+
"those tools handle primitive geometry only."
|
|
360
|
+
),
|
|
361
|
+
}
|
|
362
|
+
return results
|
|
363
|
+
|
|
364
|
+
# ── Semantic registry lookup ───────────────────────────────────────────────
|
|
365
|
+
try:
|
|
366
|
+
from src.runtime.semantic_registry import get_semantic_registry
|
|
367
|
+
reg = get_semantic_registry()
|
|
368
|
+
plan = reg.resolve_to_execution_plan(intent, {"parent": "/obj"})
|
|
369
|
+
if plan.get("ok"):
|
|
370
|
+
results["semantic_operation"] = {
|
|
371
|
+
"operation_id": plan.get("operation_id"),
|
|
372
|
+
"sample_operations": plan.get("operations", [])[:3],
|
|
373
|
+
"usage": (
|
|
374
|
+
f"Use plan_scene with prompt containing '{intent}' "
|
|
375
|
+
"to generate a full plan automatically."
|
|
376
|
+
),
|
|
377
|
+
}
|
|
378
|
+
except Exception:
|
|
379
|
+
pass
|
|
380
|
+
|
|
381
|
+
# ── Workflow template lookup ───────────────────────────────────────────────
|
|
382
|
+
try:
|
|
383
|
+
from src.runtime.workflow_templates import get_workflow_templates
|
|
384
|
+
wt = get_workflow_templates()
|
|
385
|
+
for tmpl in wt.list_templates():
|
|
386
|
+
tid = tmpl.get("template_id", "")
|
|
387
|
+
desc = tmpl.get("description", "")
|
|
388
|
+
tags = " ".join(tmpl.get("tags", []))
|
|
389
|
+
low = intent.lower()
|
|
390
|
+
if low in tid.lower() or low in desc.lower() or low in tags.lower():
|
|
391
|
+
results["template_example"] = {
|
|
392
|
+
"template_id": tid,
|
|
393
|
+
"description": desc,
|
|
394
|
+
"variables": tmpl.get("variables", {}),
|
|
395
|
+
"usage": (
|
|
396
|
+
"Use query_workflow_templates and then pass the resolved ops "
|
|
397
|
+
"to execute_workflow_transaction."
|
|
398
|
+
),
|
|
399
|
+
}
|
|
400
|
+
break
|
|
401
|
+
except Exception:
|
|
402
|
+
pass
|
|
403
|
+
|
|
404
|
+
if len(results) == 2: # only ok + intent — nothing found
|
|
405
|
+
results["ok"] = False
|
|
406
|
+
results["error"] = f"No examples found for intent: {intent!r}"
|
|
407
|
+
return results
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
async def _handle_query_node_parameters(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
411
|
+
node_path = str(args.get("node_path", "")).strip()
|
|
412
|
+
if not node_path:
|
|
413
|
+
return {"ok": False, "error": "node_path is required"}
|
|
414
|
+
try:
|
|
415
|
+
from src.utils.hou_bridge import get_bridge
|
|
416
|
+
bridge = get_bridge()
|
|
417
|
+
parms = bridge.get_parms(node_path)
|
|
418
|
+
names = sorted(parms.keys())
|
|
419
|
+
return {
|
|
420
|
+
"ok": True,
|
|
421
|
+
"node_path": node_path,
|
|
422
|
+
"parameters": parms,
|
|
423
|
+
"param_names": names,
|
|
424
|
+
"count": len(names),
|
|
425
|
+
}
|
|
426
|
+
except Exception as exc:
|
|
427
|
+
return {"ok": False, "error": str(exc)}
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
# ---------------------------------------------------------------------------
|
|
431
|
+
# Handlers — PLANNING group
|
|
432
|
+
# ---------------------------------------------------------------------------
|
|
433
|
+
|
|
434
|
+
def _parse_intent_tier128(prompt: str) -> Dict[str, Any]:
|
|
435
|
+
"""
|
|
436
|
+
Run the Tier 12.8 semantic intent parser on a prompt.
|
|
437
|
+
Returns a dict with environment, keywords, role, storytelling, lookdev, etc.
|
|
438
|
+
Never raises — returns {} on any import or parse error.
|
|
439
|
+
"""
|
|
440
|
+
try:
|
|
441
|
+
from src.runtime.assets.vector_search.intent_parser import (
|
|
442
|
+
get_intent_parser as _vec_get)
|
|
443
|
+
_p = _vec_get().parse(prompt)
|
|
444
|
+
return _p.to_dict() if hasattr(_p, "to_dict") else {}
|
|
445
|
+
except Exception:
|
|
446
|
+
return {}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
async def _handle_plan_scene(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
450
|
+
prompt = str(args.get("prompt", "")).strip()
|
|
451
|
+
if not prompt:
|
|
452
|
+
return {"ok": False, "error": "prompt is required"}
|
|
453
|
+
|
|
454
|
+
# ── Always run the Tier 12.8 semantic intent parser first ────────────────
|
|
455
|
+
# This gives structured environment / keywords / role even for scene-building
|
|
456
|
+
# intents that will be redirected, and serves as a fallback for lighting /
|
|
457
|
+
# structural prompts the legacy parser cannot handle.
|
|
458
|
+
t128 = _parse_intent_tier128(prompt)
|
|
459
|
+
|
|
460
|
+
# ── Intercept scene-building intents ─────────────────────────────────────
|
|
461
|
+
# Scene / environment assembly must go through build_scene_from_assets
|
|
462
|
+
# which imports real Megascans assets instead of primitive geometry.
|
|
463
|
+
# Return ok=True with the parsed intent so callers can inspect it and
|
|
464
|
+
# then call build_scene_from_assets directly.
|
|
465
|
+
if _is_scene_building_intent(prompt):
|
|
466
|
+
return {
|
|
467
|
+
"ok": True,
|
|
468
|
+
"redirect": "build_scene_from_assets",
|
|
469
|
+
"parsed_intent": t128,
|
|
470
|
+
"environment": t128.get("environment", ""),
|
|
471
|
+
"keywords": t128.get("keywords", []),
|
|
472
|
+
"role": t128.get("role", ""),
|
|
473
|
+
"storytelling": t128.get("storytelling", ""),
|
|
474
|
+
# Synthetic plan — allows review_execution to score this intent
|
|
475
|
+
"plan": {
|
|
476
|
+
"ok": True,
|
|
477
|
+
"intent": prompt,
|
|
478
|
+
"environment": t128.get("environment", ""),
|
|
479
|
+
"keywords": t128.get("keywords", []),
|
|
480
|
+
"operations": [],
|
|
481
|
+
"requires_approval": False,
|
|
482
|
+
"notes": "Scene-building intent — execute via build_scene_from_assets.",
|
|
483
|
+
},
|
|
484
|
+
"message": (
|
|
485
|
+
f"Scene-building intent detected and parsed. "
|
|
486
|
+
f"Call build_scene_from_assets(intent={prompt!r}, top_k=10, parent='/obj') "
|
|
487
|
+
f"to import real Megascans assets and run the full layout pipeline."
|
|
488
|
+
),
|
|
489
|
+
"action_required": (
|
|
490
|
+
f"build_scene_from_assets(intent={prompt!r}, top_k=10, parent='/obj')"
|
|
491
|
+
),
|
|
492
|
+
}
|
|
493
|
+
# ─────────────────────────────────────────────────────────────────────────
|
|
494
|
+
|
|
495
|
+
try:
|
|
496
|
+
from src.runtime.intent_parser import get_intent_parser
|
|
497
|
+
from src.runtime.contextual_reasoning import get_contextual_reasoner
|
|
498
|
+
from src.runtime.ai_planner import get_ai_planner
|
|
499
|
+
parsed = await get_intent_parser().parse(prompt)
|
|
500
|
+
|
|
501
|
+
# If the legacy parser returns a null/empty intent (e.g. for lighting or
|
|
502
|
+
# structural asset prompts it doesn't understand), enrich it with the
|
|
503
|
+
# Tier 12.8 result so the planner has something meaningful to work with.
|
|
504
|
+
if not parsed.get("intent") and t128:
|
|
505
|
+
parsed = dict(parsed)
|
|
506
|
+
parsed["intent"] = prompt
|
|
507
|
+
parsed["environment"] = t128.get("environment", parsed.get("environment", ""))
|
|
508
|
+
parsed["keywords"] = t128.get("keywords", parsed.get("keywords", []))
|
|
509
|
+
parsed["role"] = t128.get("role", "")
|
|
510
|
+
parsed["storytelling"]= t128.get("storytelling", "")
|
|
511
|
+
parsed["lookdev"] = t128.get("lookdev", "")
|
|
512
|
+
parsed["t128_parsed"] = t128
|
|
513
|
+
|
|
514
|
+
analysis = get_contextual_reasoner().analyze(
|
|
515
|
+
parsed.get("intent", prompt),
|
|
516
|
+
parsed.get("parameters", {}),
|
|
517
|
+
)
|
|
518
|
+
plan = await get_ai_planner().plan(parsed, analysis)
|
|
519
|
+
return {
|
|
520
|
+
"ok": plan.get("ok", False),
|
|
521
|
+
"plan": plan,
|
|
522
|
+
"parsed_intent": parsed,
|
|
523
|
+
"context_analysis": analysis,
|
|
524
|
+
"message": (
|
|
525
|
+
"Plan generated. Review plan.operations and plan.requires_approval "
|
|
526
|
+
"before calling execute_workflow_transaction."
|
|
527
|
+
),
|
|
528
|
+
}
|
|
529
|
+
except Exception as exc:
|
|
530
|
+
return {"ok": False, "error": str(exc)}
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
async def _handle_preview_execution(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
534
|
+
plan_json = str(args.get("plan_json", "")).strip()
|
|
535
|
+
ops_json = str(args.get("operations_json", "")).strip()
|
|
536
|
+
operations: List[Dict[str, Any]] = []
|
|
537
|
+
try:
|
|
538
|
+
if plan_json:
|
|
539
|
+
plan = json.loads(plan_json)
|
|
540
|
+
operations = plan.get("operations", [])
|
|
541
|
+
elif ops_json:
|
|
542
|
+
operations = json.loads(ops_json)
|
|
543
|
+
except json.JSONDecodeError as exc:
|
|
544
|
+
return {"ok": False, "error": f"Invalid JSON: {exc}"}
|
|
545
|
+
if not operations:
|
|
546
|
+
return {"ok": False, "error": "No operations to preview (provide plan_json or operations_json)"}
|
|
547
|
+
try:
|
|
548
|
+
from src.runtime.validation_engine import get_validation_engine
|
|
549
|
+
from src.runtime.resource_estimator import get_resource_estimator
|
|
550
|
+
from src.runtime.workflow_optimizer import get_workflow_optimizer
|
|
551
|
+
from src.runtime.predictive_execution import get_predictive_engine
|
|
552
|
+
from src.runtime.execution_explainer import get_execution_explainer
|
|
553
|
+
validation = await get_validation_engine().validate_operations(operations)
|
|
554
|
+
estimate = get_resource_estimator().estimate_transaction(operations)
|
|
555
|
+
optimizer = get_workflow_optimizer().analyze_plan(operations)
|
|
556
|
+
prediction = get_predictive_engine().predict(operations)
|
|
557
|
+
explanation = get_execution_explainer().explain_validation(validation)
|
|
558
|
+
safe = (
|
|
559
|
+
validation.get("valid", False)
|
|
560
|
+
and prediction.get("predicted_risk") in ("low", "medium")
|
|
561
|
+
)
|
|
562
|
+
return {
|
|
563
|
+
"ok": True,
|
|
564
|
+
"validation": validation,
|
|
565
|
+
"resource_estimate": estimate,
|
|
566
|
+
"optimization": optimizer,
|
|
567
|
+
"prediction": prediction,
|
|
568
|
+
"explanation": explanation,
|
|
569
|
+
"op_count": len(operations),
|
|
570
|
+
"safe_to_execute": safe,
|
|
571
|
+
"message": (
|
|
572
|
+
"Preview complete. Check safe_to_execute and validation.warnings "
|
|
573
|
+
"before calling execute_workflow_transaction."
|
|
574
|
+
),
|
|
575
|
+
}
|
|
576
|
+
except Exception as exc:
|
|
577
|
+
return {"ok": False, "error": str(exc)}
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
async def _handle_validate_execution_plan(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
581
|
+
ops_json = str(args.get("operations_json", "")).strip()
|
|
582
|
+
if not ops_json:
|
|
583
|
+
return {"ok": False, "error": "operations_json is required"}
|
|
584
|
+
try:
|
|
585
|
+
operations = json.loads(ops_json)
|
|
586
|
+
except json.JSONDecodeError as exc:
|
|
587
|
+
return {"ok": False, "error": f"Invalid JSON: {exc}"}
|
|
588
|
+
try:
|
|
589
|
+
from src.runtime.validation_engine import get_validation_engine
|
|
590
|
+
from src.runtime.plan_validator import get_plan_validator
|
|
591
|
+
validation = await get_validation_engine().validate_operations(operations)
|
|
592
|
+
plan_result = await get_plan_validator().validate(
|
|
593
|
+
{"operations": operations, "ok": validation.get("valid", False)}
|
|
594
|
+
)
|
|
595
|
+
return {
|
|
596
|
+
"ok": True,
|
|
597
|
+
"validation": validation,
|
|
598
|
+
"plan_validation": plan_result,
|
|
599
|
+
"valid": validation.get("valid") and plan_result.get("valid"),
|
|
600
|
+
"errors": (validation.get("errors", []) + plan_result.get("errors", [])),
|
|
601
|
+
"warnings": (validation.get("warnings", []) + plan_result.get("warnings", [])),
|
|
602
|
+
"risk_level": plan_result.get("risk_level", validation.get("risk_level", "low")),
|
|
603
|
+
}
|
|
604
|
+
except Exception as exc:
|
|
605
|
+
return {"ok": False, "error": str(exc)}
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
# ---------------------------------------------------------------------------
|
|
609
|
+
# Handlers — EXECUTION group
|
|
610
|
+
# ---------------------------------------------------------------------------
|
|
611
|
+
|
|
612
|
+
async def _handle_execute_workflow_transaction(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
613
|
+
plan_json = str(args.get("plan_json", "")).strip()
|
|
614
|
+
intent = str(args.get("intent", "")).strip()
|
|
615
|
+
params_json = str(args.get("parameters_json", "{}")).strip()
|
|
616
|
+
dry_run = bool(args.get("dry_run", False))
|
|
617
|
+
approver = str(args.get("approver", "")).strip()
|
|
618
|
+
|
|
619
|
+
# --- Named-intent path via SemanticExecutor ---
|
|
620
|
+
if intent and not plan_json:
|
|
621
|
+
# ── Intercept: redirect scene-building intents to build_scene_from_assets
|
|
622
|
+
if _is_scene_building_intent(intent):
|
|
623
|
+
return await _handle_build_scene_from_assets({
|
|
624
|
+
"intent": intent, "top_k": 10, "parent": "/obj",
|
|
625
|
+
"quality": "medium", "spacing": 3.0, "my_assets_only": False,
|
|
626
|
+
"allow_download": True,
|
|
627
|
+
})
|
|
628
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
629
|
+
try:
|
|
630
|
+
parameters = json.loads(params_json) if params_json else {}
|
|
631
|
+
except json.JSONDecodeError as exc:
|
|
632
|
+
return {"ok": False, "error": f"Invalid parameters_json: {exc}"}
|
|
633
|
+
try:
|
|
634
|
+
from src.runtime.semantic_execution import get_semantic_executor
|
|
635
|
+
result = await get_semantic_executor().execute(
|
|
636
|
+
intent, parameters,
|
|
637
|
+
dry_run=dry_run, auto_commit=True, rollback_on_error=True,
|
|
638
|
+
)
|
|
639
|
+
return {
|
|
640
|
+
"ok": result.get("ok", False),
|
|
641
|
+
"execution_result": result,
|
|
642
|
+
"message": "Execution complete. Call review_execution to verify.",
|
|
643
|
+
}
|
|
644
|
+
except Exception as exc:
|
|
645
|
+
return {"ok": False, "error": str(exc)}
|
|
646
|
+
|
|
647
|
+
# --- Plan-dict path ---
|
|
648
|
+
try:
|
|
649
|
+
plan = json.loads(plan_json) if plan_json else {}
|
|
650
|
+
operations = plan.get("operations", [])
|
|
651
|
+
except json.JSONDecodeError as exc:
|
|
652
|
+
return {"ok": False, "error": f"Invalid plan_json: {exc}"}
|
|
653
|
+
|
|
654
|
+
if not operations:
|
|
655
|
+
return {"ok": False, "error": "No operations to execute (provide plan_json or intent)"}
|
|
656
|
+
|
|
657
|
+
# ── Intercept: reject primitive-only scene plans ─────────────────────────
|
|
658
|
+
plan_intent = str(plan.get("intent", intent or "")).strip()
|
|
659
|
+
if _is_scene_building_intent(plan_intent) and _plan_is_primitive_only(operations):
|
|
660
|
+
return await _handle_build_scene_from_assets({
|
|
661
|
+
"intent": plan_intent, "top_k": 10, "parent": "/obj",
|
|
662
|
+
"quality": "medium", "spacing": 3.0, "my_assets_only": False,
|
|
663
|
+
"allow_download": True,
|
|
664
|
+
})
|
|
665
|
+
# ─────────────────────────────────────────────────────────────────────────
|
|
666
|
+
|
|
667
|
+
if not plan.get("ok", True):
|
|
668
|
+
return {
|
|
669
|
+
"ok": False,
|
|
670
|
+
"error": "Plan has ok=False — fix plan errors before executing",
|
|
671
|
+
"plan_errors": plan.get("errors", []),
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if plan.get("requires_approval") and not approver:
|
|
675
|
+
return {
|
|
676
|
+
"ok": False,
|
|
677
|
+
"status": "pending_approval",
|
|
678
|
+
"error": "Plan requires approval. Provide an 'approver' name to authorize.",
|
|
679
|
+
"requires_approval": True,
|
|
680
|
+
"approval_reasons": plan.get("approval_reasons", []),
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
# Execute through the transaction system
|
|
684
|
+
try:
|
|
685
|
+
from src.runtime.transaction_manager import get_transaction_manager
|
|
686
|
+
from src.runtime import houdini_runtime
|
|
687
|
+
|
|
688
|
+
txn_name = plan.get("intent", intent or "mcp_execution")
|
|
689
|
+
txn_id = await get_transaction_manager().begin_transaction(
|
|
690
|
+
txn_name, metadata={"via": "mcp", "approver": approver or None}
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
if dry_run:
|
|
694
|
+
from src.runtime.validation_engine import get_validation_engine
|
|
695
|
+
validation = await get_validation_engine().validate_operations(operations)
|
|
696
|
+
await get_transaction_manager().mark_failed(txn_id, "dry_run — no execution")
|
|
697
|
+
return {
|
|
698
|
+
"ok": True,
|
|
699
|
+
"status": "dry_run",
|
|
700
|
+
"validation": validation,
|
|
701
|
+
"op_count": len(operations),
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
created_paths: List[str] = []
|
|
705
|
+
errors: List[str] = []
|
|
706
|
+
operations_executed: List[Dict[str, Any]] = []
|
|
707
|
+
|
|
708
|
+
for op in operations:
|
|
709
|
+
op_result = await houdini_runtime.execute_operation(op)
|
|
710
|
+
operations_executed.append(op_result)
|
|
711
|
+
await get_transaction_manager().record_operation(txn_id, op_result)
|
|
712
|
+
if op_result.get("status") == "failed":
|
|
713
|
+
errors.append(op_result.get("error", "unknown"))
|
|
714
|
+
await get_transaction_manager().rollback_transaction(txn_id)
|
|
715
|
+
return {
|
|
716
|
+
"ok": False,
|
|
717
|
+
"status": "rolled_back",
|
|
718
|
+
"errors": errors,
|
|
719
|
+
"created_paths": created_paths,
|
|
720
|
+
"transaction_id": txn_id,
|
|
721
|
+
"operations_executed": operations_executed,
|
|
722
|
+
}
|
|
723
|
+
path = (op_result.get("result") or {}).get("path")
|
|
724
|
+
if path:
|
|
725
|
+
created_paths.append(path)
|
|
726
|
+
|
|
727
|
+
await get_transaction_manager().commit_transaction(txn_id)
|
|
728
|
+
return {
|
|
729
|
+
"ok": True,
|
|
730
|
+
"status": "committed",
|
|
731
|
+
"transaction_id": txn_id,
|
|
732
|
+
"created_paths": created_paths,
|
|
733
|
+
"op_count": len(operations),
|
|
734
|
+
"operations_executed": operations_executed,
|
|
735
|
+
"message": "Execution committed. Call review_execution to verify the result.",
|
|
736
|
+
}
|
|
737
|
+
except Exception as exc:
|
|
738
|
+
return {"ok": False, "error": str(exc)}
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
async def _handle_check_vibrante_config(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
742
|
+
"""
|
|
743
|
+
Report the current Vibrante credential / path configuration and tell the
|
|
744
|
+
user exactly which file to edit when something is missing.
|
|
745
|
+
|
|
746
|
+
Priority order for reading credentials:
|
|
747
|
+
1. Live Houdini session (bridge.run_code) — checked first, always
|
|
748
|
+
2. vibrante_node.json file sources (packages dir → local.json → source copy)
|
|
749
|
+
|
|
750
|
+
This tool should be called BEFORE any acquisition tool when the agent
|
|
751
|
+
suspects credentials may be missing.
|
|
752
|
+
"""
|
|
753
|
+
import os
|
|
754
|
+
from pathlib import Path
|
|
755
|
+
from src.utils.vibrante_config import (
|
|
756
|
+
apply_vibrante_config,
|
|
757
|
+
read_from_houdini_session,
|
|
758
|
+
find_vibrante_node_json, read_vibrante_config, _houdini_pkg_dirs,
|
|
759
|
+
_VIBRANTE_ENV_VARS,
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
# Step 1: read from live Houdini session first, then file fallback
|
|
763
|
+
apply_vibrante_config(force=True)
|
|
764
|
+
|
|
765
|
+
# Report whether Houdini session was reachable
|
|
766
|
+
houdini_values = read_from_houdini_session()
|
|
767
|
+
houdini_reachable = bool(houdini_values)
|
|
768
|
+
|
|
769
|
+
# Locate the config file being used as fallback
|
|
770
|
+
config_file = find_vibrante_node_json()
|
|
771
|
+
|
|
772
|
+
# Discover Houdini packages paths
|
|
773
|
+
houdini_pkg_paths: List[Path] = []
|
|
774
|
+
_houdini_pkg_dirs(houdini_pkg_paths)
|
|
775
|
+
installed_pkg = next((p for p in houdini_pkg_paths if p.exists()), None)
|
|
776
|
+
canonical_pkg = houdini_pkg_paths[0] if houdini_pkg_paths else None
|
|
777
|
+
|
|
778
|
+
# File values (for reporting what the file contains)
|
|
779
|
+
file_values = read_vibrante_config(config_file) if config_file else {}
|
|
780
|
+
|
|
781
|
+
# Build status after apply_vibrante_config has already run
|
|
782
|
+
var_status: Dict[str, str] = {}
|
|
783
|
+
for var in _VIBRANTE_ENV_VARS:
|
|
784
|
+
if os.environ.get(var, "").strip():
|
|
785
|
+
# Determine which source provided it
|
|
786
|
+
if houdini_values.get(var, "").strip():
|
|
787
|
+
var_status[var] = "set_from_houdini_session"
|
|
788
|
+
else:
|
|
789
|
+
var_status[var] = "set_in_env"
|
|
790
|
+
elif file_values.get(var, "").strip() and not file_values[var].startswith("<"):
|
|
791
|
+
var_status[var] = "set_in_file"
|
|
792
|
+
else:
|
|
793
|
+
var_status[var] = "missing"
|
|
794
|
+
|
|
795
|
+
missing = [v for v, s in var_status.items() if s == "missing"]
|
|
796
|
+
acquisition_vars = [
|
|
797
|
+
"VIBRANTE_MEGASCANS_LIBRARY",
|
|
798
|
+
"VIBRANTE_MEGASCANS_TOKEN",
|
|
799
|
+
"VIBRANTE_ASSET_CACHE",
|
|
800
|
+
]
|
|
801
|
+
missing_critical = [v for v in acquisition_vars if var_status.get(v) == "missing"]
|
|
802
|
+
|
|
803
|
+
# Build the actionable edit instruction
|
|
804
|
+
edit_target = installed_pkg or config_file or canonical_pkg
|
|
805
|
+
if missing_critical:
|
|
806
|
+
example_lines = "\n".join(
|
|
807
|
+
f' {{"{v}": "your_value_here"}}' for v in missing_critical
|
|
808
|
+
)
|
|
809
|
+
if houdini_reachable:
|
|
810
|
+
how_to_fix = (
|
|
811
|
+
"Houdini is running but these vars are not set in its environment. "
|
|
812
|
+
f"Open this file in Houdini's packages directory:\n {edit_target}\n\n"
|
|
813
|
+
f"Add or fill in these entries in the 'env' array:\n{example_lines}\n\n"
|
|
814
|
+
"Restart Houdini after editing so the package reloads. "
|
|
815
|
+
"The Vibrante runtime will then read them from the live session automatically.\n\n"
|
|
816
|
+
"IMPORTANT: Do NOT use $env: or SetEnvironmentVariable."
|
|
817
|
+
)
|
|
818
|
+
else:
|
|
819
|
+
how_to_fix = (
|
|
820
|
+
"Houdini session is not reachable. Editing the config file directly:\n\n"
|
|
821
|
+
f"Open this file in your editor:\n {edit_target}\n\n"
|
|
822
|
+
f"Add or fill in these entries in the 'env' array:\n{example_lines}\n\n"
|
|
823
|
+
"Save the file. The next acquisition call reads it automatically — "
|
|
824
|
+
"no restart, no shell commands needed.\n\n"
|
|
825
|
+
"IMPORTANT: Do NOT use $env: or SetEnvironmentVariable — "
|
|
826
|
+
"edit vibrante_node.json directly."
|
|
827
|
+
)
|
|
828
|
+
if installed_pkg is None and canonical_pkg:
|
|
829
|
+
how_to_fix += (
|
|
830
|
+
f"\n\nNOTE: {canonical_pkg} does not exist yet. "
|
|
831
|
+
"Copy plugins/houdini/vibrante_node.json there and fill in your values "
|
|
832
|
+
f"(or edit the file currently in use: {config_file})."
|
|
833
|
+
)
|
|
834
|
+
else:
|
|
835
|
+
src = "Houdini session" if houdini_reachable else "config file"
|
|
836
|
+
how_to_fix = f"All acquisition credentials are configured (read from {src}). No action needed."
|
|
837
|
+
|
|
838
|
+
# Build bridge status message separately so it's always present
|
|
839
|
+
if houdini_reachable:
|
|
840
|
+
bridge_status = "Connected (port 18811)."
|
|
841
|
+
else:
|
|
842
|
+
pkg_note = (
|
|
843
|
+
f"Package already at: {installed_pkg}"
|
|
844
|
+
if installed_pkg
|
|
845
|
+
else (
|
|
846
|
+
f"Package not yet installed -- copy "
|
|
847
|
+
f"plugins/houdini/vibrante_node.json to "
|
|
848
|
+
f"{canonical_pkg or '~/Documents/houdiniXX.Y/packages/vibrante_node.json'} "
|
|
849
|
+
f"and restart Houdini first."
|
|
850
|
+
)
|
|
851
|
+
)
|
|
852
|
+
bridge_status = (
|
|
853
|
+
"NOT connected (port 18811 refused). "
|
|
854
|
+
"In Houdini: open the Vibrante-Node menu -> Launch Vibrante. "
|
|
855
|
+
"That starts the bridge server so credentials are read directly from the Houdini session. "
|
|
856
|
+
f"{pkg_note}"
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
return {
|
|
860
|
+
"ok": True,
|
|
861
|
+
"houdini_session_reachable": houdini_reachable,
|
|
862
|
+
"bridge_status": bridge_status,
|
|
863
|
+
"houdini_session_vars": sorted(houdini_values.keys()),
|
|
864
|
+
"config_file_used": str(config_file) if config_file else None,
|
|
865
|
+
"canonical_pkg_path": str(canonical_pkg) if canonical_pkg else None,
|
|
866
|
+
"installed_in_houdini_packages": installed_pkg is not None,
|
|
867
|
+
"var_status": var_status,
|
|
868
|
+
"missing_critical": missing_critical,
|
|
869
|
+
"all_configured": len(missing_critical) == 0,
|
|
870
|
+
"how_to_fix": how_to_fix,
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
def _compute_structural_transform(
|
|
875
|
+
role: str,
|
|
876
|
+
room_half_width: float,
|
|
877
|
+
ceiling_y: float,
|
|
878
|
+
ground_ty: float,
|
|
879
|
+
) -> tuple:
|
|
880
|
+
"""
|
|
881
|
+
Returns (tx, ty, tz, ry) for a structural asset placed per its classified role.
|
|
882
|
+
ground_ty — half-height of the asset (makes bottom flush with y=0 when ty=ground_ty).
|
|
883
|
+
ceiling_y — estimated room ceiling height in metres.
|
|
884
|
+
"""
|
|
885
|
+
rh = room_half_width
|
|
886
|
+
if role in ("beam", "support_beam"):
|
|
887
|
+
return 0.0, max(ceiling_y - ground_ty, 1.5), 0.0, 0.0
|
|
888
|
+
if role == "column":
|
|
889
|
+
return rh - 0.5, ceiling_y / 2.0, rh - 0.5, 0.0
|
|
890
|
+
if role == "floor_piece":
|
|
891
|
+
return 0.0, ground_ty, 0.0, 0.0
|
|
892
|
+
if role == "ceiling_piece":
|
|
893
|
+
return 0.0, ceiling_y - ground_ty, 0.0, 0.0
|
|
894
|
+
if role in ("doorway", "door_frame"):
|
|
895
|
+
return 0.0, ground_ty, -(rh - 0.05), 0.0
|
|
896
|
+
if role in ("window", "window_frame"):
|
|
897
|
+
return rh - 0.05, max(1.2, ground_ty), 0.0, 90.0
|
|
898
|
+
if role == "archway":
|
|
899
|
+
return 0.0, ground_ty, -(rh - 0.05), 0.0
|
|
900
|
+
if role in ("wall", "wall_segment"):
|
|
901
|
+
return 0.0, ground_ty, -(rh - 0.1), 0.0
|
|
902
|
+
if role == "fireplace":
|
|
903
|
+
return 0.0, ground_ty, rh - 0.3, 180.0
|
|
904
|
+
if role in ("stair", "railing"):
|
|
905
|
+
return -(rh - 1.0), ground_ty, rh - 1.0, 0.0
|
|
906
|
+
# architectural_module / structural_unknown — south perimeter
|
|
907
|
+
return 0.0, ground_ty, -(rh - 0.2), 0.0
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
async def _handle_build_scene_from_assets(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
911
|
+
"""
|
|
912
|
+
Full intent-to-scene pipeline as an MCP tool.
|
|
913
|
+
|
|
914
|
+
Step 1 — Parse the intent into keywords (+ environment detection).
|
|
915
|
+
Step 2 — Search the local semantic catalog for matching Megascans assets.
|
|
916
|
+
Step 3 — If catalog is empty, search the user's Megascans library via the
|
|
917
|
+
official API (view=myscans), then download + extract + mirror to
|
|
918
|
+
VIBRANTE_MEGASCANS_LIBRARY automatically.
|
|
919
|
+
Step 4 — Import each asset into Houdini via the bridge (geo node + SOP).
|
|
920
|
+
Step 5 — Build AssetMetrics for every imported asset (PHASE 1).
|
|
921
|
+
Step 5.5 — Structural routing: split assets into structural/furniture (PHASE 1.5).
|
|
922
|
+
Step 6 — Semantic layout via SemanticLayoutEngine (furniture only, PHASE 2).
|
|
923
|
+
Step 7 — Layout realization with bbox_half injection (PHASE 3).
|
|
924
|
+
Step 8 — Collision resolution using real geometry (PHASE 4).
|
|
925
|
+
Step 9 — Scene constraint solving (PHASE 5).
|
|
926
|
+
Step 10 — Apply final transforms to Houdini (PHASE 6).
|
|
927
|
+
Step 10.5 — Apply structural placement transforms (PHASE 6b).
|
|
928
|
+
Step 11 — Emit validation report (PHASE 7).
|
|
929
|
+
|
|
930
|
+
NEVER creates box / tube / sphere / grid primitives to represent real-world
|
|
931
|
+
objects. If no assets can be found or downloaded the tool returns ok=False
|
|
932
|
+
with a clear advisory — it does NOT fall back to primitives.
|
|
933
|
+
"""
|
|
934
|
+
intent = str(args.get("intent", "")).strip()
|
|
935
|
+
top_k = int(args.get("top_k", 10))
|
|
936
|
+
parent = str(args.get("parent", "/obj")).strip() or "/obj"
|
|
937
|
+
quality = str(args.get("quality", "medium")).strip()
|
|
938
|
+
spacing = float(args.get("spacing", 3.0))
|
|
939
|
+
my_assets_only = bool(args.get("my_assets_only", False))
|
|
940
|
+
allow_download = bool(args.get("allow_download", True))
|
|
941
|
+
force_online = bool(args.get("force_online", False))
|
|
942
|
+
environment = str(args.get("environment", "")).strip()
|
|
943
|
+
room_half_width = float(args.get("room_half_width", 5.0))
|
|
944
|
+
|
|
945
|
+
if not intent:
|
|
946
|
+
return {"ok": False, "error": "intent is required"}
|
|
947
|
+
|
|
948
|
+
import os
|
|
949
|
+
keywords: List[str] = []
|
|
950
|
+
assets: List[Dict[str, Any]] = []
|
|
951
|
+
source = ""
|
|
952
|
+
|
|
953
|
+
# ── Step 1: keyword extraction + environment detection ──────────────────
|
|
954
|
+
try:
|
|
955
|
+
from src.runtime.assets.vector_search.intent_parser import get_intent_parser
|
|
956
|
+
parsed = get_intent_parser().parse(intent)
|
|
957
|
+
keywords = list(parsed.keywords or [])
|
|
958
|
+
if not environment:
|
|
959
|
+
environment = str(parsed.environment or "").strip()
|
|
960
|
+
except Exception:
|
|
961
|
+
keywords = [w for w in intent.lower().split() if len(w) > 3]
|
|
962
|
+
|
|
963
|
+
# ── Step 2: local catalog search ────────────────────────────────────────
|
|
964
|
+
try:
|
|
965
|
+
from src.runtime.assets.vector_search import get_retrieval_pipeline
|
|
966
|
+
result = get_retrieval_pipeline().retrieve(intent, top_k=top_k)
|
|
967
|
+
assets = [a for a in (result.assets or [])
|
|
968
|
+
if isinstance(a, dict) and a.get("asset_id")]
|
|
969
|
+
if assets:
|
|
970
|
+
source = "catalog"
|
|
971
|
+
except Exception:
|
|
972
|
+
pass
|
|
973
|
+
|
|
974
|
+
# ── Step 2.5: direct assetsData.json scan (local Megascans library) ────────
|
|
975
|
+
if not assets:
|
|
976
|
+
try:
|
|
977
|
+
import glob as _glob
|
|
978
|
+
_ms_lib = os.environ.get("VIBRANTE_MEGASCANS_LIBRARY", "").strip()
|
|
979
|
+
_ads_path = os.path.join(_ms_lib, "assetsData.json") if _ms_lib else ""
|
|
980
|
+
if _ads_path and os.path.isfile(_ads_path):
|
|
981
|
+
with open(_ads_path, "r", encoding="utf-8", errors="replace") as _f:
|
|
982
|
+
_catalog = json.load(_f)
|
|
983
|
+
_query_words = set(
|
|
984
|
+
w.lower() for kw in (keywords or intent.lower().split())
|
|
985
|
+
for w in kw.lower().split() if len(w) > 2
|
|
986
|
+
)
|
|
987
|
+
_scored: list = []
|
|
988
|
+
for _entry in (_catalog if isinstance(_catalog, list) else []):
|
|
989
|
+
_ss = str(_entry.get("searchStr", "")).lower()
|
|
990
|
+
_name = str(_entry.get("semanticTags", {}).get("name", "")).lower()
|
|
991
|
+
_tags = " ".join(str(t) for t in _entry.get("tags", [])).lower()
|
|
992
|
+
_cats = " ".join(str(c) for c in _entry.get("categories", [])).lower()
|
|
993
|
+
_haystack = f"{_ss} {_name} {_tags} {_cats}"
|
|
994
|
+
_score = sum(1 for w in _query_words if w in _haystack)
|
|
995
|
+
if _score > 0:
|
|
996
|
+
_aid = str(_entry.get("id") or _entry.get("asset") or "")
|
|
997
|
+
_jp = _entry.get("jsonPath", [])
|
|
998
|
+
_folder = os.path.join(_ms_lib, *_jp[:-1]) if len(_jp) >= 2 else ""
|
|
999
|
+
_fbx_files = sorted(
|
|
1000
|
+
_glob.glob(os.path.join(_folder, "*_LOD3.fbx"))
|
|
1001
|
+
+ _glob.glob(os.path.join(_folder, "*_lod3.fbx"))
|
|
1002
|
+
) if _folder else []
|
|
1003
|
+
_fbx = _fbx_files[0] if _fbx_files else ""
|
|
1004
|
+
if _aid and _fbx and os.path.isfile(_fbx):
|
|
1005
|
+
_scored.append((_score, {
|
|
1006
|
+
"asset_id": _aid,
|
|
1007
|
+
"name": str(_entry.get("semanticTags", {}).get("name", _aid)),
|
|
1008
|
+
"local_path": _fbx,
|
|
1009
|
+
"provider": "megascans",
|
|
1010
|
+
"source": "local_library",
|
|
1011
|
+
}))
|
|
1012
|
+
_scored.sort(key=lambda x: x[0], reverse=True)
|
|
1013
|
+
assets = [a for _, a in _scored[:top_k]]
|
|
1014
|
+
if assets:
|
|
1015
|
+
source = "local_library"
|
|
1016
|
+
except Exception:
|
|
1017
|
+
pass
|
|
1018
|
+
|
|
1019
|
+
# ── Step 3a: Quixel Bridge (localhost:28241) — no auth needed ───────────
|
|
1020
|
+
# Run if: no local assets yet, or force_online, or local count < top_k and allow_download.
|
|
1021
|
+
_needs_online = not assets or force_online or (allow_download and len(assets) < top_k)
|
|
1022
|
+
if _needs_online:
|
|
1023
|
+
try:
|
|
1024
|
+
from src.runtime.assets.acquisition_online.quixel_bridge_client import (
|
|
1025
|
+
get_quixel_bridge_client)
|
|
1026
|
+
bridge_client = get_quixel_bridge_client()
|
|
1027
|
+
if bridge_client.is_bridge_running():
|
|
1028
|
+
query = " ".join(keywords[:6]) if keywords else intent
|
|
1029
|
+
_existing_ids = {a.get("asset_id") for a in assets}
|
|
1030
|
+
records = bridge_client.search_assets(query, limit=top_k)
|
|
1031
|
+
new_records = [r for r in records
|
|
1032
|
+
if (r.get("id") or r.get("asset_id"))
|
|
1033
|
+
and r.get("asset_id") not in _existing_ids]
|
|
1034
|
+
if new_records:
|
|
1035
|
+
assets = (assets + new_records)[: top_k]
|
|
1036
|
+
source = source or "quixel_bridge"
|
|
1037
|
+
except Exception:
|
|
1038
|
+
pass
|
|
1039
|
+
|
|
1040
|
+
# ── Step 3b: Fab public search API (no auth required) ────────────────────
|
|
1041
|
+
# After the Quixel → Fab migration (2024) the old megascans.se/v1 REST API
|
|
1042
|
+
# and accounts.quixel.se credential exchange were shut down.
|
|
1043
|
+
# The Fab public search (www.fab.com/i/listings/search) works WITHOUT auth.
|
|
1044
|
+
# Auth is now only needed for actual asset DOWNLOADS.
|
|
1045
|
+
_needs_online = not assets or force_online or (allow_download and len(assets) < top_k)
|
|
1046
|
+
if _needs_online:
|
|
1047
|
+
try:
|
|
1048
|
+
from src.runtime.assets.acquisition_online import get_megascans_search
|
|
1049
|
+
query = " ".join(keywords[:8]) if keywords else intent
|
|
1050
|
+
searcher = get_megascans_search()
|
|
1051
|
+
_existing_ids = {a.get("asset_id") for a in assets}
|
|
1052
|
+
records = searcher.search_assets(query, limit=top_k)
|
|
1053
|
+
new_api = [r.to_dict() for r in records
|
|
1054
|
+
if r.asset_id and r.asset_id not in _existing_ids]
|
|
1055
|
+
if new_api:
|
|
1056
|
+
assets = (assets + new_api)[: top_k]
|
|
1057
|
+
source = source or "fab_api"
|
|
1058
|
+
except Exception:
|
|
1059
|
+
pass # Fab search failure is non-fatal — proceed with local assets
|
|
1060
|
+
|
|
1061
|
+
if not assets:
|
|
1062
|
+
_lib_path = os.environ.get('VIBRANTE_MEGASCANS_LIBRARY', 'not set')
|
|
1063
|
+
_fab_receiver_port = 31337
|
|
1064
|
+
try:
|
|
1065
|
+
from src.runtime.assets.acquisition_online.fab_socket_receiver import _read_socket_export_port
|
|
1066
|
+
_fab_receiver_port = _read_socket_export_port()
|
|
1067
|
+
except Exception:
|
|
1068
|
+
pass
|
|
1069
|
+
config_status = await _handle_check_vibrante_config({})
|
|
1070
|
+
return {
|
|
1071
|
+
"ok": False,
|
|
1072
|
+
"error": f"No assets found for environment '{environment or intent}'.",
|
|
1073
|
+
"configuration_required": True,
|
|
1074
|
+
"how_to_fix": (
|
|
1075
|
+
"No assets are in the local library. There are three ways to get assets:\n\n"
|
|
1076
|
+
"OPTION 1 — Fab socket push (recommended, works instantly):\n"
|
|
1077
|
+
" 1. Start the Vibrante MCP server (it listens on port "
|
|
1078
|
+
f"{_fab_receiver_port} for Fab push).\n"
|
|
1079
|
+
" 2. Open Unreal Engine (with the built-in Fab panel) or the Fab desktop app.\n"
|
|
1080
|
+
" 3. Go to My Library → find the asset → click Export / Send to DCC.\n"
|
|
1081
|
+
" 4. Choose format: 'houdini', 'fbx', or 'obj'.\n"
|
|
1082
|
+
" 5. Call build_scene_from_assets again — Vibrante will pick up the pushed asset.\n\n"
|
|
1083
|
+
"OPTION 2 — Manual download:\n"
|
|
1084
|
+
" 1. Log in to fab.com → My Library → download asset as FBX/OBJ.\n"
|
|
1085
|
+
f" 2. Copy the downloaded folder to: {_lib_path}\n"
|
|
1086
|
+
" 3. Call build_scene_from_assets again — local scanner picks it up.\n\n"
|
|
1087
|
+
"OPTION 3 — Fab browser token (for asset metadata / download URLs):\n"
|
|
1088
|
+
" 1. Open fab.com in browser while logged in.\n"
|
|
1089
|
+
" 2. Press F12 → Network tab → filter by XHR → navigate to any page.\n"
|
|
1090
|
+
" 3. Find a request to fab.com → copy the 'Authorization: Bearer …' value.\n"
|
|
1091
|
+
' 4. Set it in vibrante_node.json: {"VIBRANTE_MEGASCANS_TOKEN": "eyJ..."}\n\n'
|
|
1092
|
+
"NOTE: The old Quixel Bridge / megascans.se API was shut down in 2024 "
|
|
1093
|
+
"after the Fab migration. App-credential exchange no longer works."
|
|
1094
|
+
),
|
|
1095
|
+
"sources_tried": ["local_catalog", "fab_library_scan", "quixel_bridge", "fab_api"],
|
|
1096
|
+
"fab_receiver_port": _fab_receiver_port,
|
|
1097
|
+
"library_path": _lib_path,
|
|
1098
|
+
"keywords": keywords,
|
|
1099
|
+
"config_status": config_status,
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
# ── Step 4: fetch (cache-first → API download) ──────────────────────────
|
|
1103
|
+
# Assets from local_library source already have a resolved local_path — skip fetcher.
|
|
1104
|
+
try:
|
|
1105
|
+
if source == "local_library" and all(a.get("local_path") for a in assets):
|
|
1106
|
+
from src.runtime.assets.acquisition_online.asset_fetcher import FetchResult
|
|
1107
|
+
fetch_results = [
|
|
1108
|
+
FetchResult(ok=True, asset_id=a["asset_id"], provider="megascans",
|
|
1109
|
+
local_path=a["local_path"], source="local_library")
|
|
1110
|
+
for a in assets
|
|
1111
|
+
]
|
|
1112
|
+
else:
|
|
1113
|
+
from src.runtime.assets.acquisition_online import get_asset_fetcher
|
|
1114
|
+
fetch_results = get_asset_fetcher().fetch_assets(assets, quality=quality)
|
|
1115
|
+
except Exception as exc:
|
|
1116
|
+
return {"ok": False, "error": f"Asset fetch failed: {exc}"}
|
|
1117
|
+
|
|
1118
|
+
# ── Step 5: import into Houdini ─────────────────────────────────────────
|
|
1119
|
+
try:
|
|
1120
|
+
from src.utils.hou_bridge import get_bridge
|
|
1121
|
+
bridge = get_bridge()
|
|
1122
|
+
except Exception as exc:
|
|
1123
|
+
return {"ok": False, "error": f"Houdini bridge not available: {exc}"}
|
|
1124
|
+
|
|
1125
|
+
def _sop_info(lp: str):
|
|
1126
|
+
ext = lp.rsplit(".", 1)[-1].lower()
|
|
1127
|
+
if ext in ("usd", "usda", "usdc", "usdz"):
|
|
1128
|
+
return "usdimport", "filepath"
|
|
1129
|
+
if ext == "abc":
|
|
1130
|
+
return "alembic", "fileName"
|
|
1131
|
+
return "file", "file"
|
|
1132
|
+
|
|
1133
|
+
def _get_bbox(sop_path: str) -> Dict[str, Any]:
|
|
1134
|
+
"""Return bounding box of a cooked SOP. Returns {} if not available."""
|
|
1135
|
+
try:
|
|
1136
|
+
r = bridge.run_code(
|
|
1137
|
+
"import hou\n"
|
|
1138
|
+
f"_n = hou.node({sop_path!r})\n"
|
|
1139
|
+
"_g = _n.geometry() if _n else None\n"
|
|
1140
|
+
"_bb = _g.boundingBox() if (_g and len(_g.points()) > 0) else None\n"
|
|
1141
|
+
"result = ({'size': list(_bb.sizevec()), 'center': list(_bb.center()), "
|
|
1142
|
+
"'min': list(_bb.minvec())} if _bb else None)"
|
|
1143
|
+
)
|
|
1144
|
+
return r.get("result") or {}
|
|
1145
|
+
except Exception:
|
|
1146
|
+
return {}
|
|
1147
|
+
|
|
1148
|
+
def _import_scale(info: Dict[str, Any], bbox: Dict[str, Any]) -> float:
|
|
1149
|
+
"""
|
|
1150
|
+
Return the correct uniform import scale (sx = sy = sz) for this asset.
|
|
1151
|
+
|
|
1152
|
+
Megascans FBX are exported in centimeters → scale = 0.01 (preserves
|
|
1153
|
+
real-world dimensions without any size normalisation).
|
|
1154
|
+
|
|
1155
|
+
This function NEVER normalises assets to a target height. A chair that
|
|
1156
|
+
is 84 cm tall in real life must arrive as 0.84 m in Houdini.
|
|
1157
|
+
"""
|
|
1158
|
+
try:
|
|
1159
|
+
from src.runtime.assets.real_world_scale import get_real_world_scale_resolver
|
|
1160
|
+
return get_real_world_scale_resolver().resolve_import_scale(info)
|
|
1161
|
+
except Exception:
|
|
1162
|
+
# Heuristic fallback: large Houdini-unit bbox → assume cm-space
|
|
1163
|
+
size = bbox.get("size") or []
|
|
1164
|
+
if size and len(size) >= 3 and max(size) > 10.0:
|
|
1165
|
+
return 0.01
|
|
1166
|
+
return 0.01 # default: Megascans cm-space
|
|
1167
|
+
|
|
1168
|
+
def _ground_offset(bbox: Dict[str, Any], scale: float) -> float:
|
|
1169
|
+
"""Return ty so the object bottom sits at y=0."""
|
|
1170
|
+
mn = bbox.get("min") or []
|
|
1171
|
+
if not mn or len(mn) < 3:
|
|
1172
|
+
return 0.0
|
|
1173
|
+
return round(-mn[1] * scale, 6)
|
|
1174
|
+
|
|
1175
|
+
imported: List[str] = []
|
|
1176
|
+
failed: List[str] = []
|
|
1177
|
+
scene_assets: List[Dict[str, Any]] = []
|
|
1178
|
+
node_path_map: Dict[str, str] = {} # asset_id → geo_path
|
|
1179
|
+
metrics_map: Dict[str, Any] = {} # asset_id → AssetMetrics
|
|
1180
|
+
ty_map: Dict[str, float] = {} # asset_id → ground_offset (raises bottom to y=0)
|
|
1181
|
+
cursor_x = 0.0 # running X cursor for temporary staging layout
|
|
1182
|
+
|
|
1183
|
+
for i, (info, fr) in enumerate(zip(assets, fetch_results)):
|
|
1184
|
+
aid = str(info.get("asset_id", f"asset_{i}"))
|
|
1185
|
+
if not fr.ok or not fr.local_path or not os.path.exists(fr.local_path):
|
|
1186
|
+
failed.append(f"{aid}: {fr.error or 'not available'}")
|
|
1187
|
+
continue
|
|
1188
|
+
lp = fr.local_path
|
|
1189
|
+
sop_t, pn = _sop_info(lp)
|
|
1190
|
+
safe = "".join(c if c.isalnum() or c == "_" else "_" for c in aid)[:28] or f"asset_{i}"
|
|
1191
|
+
try:
|
|
1192
|
+
geo_r = bridge.create_node(parent, "geo", safe)
|
|
1193
|
+
geo_p = geo_r["path"]
|
|
1194
|
+
for child in bridge.children(geo_p):
|
|
1195
|
+
bridge.delete_node(child["path"])
|
|
1196
|
+
sop_r = bridge.create_node(geo_p, sop_t, "load")
|
|
1197
|
+
sop_p = sop_r["path"]
|
|
1198
|
+
bridge.set_parm(sop_p, pn, lp)
|
|
1199
|
+
bridge.set_display_flag(sop_p, True)
|
|
1200
|
+
bridge.set_render_flag(sop_p, True)
|
|
1201
|
+
bridge.cook_node(sop_p)
|
|
1202
|
+
|
|
1203
|
+
# Measure imported geometry; preserve real-world dimensions (no normalisation)
|
|
1204
|
+
bbox_ = _get_bbox(sop_p)
|
|
1205
|
+
scale = _import_scale(info, bbox_)
|
|
1206
|
+
ty = _ground_offset(bbox_, scale)
|
|
1207
|
+
|
|
1208
|
+
# Derive real-world world-space dimensions and store on the asset dict
|
|
1209
|
+
# so downstream systems (layout, collision) receive actual measurements.
|
|
1210
|
+
try:
|
|
1211
|
+
from src.runtime.assets.geometry.bounding_box_extractor import (
|
|
1212
|
+
get_geometry_bbox_extractor)
|
|
1213
|
+
wbbox = get_geometry_bbox_extractor().from_houdini_bbox(bbox_, scale)
|
|
1214
|
+
info["width_m"] = wbbox["width_m"]
|
|
1215
|
+
info["height_m"] = wbbox["height_m"]
|
|
1216
|
+
info["depth_m"] = wbbox["depth_m"]
|
|
1217
|
+
info["bbox_min"] = wbbox["bbox_min"]
|
|
1218
|
+
info["bbox_max"] = wbbox["bbox_max"]
|
|
1219
|
+
info["source_unit"] = "meters"
|
|
1220
|
+
except Exception:
|
|
1221
|
+
pass
|
|
1222
|
+
|
|
1223
|
+
# ── PHASE 1: Build AssetMetrics from cooked geometry ─────────────
|
|
1224
|
+
try:
|
|
1225
|
+
from src.runtime.assets.geometry.asset_metrics import (
|
|
1226
|
+
get_asset_metrics_builder)
|
|
1227
|
+
metrics = get_asset_metrics_builder().build(info)
|
|
1228
|
+
metrics_map[aid] = metrics
|
|
1229
|
+
# Propagate classification back into info for layout engine type inference
|
|
1230
|
+
if not info.get("placement_type") and metrics.placement_type:
|
|
1231
|
+
info["placement_type"] = metrics.placement_type
|
|
1232
|
+
if not info.get("category") and metrics.category:
|
|
1233
|
+
info["category"] = metrics.category
|
|
1234
|
+
info["scale_class"] = metrics.scale_class
|
|
1235
|
+
info["role"] = metrics.role
|
|
1236
|
+
except Exception:
|
|
1237
|
+
pass
|
|
1238
|
+
|
|
1239
|
+
size_x = (bbox_.get("size") or [spacing, 0, 0])[0] * scale
|
|
1240
|
+
|
|
1241
|
+
# Temporary staging: linear placement along X (overridden by layout pipeline)
|
|
1242
|
+
bridge.set_parms(geo_p, {
|
|
1243
|
+
"tx": round(cursor_x + size_x / 2.0, 4),
|
|
1244
|
+
"ty": round(ty, 6),
|
|
1245
|
+
"tz": 0.0,
|
|
1246
|
+
"sx": scale, "sy": scale, "sz": scale,
|
|
1247
|
+
})
|
|
1248
|
+
cursor_x += size_x + spacing
|
|
1249
|
+
imported.append(geo_p)
|
|
1250
|
+
node_path_map[aid] = geo_p
|
|
1251
|
+
ty_map[aid] = ty
|
|
1252
|
+
|
|
1253
|
+
scene_asset = dict(info)
|
|
1254
|
+
scene_asset["asset_id"] = aid
|
|
1255
|
+
scene_assets.append(scene_asset)
|
|
1256
|
+
|
|
1257
|
+
except Exception as exc:
|
|
1258
|
+
failed.append(f"{safe}: {exc}")
|
|
1259
|
+
|
|
1260
|
+
if imported:
|
|
1261
|
+
try:
|
|
1262
|
+
bridge.layout_children(parent)
|
|
1263
|
+
except Exception:
|
|
1264
|
+
pass
|
|
1265
|
+
|
|
1266
|
+
# ── Layout pipeline metrics ──────────────────────────────────────────────
|
|
1267
|
+
layout_ok = False
|
|
1268
|
+
realize_ok = False
|
|
1269
|
+
collision_before = 0
|
|
1270
|
+
collision_after = 0
|
|
1271
|
+
constraint_violations = 0
|
|
1272
|
+
transforms_applied = 0
|
|
1273
|
+
assets_in_clusters = 0
|
|
1274
|
+
assets_on_surfaces = 0
|
|
1275
|
+
assets_on_walls = 0
|
|
1276
|
+
pipeline_errors: List[str] = []
|
|
1277
|
+
layout = None
|
|
1278
|
+
final_score = None
|
|
1279
|
+
routing_ok = True
|
|
1280
|
+
structural_count = 0
|
|
1281
|
+
furniture_count = len(scene_assets)
|
|
1282
|
+
shell_ready = True # default: non-blocking if shell module unavailable
|
|
1283
|
+
shell_report: Dict[str, Any] = {}
|
|
1284
|
+
shell_geometry_created = False
|
|
1285
|
+
shell_geo_nodes: Dict[str, str] = {} # label → geo node path in Houdini
|
|
1286
|
+
shell_geo_prims: Dict[str, int] = {} # label → primitive count after cook
|
|
1287
|
+
shell_geo_status = "SKIP" # PASS | FAIL | SKIP
|
|
1288
|
+
|
|
1289
|
+
# ── Phase 0: Environment Shell Construction (Tier 10.4) ──────────────────
|
|
1290
|
+
# Build the room shell (floor + walls + ceiling + anchors) before ANY asset
|
|
1291
|
+
# placement. environment_ready = False → BLOCKING gate; furniture layout,
|
|
1292
|
+
# surface placement, and decoration are all skipped.
|
|
1293
|
+
_shell_env = environment or "western_room"
|
|
1294
|
+
_shell_result = None
|
|
1295
|
+
_shell_bp: Dict[str, Any] = {}
|
|
1296
|
+
try:
|
|
1297
|
+
from src.runtime.environment_shell import get_environment_shell_builder
|
|
1298
|
+
_shell_result = get_environment_shell_builder().build(_shell_env)
|
|
1299
|
+
_sh = _shell_result.shell
|
|
1300
|
+
_shell_bp = _shell_result.blueprint or {}
|
|
1301
|
+
shell_ready = bool(_sh and _sh.environment_ready)
|
|
1302
|
+
shell_report = {
|
|
1303
|
+
"environment_ready": shell_ready,
|
|
1304
|
+
"floor_exists": _sh.floor_exists if _sh else False,
|
|
1305
|
+
"wall_count": _sh.wall_count if _sh else 0,
|
|
1306
|
+
"ceiling_exists": _sh.ceiling_exists if _sh else False,
|
|
1307
|
+
"enclosure_valid": _sh.enclosure_valid if _sh else False,
|
|
1308
|
+
"door_anchor_count": _sh.door_anchor_count if _sh else 0,
|
|
1309
|
+
"beam_anchor_count": _sh.beam_anchor_count if _sh else 0,
|
|
1310
|
+
"gate_status": _shell_result.gate.gate_status
|
|
1311
|
+
if _shell_result.gate else "",
|
|
1312
|
+
"shell_grade": _shell_result.review.grade
|
|
1313
|
+
if _shell_result.review else "F",
|
|
1314
|
+
"shell_score": _shell_result.review.overall_score
|
|
1315
|
+
if _shell_result.review else 0.0,
|
|
1316
|
+
"phase_statuses": _sh.phase_statuses if _sh else {},
|
|
1317
|
+
}
|
|
1318
|
+
if not shell_ready:
|
|
1319
|
+
_gate_findings = (
|
|
1320
|
+
_shell_result.gate.findings if _shell_result.gate else []
|
|
1321
|
+
)
|
|
1322
|
+
pipeline_errors.append(
|
|
1323
|
+
"ENVIRONMENT_NOT_READY — shell gate blocked. "
|
|
1324
|
+
f"floor={shell_report['floor_exists']}, "
|
|
1325
|
+
f"walls={shell_report['wall_count']}, "
|
|
1326
|
+
f"ceiling={shell_report['ceiling_exists']}. "
|
|
1327
|
+
+ ("; ".join(_gate_findings) if _gate_findings else "")
|
|
1328
|
+
)
|
|
1329
|
+
except Exception as exc:
|
|
1330
|
+
pipeline_errors.append(f"EnvironmentShellBuilder (non-blocking): {exc}")
|
|
1331
|
+
# shell_ready stays True — graceful fallback so a missing module does
|
|
1332
|
+
# not break existing scenes that predate Tier 10.4.
|
|
1333
|
+
|
|
1334
|
+
# ── Phase 0.75: Shell Geometry Realization (Tier 10.4.2) ─────────────────
|
|
1335
|
+
# Create actual Houdini geo nodes (box SOPs) for the validated shell.
|
|
1336
|
+
# Nodes: sh_floor / sh_wall_n / sh_wall_s / sh_wall_e / sh_wall_w / sh_ceiling
|
|
1337
|
+
# Outdoor environments receive a ground plane only (no walls / ceiling).
|
|
1338
|
+
# Furniture layout (Phase 1.5+) is blocked until shell_geo_status == "PASS".
|
|
1339
|
+
if shell_ready:
|
|
1340
|
+
try:
|
|
1341
|
+
_w = float(_shell_bp.get("room_width", 10.0))
|
|
1342
|
+
_l = float(_shell_bp.get("room_length", 12.0))
|
|
1343
|
+
_h = float(_shell_bp.get("room_height", 4.0))
|
|
1344
|
+
_is_outdoor = bool(_shell_bp.get("is_outdoor", False))
|
|
1345
|
+
_wall_thick = 0.3
|
|
1346
|
+
_floor_thick = 0.1
|
|
1347
|
+
_ceil_thick = 0.15
|
|
1348
|
+
_pfx = "sh" # keeps node names short
|
|
1349
|
+
|
|
1350
|
+
def _mk_box(label: str, sx: float, sy: float, sz: float,
|
|
1351
|
+
geo_tx: float = 0.0, geo_ty: float = 0.0,
|
|
1352
|
+
geo_tz: float = 0.0) -> str:
|
|
1353
|
+
"""Create parent/label geo node with a single box SOP inside."""
|
|
1354
|
+
_gr = bridge.create_node(parent, "geo", label)
|
|
1355
|
+
_gp = _gr["path"]
|
|
1356
|
+
for _ch in bridge.children(_gp):
|
|
1357
|
+
bridge.delete_node(_ch["path"])
|
|
1358
|
+
_sr = bridge.create_node(_gp, "box", "shape")
|
|
1359
|
+
_sp = _sr["path"]
|
|
1360
|
+
bridge.set_parms(_sp, {
|
|
1361
|
+
"sizex": round(sx, 4),
|
|
1362
|
+
"sizey": round(sy, 4),
|
|
1363
|
+
"sizez": round(sz, 4),
|
|
1364
|
+
})
|
|
1365
|
+
bridge.set_display_flag(_sp, True)
|
|
1366
|
+
bridge.set_render_flag(_sp, True)
|
|
1367
|
+
bridge.set_parms(_gp, {
|
|
1368
|
+
"tx": round(geo_tx, 4),
|
|
1369
|
+
"ty": round(geo_ty, 4),
|
|
1370
|
+
"tz": round(geo_tz, 4),
|
|
1371
|
+
})
|
|
1372
|
+
bridge.cook_node(_sp)
|
|
1373
|
+
return _gp
|
|
1374
|
+
|
|
1375
|
+
def _prim_count(geo_path: str) -> int:
|
|
1376
|
+
try:
|
|
1377
|
+
_ch_list = bridge.children(geo_path)
|
|
1378
|
+
if not _ch_list:
|
|
1379
|
+
return 0
|
|
1380
|
+
_sp_path = _ch_list[0]["path"]
|
|
1381
|
+
_rv = bridge.run_code(
|
|
1382
|
+
f"_n = hou.node({_sp_path!r})\n"
|
|
1383
|
+
"_g = _n.geometry() if _n else None\n"
|
|
1384
|
+
"result = len(_g.prims()) if _g else 0"
|
|
1385
|
+
)
|
|
1386
|
+
return int(_rv.get("result") or 0)
|
|
1387
|
+
except Exception:
|
|
1388
|
+
return 0
|
|
1389
|
+
|
|
1390
|
+
# Phase 0.75a — Floor (always present)
|
|
1391
|
+
_fg = _mk_box(f"{_pfx}_floor",
|
|
1392
|
+
_w, _floor_thick, _l,
|
|
1393
|
+
0.0, -_floor_thick / 2.0, 0.0)
|
|
1394
|
+
shell_geo_nodes["floor"] = _fg
|
|
1395
|
+
shell_geo_prims["floor"] = _prim_count(_fg)
|
|
1396
|
+
|
|
1397
|
+
if not _is_outdoor:
|
|
1398
|
+
# Phase 0.75b — Perimeter walls
|
|
1399
|
+
_wn = _mk_box(f"{_pfx}_wall_n",
|
|
1400
|
+
_w, _h, _wall_thick,
|
|
1401
|
+
0.0, _h / 2.0, -(_l / 2.0))
|
|
1402
|
+
shell_geo_nodes["wall_north"] = _wn
|
|
1403
|
+
shell_geo_prims["wall_north"] = _prim_count(_wn)
|
|
1404
|
+
|
|
1405
|
+
_ws = _mk_box(f"{_pfx}_wall_s",
|
|
1406
|
+
_w, _h, _wall_thick,
|
|
1407
|
+
0.0, _h / 2.0, _l / 2.0)
|
|
1408
|
+
shell_geo_nodes["wall_south"] = _ws
|
|
1409
|
+
shell_geo_prims["wall_south"] = _prim_count(_ws)
|
|
1410
|
+
|
|
1411
|
+
_we = _mk_box(f"{_pfx}_wall_e",
|
|
1412
|
+
_wall_thick, _h, _l,
|
|
1413
|
+
_w / 2.0, _h / 2.0, 0.0)
|
|
1414
|
+
shell_geo_nodes["wall_east"] = _we
|
|
1415
|
+
shell_geo_prims["wall_east"] = _prim_count(_we)
|
|
1416
|
+
|
|
1417
|
+
_ww = _mk_box(f"{_pfx}_wall_w",
|
|
1418
|
+
_wall_thick, _h, _l,
|
|
1419
|
+
-(_w / 2.0), _h / 2.0, 0.0)
|
|
1420
|
+
shell_geo_nodes["wall_west"] = _ww
|
|
1421
|
+
shell_geo_prims["wall_west"] = _prim_count(_ww)
|
|
1422
|
+
|
|
1423
|
+
# Phase 0.75c — Ceiling
|
|
1424
|
+
_cg = _mk_box(f"{_pfx}_ceiling",
|
|
1425
|
+
_w, _ceil_thick, _l,
|
|
1426
|
+
0.0, _h + _ceil_thick / 2.0, 0.0)
|
|
1427
|
+
shell_geo_nodes["ceiling"] = _cg
|
|
1428
|
+
shell_geo_prims["ceiling"] = _prim_count(_cg)
|
|
1429
|
+
|
|
1430
|
+
shell_geometry_created = bool(shell_geo_nodes)
|
|
1431
|
+
|
|
1432
|
+
# Evaluate geometry status
|
|
1433
|
+
_floor_ok = shell_geo_prims.get("floor", 0) > 0
|
|
1434
|
+
_walls_ok = _is_outdoor or (
|
|
1435
|
+
shell_geo_prims.get("wall_north", 0) > 0
|
|
1436
|
+
and shell_geo_prims.get("wall_south", 0) > 0
|
|
1437
|
+
and shell_geo_prims.get("wall_east", 0) > 0
|
|
1438
|
+
and shell_geo_prims.get("wall_west", 0) > 0
|
|
1439
|
+
)
|
|
1440
|
+
_ceiling_ok = _is_outdoor or shell_geo_prims.get("ceiling", 0) > 0
|
|
1441
|
+
shell_geo_status = "PASS" if (_floor_ok and _walls_ok and _ceiling_ok) else "FAIL"
|
|
1442
|
+
|
|
1443
|
+
# Write back into shell_report so callers see the full picture
|
|
1444
|
+
shell_report["geometry_nodes"] = dict(shell_geo_nodes)
|
|
1445
|
+
shell_report["geometry_prims"] = dict(shell_geo_prims)
|
|
1446
|
+
shell_report["geometry_count"] = len(shell_geo_nodes)
|
|
1447
|
+
shell_report["anchor_count"] = sum(
|
|
1448
|
+
getattr(_shell_result.shell, k, 0)
|
|
1449
|
+
for k in ("door_anchor_count", "window_anchor_count",
|
|
1450
|
+
"beam_anchor_count", "column_anchor_count")
|
|
1451
|
+
) if (_shell_result and _shell_result.shell) else 0
|
|
1452
|
+
|
|
1453
|
+
if shell_geo_status == "FAIL":
|
|
1454
|
+
pipeline_errors.append(
|
|
1455
|
+
"SHELL_GEOMETRY_STATUS=FAIL — "
|
|
1456
|
+
f"floor={shell_geo_prims.get('floor', 0)} prims, "
|
|
1457
|
+
f"wall_north={shell_geo_prims.get('wall_north', 0)} prims, "
|
|
1458
|
+
f"ceiling={shell_geo_prims.get('ceiling', 0)} prims"
|
|
1459
|
+
)
|
|
1460
|
+
except Exception as exc:
|
|
1461
|
+
shell_geo_status = "FAIL"
|
|
1462
|
+
pipeline_errors.append(f"ShellGeometryRealization: {exc}")
|
|
1463
|
+
|
|
1464
|
+
if scene_assets and shell_ready:
|
|
1465
|
+
# ── PHASE 1.5: Structural routing (Tier 10.3.5) ──────────────────────
|
|
1466
|
+
# Classify every asset and split into structural (beam/wall/door/column/…)
|
|
1467
|
+
# and furniture (chair/table/prop/…). Only furniture enters SemanticLayoutEngine.
|
|
1468
|
+
# Structural assets are placed separately in PHASE 6b.
|
|
1469
|
+
furniture_assets: List[Dict[str, Any]] = list(scene_assets)
|
|
1470
|
+
structural_assets: List[Dict[str, Any]] = []
|
|
1471
|
+
try:
|
|
1472
|
+
from src.runtime.environment_realization.structural_routing_engine import (
|
|
1473
|
+
get_structural_routing_engine)
|
|
1474
|
+
_routing = get_structural_routing_engine().route(scene_assets, environment)
|
|
1475
|
+
furniture_assets = _routing.furniture_assets
|
|
1476
|
+
structural_assets= _routing.structural_assets
|
|
1477
|
+
routing_ok = _routing.production_ready
|
|
1478
|
+
structural_count = len(structural_assets)
|
|
1479
|
+
furniture_count = len(furniture_assets)
|
|
1480
|
+
except Exception as exc:
|
|
1481
|
+
pipeline_errors.append(f"StructuralRoutingEngine: {exc}")
|
|
1482
|
+
|
|
1483
|
+
# ── PHASE 2: Semantic Layout (furniture/props only) ──────────────────
|
|
1484
|
+
try:
|
|
1485
|
+
from src.runtime.layout.semantic_layout_engine import get_semantic_layout_engine
|
|
1486
|
+
layout = get_semantic_layout_engine().build_layout(furniture_assets, environment)
|
|
1487
|
+
layout_ok = layout.ok
|
|
1488
|
+
if layout_ok:
|
|
1489
|
+
assets_in_clusters = sum(
|
|
1490
|
+
len(c.get("members", [])) for c in (layout.clusters or []))
|
|
1491
|
+
assets_on_surfaces = len(layout.surface_placements or [])
|
|
1492
|
+
assets_on_walls = len(layout.wall_attachments or [])
|
|
1493
|
+
except Exception as exc:
|
|
1494
|
+
pipeline_errors.append(f"SemanticLayoutEngine: {exc}")
|
|
1495
|
+
layout = None
|
|
1496
|
+
layout_ok = False
|
|
1497
|
+
|
|
1498
|
+
if layout_ok and layout is not None:
|
|
1499
|
+
# ── PHASE 3: Layout Realization ───────────────────────────────────
|
|
1500
|
+
try:
|
|
1501
|
+
from src.runtime.layout_realization.layout_realization_engine import (
|
|
1502
|
+
get_layout_realization_engine)
|
|
1503
|
+
type_hints: Dict[str, str] = {
|
|
1504
|
+
aid_: m.placement_type
|
|
1505
|
+
for aid_, m in metrics_map.items()
|
|
1506
|
+
if m.placement_type
|
|
1507
|
+
}
|
|
1508
|
+
realized = get_layout_realization_engine().realize(
|
|
1509
|
+
layout.to_dict(),
|
|
1510
|
+
room_half_width=room_half_width,
|
|
1511
|
+
type_hints=type_hints,
|
|
1512
|
+
)
|
|
1513
|
+
realize_ok = realized.ok
|
|
1514
|
+
|
|
1515
|
+
if realize_ok and realized.transforms:
|
|
1516
|
+
# Inject real bbox half-extents from cooked geometry into every
|
|
1517
|
+
# transform so that Phase 4 collision uses actual asset footprints.
|
|
1518
|
+
for xf in realized.transforms:
|
|
1519
|
+
m = metrics_map.get(xf.asset_id)
|
|
1520
|
+
if m:
|
|
1521
|
+
xf.bbox_half_x = m.width_m / 2.0
|
|
1522
|
+
xf.bbox_half_y = m.height_m / 2.0
|
|
1523
|
+
xf.bbox_half_z = m.depth_m / 2.0
|
|
1524
|
+
|
|
1525
|
+
# ── PHASE 4: Collision resolution with real geometry ───────
|
|
1526
|
+
from src.runtime.layout_realization.collision_solver import (
|
|
1527
|
+
get_collision_solver)
|
|
1528
|
+
col_result = get_collision_solver().solve(
|
|
1529
|
+
realized.transforms, room_half_width, type_hints)
|
|
1530
|
+
collision_before = col_result.collisions_found
|
|
1531
|
+
collision_after = col_result.collisions_remaining
|
|
1532
|
+
|
|
1533
|
+
# ── PHASE 5: Scene constraint solver ──────────────────────
|
|
1534
|
+
from src.runtime.layout_realization.scene_constraint_solver import (
|
|
1535
|
+
get_scene_constraint_solver)
|
|
1536
|
+
hero_id = ""
|
|
1537
|
+
for ap in (layout.anchor_placements or []):
|
|
1538
|
+
if isinstance(ap, dict) and ap.get("is_hero"):
|
|
1539
|
+
hero_id = str(ap.get("anchor_id", ""))
|
|
1540
|
+
break
|
|
1541
|
+
con_result = get_scene_constraint_solver().solve_constraints(
|
|
1542
|
+
col_result.transforms, room_half_width, type_hints, hero_id)
|
|
1543
|
+
constraint_violations = con_result.violations_remaining
|
|
1544
|
+
final_transforms = con_result.transforms
|
|
1545
|
+
|
|
1546
|
+
# ── PHASE 6: Apply final transforms to Houdini ────────────
|
|
1547
|
+
# ground_ty raises the asset bottom to y=0; xf.ty is the
|
|
1548
|
+
# layout vertical offset (0.0 = floor, 0.75 = table surface, etc.)
|
|
1549
|
+
for xf in final_transforms:
|
|
1550
|
+
geo_p = node_path_map.get(xf.asset_id)
|
|
1551
|
+
if not geo_p:
|
|
1552
|
+
continue
|
|
1553
|
+
ground_ty = ty_map.get(xf.asset_id, 0.0)
|
|
1554
|
+
try:
|
|
1555
|
+
bridge.set_parms(geo_p, {
|
|
1556
|
+
"tx": round(xf.tx, 4),
|
|
1557
|
+
"ty": round(ground_ty + xf.ty, 4),
|
|
1558
|
+
"tz": round(xf.tz, 4),
|
|
1559
|
+
"ry": round(xf.ry, 4),
|
|
1560
|
+
})
|
|
1561
|
+
transforms_applied += 1
|
|
1562
|
+
except Exception as exc:
|
|
1563
|
+
pipeline_errors.append(f"set_parms {geo_p}: {exc}")
|
|
1564
|
+
|
|
1565
|
+
final_score = (
|
|
1566
|
+
collision_after == 0
|
|
1567
|
+
and constraint_violations == 0
|
|
1568
|
+
and transforms_applied > 0
|
|
1569
|
+
)
|
|
1570
|
+
|
|
1571
|
+
except Exception as exc:
|
|
1572
|
+
pipeline_errors.append(f"LayoutRealizationEngine: {exc}")
|
|
1573
|
+
|
|
1574
|
+
# ── PHASE 6b: Structural asset placement ─────────────────────────────
|
|
1575
|
+
# Place beams, columns, doorways, walls, etc. per their structural role.
|
|
1576
|
+
# These assets bypassed SemanticLayoutEngine intentionally; they are
|
|
1577
|
+
# positioned relative to the room shell using role-derived offsets.
|
|
1578
|
+
if structural_assets:
|
|
1579
|
+
_ceiling_y = max(3.0, room_half_width * 0.65)
|
|
1580
|
+
for sa in structural_assets:
|
|
1581
|
+
_aid = sa.get("asset_id", "")
|
|
1582
|
+
_gp = node_path_map.get(_aid)
|
|
1583
|
+
if not _gp:
|
|
1584
|
+
continue
|
|
1585
|
+
_role = sa.get("_structural_role", "structural_unknown")
|
|
1586
|
+
_ground = ty_map.get(_aid, 0.0)
|
|
1587
|
+
_tx, _ty, _tz, _ry = _compute_structural_transform(
|
|
1588
|
+
_role, room_half_width, _ceiling_y, _ground)
|
|
1589
|
+
try:
|
|
1590
|
+
bridge.set_parms(_gp, {
|
|
1591
|
+
"tx": round(_tx, 4),
|
|
1592
|
+
"ty": round(_ty, 4),
|
|
1593
|
+
"tz": round(_tz, 4),
|
|
1594
|
+
"ry": round(_ry, 4),
|
|
1595
|
+
})
|
|
1596
|
+
transforms_applied += 1
|
|
1597
|
+
except Exception as exc:
|
|
1598
|
+
pipeline_errors.append(f"structural set_parms {_gp}: {exc}")
|
|
1599
|
+
|
|
1600
|
+
# ── PHASE 7: Validation Report ───────────────────────────────────────────
|
|
1601
|
+
pipeline_pass = (
|
|
1602
|
+
shell_ready
|
|
1603
|
+
and routing_ok
|
|
1604
|
+
and layout_ok
|
|
1605
|
+
and realize_ok
|
|
1606
|
+
and collision_after == 0
|
|
1607
|
+
and constraint_violations == 0
|
|
1608
|
+
and transforms_applied > 0
|
|
1609
|
+
)
|
|
1610
|
+
|
|
1611
|
+
layout_pipeline_report = {
|
|
1612
|
+
"imported_assets": len(imported),
|
|
1613
|
+
"assets_with_metrics": len(metrics_map),
|
|
1614
|
+
"structural_assets_routed": structural_count,
|
|
1615
|
+
"furniture_assets_to_layout": furniture_count,
|
|
1616
|
+
"routing_ok": routing_ok,
|
|
1617
|
+
"assets_in_clusters": assets_in_clusters,
|
|
1618
|
+
"assets_on_surfaces": assets_on_surfaces,
|
|
1619
|
+
"assets_attached_to_walls": assets_on_walls,
|
|
1620
|
+
"assets_resolved": transforms_applied,
|
|
1621
|
+
"collision_count_before": collision_before,
|
|
1622
|
+
"collision_count_after": collision_after,
|
|
1623
|
+
"constraint_violations": constraint_violations,
|
|
1624
|
+
"final_score": final_score,
|
|
1625
|
+
"production_ready": pipeline_pass,
|
|
1626
|
+
# Shell fields (Tier 10.4 / 10.4.2)
|
|
1627
|
+
"shell_ready": shell_ready,
|
|
1628
|
+
"shell_geo_status": shell_geo_status,
|
|
1629
|
+
"shell_geometry_created": shell_geometry_created,
|
|
1630
|
+
"shell_geo_nodes": dict(shell_geo_nodes),
|
|
1631
|
+
"shell_geo_prims": dict(shell_geo_prims),
|
|
1632
|
+
"shell_geometry_count": len(shell_geo_nodes),
|
|
1633
|
+
"shell_report": shell_report,
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
ok = len(imported) > 0
|
|
1637
|
+
return {
|
|
1638
|
+
"ok": ok,
|
|
1639
|
+
"imported_paths": imported,
|
|
1640
|
+
"asset_count": len(imported),
|
|
1641
|
+
"failed_count": len(failed),
|
|
1642
|
+
"failed": failed,
|
|
1643
|
+
"keywords": keywords,
|
|
1644
|
+
"source": source,
|
|
1645
|
+
"environment": environment,
|
|
1646
|
+
"layout_pipeline_report": layout_pipeline_report,
|
|
1647
|
+
"END_TO_END_LAYOUT_STATUS": "PASS" if pipeline_pass else "FAIL",
|
|
1648
|
+
"SHELL_RUNTIME_STATUS": "PASS" if shell_ready else "FAIL",
|
|
1649
|
+
"SHELL_GEOMETRY_STATUS": shell_geo_status,
|
|
1650
|
+
"pipeline_errors": pipeline_errors,
|
|
1651
|
+
"message": (
|
|
1652
|
+
f"Imported {len(imported)} assets into {parent} from {source}. "
|
|
1653
|
+
+ (f"{len(failed)} failed: {failed[:3]}. " if failed else "")
|
|
1654
|
+
+ (f"Shell: {'PASS' if shell_ready else 'FAIL (BLOCKING)'} "
|
|
1655
|
+
f"Geo: {shell_geo_status} ({len(shell_geo_nodes)} nodes). "
|
|
1656
|
+
if shell_report else "")
|
|
1657
|
+
+ (f"Layout: {'PASS' if pipeline_pass else 'FAIL'} "
|
|
1658
|
+
f"({transforms_applied}/{len(imported)} transforms, "
|
|
1659
|
+
f"{collision_after} collisions, {constraint_violations} violations). "
|
|
1660
|
+
if scene_assets else "")
|
|
1661
|
+
+ "Next step: add lighting and camera."
|
|
1662
|
+
) if ok else (
|
|
1663
|
+
f"No assets imported. Failures: {failed[:5]}"
|
|
1664
|
+
),
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
|
|
1668
|
+
async def _handle_review_execution(args: Dict[str, Any]) -> Dict[str, Any]:
|
|
1669
|
+
exec_json = str(args.get("execution_result_json", "")).strip()
|
|
1670
|
+
plan_json = str(args.get("plan_json", "")).strip()
|
|
1671
|
+
if not exec_json:
|
|
1672
|
+
return {"ok": False, "error": "execution_result_json is required"}
|
|
1673
|
+
try:
|
|
1674
|
+
execution_result = json.loads(exec_json)
|
|
1675
|
+
plan = json.loads(plan_json) if plan_json else {}
|
|
1676
|
+
except json.JSONDecodeError as exc:
|
|
1677
|
+
return {"ok": False, "error": f"Invalid JSON: {exc}"}
|
|
1678
|
+
|
|
1679
|
+
# ── build_scene_from_assets result — metrics-based review ─────────────────
|
|
1680
|
+
# That tool bypasses plan_scene and the operation-diff reviewer entirely.
|
|
1681
|
+
# Compute a direct score from pipeline report metrics instead.
|
|
1682
|
+
if "END_TO_END_LAYOUT_STATUS" in execution_result:
|
|
1683
|
+
rpt = execution_result.get("layout_pipeline_report", {})
|
|
1684
|
+
score = 0.0
|
|
1685
|
+
if execution_result.get("ok"): score += 0.20
|
|
1686
|
+
if execution_result.get("asset_count", 0) > 0: score += 0.20
|
|
1687
|
+
if rpt.get("routing_ok"): score += 0.10
|
|
1688
|
+
if rpt.get("shell_ready", True): score += 0.05
|
|
1689
|
+
if rpt.get("shell_geo_status", "SKIP") == "PASS": score += 0.05
|
|
1690
|
+
if rpt.get("collision_count_after", 1) == 0: score += 0.20
|
|
1691
|
+
if rpt.get("constraint_violations", 1) == 0: score += 0.10
|
|
1692
|
+
if rpt.get("production_ready"): score += 0.10
|
|
1693
|
+
# Master gate: all three PASS flags → ≥ 0.75
|
|
1694
|
+
if (execution_result.get("END_TO_END_LAYOUT_STATUS") == "PASS"
|
|
1695
|
+
and execution_result.get("SHELL_RUNTIME_STATUS", "PASS") == "PASS"
|
|
1696
|
+
and execution_result.get("SHELL_GEOMETRY_STATUS", "PASS") == "PASS"):
|
|
1697
|
+
score = max(score, 0.75)
|
|
1698
|
+
score = min(round(score, 3), 1.0)
|
|
1699
|
+
outcome = (
|
|
1700
|
+
"success" if score >= 0.70 else
|
|
1701
|
+
"partial_success" if score >= 0.40 else
|
|
1702
|
+
"failure"
|
|
1703
|
+
)
|
|
1704
|
+
review = {
|
|
1705
|
+
"intent": execution_result.get("intent", execution_result.get("environment", "")),
|
|
1706
|
+
"outcome": outcome,
|
|
1707
|
+
"intent_match_score": score,
|
|
1708
|
+
"findings": list(execution_result.get("pipeline_errors", [])),
|
|
1709
|
+
"asset_count": execution_result.get("asset_count", 0),
|
|
1710
|
+
"routing_ok": rpt.get("routing_ok", False),
|
|
1711
|
+
"structural_routed": rpt.get("structural_assets_routed", 0),
|
|
1712
|
+
"furniture_to_layout":rpt.get("furniture_assets_to_layout", 0),
|
|
1713
|
+
"collision_count_after": rpt.get("collision_count_after", 0),
|
|
1714
|
+
"constraint_violations": rpt.get("constraint_violations", 0),
|
|
1715
|
+
"production_ready": rpt.get("production_ready", False),
|
|
1716
|
+
}
|
|
1717
|
+
return {
|
|
1718
|
+
"ok": True,
|
|
1719
|
+
"review": review,
|
|
1720
|
+
"explanation": {
|
|
1721
|
+
"summary": (
|
|
1722
|
+
f"Scene build review — {outcome}. "
|
|
1723
|
+
f"Score: {score:.0%}. "
|
|
1724
|
+
f"{execution_result.get('asset_count', 0)} assets placed, "
|
|
1725
|
+
f"{rpt.get('collision_count_after', 0)} collisions remaining."
|
|
1726
|
+
),
|
|
1727
|
+
"metrics": rpt,
|
|
1728
|
+
},
|
|
1729
|
+
"outcome": outcome,
|
|
1730
|
+
"intent_match_score": score,
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
try:
|
|
1734
|
+
from src.runtime.execution_review import get_execution_reviewer
|
|
1735
|
+
from src.runtime.execution_explainer import get_execution_explainer
|
|
1736
|
+
review = get_execution_reviewer().review(plan, execution_result)
|
|
1737
|
+
explanation = get_execution_explainer().explain_review(review)
|
|
1738
|
+
return {
|
|
1739
|
+
"ok": True,
|
|
1740
|
+
"review": review,
|
|
1741
|
+
"explanation": explanation,
|
|
1742
|
+
"outcome": review.get("outcome"),
|
|
1743
|
+
"intent_match_score": review.get("intent_match_score"),
|
|
1744
|
+
}
|
|
1745
|
+
except Exception as exc:
|
|
1746
|
+
return {"ok": False, "error": str(exc)}
|
|
1747
|
+
|
|
1748
|
+
|
|
1749
|
+
# ---------------------------------------------------------------------------
|
|
1750
|
+
# Registration
|
|
1751
|
+
# ---------------------------------------------------------------------------
|
|
1752
|
+
|
|
1753
|
+
def register_all_tools(transport=None) -> "MCPToolRegistry":
|
|
1754
|
+
"""Register all 14 semantic orchestration tools.
|
|
1755
|
+
|
|
1756
|
+
If `transport` is supplied (an MCPTransport instance) the tools are also
|
|
1757
|
+
forwarded to it via transport.register_tool(). This allows callers to do
|
|
1758
|
+
the one-liner:
|
|
1759
|
+
|
|
1760
|
+
register_all_tools(transport)
|
|
1761
|
+
|
|
1762
|
+
without having to manage the registry separately.
|
|
1763
|
+
"""
|
|
1764
|
+
registry = get_mcp_tool_registry()
|
|
1765
|
+
|
|
1766
|
+
_tools: List[ToolDefinition] = [
|
|
1767
|
+
# ── RUNTIME ────────────────────────────────────────────────────────
|
|
1768
|
+
ToolDefinition(
|
|
1769
|
+
name="initialize_runtime_context",
|
|
1770
|
+
description=(
|
|
1771
|
+
"Initialize the Vibrante Runtime context. "
|
|
1772
|
+
"Call this first before any other commands. "
|
|
1773
|
+
"Returns runtime identity, capabilities, templates, and execution rules."
|
|
1774
|
+
),
|
|
1775
|
+
inputSchema={
|
|
1776
|
+
"type": "object",
|
|
1777
|
+
"properties": {
|
|
1778
|
+
"client_id": {
|
|
1779
|
+
"type": "string",
|
|
1780
|
+
"description": "Optional identifier for this LLM client session.",
|
|
1781
|
+
},
|
|
1782
|
+
},
|
|
1783
|
+
},
|
|
1784
|
+
handler=_handle_initialize_runtime_context,
|
|
1785
|
+
category="runtime",
|
|
1786
|
+
),
|
|
1787
|
+
ToolDefinition(
|
|
1788
|
+
name="query_runtime_state",
|
|
1789
|
+
description=(
|
|
1790
|
+
"Query live Vibrante Runtime state: transaction manager, "
|
|
1791
|
+
"scene cache, execution scheduler, and audit store metrics."
|
|
1792
|
+
),
|
|
1793
|
+
inputSchema={"type": "object", "properties": {}},
|
|
1794
|
+
handler=_handle_query_runtime_state,
|
|
1795
|
+
category="runtime",
|
|
1796
|
+
),
|
|
1797
|
+
ToolDefinition(
|
|
1798
|
+
name="query_scene_context",
|
|
1799
|
+
description=(
|
|
1800
|
+
"Get a structured snapshot of the current Houdini scene: "
|
|
1801
|
+
"hip file, frame range, node networks, selection, and loaded HDAs. "
|
|
1802
|
+
"Requires a live Houdini + Vibrante-Node bridge."
|
|
1803
|
+
),
|
|
1804
|
+
inputSchema={
|
|
1805
|
+
"type": "object",
|
|
1806
|
+
"properties": {
|
|
1807
|
+
"force_refresh": {
|
|
1808
|
+
"type": "boolean",
|
|
1809
|
+
"description": "Bypass the 5-second scene cache and re-read from Houdini.",
|
|
1810
|
+
"default": False,
|
|
1811
|
+
},
|
|
1812
|
+
},
|
|
1813
|
+
},
|
|
1814
|
+
handler=_handle_query_scene_context,
|
|
1815
|
+
category="runtime",
|
|
1816
|
+
),
|
|
1817
|
+
# ── KNOWLEDGE ──────────────────────────────────────────────────────
|
|
1818
|
+
ToolDefinition(
|
|
1819
|
+
name="query_capabilities",
|
|
1820
|
+
description=(
|
|
1821
|
+
"Enumerate what the Vibrante Runtime can do: Houdini ops, "
|
|
1822
|
+
"renderers, MCP servers, semantic operations, etc."
|
|
1823
|
+
),
|
|
1824
|
+
inputSchema={
|
|
1825
|
+
"type": "object",
|
|
1826
|
+
"properties": {
|
|
1827
|
+
"cap_type": {
|
|
1828
|
+
"type": "string",
|
|
1829
|
+
"description": (
|
|
1830
|
+
"Filter by capability type "
|
|
1831
|
+
"(houdini_op, renderer, mcp_server, semantic_operation, …). "
|
|
1832
|
+
"Omit to return all."
|
|
1833
|
+
),
|
|
1834
|
+
},
|
|
1835
|
+
},
|
|
1836
|
+
},
|
|
1837
|
+
handler=_handle_query_capabilities,
|
|
1838
|
+
category="knowledge",
|
|
1839
|
+
),
|
|
1840
|
+
ToolDefinition(
|
|
1841
|
+
name="query_workflow_templates",
|
|
1842
|
+
description=(
|
|
1843
|
+
"Browse available workflow templates (pyro_source, karma_render, "
|
|
1844
|
+
"usd_export, asset_publish, etc.). "
|
|
1845
|
+
"Templates resolve to concrete op lists safe for execute_workflow_transaction."
|
|
1846
|
+
),
|
|
1847
|
+
inputSchema={
|
|
1848
|
+
"type": "object",
|
|
1849
|
+
"properties": {
|
|
1850
|
+
"tag": {
|
|
1851
|
+
"type": "string",
|
|
1852
|
+
"description": "Filter templates by tag (e.g. 'vfx', 'render').",
|
|
1853
|
+
},
|
|
1854
|
+
},
|
|
1855
|
+
},
|
|
1856
|
+
handler=_handle_query_workflow_templates,
|
|
1857
|
+
category="knowledge",
|
|
1858
|
+
),
|
|
1859
|
+
ToolDefinition(
|
|
1860
|
+
name="query_examples",
|
|
1861
|
+
description=(
|
|
1862
|
+
"Get execution examples and usage guidance for a given intent "
|
|
1863
|
+
"or semantic operation name."
|
|
1864
|
+
),
|
|
1865
|
+
inputSchema={
|
|
1866
|
+
"type": "object",
|
|
1867
|
+
"required": ["intent"],
|
|
1868
|
+
"properties": {
|
|
1869
|
+
"intent": {
|
|
1870
|
+
"type": "string",
|
|
1871
|
+
"description": (
|
|
1872
|
+
"Semantic operation name or natural-language description "
|
|
1873
|
+
"(e.g. 'build_pyro_source', 'karma render', 'cache geometry')."
|
|
1874
|
+
),
|
|
1875
|
+
},
|
|
1876
|
+
},
|
|
1877
|
+
},
|
|
1878
|
+
handler=_handle_query_examples,
|
|
1879
|
+
category="knowledge",
|
|
1880
|
+
),
|
|
1881
|
+
ToolDefinition(
|
|
1882
|
+
name="query_node_parameters",
|
|
1883
|
+
description=(
|
|
1884
|
+
"List all parameter names and current values for a Houdini node. "
|
|
1885
|
+
"Use this to discover the correct parameter name before calling "
|
|
1886
|
+
"execute_workflow_transaction with set_parms ops. "
|
|
1887
|
+
"Requires a live Houdini + Vibrante-Node bridge."
|
|
1888
|
+
),
|
|
1889
|
+
inputSchema={
|
|
1890
|
+
"type": "object",
|
|
1891
|
+
"required": ["node_path"],
|
|
1892
|
+
"properties": {
|
|
1893
|
+
"node_path": {
|
|
1894
|
+
"type": "string",
|
|
1895
|
+
"description": (
|
|
1896
|
+
"Full Houdini path of the node to inspect "
|
|
1897
|
+
"(e.g. '/obj/pyro_sim/pyro_dopnet/source_volume1')."
|
|
1898
|
+
),
|
|
1899
|
+
},
|
|
1900
|
+
},
|
|
1901
|
+
},
|
|
1902
|
+
handler=_handle_query_node_parameters,
|
|
1903
|
+
category="knowledge",
|
|
1904
|
+
),
|
|
1905
|
+
# ── PLANNING ───────────────────────────────────────────────────────
|
|
1906
|
+
ToolDefinition(
|
|
1907
|
+
name="plan_scene",
|
|
1908
|
+
description=(
|
|
1909
|
+
"Parse a natural-language prompt into a structured execution plan "
|
|
1910
|
+
"via the AI planning pipeline (intent parser → context analysis → AI planner). "
|
|
1911
|
+
"Returns the plan dict with operations, risk, and approval requirements. "
|
|
1912
|
+
"Does NOT execute anything."
|
|
1913
|
+
),
|
|
1914
|
+
inputSchema={
|
|
1915
|
+
"type": "object",
|
|
1916
|
+
"required": ["prompt"],
|
|
1917
|
+
"properties": {
|
|
1918
|
+
"prompt": {
|
|
1919
|
+
"type": "string",
|
|
1920
|
+
"description": "Natural-language description of the scene or workflow to build.",
|
|
1921
|
+
},
|
|
1922
|
+
},
|
|
1923
|
+
},
|
|
1924
|
+
handler=_handle_plan_scene,
|
|
1925
|
+
category="planning",
|
|
1926
|
+
),
|
|
1927
|
+
ToolDefinition(
|
|
1928
|
+
name="preview_execution",
|
|
1929
|
+
description=(
|
|
1930
|
+
"Inspect a set of operations without executing them. "
|
|
1931
|
+
"Returns validation results, resource estimates, risk prediction, "
|
|
1932
|
+
"and optimization tips. Always call this before execute_workflow_transaction."
|
|
1933
|
+
),
|
|
1934
|
+
inputSchema={
|
|
1935
|
+
"type": "object",
|
|
1936
|
+
"properties": {
|
|
1937
|
+
"plan_json": {
|
|
1938
|
+
"type": "string",
|
|
1939
|
+
"description": "JSON-serialised plan dict returned by plan_scene.",
|
|
1940
|
+
},
|
|
1941
|
+
"operations_json": {
|
|
1942
|
+
"type": "string",
|
|
1943
|
+
"description": "JSON-serialised list of operation dicts (alternative to plan_json).",
|
|
1944
|
+
},
|
|
1945
|
+
},
|
|
1946
|
+
},
|
|
1947
|
+
handler=_handle_preview_execution,
|
|
1948
|
+
category="planning",
|
|
1949
|
+
),
|
|
1950
|
+
ToolDefinition(
|
|
1951
|
+
name="validate_execution_plan",
|
|
1952
|
+
description=(
|
|
1953
|
+
"Run structural + constraint validation on an operation list. "
|
|
1954
|
+
"Returns errors, warnings, and risk level without executing."
|
|
1955
|
+
),
|
|
1956
|
+
inputSchema={
|
|
1957
|
+
"type": "object",
|
|
1958
|
+
"required": ["operations_json"],
|
|
1959
|
+
"properties": {
|
|
1960
|
+
"operations_json": {
|
|
1961
|
+
"type": "string",
|
|
1962
|
+
"description": "JSON-serialised list of operation dicts.",
|
|
1963
|
+
},
|
|
1964
|
+
},
|
|
1965
|
+
},
|
|
1966
|
+
handler=_handle_validate_execution_plan,
|
|
1967
|
+
category="planning",
|
|
1968
|
+
),
|
|
1969
|
+
# ── EXECUTION ──────────────────────────────────────────────────────
|
|
1970
|
+
ToolDefinition(
|
|
1971
|
+
name="execute_workflow_transaction",
|
|
1972
|
+
description=(
|
|
1973
|
+
"Execute a validated plan via the Vibrante transaction system. "
|
|
1974
|
+
"Provide either plan_json (from plan_scene) or intent + parameters_json. "
|
|
1975
|
+
"High-risk plans require an approver name. "
|
|
1976
|
+
"Use dry_run=true to validate without committing."
|
|
1977
|
+
),
|
|
1978
|
+
inputSchema={
|
|
1979
|
+
"type": "object",
|
|
1980
|
+
"properties": {
|
|
1981
|
+
"plan_json": {
|
|
1982
|
+
"type": "string",
|
|
1983
|
+
"description": "JSON-serialised plan dict from plan_scene.",
|
|
1984
|
+
},
|
|
1985
|
+
"intent": {
|
|
1986
|
+
"type": "string",
|
|
1987
|
+
"description": "Named semantic operation id (alternative to plan_json).",
|
|
1988
|
+
},
|
|
1989
|
+
"parameters_json": {
|
|
1990
|
+
"type": "string",
|
|
1991
|
+
"description": "JSON object of parameters for the semantic operation.",
|
|
1992
|
+
"default": "{}",
|
|
1993
|
+
},
|
|
1994
|
+
"dry_run": {
|
|
1995
|
+
"type": "boolean",
|
|
1996
|
+
"description": "Validate only — do not commit to Houdini.",
|
|
1997
|
+
"default": False,
|
|
1998
|
+
},
|
|
1999
|
+
"approver": {
|
|
2000
|
+
"type": "string",
|
|
2001
|
+
"description": "Approver name required for high-risk plans.",
|
|
2002
|
+
},
|
|
2003
|
+
},
|
|
2004
|
+
},
|
|
2005
|
+
handler=_handle_execute_workflow_transaction,
|
|
2006
|
+
category="execution",
|
|
2007
|
+
),
|
|
2008
|
+
# ── CONFIGURATION CHECK ────────────────────────────────────────────
|
|
2009
|
+
ToolDefinition(
|
|
2010
|
+
name="check_vibrante_config",
|
|
2011
|
+
description=(
|
|
2012
|
+
"Check the current Vibrante credential and path configuration. "
|
|
2013
|
+
"Returns which env vars are set, which are missing, the exact "
|
|
2014
|
+
"filesystem path of the config file to edit, and a ready-to-use "
|
|
2015
|
+
"how_to_fix instruction. "
|
|
2016
|
+
"Call this BEFORE any acquisition or scene-build tool if credentials "
|
|
2017
|
+
"may be missing — relay how_to_fix verbatim to the user."
|
|
2018
|
+
),
|
|
2019
|
+
inputSchema={"type": "object", "properties": {}},
|
|
2020
|
+
handler=_handle_check_vibrante_config,
|
|
2021
|
+
category="runtime",
|
|
2022
|
+
),
|
|
2023
|
+
# ── SCENE BUILDING ─────────────────────────────────────────────────
|
|
2024
|
+
ToolDefinition(
|
|
2025
|
+
name="build_scene_from_assets",
|
|
2026
|
+
description=(
|
|
2027
|
+
"REQUIRED FIRST STEP for any scene-building intent "
|
|
2028
|
+
"(e.g. 'western old room', 'sci-fi corridor', 'medieval tavern'). "
|
|
2029
|
+
"Full pipeline: intent → keyword extraction → local catalog search "
|
|
2030
|
+
"→ Megascans API download if catalog empty → Houdini import. "
|
|
2031
|
+
"NEVER creates box/tube/sphere/grid primitives. "
|
|
2032
|
+
"Works for ANY environment or style. "
|
|
2033
|
+
"Call this BEFORE adding lights or camera."
|
|
2034
|
+
),
|
|
2035
|
+
inputSchema={
|
|
2036
|
+
"type": "object",
|
|
2037
|
+
"required": ["intent"],
|
|
2038
|
+
"properties": {
|
|
2039
|
+
"intent": {
|
|
2040
|
+
"type": "string",
|
|
2041
|
+
"description": (
|
|
2042
|
+
"Natural-language description of the scene to build. "
|
|
2043
|
+
"Examples: 'western old room with barrels and saloon furniture', "
|
|
2044
|
+
"'abandoned factory with rusty machinery', 'desert village at dusk'."
|
|
2045
|
+
),
|
|
2046
|
+
},
|
|
2047
|
+
"top_k": {
|
|
2048
|
+
"type": "integer",
|
|
2049
|
+
"description": "Max number of assets to retrieve and import.",
|
|
2050
|
+
"default": 10,
|
|
2051
|
+
},
|
|
2052
|
+
"parent": {
|
|
2053
|
+
"type": "string",
|
|
2054
|
+
"description": "Houdini parent network path (default: /obj).",
|
|
2055
|
+
"default": "/obj",
|
|
2056
|
+
},
|
|
2057
|
+
"quality": {
|
|
2058
|
+
"type": "string",
|
|
2059
|
+
"description": "Download quality: 'low', 'medium', or 'high'.",
|
|
2060
|
+
"default": "medium",
|
|
2061
|
+
},
|
|
2062
|
+
"spacing": {
|
|
2063
|
+
"type": "number",
|
|
2064
|
+
"description": "Spacing in metres between imported assets along X axis.",
|
|
2065
|
+
"default": 3.0,
|
|
2066
|
+
},
|
|
2067
|
+
"my_assets_only": {
|
|
2068
|
+
"type": "boolean",
|
|
2069
|
+
"description": (
|
|
2070
|
+
"If true, search only assets you own on Megascans (view=myscans). "
|
|
2071
|
+
"Default false — searches the full Megascans catalog so missing "
|
|
2072
|
+
"local assets can be found and downloaded automatically."
|
|
2073
|
+
),
|
|
2074
|
+
"default": False,
|
|
2075
|
+
},
|
|
2076
|
+
"allow_download": {
|
|
2077
|
+
"type": "boolean",
|
|
2078
|
+
"description": (
|
|
2079
|
+
"When true (default), the pipeline supplements local results with "
|
|
2080
|
+
"Megascans API downloads whenever fewer than top_k assets are found "
|
|
2081
|
+
"locally. Set to false to restrict to local sources only."
|
|
2082
|
+
),
|
|
2083
|
+
"default": True,
|
|
2084
|
+
},
|
|
2085
|
+
"force_online": {
|
|
2086
|
+
"type": "boolean",
|
|
2087
|
+
"description": (
|
|
2088
|
+
"When true, always queries Quixel Bridge and the Megascans API even "
|
|
2089
|
+
"when the local catalog already returned top_k results. Use this to "
|
|
2090
|
+
"refresh stale local results or to merge online assets into the scene."
|
|
2091
|
+
),
|
|
2092
|
+
"default": False,
|
|
2093
|
+
},
|
|
2094
|
+
"environment": {
|
|
2095
|
+
"type": "string",
|
|
2096
|
+
"description": (
|
|
2097
|
+
"Target environment name for semantic layout "
|
|
2098
|
+
"(e.g. 'western_room', 'industrial_hangar', 'robotics_lab'). "
|
|
2099
|
+
"Auto-detected from intent if omitted."
|
|
2100
|
+
),
|
|
2101
|
+
"default": "",
|
|
2102
|
+
},
|
|
2103
|
+
"room_half_width": {
|
|
2104
|
+
"type": "number",
|
|
2105
|
+
"description": (
|
|
2106
|
+
"Half-width of the room boundary in metres used for "
|
|
2107
|
+
"collision and constraint solving. Default 5.0 (10 m room)."
|
|
2108
|
+
),
|
|
2109
|
+
"default": 5.0,
|
|
2110
|
+
},
|
|
2111
|
+
},
|
|
2112
|
+
},
|
|
2113
|
+
handler=_handle_build_scene_from_assets,
|
|
2114
|
+
category="execution",
|
|
2115
|
+
),
|
|
2116
|
+
ToolDefinition(
|
|
2117
|
+
name="review_execution",
|
|
2118
|
+
description=(
|
|
2119
|
+
"Post-execution review: compare the actual execution result against "
|
|
2120
|
+
"the original plan, compute intent-match score, and return findings "
|
|
2121
|
+
"and recommendations. Always call after execute_workflow_transaction."
|
|
2122
|
+
),
|
|
2123
|
+
inputSchema={
|
|
2124
|
+
"type": "object",
|
|
2125
|
+
"required": ["execution_result_json"],
|
|
2126
|
+
"properties": {
|
|
2127
|
+
"execution_result_json": {
|
|
2128
|
+
"type": "string",
|
|
2129
|
+
"description": "JSON-serialised result dict from execute_workflow_transaction.",
|
|
2130
|
+
},
|
|
2131
|
+
"plan_json": {
|
|
2132
|
+
"type": "string",
|
|
2133
|
+
"description": "JSON-serialised plan dict from plan_scene (optional but recommended).",
|
|
2134
|
+
},
|
|
2135
|
+
},
|
|
2136
|
+
},
|
|
2137
|
+
handler=_handle_review_execution,
|
|
2138
|
+
category="execution",
|
|
2139
|
+
),
|
|
2140
|
+
]
|
|
2141
|
+
|
|
2142
|
+
for defn in _tools:
|
|
2143
|
+
registry.register_tool(defn)
|
|
2144
|
+
if transport is not None:
|
|
2145
|
+
transport.register_tool(defn)
|
|
2146
|
+
|
|
2147
|
+
return registry
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
# ---------------------------------------------------------------------------
|
|
2151
|
+
# Singleton
|
|
2152
|
+
# ---------------------------------------------------------------------------
|
|
2153
|
+
|
|
2154
|
+
_INSTANCE: Optional[MCPToolRegistry] = None
|
|
2155
|
+
_LOCK = threading.Lock()
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
def get_mcp_tool_registry() -> MCPToolRegistry:
|
|
2159
|
+
global _INSTANCE
|
|
2160
|
+
with _LOCK:
|
|
2161
|
+
if _INSTANCE is None:
|
|
2162
|
+
_INSTANCE = MCPToolRegistry()
|
|
2163
|
+
return _INSTANCE
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
def reset_mcp_tool_registry_for_tests() -> None:
|
|
2167
|
+
global _INSTANCE
|
|
2168
|
+
with _LOCK:
|
|
2169
|
+
_INSTANCE = None
|