agentscape3d-engine 0.0.0-stage → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/cli.mjs +53 -0
  4. package/dist/AssetCompiler-A99wKf7H.js +2424 -0
  5. package/dist/AssetCompiler-A99wKf7H.js.map +1 -0
  6. package/dist/AssetInputContracts-uKYeQu-X.js +245 -0
  7. package/dist/AssetInputContracts-uKYeQu-X.js.map +1 -0
  8. package/dist/AssetRecipe-DCaLLXvG.js +67 -0
  9. package/dist/AssetRecipe-DCaLLXvG.js.map +1 -0
  10. package/dist/BrowserCodeWorker.js +53850 -0
  11. package/dist/BrowserCodeWorker.js.map +1 -0
  12. package/dist/KinematicHypothesisScreen-4v7GBwdv.js +241 -0
  13. package/dist/KinematicHypothesisScreen-4v7GBwdv.js.map +1 -0
  14. package/dist/SceneSerializer-CLCzQjL_.js +350 -0
  15. package/dist/SceneSerializer-CLCzQjL_.js.map +1 -0
  16. package/dist/StylePack-CD_BC-Mv.js +6317 -0
  17. package/dist/StylePack-CD_BC-Mv.js.map +1 -0
  18. package/dist/WorldArchive-dYf1OpSe.js +417 -0
  19. package/dist/WorldArchive-dYf1OpSe.js.map +1 -0
  20. package/dist/WorldIO-Dqz4MqTQ.js +149 -0
  21. package/dist/WorldIO-Dqz4MqTQ.js.map +1 -0
  22. package/dist/blankWorld-OoOvN_IK.js +75 -0
  23. package/dist/blankWorld-OoOvN_IK.js.map +1 -0
  24. package/dist/core.d.ts +68 -0
  25. package/dist/core.js +209 -0
  26. package/dist/core.js.map +1 -0
  27. package/dist/disposeObject3D-B3HCflvO.js +128 -0
  28. package/dist/disposeObject3D-B3HCflvO.js.map +1 -0
  29. package/dist/environments-B1WaICAN.js +4197 -0
  30. package/dist/environments-B1WaICAN.js.map +1 -0
  31. package/dist/gltfIO-BMK1hc2D.js +9 -0
  32. package/dist/gltfIO-BMK1hc2D.js.map +1 -0
  33. package/dist/grandUrbanBlock-Bdjgc6ZT.js +515 -0
  34. package/dist/grandUrbanBlock-Bdjgc6ZT.js.map +1 -0
  35. package/dist/index.d.ts +275 -0
  36. package/dist/index.js +16239 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/magicCabin-DPQi_jh-.js +11019 -0
  39. package/dist/magicCabin-DPQi_jh-.js.map +1 -0
  40. package/dist/mcp.d.ts +2 -0
  41. package/dist/mcp.js +1 -0
  42. package/dist/monumentHall-IOLbRZQC.js +403 -0
  43. package/dist/monumentHall-IOLbRZQC.js.map +1 -0
  44. package/dist/node.d.ts +16 -0
  45. package/dist/node.js +26 -0
  46. package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
  47. package/dist/ruinedCourtyard-BtaF_aOi.js +696 -0
  48. package/dist/ruinedCourtyard-BtaF_aOi.js.map +1 -0
  49. package/dist/runtime/application/AgentTools.js +28 -0
  50. package/dist/runtime/application/README.md +14 -0
  51. package/dist/runtime/application/agent/ProgressiveAgentTools.js +92 -0
  52. package/dist/runtime/application/agent/StudioMcpAllowlist.js +8 -0
  53. package/dist/runtime/application/buildTaskObservation.js +117 -0
  54. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +46 -0
  55. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +35 -0
  56. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +17 -0
  57. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +72 -0
  58. package/dist/runtime/application/createSession.js +66 -0
  59. package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
  60. package/dist/runtime/application/generation/GenerationOrchestrator.js +629 -0
  61. package/dist/runtime/application/generation/GenerationRuntime.js +214 -0
  62. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +285 -0
  63. package/dist/runtime/application/native-scene/CodeProject.js +119 -0
  64. package/dist/runtime/application/native-scene/CodeProjectModules.js +128 -0
  65. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +62 -0
  66. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
  67. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
  68. package/dist/runtime/application/native-scene/NativeSceneHost.js +319 -0
  69. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
  70. package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
  71. package/dist/runtime/application/object-forge/SceneObjectForge.js +232 -0
  72. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +59 -0
  73. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +22 -0
  74. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +40 -0
  75. package/dist/runtime/application/scene/CapabilityResolver.js +79 -0
  76. package/dist/runtime/application/scene/RequestWindow.js +54 -0
  77. package/dist/runtime/application/scene/SceneAgentTools.js +21 -0
  78. package/dist/runtime/application/scene/SceneContracts.js +45 -0
  79. package/dist/runtime/application/scene/SceneEditService.js +144 -0
  80. package/dist/runtime/application/scene/SceneFacade.js +261 -0
  81. package/dist/runtime/application/scene/SceneInteractionAdapters.js +40 -0
  82. package/dist/runtime/application/scene/SceneJobController.js +229 -0
  83. package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
  84. package/dist/runtime/application/scene/ScenePackage.js +162 -0
  85. package/dist/runtime/application/scene/ScenePersistence.js +50 -0
  86. package/dist/runtime/application/scene/SceneProject.js +95 -0
  87. package/dist/runtime/application/scene/SceneSkillNames.js +5 -0
  88. package/dist/runtime/application/scene/StarterScene.js +56 -0
  89. package/dist/runtime/application/scene/WorldArchive.js +87 -0
  90. package/dist/runtime/application/scene/WorldDirectory.js +20 -0
  91. package/dist/runtime/application/scene/WorldDocument.js +74 -0
  92. package/dist/runtime/application/scene/WorldIO.js +103 -0
  93. package/dist/runtime/application/scene/WorldStorage.js +137 -0
  94. package/dist/runtime/application/skills/SkillRegistry.js +189 -0
  95. package/dist/runtime/application/skills/packs/acceptanceSkills.js +32 -0
  96. package/dist/runtime/application/skills/packs/affordanceSkills.js +36 -0
  97. package/dist/runtime/application/skills/packs/assetSkills.js +46 -0
  98. package/dist/runtime/application/skills/packs/authoringSkills.js +16 -0
  99. package/dist/runtime/application/skills/packs/batchSkills.js +22 -0
  100. package/dist/runtime/application/skills/packs/codeSkills.js +106 -0
  101. package/dist/runtime/application/skills/packs/generationSkills.js +45 -0
  102. package/dist/runtime/application/skills/packs/interactionSkills.js +46 -0
  103. package/dist/runtime/application/skills/packs/recoverySkills.js +80 -0
  104. package/dist/runtime/application/skills/packs/sceneSkills.js +24 -0
  105. package/dist/runtime/application/skills/packs/spatialSkills.js +35 -0
  106. package/dist/runtime/application/skills/packs/verificationSkills.js +14 -0
  107. package/dist/runtime/application/skills/packs/worldSkills.js +45 -0
  108. package/dist/runtime/application/skills/registerCoreSkills.js +31 -0
  109. package/dist/runtime/application/skills/skillPrimitives.js +4 -0
  110. package/dist/runtime/application/tasks/CabinetCupTask.js +76 -0
  111. package/dist/runtime/application/tasks.jsonl +67 -0
  112. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +42 -0
  113. package/dist/runtime/application/world-authoring/AuthoringDiff.js +149 -0
  114. package/dist/runtime/application/world-authoring/AuthoringDocument.js +825 -0
  115. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +109 -0
  116. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +17 -0
  117. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +29 -0
  118. package/dist/runtime/application/world-authoring/AuthoringPatch.js +118 -0
  119. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +334 -0
  120. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +126 -0
  121. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +144 -0
  122. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +174 -0
  123. package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
  124. package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
  125. package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +77 -0
  126. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +1 -0
  127. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +30 -0
  128. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +17 -0
  129. package/dist/runtime/apps/mcp-server/CodeExecutor.js +71 -0
  130. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +42 -0
  131. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +66 -0
  132. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +159 -0
  133. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +8 -0
  134. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +47 -0
  135. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +132 -0
  136. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +6 -0
  137. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +116 -0
  138. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +60 -0
  139. package/dist/runtime/apps/mcp-server/README.md +150 -0
  140. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +1 -0
  141. package/dist/runtime/apps/mcp-server/SandboxBundle.js +13 -0
  142. package/dist/runtime/apps/mcp-server/SessionManager.js +80 -0
  143. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +58 -0
  144. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +190 -0
  145. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +16 -0
  146. package/dist/runtime/apps/mcp-server/VALIDATION.md +45 -0
  147. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +332 -0
  148. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +32 -0
  149. package/dist/runtime/apps/mcp-server/examples/code-house.js +24 -0
  150. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +85 -0
  151. package/dist/runtime/apps/mcp-server/main.mjs +65 -0
  152. package/dist/runtime/apps/mcp-server/registerTools.js +225 -0
  153. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
  154. package/dist/runtime/apps/mcp-server/security.js +21 -0
  155. package/dist/runtime/apps/mcp-server/tasks.jsonl +9 -0
  156. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +157 -0
  157. package/dist/runtime/apps/server/README.md +7 -0
  158. package/dist/runtime/apps/server/WorldDiskStorage.js +51 -0
  159. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +278 -0
  160. package/dist/runtime/apps/server/tasks.jsonl +10 -0
  161. package/dist/runtime/foundation/EventBus.js +18 -0
  162. package/dist/runtime/foundation/JsonGateway.js +47 -0
  163. package/dist/runtime/foundation/PolicyEngine.js +21 -0
  164. package/dist/runtime/foundation/README.md +7 -0
  165. package/dist/runtime/foundation/TraceRecorder.js +76 -0
  166. package/dist/runtime/foundation/errors.js +8 -0
  167. package/dist/runtime/foundation/simulation/SimulationProfile.js +143 -0
  168. package/dist/runtime/foundation/version.js +2 -0
  169. package/dist/runtime/modules/agent/README.md +11 -0
  170. package/dist/runtime/modules/agent/ToolCallingAgent.js +19 -0
  171. package/dist/runtime/modules/agent/bootstrapWorld.js +10 -0
  172. package/dist/runtime/modules/agent/buildRecoveryProposals.js +533 -0
  173. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +128 -0
  174. package/dist/runtime/modules/agent/execution/AgentRunResults.js +55 -0
  175. package/dist/runtime/modules/agent/execution/AgentRunSession.js +393 -0
  176. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +40 -0
  177. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +19 -0
  178. package/dist/runtime/modules/agent/prompt/index.js +52 -0
  179. package/dist/runtime/modules/agent/tasks.jsonl +94 -0
  180. package/dist/runtime/modules/artifact/ArtifactContentGate.js +144 -0
  181. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +280 -0
  182. package/dist/runtime/modules/artifact/ArtifactImporter.js +185 -0
  183. package/dist/runtime/modules/artifact/ArtifactModule.js +111 -0
  184. package/dist/runtime/modules/artifact/ArtifactRegistry.js +197 -0
  185. package/dist/runtime/modules/artifact/IncrementalSha256.js +129 -0
  186. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +115 -0
  187. package/dist/runtime/modules/artifact/README.md +7 -0
  188. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +67 -0
  189. package/dist/runtime/modules/artifact/tasks.jsonl +31 -0
  190. package/dist/runtime/modules/asset/AssetModule.js +399 -0
  191. package/dist/runtime/modules/asset/README.md +54 -0
  192. package/dist/runtime/modules/asset/loading/AssetLoader.js +157 -0
  193. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +61 -0
  194. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +95 -0
  195. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +33 -0
  196. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +103 -0
  197. package/dist/runtime/modules/asset/model/AssetInputContracts.js +100 -0
  198. package/dist/runtime/modules/asset/model/AssetRef.js +12 -0
  199. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +172 -0
  200. package/dist/runtime/modules/asset/model/admission.js +117 -0
  201. package/dist/runtime/modules/asset/model/errors.js +6 -0
  202. package/dist/runtime/modules/asset/model/parts.js +27 -0
  203. package/dist/runtime/modules/asset/model/resourceBudget.js +10 -0
  204. package/dist/runtime/modules/asset/model/schema.js +150 -0
  205. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +78 -0
  206. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +84 -0
  207. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +86 -0
  208. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +81 -0
  209. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +272 -0
  210. package/dist/runtime/modules/asset/production/AssetRecipe.js +47 -0
  211. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +45 -0
  212. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +590 -0
  213. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +173 -0
  214. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +124 -0
  215. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +56 -0
  216. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +6 -0
  217. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +74 -0
  218. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +63 -0
  219. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +48 -0
  220. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +16 -0
  221. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +30 -0
  222. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +75 -0
  223. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +20 -0
  224. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +34 -0
  225. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +32 -0
  226. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +116 -0
  227. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +84 -0
  228. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +63 -0
  229. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +16 -0
  230. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +23 -0
  231. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +50 -0
  232. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +60 -0
  233. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +93 -0
  234. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +32 -0
  235. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +55 -0
  236. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +203 -0
  237. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +43 -0
  238. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +33 -0
  239. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +60 -0
  240. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +23 -0
  241. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +198 -0
  242. package/dist/runtime/modules/asset/registry/AssetCatalog.js +72 -0
  243. package/dist/runtime/modules/asset/registry/AssetRegistry.js +51 -0
  244. package/dist/runtime/modules/asset/registry/manifests/index.js +173 -0
  245. package/dist/runtime/modules/asset/tasks.jsonl +87 -0
  246. package/dist/runtime/modules/generation/README.md +9 -0
  247. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +45 -0
  248. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +169 -0
  249. package/dist/runtime/modules/generation/connector/ConnectorClient.js +192 -0
  250. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +167 -0
  251. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +179 -0
  252. package/dist/runtime/modules/generation/connector/ConnectorSession.js +202 -0
  253. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +239 -0
  254. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +99 -0
  255. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +91 -0
  256. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +50 -0
  257. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +304 -0
  258. package/dist/runtime/modules/generation/tasks.jsonl +35 -0
  259. package/dist/runtime/modules/navigation/NavigationBackend.js +17 -0
  260. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +245 -0
  261. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
  262. package/dist/runtime/modules/physics/PhysicsApiSurface.js +651 -0
  263. package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
  264. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +410 -0
  265. package/dist/runtime/modules/rendering/README.md +7 -0
  266. package/dist/runtime/modules/rendering/RendererProbe.js +153 -0
  267. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +140 -0
  268. package/dist/runtime/modules/rendering/createRenderer.js +76 -0
  269. package/dist/runtime/modules/rendering/disposeObject3D.js +37 -0
  270. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +74 -0
  271. package/dist/runtime/modules/rendering/spatial/ThreeBvhRuntime.js +107 -0
  272. package/dist/runtime/modules/rendering/style/StylePack.js +34 -0
  273. package/dist/runtime/modules/rendering/style/StyleSystem.js +173 -0
  274. package/dist/runtime/modules/rendering/tasks.jsonl +7 -0
  275. package/dist/runtime/modules/world/README.md +13 -0
  276. package/dist/runtime/modules/world/build/WorldBuilder.js +170 -0
  277. package/dist/runtime/modules/world/compiler/PipelineEngine.js +32 -0
  278. package/dist/runtime/modules/world/compiler/WorldAdmission.js +43 -0
  279. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +68 -0
  280. package/dist/runtime/modules/world/compiler/WorldCompilation.js +157 -0
  281. package/dist/runtime/modules/world/compiler/WorldComposer.js +201 -0
  282. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +76 -0
  283. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +356 -0
  284. package/dist/runtime/modules/world/compiler/WorldRetry.js +75 -0
  285. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +379 -0
  286. package/dist/runtime/modules/world/content/blankWorld.js +35 -0
  287. package/dist/runtime/modules/world/content/environments.js +84 -0
  288. package/dist/runtime/modules/world/content/grandUrbanBlock.js +189 -0
  289. package/dist/runtime/modules/world/content/magic-cabin/README.md +28 -0
  290. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +64 -0
  291. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +7078 -0
  292. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +26 -0
  293. package/dist/runtime/modules/world/content/magic-cabin/materials.js +20 -0
  294. package/dist/runtime/modules/world/content/magicCabin.js +190 -0
  295. package/dist/runtime/modules/world/content/monumentHall.js +154 -0
  296. package/dist/runtime/modules/world/content/ruinedCourtyard.js +196 -0
  297. package/dist/runtime/modules/world/content/suzhouGarden/README.md +141 -0
  298. package/dist/runtime/modules/world/content/suzhouGarden/index.js +137 -0
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +491 -0
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +670 -0
  301. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +578 -0
  302. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +127 -0
  303. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +642 -0
  304. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +650 -0
  305. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +280 -0
  306. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +242 -0
  307. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +215 -0
  308. package/dist/runtime/modules/world/content/woodlandWorkshop.js +192 -0
  309. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +36 -0
  310. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +351 -0
  311. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +490 -0
  312. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +505 -0
  313. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +101 -0
  314. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +435 -0
  315. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +169 -0
  316. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +245 -0
  317. package/dist/runtime/modules/world/errors.js +9 -0
  318. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +50 -0
  319. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +297 -0
  320. package/dist/runtime/modules/world/runtime/CommandHistory.js +80 -0
  321. package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +150 -0
  322. package/dist/runtime/modules/world/runtime/ObjectStore.js +31 -0
  323. package/dist/runtime/modules/world/runtime/ObjectTransform.js +62 -0
  324. package/dist/runtime/modules/world/runtime/ObservedEntity.js +37 -0
  325. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +207 -0
  326. package/dist/runtime/modules/world/runtime/SceneSerializer.js +246 -0
  327. package/dist/runtime/modules/world/runtime/WorldAuthority.js +41 -0
  328. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +14 -0
  329. package/dist/runtime/modules/world/runtime/WorldCommands.js +502 -0
  330. package/dist/runtime/modules/world/runtime/WorldObservation.js +71 -0
  331. package/dist/runtime/modules/world/runtime/WorldQueries.js +340 -0
  332. package/dist/runtime/modules/world/runtime/WorldRecovery.js +78 -0
  333. package/dist/runtime/modules/world/runtime/WorldRuntime.js +665 -0
  334. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +107 -0
  335. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +130 -0
  336. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +79 -0
  337. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +195 -0
  338. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +70 -0
  339. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +115 -0
  340. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +305 -0
  341. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +214 -0
  342. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +65 -0
  343. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +222 -0
  344. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +130 -0
  345. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
  346. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
  347. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +120 -0
  348. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +102 -0
  349. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
  350. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +99 -0
  351. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
  352. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
  353. package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +125 -0
  354. package/dist/runtime/modules/world/runtime/systems/Instrument.js +38 -0
  355. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +728 -0
  356. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +269 -0
  357. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +469 -0
  358. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1673 -0
  359. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +457 -0
  360. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +284 -0
  361. package/dist/runtime/modules/world/spec/WorldIR.js +165 -0
  362. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +86 -0
  363. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +51 -0
  364. package/dist/runtime/modules/world/spec/WorldRevision.js +231 -0
  365. package/dist/runtime/modules/world/spec/WorldSpec.js +86 -0
  366. package/dist/runtime/modules/world/tasks.jsonl +530 -0
  367. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +254 -0
  368. package/dist/runtime/modules/world/verification/Finding.js +105 -0
  369. package/dist/runtime/modules/world/verification/InteractionEvidence.js +69 -0
  370. package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
  371. package/dist/runtime/modules/world/verification/WorldAcceptance.js +158 -0
  372. package/dist/runtime/modules/world/verification/WorldValidator.js +65 -0
  373. package/dist/runtime/package-lock.json +16048 -0
  374. package/dist/runtime/package.json +105 -0
  375. package/dist/runtime/public/assets/cabinet.glb +0 -0
  376. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  377. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  379. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  380. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  381. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  382. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  383. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  384. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  385. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  386. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  387. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  388. package/dist/schema-BWpTl0Wj.js +359 -0
  389. package/dist/schema-BWpTl0Wj.js.map +1 -0
  390. package/dist/suzhouGarden-H9tiPgxq.js +6150 -0
  391. package/dist/suzhouGarden-H9tiPgxq.js.map +1 -0
  392. package/dist/woodlandWorkshop-D6zzSbHr.js +483 -0
  393. package/dist/woodlandWorkshop-D6zzSbHr.js.map +1 -0
  394. package/dist/yuanmingyuan-D6IHqjZ-.js +4955 -0
  395. package/dist/yuanmingyuan-D6IHqjZ-.js.map +1 -0
  396. package/package.json +70 -4
