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,170 @@
1
+ import { createCanonicalWorldPipeline } from '../compiler/createWorldPipeline.js';
2
+ import { buildWorldRetryPlan } from '../compiler/WorldRetry.js';
3
+ import { recompileWorldRevision } from '../compiler/WorldRecompiler.js';
4
+ import { captureWorldAuthority, restoreWorldAuthority } from '../runtime/WorldAuthority.js';
5
+
6
+ export class WorldBuilder {
7
+ constructor(runtime, { pipeline = null, retryBudget = 2 } = {}) {
8
+ if (!runtime) throw new TypeError('WorldBuilder requires a runtime');
9
+ if (!Number.isInteger(retryBudget) || retryBudget < 1) throw new TypeError('WorldBuilder retryBudget must be a positive integer');
10
+ this.runtime = runtime;
11
+ this.pipeline = pipeline || createCanonicalWorldPipeline(runtime);
12
+ this.retryBudget = retryBudget;
13
+ }
14
+
15
+ async run(plan) {
16
+ const runtime = this.runtime;
17
+ const before = runtime.snapshot();
18
+ const authorityBefore = captureWorldAuthority(runtime);
19
+ const attempts = [];
20
+ let candidate = plan;
21
+
22
+ const restoreBefore = async (cause = null) => {
23
+ try {
24
+ await runtime.restoreSnapshot(before);
25
+ restoreWorldAuthority(runtime,authorityBefore);
26
+ } catch (rollbackError) {
27
+ const failure = new AggregateError(
28
+ cause ? [cause, rollbackError] : [rollbackError],
29
+ 'World build rollback failed',
30
+ cause ? { cause } : undefined
31
+ );
32
+ failure.code = 'WORLD_BUILD_ROLLBACK_FAILED';
33
+ failure.rollbackError = rollbackError;
34
+ throw failure;
35
+ }
36
+ };
37
+
38
+ const runCandidate = async (candidatePlan) => {
39
+ try {
40
+ runtime.loadRuleGraph?.([]);
41
+ await runtime.clearObjects({ silent:true });
42
+ return await this.pipeline.run(candidatePlan);
43
+ } catch (error) {
44
+ await restoreBefore(error);
45
+ throw error;
46
+ }
47
+ };
48
+
49
+ for (let attempt = 1; attempt <= this.retryBudget; attempt++) {
50
+ const pipeline = await runCandidate(candidate);
51
+ const admission = pipeline.state?.reports?.worldAdmission;
52
+ if (!admission) {
53
+ const error = new Error('Canonical world pipeline produced no world admission');
54
+ error.code = 'WORLD_PIPELINE_ADMISSION_MISSING';
55
+ await restoreBefore(error);
56
+ throw error;
57
+ }
58
+
59
+ const record = { attempt, admission:structuredClone(admission) };
60
+ attempts.push(record);
61
+ if (admission.status !== 'rejected') {
62
+ return {
63
+ status:`world-${admission.status}`,
64
+ admission,
65
+ pipeline,
66
+ attempts,
67
+ retry:attempts.length > 1 ? attempts.at(-2).retry : null
68
+ };
69
+ }
70
+
71
+ await restoreBefore();
72
+ const retry = buildWorldRetryPlan(pipeline, {
73
+ generatorConfigured:runtime.generation?.canGenerateAsset?.() === true,
74
+ attempt,
75
+ budget:this.retryBudget
76
+ });
77
+ record.retry = retry;
78
+ if (retry.status !== 'retry-proposed') {
79
+ return {
80
+ status:'world-rejected',
81
+ reason:admission.reasons?.[0] || 'WORLD_REJECTED',
82
+ rolledBack:true,
83
+ admission,
84
+ pipeline,
85
+ attempts,
86
+ retry
87
+ };
88
+ }
89
+
90
+ const generation = await this.materializeRetryAssets(retry);
91
+ record.generation = generation.status === 'generated'
92
+ ? { status:generation.status, assets:structuredClone(generation.assets) }
93
+ : { status:generation.status, reason:generation.reason, ...(generation.error ? { error:generation.error } : {}) };
94
+ if (generation.status !== 'generated') {
95
+ const failedRetry = { ...retry, status:'generation-failed', retriable:false, generation:record.generation };
96
+ record.retry = failedRetry;
97
+ return {
98
+ status:'world-rejected',
99
+ reason:generation.reason || 'GENERATION_FAILED',
100
+ rolledBack:true,
101
+ admission,
102
+ pipeline,
103
+ attempts,
104
+ retry:failedRetry
105
+ };
106
+ }
107
+ candidate = generation.plan;
108
+ }
109
+
110
+ throw new Error('World retry loop exceeded its fixed budget');
111
+ }
112
+
113
+ recompile(options = {}) {
114
+ return recompileWorldRevision(this.runtime, { ...options, pipeline:this.pipeline });
115
+ }
116
+
117
+ async materializeRetryAssets(retry) {
118
+ const runtime = this.runtime;
119
+ if (retry?.status !== 'retry-proposed') return { status:'not-requested', plan:retry?.nextIR || null, assets:[] };
120
+ if (typeof runtime.generation?.generateAsset !== 'function') {
121
+ return { status:'generation-failed', reason:'GENERATOR_UNAVAILABLE', plan:null, assets:[] };
122
+ }
123
+
124
+ const plan = structuredClone(retry.nextIR);
125
+ const generated = [];
126
+ for (const action of retry.actions || []) {
127
+ if (action.kind !== 'enable-generation') continue;
128
+ const entity = plan.entities.find((item) =>
129
+ (action.instanceId && item.id === action.instanceId)
130
+ || (!action.instanceId && item.asset?.query === action.query)
131
+ );
132
+ if (!entity) {
133
+ return { status:'generation-failed', reason:'RETRY_ENTITY_NOT_FOUND', plan:null, assets:generated, action:structuredClone(action) };
134
+ }
135
+
136
+ const asset = entity.asset || {};
137
+ const prompt = asset.prompt || asset.query || asset.type || action.query || '';
138
+ let produced;
139
+ try {
140
+ produced = await runtime.generation.generateAsset(prompt, {
141
+ ...(entity.id ? { instanceId:entity.id } : {}),
142
+ ...(asset.provider ? { provider:asset.provider } : {})
143
+ });
144
+ } catch (error) {
145
+ return {
146
+ status:'generation-failed',
147
+ reason:error?.code || 'GENERATION_FAILED',
148
+ plan:null,
149
+ assets:generated,
150
+ error:{ code:error?.code || 'GENERATION_FAILED', message:error?.message || String(error) }
151
+ };
152
+ }
153
+
154
+ const assetId = produced?.id || null;
155
+ if (!assetId || runtime.assetModule?.hasAsset?.(assetId) !== true) {
156
+ return {
157
+ status:'generation-failed',
158
+ reason:produced?.status || 'GENERATED_ASSET_NOT_PUBLISHED',
159
+ plan:null,
160
+ assets:generated,
161
+ result:produced ? structuredClone(produced) : null
162
+ };
163
+ }
164
+ entity.asset = { ...asset, assetId };
165
+ generated.push({ instanceId:entity.id || null, assetId, status:produced.status || 'generated' });
166
+ }
167
+
168
+ return { status:'generated', plan, assets:generated };
169
+ }
170
+ }
@@ -0,0 +1,32 @@
1
+ export class PipelineEngine {
2
+ constructor({ events = null, trace = null } = {}) {
3
+ this.events = events;
4
+ this.trace = trace;
5
+ this.stages = new Map();
6
+ }
7
+
8
+ register(name, handler) {
9
+ if (this.stages.has(name)) throw new Error(`Pipeline stage already exists: ${name}`);
10
+ this.stages.set(name, handler);
11
+ return this;
12
+ }
13
+
14
+ async run(input, { stages, context = {} } = {}) {
15
+ const selected = stages || [...this.stages.keys()];
16
+ let state = { input, artifacts: {}, reports: {}, ...context };
17
+ const timeline = [];
18
+ for (const name of selected) {
19
+ const handler = this.stages.get(name);
20
+ if (!handler) throw new Error(`Unknown pipeline stage: ${name}`);
21
+ const started = performance.now();
22
+ this.events?.emit('pipeline.stage.started', { name });
23
+ this.trace?.emit('pipeline.stage.started', { name }, { actor: 'pipeline' });
24
+ state = await handler(state) || state;
25
+ const elapsedMs = Math.round(performance.now() - started);
26
+ timeline.push({ name, elapsedMs });
27
+ this.events?.emit('pipeline.stage.completed', { name, elapsedMs });
28
+ this.trace?.emit('pipeline.stage.completed', { name, elapsedMs }, { actor: 'pipeline' });
29
+ }
30
+ return { state, timeline };
31
+ }
32
+ }
@@ -0,0 +1,43 @@
1
+ const clone = (value) => value == null ? value : structuredClone(value);
2
+
3
+ export function evaluateWorldAdmission({
4
+ validation = null,
5
+ acceptance = null,
6
+ assetAdmission = null,
7
+ layoutAdmission = null,
8
+ behaviorAdmission = null,
9
+ physicsAdmission = null,
10
+ relationAdmission = null
11
+ } = {}) {
12
+ const hard = validation?.counts?.hard || 0;
13
+ const advisory = validation?.counts?.advisory || 0;
14
+ const acceptanceRejected = acceptance?.status === 'world-incomplete';
15
+ const rejected = [assetAdmission, layoutAdmission, behaviorAdmission, physicsAdmission, relationAdmission]
16
+ .some((admission) => admission?.status === 'rejected');
17
+ const provisional = advisory
18
+ || assetAdmission?.status === 'provisional'
19
+ || layoutAdmission?.status === 'provisional';
20
+
21
+ return {
22
+ status: hard || rejected || acceptanceRejected ? 'rejected' : provisional ? 'provisional' : 'ready',
23
+ reasons: [
24
+ ...(hard ? [`VALIDATION_HARD:${hard}`] : []),
25
+ ...(advisory ? [`VALIDATION_ADVISORY:${advisory}`] : []),
26
+ ...(assetAdmission?.status === 'rejected' ? ['ASSET_UNRESOLVED'] : []),
27
+ ...(assetAdmission?.status === 'provisional' ? ['ASSET_PROVISIONAL'] : []),
28
+ ...(layoutAdmission?.status === 'rejected' ? [layoutAdmission.reason || 'LAYOUT_REJECTED'] : []),
29
+ ...(layoutAdmission?.status === 'provisional' ? ['LAYOUT_PROVISIONAL'] : []),
30
+ ...(behaviorAdmission?.status === 'rejected' ? [behaviorAdmission.reason || behaviorAdmission.issues?.[0]?.code || 'BEHAVIOR_REJECTED'] : []),
31
+ ...(physicsAdmission?.status === 'rejected' ? [physicsAdmission.reason || physicsAdmission.issues?.[0]?.code || 'PHYSICS_REJECTED'] : []),
32
+ ...(relationAdmission?.status === 'rejected' ? [relationAdmission.reason || 'RELATION_REJECTED'] : []),
33
+ ...(acceptanceRejected ? ['WORLD_ACCEPTANCE_FAILED'] : [])
34
+ ],
35
+ validation: { hard, advisory },
36
+ ...(assetAdmission ? { assets:clone(assetAdmission) } : {}),
37
+ ...(layoutAdmission ? { layout:clone(layoutAdmission) } : {}),
38
+ ...(behaviorAdmission ? { behavior:clone(behaviorAdmission) } : {}),
39
+ ...(physicsAdmission ? { physics:clone(physicsAdmission) } : {}),
40
+ ...(relationAdmission ? { relations:clone(relationAdmission) } : {}),
41
+ ...(acceptance ? { acceptance:clone(acceptance) } : {})
42
+ };
43
+ }
@@ -0,0 +1,68 @@
1
+ import { assetIdFromRef } from '../../asset/model/AssetRef.js';
2
+ import { inferCarryCapability, isCarryOperation } from '../runtime/interaction/CarryCapability.js';
3
+ import { compileBehaviorGraph } from '../runtime/behavior/BehaviorCompiler.js';
4
+ import { compileRuleGraph } from '../runtime/behavior/RuleGraph.js';
5
+
6
+ export const WORLD_BEHAVIOR_BUNDLE_SCHEMA='agentscape.world-behavior-bundle';
7
+ export const WORLD_BEHAVIOR_BUNDLE_VERSION=1;
8
+
9
+ export function compileWorldBehaviorBundle(worldIR){
10
+ const entityIds=new Set((worldIR?.entities||[]).map((entity)=>entity.id).filter(Boolean));
11
+ const behaviorGraph=compileBehaviorGraph(worldIR?.interactions||[],{worldRevisionId:worldIR?.revision?.id || null});
12
+ for(const command of behaviorGraph.commands){
13
+ for(const [field,id] of [['targetId',command.targetId],['supportId',command.supportId]]){
14
+ if(id&&!entityIds.has(id)){
15
+ const error=new Error(`Behavior ${field} is outside World IR entities: ${id}`);
16
+ error.code='WORLD_BEHAVIOR_REFERENCE_INVALID'; error.commandId=command.commandId; error.entityId=id; throw error;
17
+ }
18
+ }
19
+ }
20
+ const capabilityIntents=(worldIR?.entities||[])
21
+ .filter((entity)=>entity.id && entity.capabilityIntent?.length)
22
+ .map((entity)=>({entityId:entity.id,capabilities:[...entity.capabilityIntent]}));
23
+ const ruleGraph=compileRuleGraph(worldIR?.rules||[]);
24
+ for(const rule of ruleGraph.rules){
25
+ const refs=[rule.condition?.targetId,rule.effect?.targetId].filter(Boolean);
26
+ for(const id of refs){
27
+ if(!entityIds.has(id)){
28
+ const error=new Error(`Rule target is outside World IR entities: ${id}`);
29
+ error.code='WORLD_RULE_REFERENCE_INVALID'; error.ruleId=rule.id; error.entityId=id; throw error;
30
+ }
31
+ }
32
+ }
33
+ return {schema:WORLD_BEHAVIOR_BUNDLE_SCHEMA,schemaVersion:WORLD_BEHAVIOR_BUNDLE_VERSION,worldRevisionId:worldIR?.revision?.id || null,capabilityIntents,behaviorGraph,ruleGraph};
34
+ }
35
+
36
+ export function admitWorldBehavior(bundle,{resolvedAssets=[],getManifest}={}){
37
+ if(bundle?.schema!==WORLD_BEHAVIOR_BUNDLE_SCHEMA||bundle.schemaVersion!==WORLD_BEHAVIOR_BUNDLE_VERSION) throw new TypeError('Unsupported WorldBehavior bundle');
38
+ const byId=new Map((resolvedAssets||[]).filter((item)=>item.id).map((item)=>[item.id,item]));
39
+ const issues=[];
40
+ for(const intent of bundle.capabilityIntents||[]){
41
+ const target=byId.get(intent.entityId);
42
+ if(!target){issues.push({code:'BEHAVIOR_INTENT_TARGET_MISSING',targetId:intent.entityId});continue;}
43
+ const assetId=assetIdFromRef(target.assetRef);
44
+ if(!assetId){issues.push({code:'BEHAVIOR_INTENT_TARGET_UNRESOLVED',targetId:intent.entityId});continue;}
45
+ const manifest=getManifest?.(assetId);
46
+ const actions=new Set((manifest?.actions||[]).map((action)=>String(action).toUpperCase()));
47
+ if (inferCarryCapability(manifest).eligible) for (const name of ['PICKUP','DROP','PLACE']) actions.add(name);
48
+ else if (manifest?.physics?.carryable === false) for (const name of ['PICKUP','DROP','PLACE']) actions.delete(name);
49
+ for(const capability of intent.capabilities){
50
+ if(!actions.has(capability)) issues.push({code:'BEHAVIOR_CAPABILITY_INTENT_UNSUPPORTED',targetId:intent.entityId,capability,assetId});
51
+ }
52
+ }
53
+ for(const command of bundle.behaviorGraph.commands){
54
+ const targetId=command.targetId;
55
+ const target=targetId?byId.get(targetId):null;
56
+ if(targetId&&!target){issues.push({code:'BEHAVIOR_TARGET_MISSING',commandId:command.commandId,targetId});continue;}
57
+ const assetId=assetIdFromRef(target?.assetRef);
58
+ if(targetId&&!assetId){issues.push({code:'BEHAVIOR_TARGET_UNRESOLVED',commandId:command.commandId,targetId});continue;}
59
+ if(['OPEN','CLOSE','PICKUP'].includes(command.capability)){
60
+ const manifest=getManifest?.(assetId);
61
+ const action=command.capability.toLowerCase();
62
+ const supported = (manifest?.actions?.includes(action) || (isCarryOperation(action) && inferCarryCapability(manifest).eligible))
63
+ && (!isCarryOperation(action) || manifest?.physics?.carryable !== false);
64
+ if(!supported) issues.push({code:'BEHAVIOR_CAPABILITY_UNSUPPORTED',commandId:command.commandId,targetId,capability:command.capability,assetId});
65
+ }
66
+ }
67
+ return {status:issues.length?'rejected':'ready',issues};
68
+ }
@@ -0,0 +1,157 @@
1
+ import { normalizeWorldIR, upgradeLegacyWorldSpec } from '../spec/WorldIR.js';
2
+ import { normalizeWorldSpec } from '../spec/WorldSpec.js';
3
+ import { compileWorldBehaviorBundle } from './WorldBehaviorCompiler.js';
4
+ import { compileWorldPhysicsRequirements } from './WorldPhysicsAdmission.js';
5
+ import { compileWorldAcceptance } from '../verification/WorldAcceptance.js';
6
+ import { createAssetRef } from '../../asset/model/AssetRef.js';
7
+
8
+ export const WORLD_COMPILATION_SCHEMA = 'agentscape.world-compilation';
9
+ export const WORLD_COMPILATION_VERSION = 2;
10
+
11
+ const clone = (value) => structuredClone(value);
12
+ const hasState = (entity) => Object.keys(entity.initialState || {}).length > 0;
13
+
14
+ const invalidReference = (path, entityId) => {
15
+ const error = new TypeError(`WorldIR ${path} references unknown entity: ${entityId}`);
16
+ error.code = 'WORLD_IR_REFERENCE_INVALID';
17
+ error.path = path;
18
+ error.entityId = entityId;
19
+ return error;
20
+ };
21
+
22
+ const requireEntity = (entityIds, path, entityId) => {
23
+ if (entityId && !entityIds.has(entityId)) throw invalidReference(path, entityId);
24
+ };
25
+
26
+ const unsupportedExecutionFeatures = (worldIR) => {
27
+ const features=[];
28
+ if(worldIR.spatial.constraints.length) features.push('spatial.constraints');
29
+ const fallback=worldIR.policy.physics?.fallbackPolicy;
30
+ if(fallback && fallback!=='deny') features.push('policy.physics.fallbackPolicy');
31
+ for(const entity of worldIR.entities){
32
+ const qualityFallback=entity.physicsRequirement?.qualityPolicy?.fallbackPolicy;
33
+ if(qualityFallback && qualityFallback!=='deny') features.push(`entities.${entity.id||'$anonymous'}.physicsRequirement.qualityPolicy.fallbackPolicy`);
34
+ }
35
+ if(features.length){
36
+ const error=new TypeError(`WorldIR features are not executable by the canonical pipeline: ${features.join(', ')}`);
37
+ error.code='WORLD_IR_FEATURE_UNSUPPORTED';
38
+ error.features=features;
39
+ throw error;
40
+ }
41
+ return worldIR;
42
+ };
43
+
44
+ export function assertWorldIRReferences(worldIR) {
45
+ const entityIds = new Set(worldIR.entities.map((entity) => entity.id).filter(Boolean));
46
+ const entityById = new Map(worldIR.entities.filter((entity)=>entity.id).map((entity)=>[entity.id,entity]));
47
+
48
+ worldIR.entities.forEach((entity, index) => {
49
+ if (!entity.id && (entity.capabilityIntent.length || hasState(entity))) {
50
+ const error = new TypeError(`WorldIR entity[${index}] requires id for capabilityIntent or initialState`);
51
+ error.code = 'WORLD_IR_ENTITY_ID_REQUIRED';
52
+ throw error;
53
+ }
54
+ });
55
+
56
+ const anchoredSubjects=new Set();
57
+ worldIR.spatial.relations.forEach((relation, index) => {
58
+ requireEntity(entityIds, `spatial.relations[${index}].subject`, relation.subject);
59
+ if(relation.object) requireEntity(entityIds, `spatial.relations[${index}].object`, relation.object);
60
+ if(relation.anchor?.kind==='observation'){
61
+ if(anchoredSubjects.has(relation.subject)){
62
+ const error=new TypeError(`WorldIR entity ${relation.subject} has multiple observation anchors`);
63
+ error.code='WORLD_IR_OBSERVATION_ANCHOR_AMBIGUOUS';
64
+ error.entityId=relation.subject;
65
+ throw error;
66
+ }
67
+ anchoredSubjects.add(relation.subject);
68
+ if(entityById.get(relation.subject)?.transform?.position){
69
+ const error=new TypeError(`WorldIR entity ${relation.subject} cannot combine explicit transform.position with an observation anchor`);
70
+ error.code='WORLD_IR_OBSERVATION_ANCHOR_POSITION_CONFLICT';
71
+ error.entityId=relation.subject;
72
+ throw error;
73
+ }
74
+ }
75
+ });
76
+ worldIR.spatial.constraints.forEach((constraint, index) => {
77
+ requireEntity(entityIds, `spatial.constraints[${index}].subject`, constraint.subject);
78
+ requireEntity(entityIds, `spatial.constraints[${index}].object`, constraint.object);
79
+ });
80
+ worldIR.interactions.forEach((interaction, index) => {
81
+ requireEntity(entityIds, `interactions[${index}].targetId`, interaction.targetId);
82
+ requireEntity(entityIds, `interactions[${index}].supportId`, interaction.supportId);
83
+ });
84
+ worldIR.acceptance.forEach((criterion, index) => {
85
+ requireEntity(entityIds, `acceptance[${index}].targetId`, criterion.targetId);
86
+ requireEntity(entityIds, `acceptance[${index}].subject`, criterion.subject);
87
+ requireEntity(entityIds, `acceptance[${index}].object`, criterion.object);
88
+ });
89
+ return worldIR;
90
+ }
91
+
92
+ const assetRequests = (worldIR) => worldIR.entities.map((entity) => ({
93
+ ...(entity.id ? { id:entity.id } : {}),
94
+ ...clone(entity.asset)
95
+ }));
96
+
97
+ const executionEntities = (worldIR) => worldIR.entities.map((entity) => ({
98
+ ...(entity.id ? { id:entity.id } : {}),
99
+ ...(entity.asset.assetId ? { assetRef:createAssetRef(entity.asset.assetId) } : {}),
100
+ ...(entity.transform.position ? { position:[...entity.transform.position] } : {}),
101
+ ...(entity.capabilityIntent.length ? { capabilityIntent:[...entity.capabilityIntent] } : {}),
102
+ ...(hasState(entity) ? { initialState:clone(entity.initialState) } : {})
103
+ }));
104
+
105
+ const compatibilityWorldSpec = (worldIR) => {
106
+ const anchored=worldIR.spatial.relations.find((relation)=>relation.anchor);
107
+ if(anchored){
108
+ const error=new TypeError('Legacy WorldSpec cannot represent observation-anchored relations');
109
+ error.code='WORLD_IR_COMPATIBILITY_UNSUPPORTED';
110
+ error.feature='spatial.relations.anchor';
111
+ throw error;
112
+ }
113
+ return normalizeWorldSpec({
114
+ name:worldIR.intent.name,
115
+ description:worldIR.intent.description,
116
+ generation:clone(worldIR.policy.generation),
117
+ assets:worldIR.entities.map((entity) => ({
118
+ ...(entity.id ? { id:entity.id } : {}),
119
+ ...clone(entity.asset),
120
+ ...(entity.transform.position ? { position:[...entity.transform.position] } : {})
121
+ })),
122
+ relations:worldIR.spatial.relations.map(clone)
123
+ });
124
+ };
125
+
126
+ export function projectWorldIRToWorldSpec(input) {
127
+ return compatibilityWorldSpec(assertWorldIRReferences(normalizeWorldIR(input)));
128
+ }
129
+
130
+ export function compileWorldInput(input) {
131
+ if(input?.schema==='agentscape.world-ir') return compileWorldIR(input);
132
+ const worldIR=upgradeLegacyWorldSpec(input);
133
+ return {
134
+ ...compileWorldIR(worldIR),
135
+ compatibility:{source:'legacy-world-spec',worldSpec:compatibilityWorldSpec(worldIR)}
136
+ };
137
+ }
138
+
139
+ export function compileWorldIR(input) {
140
+ const worldIR = unsupportedExecutionFeatures(assertWorldIRReferences(normalizeWorldIR(input)));
141
+ const behaviorBundle = compileWorldBehaviorBundle(worldIR);
142
+ const physicsRequirements = compileWorldPhysicsRequirements(worldIR);
143
+ const acceptanceGraph = worldIR.acceptance.length ? compileWorldAcceptance(worldIR.acceptance) : null;
144
+
145
+ return {
146
+ schema:WORLD_COMPILATION_SCHEMA,
147
+ schemaVersion:WORLD_COMPILATION_VERSION,
148
+ worldRevisionId:worldIR.revision.id,
149
+ worldIR:clone(worldIR),
150
+ assetRequests:assetRequests(worldIR),
151
+ entities:executionEntities(worldIR),
152
+ relations:worldIR.spatial.relations.map(clone),
153
+ behaviorBundle,
154
+ physicsRequirements,
155
+ acceptanceGraph
156
+ };
157
+ }
@@ -0,0 +1,201 @@
1
+ import { assetIdFromRef } from '../../asset/model/AssetRef.js';
2
+
3
+ const rootColliderExtent = (spec) => {
4
+ const t=spec.translation || [0,0,0];
5
+ if (spec.shape==='box' && spec.halfExtents?.length===3) {
6
+ const [hx,hy,hz]=spec.halfExtents;
7
+ return {radius:Math.hypot(t[0],t[2])+Math.hypot(hx,hz),minY:t[1]-hy};
8
+ }
9
+ if (spec.shape==='cylinder' && Number.isFinite(spec.radius) && Number.isFinite(spec.halfHeight)) {
10
+ return {radius:Math.hypot(t[0],t[2])+spec.radius,minY:t[1]-spec.halfHeight};
11
+ }
12
+ if (spec.shape==='capsule' && Number.isFinite(spec.radius) && Number.isFinite(spec.halfHeight)) {
13
+ return {radius:Math.hypot(t[0],t[2])+spec.radius,minY:t[1]-(spec.halfHeight+spec.radius)};
14
+ }
15
+ if (spec.shape==='convexHull' && Array.isArray(spec.vertices)) {
16
+ let radius=0,minY=Infinity;
17
+ for(let i=0;i+2<spec.vertices.length;i+=3) {
18
+ radius=Math.max(radius,Math.hypot(t[0]+spec.vertices[i],t[2]+spec.vertices[i+2]));
19
+ minY=Math.min(minY,t[1]+spec.vertices[i+1]);
20
+ }
21
+ if (Number.isFinite(minY)) return {radius,minY};
22
+ }
23
+ return null;
24
+ };
25
+
26
+ export function manifestFootprint(manifest) {
27
+ const colliders=manifest?.physics?.colliders || [];
28
+ if (!colliders.length) return {checked:false,reason:'ROOT_COLLIDER_UNAVAILABLE'};
29
+ let radius=.01,minY=Infinity;
30
+ for(const collider of colliders) {
31
+ const extent=rootColliderExtent(collider);
32
+ if (!extent) return {checked:false,reason:'ROOT_COLLIDER_UNSUPPORTED',shape:collider.shape || null};
33
+ radius=Math.max(radius,extent.radius);
34
+ minY=Math.min(minY,extent.minY);
35
+ }
36
+ return {
37
+ checked:true,radius,minY,
38
+ coverage:Object.values(manifest.parts || {}).some((part)=>part.physics?.colliders?.length)?'root-only':'full-root'
39
+ };
40
+ }
41
+
42
+ const candidatePoints = ({minX,maxX,minZ,maxZ,step=1}) => {
43
+ const cx=(minX+maxX)/2,cz=(minZ+maxZ)/2;
44
+ const nx=Math.max(0,Math.floor((maxX-minX)/(2*step)));
45
+ const nz=Math.max(0,Math.floor((maxZ-minZ)/(2*step)));
46
+ const values=[];
47
+ for(let ix=-nx;ix<=nx;ix++) for(let iz=-nz;iz<=nz;iz++) {
48
+ const x=cx+ix*step,z=cz+iz*step;
49
+ if(x<minX-1e-9||x>maxX+1e-9||z<minZ-1e-9||z>maxZ+1e-9) continue;
50
+ values.push({x,z,d2:(x-cx)**2+(z-cz)**2});
51
+ }
52
+ return values.sort((a,b)=>a.d2-b.d2 || a.z-b.z || a.x-b.x);
53
+ };
54
+
55
+ const circlesOverlap=(a,b,clearance)=>Math.hypot(a.x-b.x,a.z-b.z)<a.radius+b.radius+clearance-1e-9;
56
+
57
+ const normalizeLayout=(layout)=>{
58
+ if(!layout?.bounds || !Number.isFinite(layout.groundY)) return {checked:false,reason:'WORLD_LAYOUT_UNAVAILABLE'};
59
+ const [minX,minZ]=layout.bounds.min || [],[maxX,maxZ]=layout.bounds.max || [];
60
+ if(![minX,minZ,maxX,maxZ].every(Number.isFinite) || minX>=maxX || minZ>=maxZ) return {checked:false,reason:'WORLD_LAYOUT_INVALID'};
61
+ return {checked:true,minX,minZ,maxX,maxZ,groundY:layout.groundY,margin:Number.isFinite(layout.margin)?Math.max(0,layout.margin):.5};
62
+ };
63
+
64
+ const checkPosition=(manifest,footprint,position,{layout,reserved=[],poseClear,clearance=.35}={})=>{
65
+ const circle={x:position[0],z:position[2],radius:footprint.radius};
66
+ if(circle.x-footprint.radius<layout.minX+layout.margin || circle.x+footprint.radius>layout.maxX-layout.margin || circle.z-footprint.radius<layout.minZ+layout.margin || circle.z+footprint.radius>layout.maxZ-layout.margin) return {checked:true,clear:false,reason:'OUTSIDE_LAYOUT_BOUNDS',circle};
67
+ if(reserved.some((other)=>circlesOverlap(circle,other,clearance))) return {checked:true,clear:false,reason:'BATCH_FOOTPRINT_OVERLAP',circle};
68
+ const physics=poseClear?.(manifest,position);
69
+ if(!physics?.checked) return {checked:false,clear:false,reason:physics?.reason || 'LAYOUT_PHYSICS_UNAVAILABLE',circle,physics};
70
+ if(!physics.clear) return {checked:true,clear:false,reason:'WORLD_POSE_BLOCKED',blockedBy:physics.blockedBy || [],circle,physics};
71
+ return {checked:true,clear:true,circle,physics};
72
+ };
73
+
74
+ export function preflightWorldPosition(manifest,position,{layout,poseClear,occupied=[],clearance=.35}={}){
75
+ const normalized=normalizeLayout(layout);
76
+ if(!normalized.checked) return normalized;
77
+ if(!Array.isArray(position) || position.length!==3 || !position.every(Number.isFinite)) return {checked:false,reason:'WORLD_POSITION_INVALID'};
78
+ const footprint=manifestFootprint(manifest);
79
+ if(!footprint.checked) return footprint;
80
+ const reserved=[];
81
+ for(const item of occupied){
82
+ if(!item?.manifest || !Array.isArray(item.position) || item.position.length!==3) return {checked:false,reason:'OCCUPIED_POSITION_INVALID'};
83
+ const other=manifestFootprint(item.manifest);
84
+ if(!other.checked) return {checked:false,reason:other.reason,occupiedId:item.id || null};
85
+ reserved.push({x:item.position[0],z:item.position[2],radius:other.radius});
86
+ }
87
+ const verdict=checkPosition(manifest,footprint,position,{layout:normalized,reserved,poseClear,clearance});
88
+ return {...verdict,coverage:footprint.coverage,status:verdict.clear?(footprint.coverage==='root-only'?'provisional':'ready'):'rejected'};
89
+ }
90
+
91
+ export function composeWorldLayout(requests,{getManifest,poseClear,layout,clearance=.35}={}) {
92
+ const normalized=normalizeLayout(layout);
93
+ if(!normalized.checked) return {status:'rejected',reason:normalized.reason,placements:[],issues:[]};
94
+ const {minX,minZ,maxX,maxZ,groundY,margin}=normalized;
95
+ const reserved=[]; const placements=[]; const issues=[];
96
+ let provisional=false;
97
+
98
+ for(const request of requests) {
99
+ const assetId=assetIdFromRef(request.assetRef);
100
+ if (!assetId) continue;
101
+ const manifest=getManifest(assetId);
102
+ const footprint=manifestFootprint(manifest);
103
+ if (!footprint.checked) return {status:'rejected',reason:footprint.reason,placements,issues:[...issues,{id:request.id || null,assetId,reason:footprint.reason}]};
104
+ if (footprint.coverage==='root-only') { provisional=true; issues.push({id:request.id || null,assetId,reason:'ARTICULATED_LAYOUT_ROOT_ONLY'}); }
105
+ const groundPositionY=groundY-footprint.minY+.01;
106
+ const test=(position)=>{
107
+ const verdict=checkPosition(manifest,footprint,position,{layout:normalized,reserved,poseClear,clearance});
108
+ return verdict.clear?{ok:true,circle:verdict.circle,physics:verdict.physics}:{ok:false,reason:verdict.reason,blockedBy:verdict.blockedBy || []};
109
+ };
110
+
111
+ let position=request.position ? [...request.position] : null;
112
+ let mode='explicit';
113
+ const explicitGroundY=groundY-footprint.minY;
114
+ if(position && Math.abs(position[1]-explicitGroundY)<=.03) {
115
+ position[1]=Number(groundPositionY.toFixed(4));
116
+ mode='explicit-grounded';
117
+ }
118
+ let verdict=position ? test(position) : null;
119
+ if (!position) {
120
+ mode='auto';
121
+ const autoY=groundPositionY;
122
+ const step=Math.max(.5,Math.min(2,footprint.radius));
123
+ for(const point of candidatePoints({minX:minX+margin+footprint.radius,maxX:maxX-margin-footprint.radius,minZ:minZ+margin+footprint.radius,maxZ:maxZ-margin-footprint.radius,step})) {
124
+ const candidate=[Number(point.x.toFixed(4)),Number(autoY.toFixed(4)),Number(point.z.toFixed(4))];
125
+ const result=test(candidate);
126
+ if (result.ok) { position=candidate; verdict=result; break; }
127
+ }
128
+ }
129
+ if (!position || !verdict?.ok) return {status:'rejected',reason:verdict?.reason || 'NO_LAYOUT_POSITION',placements,issues:[...issues,{id:request.id || null,assetId,reason:verdict?.reason || 'NO_LAYOUT_POSITION',blockedBy:verdict?.blockedBy || []}]};
130
+ reserved.push(verdict.circle);
131
+ placements.push({id:request.id || null,assetId,position,mode,radius:Number(footprint.radius.toFixed(4)),coverage:footprint.coverage});
132
+ }
133
+ return {status:provisional?'provisional':'ready',reason:provisional?'ARTICULATED_LAYOUT_ROOT_ONLY':null,placements,issues};
134
+ }
135
+
136
+
137
+ export function composeNearPlacement(subjectManifest,targetManifest,targetPosition,{subjectY=0,distance=null,poseClear,clearance=.35}={}) {
138
+ const subject=manifestFootprint(subjectManifest),target=manifestFootprint(targetManifest);
139
+ if (!subject.checked) return {checked:false,reason:subject.reason,source:'subject-footprint'};
140
+ if (!target.checked) return {checked:false,reason:target.reason,source:'target-footprint'};
141
+ const minimum=subject.radius+target.radius+clearance;
142
+ const spacing=distance == null ? minimum : Number(distance);
143
+ if (!Number.isFinite(spacing) || spacing<=0) return {checked:false,reason:'NEAR_DISTANCE_INVALID'};
144
+ if (spacing+1e-9<minimum) return {checked:false,reason:'NEAR_DISTANCE_TOO_SMALL',minimumDistance:minimum,requestedDistance:spacing};
145
+ const [x,,z]=targetPosition;
146
+ const candidates=[[x+spacing,subjectY,z],[x-spacing,subjectY,z],[x,subjectY,z+spacing],[x,subjectY,z-spacing]];
147
+ const blocked=[];
148
+ for (const position of candidates) {
149
+ const result=poseClear(subjectManifest,position);
150
+ if (result?.checked && result.clear) return {
151
+ checked:true,position:position.map((v)=>Number(v.toFixed(4))),distance:Number(spacing.toFixed(4)),
152
+ mode:distance == null?'runtime-derived':'explicit',coverage:subject.coverage
153
+ };
154
+ blocked.push({position,reason:result?.reason || (result?.checked?'WORLD_POSE_BLOCKED':'LAYOUT_PHYSICS_UNAVAILABLE'),blockedBy:result?.blockedBy || []});
155
+ }
156
+ return {checked:false,reason:'NEAR_NO_CLEAR_POSE',distance:spacing,blocked};
157
+ }
158
+
159
+ const observedCenter=(observation)=>{
160
+ const point=observation?.localization?.kind==='point-scale' ? observation.localization.center : observation?.center;
161
+ return Array.isArray(point)&&point.length===3&&point.every(Number.isFinite) ? [...point] : null;
162
+ };
163
+
164
+ export function composeObservedNearPlacement(subjectManifest,observation,{layout,poseClear,distance=null,clearance=.35,maxDistance=3,occupied=[]}={}){
165
+ const normalized=normalizeLayout(layout);
166
+ if(!normalized.checked) return {checked:false,reason:normalized.reason};
167
+ const footprint=manifestFootprint(subjectManifest);
168
+ if(!footprint.checked) return {checked:false,reason:footprint.reason,source:'subject-footprint'};
169
+ const center=observedCenter(observation);
170
+ if(!center) return {checked:false,reason:'OBSERVATION_LOCALIZATION_UNAVAILABLE'};
171
+ if(typeof poseClear!=='function') return {checked:false,reason:'LAYOUT_PHYSICS_UNAVAILABLE'};
172
+ const reserved=[];
173
+ for(const item of occupied){
174
+ if(!item?.manifest || !Array.isArray(item.position) || item.position.length!==3) return {checked:false,reason:'OCCUPIED_POSITION_INVALID'};
175
+ const other=manifestFootprint(item.manifest);
176
+ if(!other.checked) return {checked:false,reason:other.reason,occupiedId:item.id || null};
177
+ reserved.push({x:item.position[0],z:item.position[2],radius:other.radius});
178
+ }
179
+ const explicit=distance!=null;
180
+ const observedScale=Number.isFinite(observation?.localization?.scale)&&observation.localization.scale>0 ? observation.localization.scale : 0;
181
+ const startDistance=explicit ? Number(distance) : Math.max(footprint.radius+clearance+.25,Math.min(1.5,observedScale+footprint.radius+clearance));
182
+ if(!Number.isFinite(startDistance)||startDistance<=0) return {checked:false,reason:'NEAR_DISTANCE_INVALID'};
183
+ const limit=Math.max(startDistance,Number.isFinite(maxDistance)?maxDistance:3);
184
+ const groundY=normalized.groundY-footprint.minY+.01;
185
+ const directions=[[1,0],[-1,0],[0,1],[0,-1],[Math.SQRT1_2,Math.SQRT1_2],[-Math.SQRT1_2,Math.SQRT1_2],[Math.SQRT1_2,-Math.SQRT1_2],[-Math.SQRT1_2,-Math.SQRT1_2]];
186
+ const blocked=[];
187
+ for(let radius=startDistance;radius<=limit+1e-9;radius+=.35){
188
+ for(const [dx,dz] of directions){
189
+ const position=[Number((center[0]+dx*radius).toFixed(4)),Number(groundY.toFixed(4)),Number((center[2]+dz*radius).toFixed(4))];
190
+ const bounds=checkPosition(subjectManifest,footprint,position,{layout:normalized,reserved,poseClear,clearance});
191
+ if(bounds.checked&&bounds.clear) return {
192
+ checked:true,status:footprint.coverage==='root-only'?'provisional':'ready',position,
193
+ distance:Number(Math.hypot(position[0]-center[0],position[2]-center[2]).toFixed(4)),
194
+ requestedDistance:explicit?startDistance:null,mode:explicit?'observation-explicit':'observation-auto',
195
+ observationId:observation?.id||null,anchor:[...center],radius:Number(footprint.radius.toFixed(4)),coverage:footprint.coverage,collisionVerified:true
196
+ };
197
+ blocked.push({position,reason:bounds.reason,blockedBy:bounds.blockedBy||[]});
198
+ }
199
+ }
200
+ return {checked:false,reason:'OBSERVATION_NEAR_NO_CLEAR_POSE',observationId:observation?.id||null,anchor:center,startDistance,maxDistance:limit,blocked};
201
+ }