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,417 @@
1
+ import { s as IncrementalSha256 } from "./environments-B1WaICAN.js";
2
+ // ../../application/scene/WorldStorage.js
3
+ const WORLD_BLOCK_BYTES = 1048576;
4
+ const encoder$1 = new TextEncoder();
5
+ const decoder$1 = new TextDecoder("utf-8", { fatal: true });
6
+ const worldStorageError = (code) => Object.assign(new Error(code), { code });
7
+ function checkHash(hash) {
8
+ if (!/^[a-f0-9]{64}$/.test(hash)) throw worldStorageError("WORLD_HASH_INVALID");
9
+ return hash;
10
+ }
11
+ const hashBytes = (bytes) => new IncrementalSha256().update(bytes).digestHex();
12
+ function checkCancelled(signal) {
13
+ if (signal?.aborted) throw worldStorageError("WORLD_CANCELLED");
14
+ }
15
+ /** Immutable content-addressed blocks. Backend owns durable bytes, never a world/entity cache. */
16
+ var WorldStorage = class {
17
+ constructor(backend) {
18
+ if (!backend?.read || !backend?.write) throw new TypeError("WorldStorage requires a block backend");
19
+ this.backend = backend;
20
+ }
21
+ async put(bytes, { signal } = {}) {
22
+ checkCancelled(signal);
23
+ if (!(bytes instanceof Uint8Array) || bytes.length > 1048576) throw worldStorageError("WORLD_BLOCK_BUDGET");
24
+ const hash = hashBytes(bytes);
25
+ await this.backend.write(hash, bytes);
26
+ checkCancelled(signal);
27
+ return {
28
+ hash,
29
+ bytes: bytes.length
30
+ };
31
+ }
32
+ async read(ref, { signal } = {}) {
33
+ checkCancelled(signal);
34
+ checkHash(ref?.hash);
35
+ if (!Number.isSafeInteger(ref.bytes) || ref.bytes < 0 || ref.bytes > 1048576) throw worldStorageError("WORLD_BLOCK_BUDGET");
36
+ const bytes = await this.backend.read(ref.hash, ref.bytes);
37
+ checkCancelled(signal);
38
+ if (!(bytes instanceof Uint8Array) || bytes.length !== ref.bytes || hashBytes(bytes) !== ref.hash) throw worldStorageError("WORLD_INTEGRITY_MISMATCH");
39
+ return bytes;
40
+ }
41
+ async putNode(kind, data, refs = [], options = {}) {
42
+ return {
43
+ ...await this.put(encoder$1.encode(JSON.stringify({
44
+ kind,
45
+ data,
46
+ refs
47
+ })), options),
48
+ kind
49
+ };
50
+ }
51
+ async node(ref, options = {}) {
52
+ let node;
53
+ try {
54
+ node = JSON.parse(decoder$1.decode(await this.read(ref, options)));
55
+ } catch (error) {
56
+ if (error.code) throw error;
57
+ throw worldStorageError("WORLD_NODE_INVALID");
58
+ }
59
+ if (!node || node.kind !== ref.kind || !Array.isArray(node.refs) || node.refs.length > 2048) throw worldStorageError("WORLD_NODE_INVALID");
60
+ for (const link of node.refs) {
61
+ checkHash(link?.hash);
62
+ if (!Number.isSafeInteger(link.bytes) || link.bytes < 0 || link.bytes > 1048576) throw worldStorageError("WORLD_BLOCK_BUDGET");
63
+ }
64
+ return node;
65
+ }
66
+ /** Page list is immutable; newest page points to its predecessor. No unbounded root index. */
67
+ async writePages(kind, items, { pageSize = 128, signal } = {}) {
68
+ if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 1024) throw worldStorageError("WORLD_PAGE_BUDGET");
69
+ let previous = null, count = 0, page = [];
70
+ const flush = async () => {
71
+ const refs = [...page.flatMap((item) => item.resource ? [item.resource] : []), ...previous ? [previous] : []];
72
+ previous = await this.putNode(kind, {
73
+ items: page,
74
+ previous,
75
+ count
76
+ }, refs, { signal });
77
+ page = [];
78
+ };
79
+ for await (const item of items) {
80
+ checkCancelled(signal);
81
+ page.push(item);
82
+ count++;
83
+ if (page.length === pageSize) await flush();
84
+ }
85
+ if (page.length) await flush();
86
+ return previous;
87
+ }
88
+ async *pages(ref, kind, options = {}) {
89
+ const visited = /* @__PURE__ */ new Set();
90
+ while (ref) {
91
+ if (ref.kind !== kind || visited.has(ref.hash)) throw worldStorageError("WORLD_PAGE_INVALID");
92
+ visited.add(ref.hash);
93
+ const node = await this.node(ref, options), { items, previous } = node.data || {};
94
+ if (!Array.isArray(items) || items.length > 1024 || JSON.stringify(node.refs) !== JSON.stringify([...items.flatMap((item) => item.resource ? [item.resource] : []), ...previous ? [previous] : []])) throw worldStorageError("WORLD_PAGE_INVALID");
95
+ yield items;
96
+ ref = previous;
97
+ }
98
+ }
99
+ /** Consumes bounded chunks with backpressure. Large producer chunks are rejected before copying. */
100
+ async putResource(source, { format = "application/octet-stream", signal } = {}) {
101
+ const digest = new IncrementalSha256();
102
+ let size = 0, previous = null, blocks = [], buffer = new Uint8Array(WORLD_BLOCK_BYTES), used = 0;
103
+ const flushIndex = async () => {
104
+ const refs = [...blocks, ...previous ? [previous] : []];
105
+ previous = await this.putNode("resource-blocks", {
106
+ blocks,
107
+ previous
108
+ }, refs, { signal });
109
+ blocks = [];
110
+ };
111
+ const flushBlock = async () => {
112
+ blocks.push(await this.put(buffer.subarray(0, used), { signal }));
113
+ used = 0;
114
+ if (blocks.length === 128) await flushIndex();
115
+ };
116
+ for await (const chunk of source) {
117
+ checkCancelled(signal);
118
+ if (!(chunk instanceof Uint8Array) || chunk.length > 1048576) throw worldStorageError("WORLD_SOURCE_CHUNK_BUDGET");
119
+ digest.update(chunk);
120
+ size += chunk.length;
121
+ if (!Number.isSafeInteger(size)) throw worldStorageError("WORLD_SIZE_INVALID");
122
+ let offset = 0;
123
+ while (offset < chunk.length) {
124
+ const take = Math.min(chunk.length - offset, buffer.length - used);
125
+ buffer.set(chunk.subarray(offset, offset + take), used);
126
+ used += take;
127
+ offset += take;
128
+ if (used === buffer.length) await flushBlock();
129
+ }
130
+ }
131
+ if (used) await flushBlock();
132
+ if (blocks.length) await flushIndex();
133
+ return this.putNode("resource", {
134
+ sha256: digest.digestHex(),
135
+ size,
136
+ format,
137
+ blocks: previous
138
+ }, previous ? [previous] : [], { signal });
139
+ }
140
+ async *resource(ref, options = {}) {
141
+ if (ref?.kind !== "resource") throw worldStorageError("WORLD_RESOURCE_INVALID");
142
+ const { data, refs } = await this.node(ref, options);
143
+ if (JSON.stringify(refs) !== JSON.stringify(data.blocks ? [data.blocks] : [])) throw worldStorageError("WORLD_RESOURCE_INVALID");
144
+ checkHash(data.sha256);
145
+ if (!Number.isSafeInteger(data.size) || data.size < 0) throw worldStorageError("WORLD_SIZE_INVALID");
146
+ const pages = [], seen = /* @__PURE__ */ new Set();
147
+ let index = data.blocks;
148
+ while (index) {
149
+ if (index.kind !== "resource-blocks" || seen.has(index.hash)) throw worldStorageError("WORLD_RESOURCE_INVALID");
150
+ seen.add(index.hash);
151
+ const node = await this.node(index, options);
152
+ if (!Array.isArray(node.data.blocks) || node.data.blocks.length > 128 || JSON.stringify(node.refs) !== JSON.stringify([...node.data.blocks, ...node.data.previous ? [node.data.previous] : []])) throw worldStorageError("WORLD_RESOURCE_INVALID");
153
+ pages.push(index);
154
+ index = node.data.previous;
155
+ }
156
+ let size = 0;
157
+ const digest = new IncrementalSha256();
158
+ for (const page of pages.reverse()) {
159
+ const node = await this.node(page, options);
160
+ for (const block of node.data.blocks) {
161
+ const bytes = await this.read(block, options);
162
+ size += bytes.length;
163
+ if (size > data.size) throw worldStorageError("WORLD_SIZE_MISMATCH");
164
+ digest.update(bytes);
165
+ yield bytes;
166
+ }
167
+ }
168
+ if (size !== data.size || digest.digestHex() !== data.sha256) throw worldStorageError("WORLD_RESOURCE_INTEGRITY");
169
+ }
170
+ };
171
+ /** File/Blob input, never file.arrayBuffer() on an entire world. */
172
+ async function* blobChunks(blob, { signal } = {}) {
173
+ for (let offset = 0; offset < blob.size; offset += WORLD_BLOCK_BYTES) {
174
+ checkCancelled(signal);
175
+ yield new Uint8Array(await blob.slice(offset, offset + WORLD_BLOCK_BYTES).arrayBuffer());
176
+ }
177
+ }
178
+ // ../../application/scene/WorldDocument.js
179
+ const WORLD_SCHEMA = "agentscape.world";
180
+ /** Only small metadata is in the root. Entity and asset pages are content-addressed chains. */
181
+ async function writeWorldDocument(runtime, storage, { name = "Untitled World", signal, includeCamera = true, includeStyle = true, includeEnvironmentState = true } = {}) {
182
+ if (runtime.mutationOwner) throw worldStorageError("WORLD_BUSY");
183
+ return runtime.exclusiveMutation("world:save", () => writeLocked(runtime, storage, {
184
+ name,
185
+ signal,
186
+ includeCamera,
187
+ includeStyle,
188
+ includeEnvironmentState
189
+ }));
190
+ }
191
+ async function writeLocked(runtime, storage, { name, signal, includeCamera, includeStyle, includeEnvironmentState }) {
192
+ const header = runtime.serializer.serialize(runtime, {
193
+ name,
194
+ includeRelations: false,
195
+ includeObjects: false
196
+ });
197
+ delete header.objects;
198
+ delete header.assets;
199
+ if (!includeCamera) delete header.camera;
200
+ if (!includeStyle && header.metadata) delete header.metadata.stylePack;
201
+ if (!includeEnvironmentState && header.metadata) delete header.metadata.environmentState;
202
+ const assets = /* @__PURE__ */ new Set();
203
+ async function* entities() {
204
+ let ordinal = 0;
205
+ for (const entity of runtime.serializer.objects(runtime)) {
206
+ assets.add(entity.assetId);
207
+ yield {
208
+ ...entity,
209
+ ordinal: ordinal++
210
+ };
211
+ }
212
+ }
213
+ const entitiesRef = await storage.writePages("entities", entities(), { signal });
214
+ async function* assetEntries() {
215
+ for (const id of assets) {
216
+ checkCancelled(signal);
217
+ const manifest = runtime.assetModule.getManifest(id);
218
+ if (manifest.source.kind === "builtin") {
219
+ yield {
220
+ id,
221
+ builtin: true
222
+ };
223
+ continue;
224
+ }
225
+ const bytes = await runtime.assetModule.readAssetBytes(id);
226
+ async function* chunks() {
227
+ for (let offset = 0; offset < bytes.length; offset += WORLD_BLOCK_BYTES) yield bytes.subarray(offset, offset + WORLD_BLOCK_BYTES);
228
+ }
229
+ const resource = await storage.putResource(chunks(), {
230
+ format: "model/gltf-binary",
231
+ signal
232
+ });
233
+ const definition = structuredClone(manifest);
234
+ delete definition.source;
235
+ delete definition.compiler;
236
+ delete definition.verification;
237
+ yield {
238
+ id,
239
+ resource,
240
+ definition
241
+ };
242
+ }
243
+ }
244
+ const assetsRef = await storage.writePages("assets", assetEntries(), { signal });
245
+ return storage.putNode("world", {
246
+ schema: WORLD_SCHEMA,
247
+ version: 1,
248
+ header,
249
+ environment: {
250
+ plugin: runtime.environment.id,
251
+ version: 1
252
+ },
253
+ entities: entitiesRef,
254
+ assets: assetsRef
255
+ }, [entitiesRef, assetsRef].filter(Boolean), { signal });
256
+ }
257
+ async function inspectWorldDocument(storage, root, { plugins, signal } = {}) {
258
+ if (root?.kind !== "world") throw worldStorageError("WORLD_FORMAT_UNSUPPORTED");
259
+ const { data, refs } = await storage.node(root, { signal });
260
+ if (data.schema !== "agentscape.world" || data.version !== 1) throw worldStorageError("WORLD_VERSION_UNSUPPORTED");
261
+ if (JSON.stringify(refs) !== JSON.stringify([data.entities, data.assets].filter(Boolean))) throw worldStorageError("WORLD_DEPENDENCY_INVALID");
262
+ if (!data.environment || data.environment.version !== 1 || !plugins?.has(data.environment.plugin)) throw worldStorageError("WORLD_PLUGIN_UNAVAILABLE");
263
+ if (data.header?.metadata?.environment !== data.environment.plugin) throw worldStorageError("WORLD_ENVIRONMENT_MISMATCH");
264
+ return data;
265
+ }
266
+ /** Host explicitly registers trusted implementations. Package data never supplies executable source. */
267
+ var EnvironmentPlugins = class {
268
+ constructor() {
269
+ this.entries = /* @__PURE__ */ new Map();
270
+ }
271
+ register(id, { version = 1, create }) {
272
+ if (!id || version !== 1 || typeof create !== "function" || this.entries.has(id)) throw worldStorageError("WORLD_PLUGIN_INVALID");
273
+ this.entries.set(id, {
274
+ version,
275
+ create
276
+ });
277
+ return this;
278
+ }
279
+ has(id) {
280
+ return this.entries.has(id);
281
+ }
282
+ async create(descriptor, options) {
283
+ const plugin = this.entries.get(descriptor.plugin);
284
+ if (!plugin || plugin.version !== descriptor.version) throw worldStorageError("WORLD_PLUGIN_UNAVAILABLE");
285
+ return plugin.create(options);
286
+ }
287
+ };
288
+ // ../../application/scene/WorldArchive.js
289
+ const encoder = new TextEncoder();
290
+ const decoder = new TextDecoder("utf-8", { fatal: true });
291
+ const MAGIC = encoder.encode("ASWORLD1");
292
+ const u32 = (value) => {
293
+ const bytes = /* @__PURE__ */ new Uint8Array(4);
294
+ new DataView(bytes.buffer).setUint32(0, value);
295
+ return bytes;
296
+ };
297
+ /** Uncompressed framed content blocks. No filenames, links, executable code or decompression. */
298
+ async function exportWorldArchive(storage, root, writer, { linked = false, signal } = {}) {
299
+ if (!writer?.write) throw new TypeError("A backpressured binary writer is required");
300
+ const header = encoder.encode(JSON.stringify({
301
+ schema: "agentscape.world-package",
302
+ version: 1,
303
+ root,
304
+ linked
305
+ }));
306
+ if (header.length > 4096) throw worldStorageError("WORLD_HEADER_BUDGET");
307
+ const write = async (bytes) => {
308
+ checkCancelled(signal);
309
+ await writer.write(bytes);
310
+ };
311
+ await write(MAGIC);
312
+ await write(u32(header.length));
313
+ await write(header);
314
+ const pending = [root], visited = /* @__PURE__ */ new Set();
315
+ while (!linked && pending.length) {
316
+ const ref = pending.pop();
317
+ if (visited.has(ref.hash)) continue;
318
+ visited.add(ref.hash);
319
+ const bytes = await storage.read(ref, { signal });
320
+ const descriptor = encoder.encode(JSON.stringify(ref));
321
+ if (descriptor.length > 4096) throw worldStorageError("WORLD_HEADER_BUDGET");
322
+ await write(u32(descriptor.length));
323
+ await write(descriptor);
324
+ await write(bytes);
325
+ if (ref.kind) pending.push(...(await storage.node(ref, { signal })).refs);
326
+ }
327
+ await write(u32(0));
328
+ return {
329
+ root,
330
+ blocks: visited.size,
331
+ linked
332
+ };
333
+ }
334
+ var Reader = class {
335
+ constructor(source, signal) {
336
+ this.source = source[Symbol.asyncIterator]();
337
+ this.signal = signal;
338
+ this.chunk = /* @__PURE__ */ new Uint8Array();
339
+ this.offset = 0;
340
+ }
341
+ async take(length) {
342
+ if (length > 1048576) throw worldStorageError("WORLD_BLOCK_BUDGET");
343
+ const result = new Uint8Array(length);
344
+ let written = 0;
345
+ while (written < length) {
346
+ checkCancelled(this.signal);
347
+ if (this.offset === this.chunk.length) {
348
+ const item = await this.source.next();
349
+ if (item.done) throw worldStorageError("WORLD_TRUNCATED");
350
+ if (!(item.value instanceof Uint8Array) || item.value.length > 1048576 || !item.value.length) throw worldStorageError("WORLD_SOURCE_CHUNK_BUDGET");
351
+ this.chunk = item.value;
352
+ this.offset = 0;
353
+ }
354
+ const take = Math.min(length - written, this.chunk.length - this.offset);
355
+ result.set(this.chunk.subarray(this.offset, this.offset + take), written);
356
+ written += take;
357
+ this.offset += take;
358
+ }
359
+ return result;
360
+ }
361
+ async number() {
362
+ return new DataView((await this.take(4)).buffer).getUint32(0);
363
+ }
364
+ async json(length) {
365
+ if (!length || length > 4096) throw worldStorageError("WORLD_HEADER_BUDGET");
366
+ try {
367
+ return JSON.parse(decoder.decode(await this.take(length)));
368
+ } catch (error) {
369
+ if (error.code) throw error;
370
+ throw worldStorageError("WORLD_HEADER_INVALID");
371
+ }
372
+ }
373
+ async end() {
374
+ if (this.offset !== this.chunk.length || !(await this.source.next()).done) throw worldStorageError("WORLD_TRAILING_BYTES");
375
+ }
376
+ };
377
+ /** Writes immutable blocks only. Caller publishes the returned root after semantic validation/commit. */
378
+ async function importWorldArchive(storage, source, { signal } = {}) {
379
+ const reader = new Reader(source, signal);
380
+ try {
381
+ if (decoder.decode(await reader.take(8)) !== "ASWORLD1") throw worldStorageError("WORLD_FORMAT_UNSUPPORTED");
382
+ const header = await reader.json(await reader.number());
383
+ if (header.schema !== "agentscape.world-package" || header.version !== 1 || typeof header.linked !== "boolean") throw worldStorageError("WORLD_VERSION_UNSUPPORTED");
384
+ checkHash(header.root?.hash);
385
+ const visited = /* @__PURE__ */ new Set();
386
+ while (true) {
387
+ const length = await reader.number();
388
+ if (!length) break;
389
+ if (header.linked) throw worldStorageError("WORLD_LINKED_PAYLOAD");
390
+ const ref = await reader.json(length);
391
+ checkHash(ref?.hash);
392
+ if (visited.has(ref.hash)) throw worldStorageError("WORLD_DUPLICATE_BLOCK");
393
+ if (!Number.isSafeInteger(ref.bytes) || ref.bytes < 0 || ref.bytes > 1048576) throw worldStorageError("WORLD_BLOCK_BUDGET");
394
+ const bytes = await reader.take(ref.bytes);
395
+ if (hashBytes(bytes) !== ref.hash) throw worldStorageError("WORLD_INTEGRITY_MISMATCH");
396
+ await storage.put(bytes, { signal });
397
+ visited.add(ref.hash);
398
+ }
399
+ await reader.end();
400
+ const pending = [header.root], checked = /* @__PURE__ */ new Set();
401
+ while (pending.length) {
402
+ const ref = pending.pop();
403
+ if (checked.has(ref.hash)) continue;
404
+ if (!header.linked && !visited.has(ref.hash)) throw worldStorageError("WORLD_DEPENDENCY_MISSING");
405
+ checked.add(ref.hash);
406
+ await storage.read(ref, { signal });
407
+ if (ref.kind) pending.push(...(await storage.node(ref, { signal })).refs);
408
+ }
409
+ if (!header.linked && checked.size !== visited.size) throw worldStorageError("WORLD_UNREFERENCED_BLOCK");
410
+ return header;
411
+ } finally {
412
+ await reader.source.return?.();
413
+ }
414
+ }
415
+ export { writeWorldDocument as a, blobChunks as c, worldStorageError as d, inspectWorldDocument as i, checkCancelled as l, importWorldArchive as n, WORLD_BLOCK_BYTES as o, EnvironmentPlugins as r, WorldStorage as s, exportWorldArchive as t, checkHash as u };
416
+
417
+ //# sourceMappingURL=WorldArchive-dYf1OpSe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorldArchive-dYf1OpSe.js","names":["encoder","decoder"],"sources":["../../../application/scene/WorldStorage.js","../../../application/scene/WorldDocument.js","../../../application/scene/WorldArchive.js"],"sourcesContent":["import { IncrementalSha256 } from '../../modules/artifact/IncrementalSha256.js';\n\nexport const WORLD_BLOCK_BYTES = 1024 * 1024;\nconst encoder = new TextEncoder(), decoder = new TextDecoder('utf-8', { fatal: true });\nexport const worldStorageError = code => Object.assign(new Error(code), { code });\nexport function checkHash(hash) {\n if (!/^[a-f0-9]{64}$/.test(hash)) throw worldStorageError('WORLD_HASH_INVALID');\n return hash;\n}\nexport const hashBytes = bytes => new IncrementalSha256().update(bytes).digestHex();\nexport function checkCancelled(signal) { if (signal?.aborted) throw worldStorageError('WORLD_CANCELLED'); }\n\n/** Immutable content-addressed blocks. Backend owns durable bytes, never a world/entity cache. */\nexport class WorldStorage {\n constructor(backend) {\n if (!backend?.read || !backend?.write) throw new TypeError('WorldStorage requires a block backend');\n this.backend = backend;\n }\n async put(bytes, { signal } = {}) {\n checkCancelled(signal);\n if (!(bytes instanceof Uint8Array) || bytes.length > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');\n const hash = hashBytes(bytes);\n await this.backend.write(hash, bytes);\n checkCancelled(signal);\n return { hash, bytes: bytes.length };\n }\n async read(ref, { signal } = {}) {\n checkCancelled(signal); checkHash(ref?.hash);\n if (!Number.isSafeInteger(ref.bytes) || ref.bytes < 0 || ref.bytes > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');\n const bytes = await this.backend.read(ref.hash, ref.bytes);\n checkCancelled(signal);\n if (!(bytes instanceof Uint8Array) || bytes.length !== ref.bytes || hashBytes(bytes) !== ref.hash) throw worldStorageError('WORLD_INTEGRITY_MISMATCH');\n return bytes;\n }\n async putNode(kind, data, refs = [], options = {}) {\n return { ...await this.put(encoder.encode(JSON.stringify({ kind, data, refs })), options), kind };\n }\n async node(ref, options = {}) {\n let node;\n try { node = JSON.parse(decoder.decode(await this.read(ref, options))); }\n catch (error) { if (error.code) throw error; throw worldStorageError('WORLD_NODE_INVALID'); }\n if (!node || node.kind !== ref.kind || !Array.isArray(node.refs) || node.refs.length > 2048) throw worldStorageError('WORLD_NODE_INVALID');\n for (const link of node.refs) {\n checkHash(link?.hash);\n if (!Number.isSafeInteger(link.bytes) || link.bytes < 0 || link.bytes > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');\n }\n return node;\n }\n /** Page list is immutable; newest page points to its predecessor. No unbounded root index. */\n async writePages(kind, items, { pageSize = 128, signal } = {}) {\n if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 1024) throw worldStorageError('WORLD_PAGE_BUDGET');\n let previous = null, count = 0, page = [];\n const flush = async () => {\n const refs = [...page.flatMap(item => item.resource ? [item.resource] : []), ...(previous ? [previous] : [])];\n previous = await this.putNode(kind, { items: page, previous, count }, refs, { signal });\n page = [];\n };\n for await (const item of items) {\n checkCancelled(signal); page.push(item); count++;\n if (page.length === pageSize) await flush();\n }\n if (page.length) await flush();\n return previous;\n }\n async *pages(ref, kind, options = {}) {\n const visited = new Set();\n while (ref) {\n if (ref.kind !== kind || visited.has(ref.hash)) throw worldStorageError('WORLD_PAGE_INVALID');\n visited.add(ref.hash);\n const node = await this.node(ref, options), { items, previous } = node.data || {};\n if (!Array.isArray(items) || items.length > 1024 || JSON.stringify(node.refs) !== JSON.stringify([...items.flatMap(item => item.resource ? [item.resource] : []), ...(previous ? [previous] : [])])) throw worldStorageError('WORLD_PAGE_INVALID');\n yield items; ref = previous;\n }\n }\n /** Consumes bounded chunks with backpressure. Large producer chunks are rejected before copying. */\n async putResource(source, { format = 'application/octet-stream', signal } = {}) {\n const digest = new IncrementalSha256();\n let size = 0, previous = null, blocks = [], buffer = new Uint8Array(WORLD_BLOCK_BYTES), used = 0;\n const flushIndex = async () => {\n const refs = [...blocks, ...(previous ? [previous] : [])];\n previous = await this.putNode('resource-blocks', { blocks, previous }, refs, { signal }); blocks = [];\n };\n const flushBlock = async () => {\n blocks.push(await this.put(buffer.subarray(0, used), { signal })); used = 0;\n if (blocks.length === 128) await flushIndex();\n };\n for await (const chunk of source) {\n checkCancelled(signal);\n if (!(chunk instanceof Uint8Array) || chunk.length > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_SOURCE_CHUNK_BUDGET');\n digest.update(chunk); size += chunk.length;\n if (!Number.isSafeInteger(size)) throw worldStorageError('WORLD_SIZE_INVALID');\n let offset = 0;\n while (offset < chunk.length) {\n const take = Math.min(chunk.length - offset, buffer.length - used);\n buffer.set(chunk.subarray(offset, offset + take), used); used += take; offset += take;\n if (used === buffer.length) await flushBlock();\n }\n }\n if (used) await flushBlock();\n if (blocks.length) await flushIndex();\n return this.putNode('resource', { sha256: digest.digestHex(), size, format, blocks: previous }, previous ? [previous] : [], { signal });\n }\n async *resource(ref, options = {}) {\n if (ref?.kind !== 'resource') throw worldStorageError('WORLD_RESOURCE_INVALID');\n const { data, refs } = await this.node(ref, options);\n if (JSON.stringify(refs) !== JSON.stringify(data.blocks ? [data.blocks] : [])) throw worldStorageError('WORLD_RESOURCE_INVALID');\n checkHash(data.sha256);\n if (!Number.isSafeInteger(data.size) || data.size < 0) throw worldStorageError('WORLD_SIZE_INVALID');\n // Only small index descriptors are retained, not resource bytes.\n const pages = [], seen = new Set(); let index = data.blocks;\n while (index) {\n if (index.kind !== 'resource-blocks' || seen.has(index.hash)) throw worldStorageError('WORLD_RESOURCE_INVALID');\n seen.add(index.hash);\n const node = await this.node(index, options);\n if (!Array.isArray(node.data.blocks) || node.data.blocks.length > 128 || JSON.stringify(node.refs) !== JSON.stringify([...node.data.blocks, ...(node.data.previous ? [node.data.previous] : [])])) throw worldStorageError('WORLD_RESOURCE_INVALID');\n pages.push(index); index = node.data.previous;\n }\n let size = 0; const digest = new IncrementalSha256();\n for (const page of pages.reverse()) {\n const node = await this.node(page, options);\n for (const block of node.data.blocks) {\n const bytes = await this.read(block, options); size += bytes.length;\n if (size > data.size) throw worldStorageError('WORLD_SIZE_MISMATCH');\n digest.update(bytes); yield bytes;\n }\n }\n if (size !== data.size || digest.digestHex() !== data.sha256) throw worldStorageError('WORLD_RESOURCE_INTEGRITY');\n }\n}\n\n/** File/Blob input, never file.arrayBuffer() on an entire world. */\nexport async function* blobChunks(blob, { signal } = {}) {\n for (let offset = 0; offset < blob.size; offset += WORLD_BLOCK_BYTES) {\n checkCancelled(signal);\n yield new Uint8Array(await blob.slice(offset, offset + WORLD_BLOCK_BYTES).arrayBuffer());\n }\n}\n","import { WORLD_BLOCK_BYTES, checkCancelled, worldStorageError } from './WorldStorage.js';\n\nexport const WORLD_SCHEMA = 'agentscape.world';\nexport const WORLD_VERSION = 1;\n\n/** Only small metadata is in the root. Entity and asset pages are content-addressed chains. */\nexport async function writeWorldDocument(runtime, storage, { name = 'Untitled World', signal, includeCamera = true, includeStyle = true, includeEnvironmentState = true } = {}) {\n if (runtime.mutationOwner) throw worldStorageError('WORLD_BUSY');\n return runtime.exclusiveMutation('world:save', () => writeLocked(runtime, storage, { name, signal, includeCamera, includeStyle, includeEnvironmentState }));\n}\n\nasync function writeLocked(runtime, storage, { name, signal, includeCamera, includeStyle, includeEnvironmentState }) {\n const header = runtime.serializer.serialize(runtime, { name, includeRelations: false, includeObjects: false });\n delete header.objects; delete header.assets;\n if (!includeCamera) delete header.camera;\n if (!includeStyle && header.metadata) delete header.metadata.stylePack;\n if (!includeEnvironmentState && header.metadata) delete header.metadata.environmentState;\n const assets = new Set();\n async function* entities() {\n let ordinal = 0;\n for (const entity of runtime.serializer.objects(runtime)) {\n assets.add(entity.assetId);\n yield { ...entity, ordinal: ordinal++ };\n }\n }\n const entitiesRef = await storage.writePages('entities', entities(), { signal });\n async function* assetEntries() {\n for (const id of assets) {\n checkCancelled(signal);\n const manifest = runtime.assetModule.getManifest(id);\n if (manifest.source.kind === 'builtin') {\n yield { id, builtin: true }; continue;\n }\n // This read is one decode unit, never all world resources. AssetModule must enforce its decode budget.\n const bytes = await runtime.assetModule.readAssetBytes(id);\n async function* chunks() {\n for (let offset = 0; offset < bytes.length; offset += WORLD_BLOCK_BYTES) yield bytes.subarray(offset, offset + WORLD_BLOCK_BYTES);\n }\n const resource = await storage.putResource(chunks(), { format: 'model/gltf-binary', signal });\n const definition = structuredClone(manifest);\n delete definition.source; delete definition.compiler; delete definition.verification;\n yield { id, resource, definition };\n }\n }\n const assetsRef = await storage.writePages('assets', assetEntries(), { signal });\n return storage.putNode('world', { schema: WORLD_SCHEMA, version: WORLD_VERSION, header,\n environment: { plugin: runtime.environment.id, version: 1 }, entities: entitiesRef, assets: assetsRef },\n [entitiesRef, assetsRef].filter(Boolean), { signal });\n}\n\nexport async function inspectWorldDocument(storage, root, { plugins, signal } = {}) {\n if (root?.kind !== 'world') throw worldStorageError('WORLD_FORMAT_UNSUPPORTED');\n const { data, refs } = await storage.node(root, { signal });\n if (data.schema !== WORLD_SCHEMA || data.version !== WORLD_VERSION) throw worldStorageError('WORLD_VERSION_UNSUPPORTED');\n if (JSON.stringify(refs) !== JSON.stringify([data.entities, data.assets].filter(Boolean))) throw worldStorageError('WORLD_DEPENDENCY_INVALID');\n if (!data.environment || data.environment.version !== 1 || !plugins?.has(data.environment.plugin)) throw worldStorageError('WORLD_PLUGIN_UNAVAILABLE');\n if (data.header?.metadata?.environment !== data.environment.plugin) throw worldStorageError('WORLD_ENVIRONMENT_MISMATCH');\n return data;\n}\n\n/** Host explicitly registers trusted implementations. Package data never supplies executable source. */\nexport class EnvironmentPlugins {\n constructor() { this.entries = new Map(); }\n register(id, { version = 1, create }) {\n if (!id || version !== 1 || typeof create !== 'function' || this.entries.has(id)) throw worldStorageError('WORLD_PLUGIN_INVALID');\n this.entries.set(id, { version, create }); return this;\n }\n has(id) { return this.entries.has(id); }\n async create(descriptor, options) {\n const plugin = this.entries.get(descriptor.plugin);\n if (!plugin || plugin.version !== descriptor.version) throw worldStorageError('WORLD_PLUGIN_UNAVAILABLE');\n return plugin.create(options);\n }\n}\n","import { WORLD_BLOCK_BYTES, checkHash, hashBytes, checkCancelled, worldStorageError } from './WorldStorage.js';\n\nconst encoder = new TextEncoder(), decoder = new TextDecoder('utf-8', { fatal: true });\nconst MAGIC = encoder.encode('ASWORLD1');\nconst u32 = value => { const bytes = new Uint8Array(4); new DataView(bytes.buffer).setUint32(0, value); return bytes; };\n\n/** Uncompressed framed content blocks. No filenames, links, executable code or decompression. */\nexport async function exportWorldArchive(storage, root, writer, { linked = false, signal } = {}) {\n if (!writer?.write) throw new TypeError('A backpressured binary writer is required');\n const header = encoder.encode(JSON.stringify({ schema: 'agentscape.world-package', version: 1, root, linked }));\n if (header.length > 4096) throw worldStorageError('WORLD_HEADER_BUDGET');\n const write = async bytes => { checkCancelled(signal); await writer.write(bytes); };\n await write(MAGIC); await write(u32(header.length)); await write(header);\n const pending = [root], visited = new Set();\n while (!linked && pending.length) {\n const ref = pending.pop();\n if (visited.has(ref.hash)) continue;\n visited.add(ref.hash);\n const bytes = await storage.read(ref, { signal });\n const descriptor = encoder.encode(JSON.stringify(ref));\n if (descriptor.length > 4096) throw worldStorageError('WORLD_HEADER_BUDGET');\n await write(u32(descriptor.length)); await write(descriptor); await write(bytes);\n if (ref.kind) pending.push(...(await storage.node(ref, { signal })).refs);\n }\n await write(u32(0));\n return { root, blocks: visited.size, linked };\n}\n\nclass Reader {\n constructor(source, signal) { this.source = source[Symbol.asyncIterator](); this.signal = signal; this.chunk = new Uint8Array(); this.offset = 0; }\n async take(length) {\n if (length > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');\n const result = new Uint8Array(length); let written = 0;\n while (written < length) {\n checkCancelled(this.signal);\n if (this.offset === this.chunk.length) {\n const item = await this.source.next();\n if (item.done) throw worldStorageError('WORLD_TRUNCATED');\n if (!(item.value instanceof Uint8Array) || item.value.length > WORLD_BLOCK_BYTES || !item.value.length) throw worldStorageError('WORLD_SOURCE_CHUNK_BUDGET');\n this.chunk = item.value; this.offset = 0;\n }\n const take = Math.min(length - written, this.chunk.length - this.offset);\n result.set(this.chunk.subarray(this.offset, this.offset + take), written); written += take; this.offset += take;\n }\n return result;\n }\n async number() { return new DataView((await this.take(4)).buffer).getUint32(0); }\n async json(length) {\n if (!length || length > 4096) throw worldStorageError('WORLD_HEADER_BUDGET');\n try { return JSON.parse(decoder.decode(await this.take(length))); }\n catch (error) { if (error.code) throw error; throw worldStorageError('WORLD_HEADER_INVALID'); }\n }\n async end() { if (this.offset !== this.chunk.length || !(await this.source.next()).done) throw worldStorageError('WORLD_TRAILING_BYTES'); }\n}\n\n/** Writes immutable blocks only. Caller publishes the returned root after semantic validation/commit. */\nexport async function importWorldArchive(storage, source, { signal } = {}) {\n const reader = new Reader(source, signal);\n try {\n if (decoder.decode(await reader.take(8)) !== 'ASWORLD1') throw worldStorageError('WORLD_FORMAT_UNSUPPORTED');\n const header = await reader.json(await reader.number());\n if (header.schema !== 'agentscape.world-package' || header.version !== 1 || typeof header.linked !== 'boolean') throw worldStorageError('WORLD_VERSION_UNSUPPORTED');\n checkHash(header.root?.hash);\n const visited = new Set();\n while (true) {\n const length = await reader.number(); if (!length) break;\n if (header.linked) throw worldStorageError('WORLD_LINKED_PAYLOAD');\n const ref = await reader.json(length); checkHash(ref?.hash);\n if (visited.has(ref.hash)) throw worldStorageError('WORLD_DUPLICATE_BLOCK');\n if (!Number.isSafeInteger(ref.bytes) || ref.bytes < 0 || ref.bytes > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');\n const bytes = await reader.take(ref.bytes);\n if (hashBytes(bytes) !== ref.hash) throw worldStorageError('WORLD_INTEGRITY_MISMATCH');\n await storage.put(bytes, { signal }); visited.add(ref.hash);\n }\n await reader.end();\n // Validate all declared graph edges, including linked packages, before returning a usable root.\n const pending = [header.root], checked = new Set();\n while (pending.length) {\n const ref = pending.pop(); if (checked.has(ref.hash)) continue;\n if (!header.linked && !visited.has(ref.hash)) throw worldStorageError('WORLD_DEPENDENCY_MISSING');\n checked.add(ref.hash); await storage.read(ref, { signal });\n if (ref.kind) pending.push(...(await storage.node(ref, { signal })).refs);\n }\n if (!header.linked && checked.size !== visited.size) throw worldStorageError('WORLD_UNREFERENCED_BLOCK');\n return header;\n } finally { await reader.source.return?.(); }\n}\n"],"mappings":";;AAEA,MAAa,oBAAoB;AACjC,MAAMA,YAAU,IAAI,YAAY;AAAGC,MAAAA,YAAU,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AACrF,MAAa,qBAAoB,SAAQ,OAAO,OAAO,IAAI,MAAM,IAAI,GAAG,EAAE,KAAK,CAAC;AAChF,SAAgB,UAAU,MAAM;CAC9B,IAAI,CAAC,iBAAiB,KAAK,IAAI,GAAG,MAAM,kBAAkB,oBAAoB;CAC9E,OAAO;AACT;AACA,MAAa,aAAY,UAAS,IAAI,kBAAkB,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,UAAU;AAClF,SAAgB,eAAe,QAAQ;CAAE,IAAI,QAAQ,SAAS,MAAM,kBAAkB,iBAAiB;AAAG;;AAG1G,IAAa,eAAb,MAA0B;CACxB,YAAY,SAAS;EACnB,IAAI,CAAC,SAAS,QAAQ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AK,IAAI,QAAA,SAA2B,MAAM,kBAAkB,oBAAoB;GACpI,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,KAAK;GACzC,IAAI,UAAU,KAAK,MAAM,IAAI,MAAM,MAAM,kBAAkB,0BAA0B;GACrF,MAAM,QAAQ,IAAI,OAAO,EAAE,OAAO,CAAC;GAAG,QAAQ,IAAI,IAAI,IAAI;EAC5D;EACA,MAAM,OAAO,IAAI;EAEjB,MAAM,UAAU,CAAC,OAAO,IAAI,GAAG,0BAAU,IAAI,IAAI;EACjD,OAAO,QAAQ,QAAQ;GACrB,MAAM,MAAM,QAAQ,IAAI;GAAG,IAAI,QAAQ,IAAI,IAAI,IAAI,GAAG;GACtD,IAAI,CAAC,OAAO,UAAU,CAAC,QAAQ,IAAI,IAAI,IAAI,GAAG,MAAM,kBAAkB,0BAA0B;GAChG,QAAQ,IAAI,IAAI,IAAI;GAAG,MAAM,QAAQ,KAAK,KAAK,EAAE,OAAO,CAAC;GACzD,IAAI,IAAI,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,KAAK,KAAK,EAAE,OAAO,CAAC,EAAA,CAAG,IAAI;EAC1E;EACA,IAAI,CAAC,OAAO,UAAU,QAAQ,SAAS,QAAQ,MAAM,MAAM,kBAAkB,0BAA0B;EACvG,OAAO;CACT,UAAU;EAAE,MAAM,OAAO,OAAO,SAAS;CAAG;AAC9C"}
@@ -0,0 +1,149 @@
1
+ import { _ as assetManifests, l as createAssetModule, n as ENVIRONMENTS } from "./environments-B1WaICAN.js";
2
+ import { t as SceneSerializer } from "./SceneSerializer-CLCzQjL_.js";
3
+ import { a as writeWorldDocument, d as worldStorageError, i as inspectWorldDocument, l as checkCancelled, n as importWorldArchive, r as EnvironmentPlugins, t as exportWorldArchive } from "./WorldArchive-dYf1OpSe.js";
4
+ // ../../application/scene/WorldIO.js
5
+ function builtinEnvironmentPlugins() {
6
+ const plugins = new EnvironmentPlugins();
7
+ for (const environment of ENVIRONMENTS) plugins.register(environment.id, { create: async (options) => (await environment.load())({
8
+ loadAssets: typeof document !== "undefined",
9
+ ...options
10
+ }) });
11
+ return plugins;
12
+ }
13
+ /** Single data import lifecycle: inspect, prepare isolated resources/state, validate, commit. */
14
+ async function prepareWorld(storage, root, { plugins = builtinEnvironmentPlugins(), signal, active = "saved", maxActiveEntities = 256, gltfLoader, onStage = () => {} } = {}) {
15
+ onStage("inspect");
16
+ const document = await inspectWorldDocument(storage, root, {
17
+ plugins,
18
+ signal
19
+ });
20
+ if (![
21
+ "saved",
22
+ "none",
23
+ "bounded"
24
+ ].includes(active) || !Number.isSafeInteger(maxActiveEntities) || maxActiveEntities < 0) throw worldStorageError("WORLD_ACTIVATION_BUDGET");
25
+ onStage("prepare");
26
+ const builtinManifests = Object.fromEntries(Object.entries(assetManifests).filter(([, manifest]) => manifest.source?.kind === "builtin"));
27
+ const assets = createAssetModule({
28
+ volatile: true,
29
+ manifests: builtinManifests,
30
+ manifestStore: null,
31
+ libraryStore: null,
32
+ gltfLoader
33
+ });
34
+ let environment = null;
35
+ try {
36
+ const ids = /* @__PURE__ */ new Set(), manifests = [];
37
+ for await (const page of storage.pages(document.assets, "assets", { signal })) for (const item of page) {
38
+ if (typeof item.id !== "string" || ids.has(item.id)) throw worldStorageError("WORLD_ASSET_ID_CONFLICT");
39
+ ids.add(item.id);
40
+ if (item.builtin === true) {
41
+ if (!assets.hasAsset(item.id) || assets.getManifest(item.id).source.kind !== "builtin") throw worldStorageError("WORLD_ASSET_UNAVAILABLE");
42
+ continue;
43
+ }
44
+ if (assets.hasAsset(item.id) || item.definition?.id !== item.id || item.definition?.source) throw worldStorageError("WORLD_ASSET_ID_CONFLICT");
45
+ const resource = await storage.node(item.resource, { signal });
46
+ if (resource.data.format !== "model/gltf-binary") throw worldStorageError("WORLD_RESOURCE_FORMAT");
47
+ for await (const _chunk of storage.resource(item.resource, { signal })) checkCancelled(signal);
48
+ const key = resource.data.sha256;
49
+ if (!assets.compiledStore.sources.has(key)) assets.compiledStore.registerSource(key, {
50
+ bytes: resource.data.size,
51
+ read: () => storage.resource(item.resource)
52
+ });
53
+ const manifest = {
54
+ ...item.definition,
55
+ source: {
56
+ kind: "compiled",
57
+ key
58
+ }
59
+ };
60
+ assets.registry.registerManifest(manifest);
61
+ manifests.push(manifest);
62
+ }
63
+ const objects = [];
64
+ let activeCount = 0;
65
+ for await (const page of storage.pages(document.entities, "entities", { signal })) for (const object of page) {
66
+ if (!ids.has(object.assetId)) throw worldStorageError("WORLD_DEPENDENCY_MISSING");
67
+ if (!Number.isSafeInteger(object.ordinal) || object.ordinal < 0) throw worldStorageError("WORLD_ENTITY_ORDINAL");
68
+ if (active === "none" || active === "bounded" && activeCount >= maxActiveEntities) object.active = false;
69
+ if (object.active !== false && ++activeCount > maxActiveEntities) throw worldStorageError("WORLD_ACTIVATION_BUDGET");
70
+ objects.push(object);
71
+ }
72
+ objects.sort((a, b) => a.ordinal - b.ordinal);
73
+ const ordered = objects.map(({ ordinal, ...object }, index) => {
74
+ if (ordinal !== index) throw worldStorageError("WORLD_ENTITY_ORDINAL");
75
+ return object;
76
+ });
77
+ onStage("validate");
78
+ const snapshot = new SceneSerializer().validate({
79
+ ...document.header,
80
+ objects: ordered,
81
+ assets: manifests
82
+ });
83
+ checkCancelled(signal);
84
+ environment = await plugins.create(document.environment, {});
85
+ checkCancelled(signal);
86
+ if (environment?.id !== document.environment.plugin) throw worldStorageError("WORLD_PLUGIN_ID_MISMATCH");
87
+ let state = "prepared";
88
+ return {
89
+ summary: {
90
+ entities: objects.length,
91
+ assets: ids.size,
92
+ activeEntities: activeCount,
93
+ dormantEntities: objects.length - activeCount,
94
+ environment: environment.id
95
+ },
96
+ async commit(runtime) {
97
+ if (state !== "prepared") throw worldStorageError("WORLD_PREPARED_STATE");
98
+ checkCancelled(signal);
99
+ state = "committing";
100
+ onStage("commit");
101
+ try {
102
+ await runtime.installWorld({
103
+ snapshot,
104
+ assetModule: assets,
105
+ environment
106
+ });
107
+ state = "committed";
108
+ } catch (error) {
109
+ state = "failed";
110
+ environment.dispose?.();
111
+ assets.loader.gltfLoader.dispose?.();
112
+ throw error;
113
+ }
114
+ return {
115
+ root,
116
+ entities: objects.length
117
+ };
118
+ },
119
+ dispose() {
120
+ if (state === "prepared") {
121
+ state = "disposed";
122
+ environment.dispose?.();
123
+ assets.loader.gltfLoader.dispose?.();
124
+ }
125
+ }
126
+ };
127
+ } catch (error) {
128
+ environment?.dispose?.();
129
+ assets.loader.gltfLoader.dispose?.();
130
+ throw error;
131
+ }
132
+ }
133
+ async function importWorld(runtime, storage, source, options = {}) {
134
+ const { root } = await importWorldArchive(storage, source, options);
135
+ const prepared = await prepareWorld(storage, root, options);
136
+ try {
137
+ return await prepared.commit(runtime);
138
+ } finally {
139
+ prepared.dispose();
140
+ }
141
+ }
142
+ async function exportWorld(runtime, storage, writer, options = {}) {
143
+ const root = await writeWorldDocument(runtime, storage, options);
144
+ if (writer) await exportWorldArchive(storage, root, writer, options);
145
+ return root;
146
+ }
147
+ export { exportWorld, importWorld, prepareWorld };
148
+
149
+ //# sourceMappingURL=WorldIO-Dqz4MqTQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorldIO-Dqz4MqTQ.js","names":[],"sources":["../../../application/scene/WorldIO.js"],"sourcesContent":["import { createAssetModule } from '../../modules/asset/AssetModule.js';\nimport { assetManifests } from '../../modules/asset/registry/manifests/index.js';\nimport { SceneSerializer } from '../../modules/world/runtime/SceneSerializer.js';\nimport { inspectWorldDocument, writeWorldDocument, EnvironmentPlugins } from './WorldDocument.js';\nimport { importWorldArchive, exportWorldArchive } from './WorldArchive.js';\nimport { checkCancelled, worldStorageError } from './WorldStorage.js';\nimport { ENVIRONMENTS } from '../../modules/world/content/environments.js';\n\nexport function builtinEnvironmentPlugins() {\n const plugins = new EnvironmentPlugins();\n for (const environment of ENVIRONMENTS) plugins.register(environment.id, {\n create: async options => (await environment.load())({ loadAssets: typeof document !== 'undefined', ...options })\n });\n return plugins;\n}\n\n/** Single data import lifecycle: inspect, prepare isolated resources/state, validate, commit. */\nexport async function prepareWorld(storage, root, {\n plugins = builtinEnvironmentPlugins(), signal, active = 'saved', maxActiveEntities = 256, gltfLoader,\n onStage = () => {}\n} = {}) {\n onStage('inspect');\n const document = await inspectWorldDocument(storage, root, { plugins, signal });\n if (!['saved', 'none', 'bounded'].includes(active) || !Number.isSafeInteger(maxActiveEntities) || maxActiveEntities < 0) throw worldStorageError('WORLD_ACTIVATION_BUDGET');\n onStage('prepare');\n const builtinManifests = Object.fromEntries(Object.entries(assetManifests).filter(([, manifest]) => manifest.source?.kind === 'builtin'));\n const assets = createAssetModule({ volatile: true, manifests: builtinManifests, manifestStore: null, libraryStore: null, gltfLoader });\n // A failed pre-commit preparation must release resources that were never installed.\n let environment = null;\n try {\n const ids = new Set(), manifests = [];\n for await (const page of storage.pages(document.assets, 'assets', { signal })) {\n for (const item of page) {\n if (typeof item.id !== 'string' || ids.has(item.id)) throw worldStorageError('WORLD_ASSET_ID_CONFLICT');\n ids.add(item.id);\n if (item.builtin === true) {\n if (!assets.hasAsset(item.id) || assets.getManifest(item.id).source.kind !== 'builtin') throw worldStorageError('WORLD_ASSET_UNAVAILABLE');\n continue;\n }\n if (assets.hasAsset(item.id) || item.definition?.id !== item.id || item.definition?.source) throw worldStorageError('WORLD_ASSET_ID_CONFLICT');\n const resource = await storage.node(item.resource, { signal });\n if (resource.data.format !== 'model/gltf-binary') throw worldStorageError('WORLD_RESOURCE_FORMAT');\n // Fully validate stream before any Runtime mutation, but retain no resource bytes.\n for await (const _chunk of storage.resource(item.resource, { signal })) checkCancelled(signal);\n const key = resource.data.sha256;\n if (!assets.compiledStore.sources.has(key)) assets.compiledStore.registerSource(key, {\n bytes: resource.data.size, read: () => storage.resource(item.resource)\n });\n const manifest = { ...item.definition, source: { kind: 'compiled', key } };\n assets.registry.registerManifest(manifest); manifests.push(manifest);\n }\n }\n const objects = []; let activeCount = 0;\n for await (const page of storage.pages(document.entities, 'entities', { signal })) {\n for (const object of page) {\n if (!ids.has(object.assetId)) throw worldStorageError('WORLD_DEPENDENCY_MISSING');\n if (!Number.isSafeInteger(object.ordinal) || object.ordinal < 0) throw worldStorageError('WORLD_ENTITY_ORDINAL');\n if (active === 'none' || (active === 'bounded' && activeCount >= maxActiveEntities)) object.active = false;\n if (object.active !== false && ++activeCount > maxActiveEntities) throw worldStorageError('WORLD_ACTIVATION_BUDGET');\n objects.push(object);\n }\n }\n objects.sort((a, b) => a.ordinal - b.ordinal);\n const ordered = objects.map(({ ordinal, ...object }, index) => {\n if (ordinal !== index) throw worldStorageError('WORLD_ENTITY_ORDINAL');\n return object;\n });\n onStage('validate');\n const snapshot = new SceneSerializer().validate({ ...document.header, objects: ordered, assets: manifests });\n checkCancelled(signal);\n environment = await plugins.create(document.environment, {});\n checkCancelled(signal);\n if (environment?.id !== document.environment.plugin) throw worldStorageError('WORLD_PLUGIN_ID_MISMATCH');\n let state = 'prepared';\n return {\n summary: { entities: objects.length, assets: ids.size, activeEntities: activeCount, dormantEntities: objects.length - activeCount, environment: environment.id },\n async commit(runtime) {\n if (state !== 'prepared') throw worldStorageError('WORLD_PREPARED_STATE');\n checkCancelled(signal); state = 'committing'; onStage('commit');\n try { await runtime.installWorld({ snapshot, assetModule: assets, environment }); state = 'committed'; }\n catch (error) { state = 'failed'; environment.dispose?.(); assets.loader.gltfLoader.dispose?.(); throw error; }\n return { root, entities: objects.length };\n },\n dispose() { if (state === 'prepared') { state = 'disposed'; environment.dispose?.(); assets.loader.gltfLoader.dispose?.(); } }\n };\n } catch (error) {\n environment?.dispose?.();\n assets.loader.gltfLoader.dispose?.();\n throw error;\n }\n}\n\nexport async function importWorld(runtime, storage, source, options = {}) {\n const { root } = await importWorldArchive(storage, source, options);\n const prepared = await prepareWorld(storage, root, options);\n try { return await prepared.commit(runtime); } finally { prepared.dispose(); }\n}\n\nexport async function exportWorld(runtime, storage, writer, options = {}) {\n const root = await writeWorldDocument(runtime, storage, options);\n if (writer) await exportWorldArchive(stor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