@@ -0,0 +1,590 @@
1
+ const HEX_SHA256 = /^[0-9a-f]{64}$/i;
2
+ const JOB_ID = /^job-[0-9a-f]{32}$/;
3
+ const SAFE_LINEAGE_KEYS = new Set(['providerCommit','modalBuildCommit','embodiedGenCommit','workflow','workflowVersion','modelRevision','seed']);
4
+
5
+ const safeRelativeRef = (value, label) => {
6
+ if (value == null) return undefined;
7
+ const text=String(value).trim();
8
+ const segments=text.split('/');
9
+ if (!text || text.length > 512 || text.includes('://') || text.includes('?') || text.includes('#') || text.startsWith('/') || text.includes('\\') || segments.includes('..')) {
10
+ fail('EMBODIEDGEN_ARTIFACT_REFERENCE_INVALID', `${label} must be a bounded relative reference without URL/query data.`);
11
+ }
12
+ return text;
13
+ };
14
+
15
+ const safeLineage = (value) => {
16
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
17
+ const out={};
18
+ for (const [key,item] of Object.entries(value)) {
19
+ if (!SAFE_LINEAGE_KEYS.has(key)) continue;
20
+ if (typeof item === 'string' && item.length <= 256 && !/https?:\/\//i.test(item)) out[key]=item;
21
+ else if (typeof item === 'number' && Number.isFinite(item)) out[key]=item;
22
+ else if (typeof item === 'boolean') out[key]=item;
23
+ }
24
+ return Object.keys(out).length ? out : null;
25
+ };
26
+
27
+ const fail = (code, message, details = undefined) => {
28
+ const error = new Error(message);
29
+ error.code = code;
30
+ if (details !== undefined) error.details = details;
31
+ throw error;
32
+ };
33
+
34
+ const normalizeBytes = (value, label) => {
35
+ if (value instanceof Uint8Array) return value;
36
+ if (value instanceof ArrayBuffer) return new Uint8Array(value);
37
+ if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
38
+ fail('EMBODIEDGEN_ARTIFACT_BYTES_MISSING', `Missing bytes for ${label}.`);
39
+ };
40
+
41
+ const sha256Hex = async (bytes) => {
42
+ const subtle = globalThis.crypto?.subtle;
43
+ if (!subtle) fail('EMBODIEDGEN_CRYPTO_UNAVAILABLE', 'WebCrypto SHA-256 is unavailable.');
44
+ const digest = new Uint8Array(await subtle.digest('SHA-256', bytes));
45
+ return Array.from(digest, (value) => value.toString(16).padStart(2, '0')).join('');
46
+ };
47
+
48
+ const artifactBytesFor = (artifactBytes, descriptor) => {
49
+ if (artifactBytes instanceof Map) return artifactBytes.get(descriptor.id) ?? artifactBytes.get(descriptor.role);
50
+ if (artifactBytes && typeof artifactBytes === 'object') return artifactBytes[descriptor.id] ?? artifactBytes[descriptor.role];
51
+ return undefined;
52
+ };
53
+
54
+ const assertDescriptor = (descriptor, seenIds, seenRoles) => {
55
+ if (!descriptor || typeof descriptor !== 'object') fail('EMBODIEDGEN_ARTIFACT_DESCRIPTOR_INVALID', 'Artifact descriptor must be an object.');
56
+ const id = String(descriptor.id || '').trim();
57
+ const role = String(descriptor.role || '').trim();
58
+ const mediaType = String(descriptor.mediaType || descriptor.mime || '').trim().toLowerCase();
59
+ const sha256 = String(descriptor.sha256 || '').trim().toLowerCase();
60
+ if (!id || !role || !mediaType || !HEX_SHA256.test(sha256)) {
61
+ fail('EMBODIEDGEN_ARTIFACT_DESCRIPTOR_INVALID', 'Artifact descriptor requires id, role, mediaType and SHA-256.', { id:id || null, role:role || null });
62
+ }
63
+ if (seenIds.has(id)) fail('EMBODIEDGEN_ARTIFACT_ID_DUPLICATE', `Duplicate artifact id: ${id}`);
64
+ if (seenRoles.has(role)) fail('EMBODIEDGEN_ARTIFACT_ROLE_DUPLICATE', `Duplicate artifact role: ${role}`);
65
+ seenIds.add(id); seenRoles.add(role);
66
+ return {
67
+ id, role, mediaType, sha256,
68
+ ...(descriptor.fileName ? { fileName:safeRelativeRef(descriptor.fileName, `${id}.fileName`) } : {}),
69
+ ...(descriptor.path ? { path:safeRelativeRef(descriptor.path, `${id}.path`) } : {}),
70
+ ...(Number.isInteger(descriptor.bytes) && descriptor.bytes >= 0 ? { bytes:descriptor.bytes } : {})
71
+ };
72
+ };
73
+
74
+ const assertHash = async (descriptor, bytes) => {
75
+ if (Number.isInteger(descriptor.bytes) && descriptor.bytes !== bytes.byteLength) {
76
+ fail('EMBODIEDGEN_ARTIFACT_SIZE_MISMATCH', `Artifact byte size mismatch for ${descriptor.id}.`, { expected:descriptor.bytes, actual:bytes.byteLength });
77
+ }
78
+ const actual = await sha256Hex(bytes);
79
+ if (actual !== descriptor.sha256) {
80
+ fail('EMBODIEDGEN_ARTIFACT_HASH_MISMATCH', `Artifact SHA-256 mismatch for ${descriptor.id}.`, { expected:descriptor.sha256, actual });
81
+ }
82
+ return actual;
83
+ };
84
+
85
+ const parseJsonArtifact = (descriptor, bytes) => {
86
+ if (!['application/json', 'application/vnd.agentscape.part-segmentation+json'].includes(descriptor.mediaType)) {
87
+ fail('EMBODIEDGEN_ARTIFACT_MEDIA_TYPE_INVALID', `Unsupported JSON artifact media type for ${descriptor.role}: ${descriptor.mediaType}`);
88
+ }
89
+ try { return JSON.parse(new TextDecoder().decode(bytes)); }
90
+ catch (error) { fail('EMBODIEDGEN_ARTIFACT_JSON_INVALID', `Invalid JSON artifact for ${descriptor.role}: ${error.message}`); }
91
+ };
92
+
93
+ const validateSegmentation = (evidence, primary) => {
94
+ if (!evidence || evidence.version !== 1 || !evidence.source || !Number.isInteger(evidence.faceCount) || evidence.faceCount <= 0 || !Array.isArray(evidence.segments)) {
95
+ fail('EMBODIEDGEN_SEGMENTATION_INVALID', 'Part segmentation must be Segmentation Evidence v1.');
96
+ }
97
+ const boundSha = String(evidence.artifact?.sha256 || '').toLowerCase();
98
+ if (!HEX_SHA256.test(boundSha) || boundSha !== primary.sha256) {
99
+ fail('EMBODIEDGEN_SEGMENTATION_GLB_MISMATCH', 'Part segmentation is not bound to the primary GLB SHA-256.', { primarySha256:primary.sha256, segmentationGlbSha256:boundSha || null });
100
+ }
101
+ const materialization = evidence.materialization;
102
+ if (!materialization?.sourceNode || !Array.isArray(materialization.primitives) || !materialization.primitives.length) {
103
+ fail('EMBODIEDGEN_SEGMENTATION_MATERIALIZATION_INVALID', 'Part segmentation requires sourceNode and primitive face labels.');
104
+ }
105
+ for (const entry of materialization.primitives) {
106
+ if (!Number.isInteger(entry?.primitive) || entry.primitive < 0 || !Array.isArray(entry.faceLabels) || !entry.faceLabels.length) {
107
+ fail('EMBODIEDGEN_SEGMENTATION_MATERIALIZATION_INVALID', 'Each segmentation primitive requires primitive>=0 and non-empty faceLabels[].');
108
+ }
109
+ }
110
+ };
111
+
112
+
113
+ const GRASP_MAX_BYTES = 2 * 1024 * 1024;
114
+ const GRASP_MAX_CANDIDATES = 256;
115
+ const GRASP_SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$/;
116
+ const FORBIDDEN_GRASP_KEYS = /(actions?|pickup|held|runtime[-_]?verified|(^|[_-])verified($|[_-])|authorization|api[-_]?key|token|secret|credential|signed[-_]?url|(^|[_-])url($|[_-])|(^|[_-])path($|[_-])|prompt|image[-_]?bytes|base64)/i;
117
+
118
+ const safeGraspText=(value,label,max=160)=>{
119
+ const text=String(value ?? '').trim();
120
+ if (!text || text.length>max || /[\u0000-\u001f\u007f]/.test(text) || /https?:\/\/|Bearer\s+/i.test(text)) {
121
+ fail('EMBODIEDGEN_GRASP_INVALID',`${label} must be bounded safe text.`);
122
+ }
123
+ return text;
124
+ };
125
+
126
+ const rejectForbiddenGraspFields=(value,path='graspEvidence')=>{
127
+ if (!value || typeof value!=='object') return;
128
+ if (Array.isArray(value)) {
129
+ value.forEach((item,index)=>rejectForbiddenGraspFields(item,`${path}[${index}]`));
130
+ return;
131
+ }
132
+ for (const [key,item] of Object.entries(value)) {
133
+ if (FORBIDDEN_GRASP_KEYS.test(key)) {
134
+ fail('EMBODIEDGEN_GRASP_FORBIDDEN_FIELD',`Grasp evidence contains forbidden execution/transport field: ${path}.${key}`);
135
+ }
136
+ rejectForbiddenGraspFields(item,`${path}.${key}`);
137
+ }
138
+ };
139
+
140
+ const determinant3=(m)=>
141
+ m[0][0]*(m[1][1]*m[2][2]-m[1][2]*m[2][1])-
142
+ m[0][1]*(m[1][0]*m[2][2]-m[1][2]*m[2][0])+
143
+ m[0][2]*(m[1][0]*m[2][1]-m[1][1]*m[2][0]);
144
+ const dot3=(a,b)=>a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
145
+ const rigidGraspPose=(value,label)=>{
146
+ if (!Array.isArray(value) || value.length!==4 || value.some((row)=>!Array.isArray(row)||row.length!==4||!row.every(Number.isFinite))) {
147
+ fail('EMBODIEDGEN_GRASP_INVALID',`${label} requires finite 4x4 pose.`);
148
+ }
149
+ const pose=value.map((row)=>row.map(Number));
150
+ const tail=pose[3];
151
+ if (Math.abs(tail[0])>1e-6 || Math.abs(tail[1])>1e-6 || Math.abs(tail[2])>1e-6 || Math.abs(tail[3]-1)>1e-6) {
152
+ fail('EMBODIEDGEN_GRASP_INVALID',`${label} must be affine with [0,0,0,1] final row.`);
153
+ }
154
+ const r=pose.slice(0,3).map((row)=>row.slice(0,3));
155
+ for (let i=0;i<3;i++) {
156
+ if (Math.abs(dot3(r[i],r[i])-1)>1e-3) fail('EMBODIEDGEN_GRASP_INVALID',`${label} rotation rows must be unit length.`);
157
+ for (let j=i+1;j<3;j++) if (Math.abs(dot3(r[i],r[j]))>1e-3) fail('EMBODIEDGEN_GRASP_INVALID',`${label} rotation rows must be orthogonal.`);
158
+ }
159
+ if (Math.abs(determinant3(r)-1)>1e-3) fail('EMBODIEDGEN_GRASP_INVALID',`${label} rotation must be right-handed.`);
160
+ for (let i=0;i<3;i++) if (Math.abs(pose[i][3])>1e6) fail('EMBODIEDGEN_GRASP_INVALID',`${label} translation exceeds bounded evidence range.`);
161
+ return pose;
162
+ };
163
+
164
+ const normalizeGraspEvidence=(payload,{role,descriptor,bundleSourceJobId=null})=>{
165
+ if (!payload || typeof payload!=='object' || Array.isArray(payload) || payload.version!==1 || !Array.isArray(payload.grasps)) {
166
+ fail('EMBODIEDGEN_GRASP_INVALID',`${role} must be Grasp Evidence v1 with grasps[].`);
167
+ }
168
+ rejectForbiddenGraspFields(payload);
169
+ if (payload.grasps.length>GRASP_MAX_CANDIDATES) fail('EMBODIEDGEN_GRASP_INVALID',`${role} exceeds ${GRASP_MAX_CANDIDATES} grasp candidates.`);
170
+ const expectedLevel=role==='sapien_grasps'?'simulator-validated':'raw';
171
+ if (String(payload.evidence_level||'')!==expectedLevel) {
172
+ fail('EMBODIEDGEN_GRASP_INVALID',`${role} requires evidence_level=${expectedLevel}.`);
173
+ }
174
+ const sourceJobId=payload.source_job_id==null?null:String(payload.source_job_id).trim();
175
+ const outputJobId=payload.output_job_id==null?null:String(payload.output_job_id).trim();
176
+ if (sourceJobId && !JOB_ID.test(sourceJobId)) fail('EMBODIEDGEN_GRASP_INVALID',`${role} source_job_id is invalid.`);
177
+ if (outputJobId && !JOB_ID.test(outputJobId)) fail('EMBODIEDGEN_GRASP_INVALID',`${role} output_job_id is invalid.`);
178
+ if (bundleSourceJobId && sourceJobId && sourceJobId!==bundleSourceJobId) {
179
+ fail('EMBODIEDGEN_GRASP_SOURCE_MISMATCH',`${role} source_job_id does not match bundle sourceJobId.`,{bundleSourceJobId,graspSourceJobId:sourceJobId});
180
+ }
181
+ const gripper=safeGraspText(payload.gripper,`${role}.gripper`,120);
182
+ if (!GRASP_SAFE_ID.test(gripper)) fail('EMBODIEDGEN_GRASP_INVALID',`${role}.gripper must be a stable identifier.`);
183
+ const sourceFrame=safeGraspText(payload.source_frame,`${role}.source_frame`,160);
184
+ const backend=safeGraspText(payload.backend,`${role}.backend`,120);
185
+ const seenRanks=new Set();
186
+ let topScore=null;
187
+ payload.grasps.forEach((grasp,index)=>{
188
+ if (!grasp || typeof grasp!=='object' || Array.isArray(grasp)) fail('EMBODIEDGEN_GRASP_INVALID',`${role}.grasps[${index}] must be an object.`);
189
+ const rank=Number(grasp.rank);
190
+ const score=Number(grasp.score);
191
+ if (!Number.isSafeInteger(rank)||rank<0||seenRanks.has(rank)) fail('EMBODIEDGEN_GRASP_INVALID',`${role}.grasps[${index}].rank must be unique non-negative integer.`);
192
+ seenRanks.add(rank);
193
+ if (!Number.isFinite(score)||score<0||score>1) fail('EMBODIEDGEN_GRASP_INVALID',`${role}.grasps[${index}].score must be within [0,1].`);
194
+ rigidGraspPose(grasp.pose,`${role}.grasps[${index}].pose`);
195
+ topScore=topScore==null?score:Math.max(topScore,score);
196
+ });
197
+ if (payload.seed!=null && !Number.isSafeInteger(Number(payload.seed))) fail('EMBODIEDGEN_GRASP_INVALID',`${role}.seed must be a safe integer.`);
198
+ return {
199
+ artifactId:descriptor.id,
200
+ sha256:descriptor.sha256,
201
+ status:'verified',
202
+ evidenceLevel:expectedLevel,
203
+ count:payload.grasps.length,
204
+ topScore,
205
+ gripper,
206
+ sourceFrame,
207
+ backend,
208
+ sourceJobId,
209
+ outputJobId,
210
+ ...(payload.seed==null?{}:{seed:Number(payload.seed)})
211
+ };
212
+ };
213
+
214
+ const URDF_PROPOSAL_MAX_PARTS = 128;
215
+ const URDF_MAX_BYTES = 5 * 1024 * 1024;
216
+ const URDF_JOINT_TYPES = new Set(['revolute','prismatic','continuous']);
217
+ const URDF_PART_ID = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$/;
218
+ const FORBIDDEN_URDF_KEYS = /(actions?|physics|targets?|motor|authorization|api[-_]?key|token|secret|credential|signed[-_]?url|(^|[_-])url($|[_-])|(^|[_-])path($|[_-])|prompt|pose|remote.*id|function.*id)/i;
219
+
220
+ const safeEvidenceText = (value, label, { allowRoot = false } = {}) => {
221
+ const text=String(value ?? '').trim();
222
+ if (allowRoot && text === '$root') return text;
223
+ if (!text || text.length > 160 || /[\u0000-\u001f\u007f]/.test(text) || /https?:\/\/|Bearer\s+/i.test(text)) {
224
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `${label} must be bounded safe text.`);
225
+ }
226
+ return text;
227
+ };
228
+
229
+ const finiteVector = (value, length, label) => {
230
+ if (!Array.isArray(value) || value.length !== length || !value.every(Number.isFinite)) {
231
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `${label} requires finite [${length}].`);
232
+ }
233
+ return value.map(Number);
234
+ };
235
+
236
+ const finiteMatrix4 = (value, label) => {
237
+ if (!Array.isArray(value) || value.length !== 4 || value.some((row) => !Array.isArray(row) || row.length !== 4 || !row.every(Number.isFinite))) {
238
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `${label} requires finite 4x4 matrix.`);
239
+ }
240
+ return value.map((row) => row.map(Number));
241
+ };
242
+
243
+ const rejectForbiddenUrdfFields = (value, path = 'partProposal') => {
244
+ if (!value || typeof value !== 'object') return;
245
+ if (Array.isArray(value)) {
246
+ value.forEach((item,index) => rejectForbiddenUrdfFields(item, `${path}[${index}]`));
247
+ return;
248
+ }
249
+ for (const [key,item] of Object.entries(value)) {
250
+ if (FORBIDDEN_URDF_KEYS.test(key)) {
251
+ fail('EMBODIEDGEN_URDF_PROPOSAL_FORBIDDEN_FIELD', `URDF proposal contains forbidden executable/transport field: ${path}.${key}`);
252
+ }
253
+ rejectForbiddenUrdfFields(item, `${path}.${key}`);
254
+ }
255
+ };
256
+
257
+ const normalizeUrdfProposal = (payload) => {
258
+ const proposal=payload?.partProposal;
259
+ if (!proposal || proposal.version !== 1 || proposal.source !== 'urdf/yourdfpy' || proposal.frameConvention !== 'urdf-link-local' || !Array.isArray(proposal.parts)) {
260
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', 'URDF proposal requires Part Proposal v1 from urdf/yourdfpy with urdf-link-local frameConvention.');
261
+ }
262
+ if (proposal.parts.length > URDF_PROPOSAL_MAX_PARTS) {
263
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal exceeds ${URDF_PROPOSAL_MAX_PARTS} movable parts.`);
264
+ }
265
+ rejectForbiddenUrdfFields(proposal);
266
+ const seen=new Set();
267
+ const seenNodes=new Set();
268
+ const parts=proposal.parts.map((raw,index) => {
269
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part ${index} must be an object.`);
270
+ const id=safeEvidenceText(raw.id, `parts[${index}].id`);
271
+ if (!URDF_PART_ID.test(id) || id === '$root') fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part id is not a stable identifier: ${id}`);
272
+ if (seen.has(id)) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `Duplicate URDF proposal part id: ${id}`);
273
+ seen.add(id);
274
+ const node=safeEvidenceText(raw.node, `parts[${index}].node`);
275
+ if (seenNodes.has(node)) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `Duplicate URDF proposal child node: ${node}`);
276
+ seenNodes.add(node);
277
+ const parent=safeEvidenceText(raw.parent || '$root', `parts[${index}].parent`, { allowRoot:true });
278
+ if (parent !== '$root' && !URDF_PART_ID.test(parent)) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal parent is not a stable identifier: ${parent}`);
279
+ const joint=raw.joint;
280
+ if (!joint || typeof joint !== 'object' || Array.isArray(joint) || !URDF_JOINT_TYPES.has(joint.type)) {
281
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part ${id} requires revolute/prismatic/continuous joint.`);
282
+ }
283
+ const axis=finiteVector(joint.axis,3,`parts[${index}].joint.axis`);
284
+ if (Math.hypot(...axis) < 1e-9) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part ${id} has zero joint axis.`);
285
+ let limits;
286
+ if (joint.limits != null) {
287
+ limits=finiteVector(joint.limits,2,`parts[${index}].joint.limits`);
288
+ if (limits[0] >= limits[1]) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part ${id} has invalid joint limits.`);
289
+ }
290
+ const urdf=joint.urdf;
291
+ if (!urdf || typeof urdf !== 'object' || Array.isArray(urdf)) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part ${id} requires urdf metadata.`);
292
+ const normalizedUrdf={
293
+ name:safeEvidenceText(urdf.name, `parts[${index}].joint.urdf.name`),
294
+ parentLink:safeEvidenceText(urdf.parentLink, `parts[${index}].joint.urdf.parentLink`),
295
+ childLink:safeEvidenceText(urdf.childLink, `parts[${index}].joint.urdf.childLink`),
296
+ originMatrix:finiteMatrix4(urdf.originMatrix,`parts[${index}].joint.urdf.originMatrix`),
297
+ parentToJointMatrix:finiteMatrix4(urdf.parentToJointMatrix,`parts[${index}].joint.urdf.parentToJointMatrix`)
298
+ };
299
+ const confidence=Number(raw.confidence ?? proposal.confidence ?? 0);
300
+ if (!Number.isFinite(confidence) || confidence < 0 || confidence > 1) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part ${id} confidence must be within [0,1].`);
301
+ return {
302
+ id,node,parent,
303
+ joint:{type:joint.type,axis,...(limits?{limits}:{}),urdf:normalizedUrdf},
304
+ confidence
305
+ };
306
+ });
307
+ const ids=new Set(parts.map((part)=>part.id));
308
+ for (const part of parts) {
309
+ if (part.parent === part.id) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal part cannot parent itself: ${part.id}`);
310
+ if (part.parent !== '$root' && !ids.has(part.parent)) {
311
+ fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal parent does not exist: ${part.parent}`);
312
+ }
313
+ }
314
+ const byId=new Map(parts.map((part)=>[part.id,part]));
315
+ for (const part of parts) {
316
+ const visited=new Set([part.id]);
317
+ let parent=part.parent;
318
+ while (parent !== '$root') {
319
+ if (visited.has(parent)) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', `URDF proposal hierarchy contains a cycle at ${parent}`);
320
+ visited.add(parent);
321
+ parent=byId.get(parent)?.parent || '$root';
322
+ }
323
+ }
324
+ const confidence=Number(proposal.confidence ?? 0);
325
+ if (!Number.isFinite(confidence) || confidence < 0 || confidence > 1) fail('EMBODIEDGEN_URDF_PROPOSAL_INVALID', 'URDF proposal confidence must be within [0,1].');
326
+ return {version:1,source:'urdf/yourdfpy',frameConvention:'urdf-link-local',confidence,parts};
327
+ };
328
+
329
+ const SEMANTIC_MAX_BYTES = 1024 * 1024;
330
+ const SEMANTIC_SAFE_TEXT = /^[^\u0000-\u001f\u007f]{1,800}$/;
331
+ const SEMANTIC_FORBIDDEN_KEYS = /(joint|axis|anchors?|limits?|motor|actions?|targets?|pickup|runtime[-_]?verified|(^|[_-])verified($|[_-])|authorization|api[-_]?key|token|secret|credential|signed[-_]?url|(^|[_-])url($|[_-])|(^|[_-])path($|[_-])|image[-_]?bytes|base64)/i;
332
+
333
+ const safeSemanticText=(value,label,max=800)=>{
334
+ const text=String(value ?? '').trim();
335
+ if (!text || text.length>max || !SEMANTIC_SAFE_TEXT.test(text) || /https?:\/\/|Bearer\s+/i.test(text)) {
336
+ fail('EMBODIEDGEN_SEMANTICS_INVALID',`${label} must be bounded safe text.`);
337
+ }
338
+ return text;
339
+ };
340
+
341
+ const rejectForbiddenSemanticFields=(value,path='partSemantics')=>{
342
+ if (!value || typeof value!=='object') return;
343
+ if (Array.isArray(value)) {
344
+ value.forEach((item,index)=>rejectForbiddenSemanticFields(item,`${path}[${index}]`));
345
+ return;
346
+ }
347
+ for (const [key,item] of Object.entries(value)) {
348
+ if (SEMANTIC_FORBIDDEN_KEYS.test(key)) {
349
+ fail('EMBODIEDGEN_SEMANTICS_FORBIDDEN_FIELD',`Part semantics contains forbidden executable/secret field: ${path}.${key}`);
350
+ }
351
+ rejectForbiddenSemanticFields(item,`${path}.${key}`);
352
+ }
353
+ };
354
+
355
+ const normalizeSemanticEvidence=(payload,{descriptor,bundleSourceJobId,segmentation,segmentationDescriptor})=>{
356
+ if (!payload || typeof payload!=='object' || Array.isArray(payload) || payload.version!==1 || payload.source!=='embodiedgen/gpt-part-semantics' || payload.profile!=='part-semantics-v1' || !Array.isArray(payload.parts)) {
357
+ fail('EMBODIEDGEN_SEMANTICS_INVALID','part_semantics must be EmbodiedGen Part Semantics v1.');
358
+ }
359
+ rejectForbiddenSemanticFields(payload);
360
+ const sourceJobId=String(payload.sourceJobId || '').trim();
361
+ const outputJobId=String(payload.outputJobId || '').trim();
362
+ if (!JOB_ID.test(sourceJobId) || !JOB_ID.test(outputJobId)) fail('EMBODIEDGEN_SEMANTICS_INVALID','part_semantics requires valid sourceJobId/outputJobId.');
363
+ if (bundleSourceJobId && sourceJobId!==bundleSourceJobId) {
364
+ fail('EMBODIEDGEN_SEMANTICS_SOURCE_MISMATCH','part_semantics sourceJobId does not match bundle sourceJobId.',{bundleSourceJobId,semanticSourceJobId:sourceJobId});
365
+ }
366
+ const boundSegmentationSha=String(payload.input?.segmentationSha256 || '').toLowerCase();
367
+ if (!HEX_SHA256.test(boundSegmentationSha) || boundSegmentationSha!==segmentationDescriptor.sha256) {
368
+ fail('EMBODIEDGEN_SEMANTICS_SEGMENTATION_MISMATCH','part_semantics is not bound to the bundle part_segmentation SHA-256.',{expected:segmentationDescriptor.sha256,actual:boundSegmentationSha||null});
369
+ }
370
+ const expectedIds=new Set((segmentation?.segments || []).map((item)=>String(item?.id ?? '')).filter(Boolean));
371
+ if (!expectedIds.size) fail('EMBODIEDGEN_SEMANTICS_INVALID','part_semantics requires non-empty segmentation IDs.');
372
+ const seen=new Set();
373
+ const parts=[];
374
+ for (let index=0;index<payload.parts.length;index++) {
375
+ const raw=payload.parts[index];
376
+ if (!raw || typeof raw!=='object' || Array.isArray(raw)) fail('EMBODIEDGEN_SEMANTICS_INVALID',`part_semantics.parts[${index}] must be an object.`);
377
+ const rawId=raw.id;
378
+ const id=typeof rawId==='number' && Number.isSafeInteger(rawId) ? String(rawId) : String(rawId ?? '').trim();
379
+ if (!id || !expectedIds.has(id) || seen.has(id)) fail('EMBODIEDGEN_SEMANTICS_INVALID',`Invalid or duplicate semantic part id: ${id||'<missing>'}.`);
380
+ seen.add(id);
381
+ const maskColor=safeSemanticText(raw.mask_color,`parts[${index}].mask_color`,80);
382
+ const partName=safeSemanticText(raw.part_name,`parts[${index}].part_name`,160);
383
+ if (typeof raw.graspable!=='boolean') fail('EMBODIEDGEN_SEMANTICS_INVALID',`parts[${index}].graspable must be boolean.`);
384
+ const scenarios=raw.grasp_scenarios;
385
+ if (!Array.isArray(scenarios) || scenarios.length>8) fail('EMBODIEDGEN_SEMANTICS_INVALID',`parts[${index}].grasp_scenarios must be a bounded list.`);
386
+ if (raw.graspable && !scenarios.length) fail('EMBODIEDGEN_SEMANTICS_INVALID',`Graspable semantic part ${id} requires a grasp scenario.`);
387
+ if (!raw.graspable && scenarios.length) fail('EMBODIEDGEN_SEMANTICS_INVALID',`Non-graspable semantic part ${id} must not claim grasp scenarios.`);
388
+ const normalizedScenarios=scenarios.map((scenario,scenarioIndex)=>{
389
+ if (!scenario || typeof scenario!=='object' || Array.isArray(scenario) || new Set(Object.keys(scenario)).size!==2 || !Object.hasOwn(scenario,'scenario') || !Object.hasOwn(scenario,'confidence')) {
390
+ fail('EMBODIEDGEN_SEMANTICS_INVALID',`parts[${index}].grasp_scenarios[${scenarioIndex}] has invalid schema.`);
391
+ }
392
+ const text=safeSemanticText(scenario.scenario,`parts[${index}].grasp_scenarios[${scenarioIndex}].scenario`,280);
393
+ const confidence=Number(scenario.confidence);
394
+ if (!Number.isFinite(confidence) || confidence<0 || confidence>1) fail('EMBODIEDGEN_SEMANTICS_INVALID',`parts[${index}].grasp_scenarios[${scenarioIndex}].confidence must be within [0,1].`);
395
+ return {scenario:text,confidence};
396
+ });
397
+ if (!Array.isArray(raw.functional_labels) || raw.functional_labels.length<1 || raw.functional_labels.length>8) {
398
+ fail('EMBODIEDGEN_SEMANTICS_INVALID',`parts[${index}].functional_labels must contain 1..8 labels.`);
399
+ }
400
+ const functionalLabels=raw.functional_labels.map((label,labelIndex)=>safeSemanticText(label,`parts[${index}].functional_labels[${labelIndex}]`,160));
401
+ const description=safeSemanticText(raw.semantic_description,`parts[${index}].semantic_description`,800);
402
+ parts.push({id,maskColor,partName,graspable:raw.graspable,graspScenarios:normalizedScenarios,functionalLabels,description});
403
+ }
404
+ if (seen.size!==expectedIds.size || [...expectedIds].some((id)=>!seen.has(id))) {
405
+ fail('EMBODIEDGEN_SEMANTICS_ID_COVERAGE','part_semantics IDs must exactly cover segmentation IDs.',{semanticIds:[...seen].sort(),segmentationIds:[...expectedIds].sort()});
406
+ }
407
+ const model=safeSemanticText(payload.provenance?.model,'provenance.model',200);
408
+ const apiStyle=safeSemanticText(payload.provenance?.apiStyle,'provenance.apiStyle',80);
409
+ const promptRevision=String(payload.provenance?.promptRevision || '').toLowerCase();
410
+ if (!HEX_SHA256.test(promptRevision)) fail('EMBODIEDGEN_SEMANTICS_INVALID','provenance.promptRevision must be SHA-256.');
411
+ return {
412
+ evidence:{
413
+ artifactId:descriptor.id,sha256:descriptor.sha256,status:'verified',source:payload.source,profile:payload.profile,
414
+ sourceJobId,outputJobId,partCount:parts.length,model,apiStyle,promptRevision,
415
+ parts:parts.map(({id,partName,graspable,functionalLabels,graspScenarios})=>({id,partName,graspable,functionalLabels,graspScenarioCount:graspScenarios.length}))
416
+ },
417
+ proposal:{
418
+ version:1,source:'embodiedgen/gpt-part-semantics',confidence:0,
419
+ parts:parts.map((part)=>({id:part.id,semantic:part.partName,confidence:0}))
420
+ }
421
+ };
422
+ };
423
+
424
+ const safeErrorCode = (error) => {
425
+ const code=String(error?.code || error?.name || 'URDF_PROPOSAL_FAILED').trim();
426
+ return /^[A-Za-z0-9._:-]{1,120}$/.test(code) ? code : 'URDF_PROPOSAL_FAILED';
427
+ };
428
+
429
+ const evidenceLevel = (roles, urdfStatus = 'none', graspLevel = 'none', semanticLevel = 'none') => ({
430
+ partSegmentation: roles.has('part_segmentation') ? 'provider' : 'none',
431
+ partSemantics: semanticLevel === 'none' && roles.has('part_semantics') ? 'provider-unverified' : semanticLevel,
432
+ grasps:graspLevel,
433
+ urdf:urdfStatus
434
+ });
435
+
436
+ export class EmbodiedGenBundleAdapter {
437
+ constructor({ compilerProvider = null } = {}) { this.compilerProvider=compilerProvider; }
438
+
439
+ /**
440
+ * Convert a versioned EmbodiedGen artifact bundle into existing AssetCompiler input.
441
+ * This adapter preserves provider evidence; it never creates a runtime Manifest.
442
+ */
443
+ async prepare(bundle, { artifactBytes = {} } = {}) {
444
+ if (!bundle || bundle.version !== 1 || bundle.provider !== 'embodiedgen' || !Array.isArray(bundle.artifacts)) {
445
+ fail('EMBODIEDGEN_BUNDLE_INVALID', 'EmbodiedGen bundle requires version=1, provider="embodiedgen" and artifacts[].');
446
+ }
447
+ const sourceJobId = String(bundle.sourceJobId || bundle.job?.id || '').trim();
448
+ if (sourceJobId && !JOB_ID.test(sourceJobId)) fail('EMBODIEDGEN_JOB_ID_INVALID', `Invalid EmbodiedGen source job id: ${sourceJobId}`);
449
+
450
+ const seenIds = new Set(); const seenRoles = new Set();
451
+ const descriptors = bundle.artifacts.map((descriptor) => assertDescriptor(descriptor, seenIds, seenRoles));
452
+ const byRole = new Map(descriptors.map((descriptor) => [descriptor.role, descriptor]));
453
+ const primary = byRole.get('primary_glb');
454
+ if (!primary) fail('EMBODIEDGEN_PRIMARY_GLB_MISSING', 'EmbodiedGen bundle requires exactly one primary_glb artifact.');
455
+ if (primary.mediaType !== 'model/gltf-binary') {
456
+ fail('EMBODIEDGEN_PRIMARY_GLB_MEDIA_TYPE_INVALID', `primary_glb must use model/gltf-binary, got ${primary.mediaType}.`);
457
+ }
458
+ const primaryBytes = normalizeBytes(artifactBytesFor(artifactBytes, primary), primary.id);
459
+ await assertHash(primary, primaryBytes);
460
+
461
+ const verifiedRoles=new Set(['primary_glb']);
462
+ let partSegmentation = null;
463
+ const segmentationDescriptor = byRole.get('part_segmentation');
464
+ if (segmentationDescriptor) {
465
+ const segmentationBytes = normalizeBytes(artifactBytesFor(artifactBytes, segmentationDescriptor), segmentationDescriptor.id);
466
+ await assertHash(segmentationDescriptor, segmentationBytes);
467
+ verifiedRoles.add('part_segmentation');
468
+ partSegmentation = parseJsonArtifact(segmentationDescriptor, segmentationBytes);
469
+ validateSegmentation(partSegmentation, primary);
470
+ }
471
+
472
+ let semanticProposal=null;
473
+ let semanticEvidence=null;
474
+ let semanticLevel='none';
475
+ const semanticDescriptor=byRole.get('part_semantics');
476
+ if (semanticDescriptor) {
477
+ if (!segmentationDescriptor || !partSegmentation) {
478
+ fail('EMBODIEDGEN_SEMANTICS_REQUIRES_SEGMENTATION','part_semantics requires verified part_segmentation in the same bundle.');
479
+ }
480
+ if (semanticDescriptor.mediaType!=='application/json') fail('EMBODIEDGEN_SEMANTICS_MEDIA_TYPE_INVALID','part_semantics must use application/json.');
481
+ const rawSemanticBytes=artifactBytesFor(artifactBytes,semanticDescriptor);
482
+ if (rawSemanticBytes == null) {
483
+ semanticEvidence={artifactId:semanticDescriptor.id,sha256:semanticDescriptor.sha256,status:'descriptor-only'};
484
+ semanticLevel='provider-unverified';
485
+ } else {
486
+ const semanticBytes=normalizeBytes(rawSemanticBytes,semanticDescriptor.id);
487
+ if (semanticBytes.byteLength>SEMANTIC_MAX_BYTES) fail('EMBODIEDGEN_SEMANTICS_TOO_LARGE',`part_semantics exceeds ${SEMANTIC_MAX_BYTES} bytes.`,{bytes:semanticBytes.byteLength,maxBytes:SEMANTIC_MAX_BYTES});
488
+ await assertHash(semanticDescriptor,semanticBytes);
489
+ const semanticPayload=parseJsonArtifact(semanticDescriptor,semanticBytes);
490
+ const normalized=normalizeSemanticEvidence(semanticPayload,{descriptor:semanticDescriptor,bundleSourceJobId:sourceJobId||null,segmentation:partSegmentation,segmentationDescriptor});
491
+ semanticEvidence=normalized.evidence;
492
+ semanticProposal=normalized.proposal;
493
+ semanticLevel='provider-verified';
494
+ verifiedRoles.add('part_semantics');
495
+ }
496
+ }
497
+
498
+ let partProposal=null;
499
+ let urdfEvidence=null;
500
+ let urdfStatus='none';
501
+ const urdfDescriptor=byRole.get('source_urdf');
502
+ if (urdfDescriptor) {
503
+ if (!['application/xml','text/xml','application/urdf+xml'].includes(urdfDescriptor.mediaType)) {
504
+ fail('EMBODIEDGEN_URDF_MEDIA_TYPE_INVALID', `source_urdf has unsupported media type: ${urdfDescriptor.mediaType}`);
505
+ }
506
+ const urdfBytes=normalizeBytes(artifactBytesFor(artifactBytes,urdfDescriptor),urdfDescriptor.id);
507
+ if (urdfBytes.byteLength > URDF_MAX_BYTES) {
508
+ fail('EMBODIEDGEN_URDF_TOO_LARGE', `source_urdf exceeds ${URDF_MAX_BYTES} bytes.`, { bytes:urdfBytes.byteLength, maxBytes:URDF_MAX_BYTES });
509
+ }
510
+ await assertHash(urdfDescriptor,urdfBytes);
511
+ verifiedRoles.add('source_urdf');
512
+ urdfStatus='verified-bytes-only';
513
+ urdfEvidence={artifactId:urdfDescriptor.id,sha256:urdfDescriptor.sha256,status:urdfStatus,parser:null,partCount:null,frameConvention:null};
514
+ const parser=this.compilerProvider;
515
+ const canParse=typeof parser?.runUrdfProposal === 'function' && (typeof parser.isConfigured !== 'function' || parser.isConfigured());
516
+ if (canParse) {
517
+ try {
518
+ partProposal=normalizeUrdfProposal(await parser.runUrdfProposal(urdfBytes));
519
+ urdfStatus='service-parsed';
520
+ urdfEvidence={
521
+ artifactId:urdfDescriptor.id,sha256:urdfDescriptor.sha256,status:urdfStatus,
522
+ parser:'asset-compiler/yourdfpy',partCount:partProposal.parts.length,frameConvention:partProposal.frameConvention
523
+ };
524
+ } catch (error) {
525
+ partProposal=null;
526
+ urdfStatus='parse-rejected';
527
+ urdfEvidence={
528
+ artifactId:urdfDescriptor.id,sha256:urdfDescriptor.sha256,status:urdfStatus,
529
+ parser:'asset-compiler/yourdfpy',partCount:null,frameConvention:null,errorCode:safeErrorCode(error)
530
+ };
531
+ }
532
+ }
533
+ }
534
+
535
+ let semanticProposalApplied=false;
536
+ if (semanticProposal && (!partProposal || !Array.isArray(partProposal.parts) || partProposal.parts.length===0)) {
537
+ partProposal=semanticProposal;
538
+ semanticProposalApplied=true;
539
+ }
540
+
541
+ const graspEvidence={};
542
+ for (const role of ['raw_grasps','sapien_grasps']) {
543
+ const descriptor=byRole.get(role);
544
+ if (!descriptor) continue;
545
+ if (descriptor.mediaType!=='application/json') fail('EMBODIEDGEN_GRASP_MEDIA_TYPE_INVALID',`${role} must use application/json.`);
546
+ const rawBytes=artifactBytesFor(artifactBytes,descriptor);
547
+ if (rawBytes == null) {
548
+ graspEvidence[role]={artifactId:descriptor.id,sha256:descriptor.sha256,status:'descriptor-only'};
549
+ continue;
550
+ }
551
+ const bytes=normalizeBytes(rawBytes,descriptor.id);
552
+ if (bytes.byteLength>GRASP_MAX_BYTES) fail('EMBODIEDGEN_GRASP_TOO_LARGE',`${role} exceeds ${GRASP_MAX_BYTES} bytes.`,{bytes:bytes.byteLength,maxBytes:GRASP_MAX_BYTES});
553
+ await assertHash(descriptor,bytes);
554
+ const payload=parseJsonArtifact(descriptor,bytes);
555
+ graspEvidence[role]=normalizeGraspEvidence(payload,{role,descriptor,bundleSourceJobId:sourceJobId||null});
556
+ verifiedRoles.add(role);
557
+ }
558
+ const graspLevel = graspEvidence.sapien_grasps?.status==='verified' ? 'sapien-validated-provider-only'
559
+ : graspEvidence.raw_grasps?.status==='verified' ? 'raw-provider-only'
560
+ : graspEvidence.sapien_grasps ? 'sapien-provider-unverified'
561
+ : graspEvidence.raw_grasps ? 'raw-provider-unverified'
562
+ : 'none';
563
+
564
+ const providerEvidence = {
565
+ provider:'embodiedgen',
566
+ bundleVersion:1,
567
+ sourceJobId:sourceJobId || null,
568
+ lineage:safeLineage(bundle.lineage),
569
+ levels:evidenceLevel(seenRoles,urdfStatus,graspLevel,semanticLevel),
570
+ ...(Object.keys(graspEvidence).length ? { grasps:graspEvidence } : {}),
571
+ ...(semanticEvidence ? { semantics:{...semanticEvidence,mappedToPartProposal:semanticProposalApplied} } : {}),
572
+ ...(urdfEvidence ? { urdf:urdfEvidence } : {}),
573
+ artifacts:descriptors.map((descriptor) => ({ ...descriptor, verified:verifiedRoles.has(descriptor.role) }))
574
+ };
575
+
576
+ const asset = bundle.asset && typeof bundle.asset === 'object' ? bundle.asset : {};
577
+ const compilerInput = {
578
+ bytes:primaryBytes,
579
+ sourceName:primary.fileName || primary.path?.split('/').pop() || 'embodiedgen.glb',
580
+ assetId:asset.id || bundle.assetId || undefined,
581
+ label:asset.label || bundle.label || undefined,
582
+ partSegmentation,
583
+ // Verified semantic evidence may become an unpromoted semantic-only Part Proposal.
584
+ // Verified URDF proposal wins when it has explicit movable parts; grasp evidence remains non-executable.
585
+ partProposal,
586
+ providerEvidence
587
+ };
588
+ return { compilerInput, providerEvidence };
589
+ }
590
+ }