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,232 @@
1
+ import { mechanicalDraftSchema } from '../../modules/asset/model/MechanicalAssetDraft.js';
2
+ import { recipeSchema, threeCodeInputSchema } from '../../modules/asset/model/AssetInputContracts.js';
3
+ import { prepareThreeCodeAsset } from '../programmatic-assets/ThreeCodeAsset.js';
4
+
5
+ const fail = code => Object.assign(new Error(code), { code });
6
+ const clone = value => structuredClone(value);
7
+ const parse = source => source?.schema === 'agentscape.mechanical-draft'
8
+ ? mechanicalDraftSchema.parse(source)
9
+ : source?.schema === 'agentscape.asset-recipe' ? recipeSchema.parse(source)
10
+ : source?.kind === 'three-code' ? threeCodeInputSchema.parse(source)
11
+ : (() => { throw fail('OBJECT_DEFINITION_UNSUPPORTED'); })();
12
+
13
+ function changeAt(document, { path, value }) {
14
+ if (typeof path !== 'string' || path.length > 192
15
+ || !/^\/(components|motions|parts|definition)\//.test(path))
16
+ throw fail('OBJECT_PATCH_PATH_FORBIDDEN');
17
+ const segments=path.split('/').slice(1);
18
+ if (segments.length < 3 || segments.length > 8 || segments.some(p=>!p || p==='__proto__' || p==='constructor' || p==='prototype'))
19
+ throw fail('OBJECT_PATCH_PATH_FORBIDDEN');
20
+ let cursor=document;
21
+ for (const part of segments.slice(0,-1)) {
22
+ if (Array.isArray(cursor)) {
23
+ const index=part.startsWith('@') ? cursor.findIndex(item=>item?.id===part.slice(1)) : /^(0|[1-9][0-9]*)$/.test(part) ? Number(part) : -1;
24
+ if(index<0 || index>=cursor.length)throw fail('OBJECT_PATCH_PATH_NOT_FOUND');
25
+ cursor=cursor[index];
26
+ } else {
27
+ if (!cursor || typeof cursor!=='object' || !Object.hasOwn(cursor,part))
28
+ throw fail('OBJECT_PATCH_PATH_NOT_FOUND');
29
+ cursor=cursor[part];
30
+ }
31
+ }
32
+ const key=segments.at(-1);
33
+ if (!cursor || typeof cursor!=='object' || !Object.hasOwn(cursor,key))
34
+ throw fail('OBJECT_PATCH_PATH_NOT_FOUND');
35
+ const previous=clone(cursor[key]);
36
+ cursor[key]=clone(value);
37
+ return {path,previous,next:clone(value)};
38
+ }
39
+
40
+ function declaredEvidence(definition) {
41
+ if (definition.schema==='agentscape.mechanical-draft') {
42
+ return {
43
+ components:definition.components.map(node=>({
44
+ id:node.id,parent:node.parent,shape:node.shape,size:node.size,
45
+ position:node.position,collision:node.collision,source:'ai-declared'
46
+ })),
47
+ motions:definition.motions.map(motion=>({
48
+ id:motion.id,node:motion.node,type:motion.type,
49
+ axis:motion.axis,limits:motion.limits,source:'ai-declared',
50
+ status:'candidate',physicsVerified:false
51
+ }))
52
+ };
53
+ }
54
+ if (definition.schema==='agentscape.asset-recipe') {
55
+ return {
56
+ components:definition.parts.map(part=>({
57
+ id:part.id,parent:part.parent||null,
58
+ shape:part.geometry?.type||'group',position:part.position||[0,0,0],
59
+ source:'ai-declared'
60
+ })),motions:[]
61
+ };
62
+ }
63
+ return {
64
+ components:Object.entries(definition.definition?.parts||{}).map(([id,part])=>({
65
+ id,node:part.node,semantic:part.semantic||null,
66
+ source:'ai-declared'
67
+ })),
68
+ motions:Object.entries(definition.definition?.parts||{}).filter(([,part])=>part.joint).map(([id,part])=>({
69
+ id,node:part.node,type:part.joint.type,axis:part.joint.axis,
70
+ limits:part.joint.limits,status:'candidate',physicsVerified:false,
71
+ source:'ai-declared'
72
+ }))
73
+ };
74
+ }
75
+
76
+ /** Read only actual instantiated Three.js nodes. An Object3D hierarchy is not a joint. */
77
+ function runtimeGeometry(object) {
78
+ const nodes=[];
79
+ if (!object?.traverse) return {nodes, truncated:false};
80
+ object.traverse(node=>{
81
+ if (nodes.length>=128) return;
82
+ const bounds=node.geometry?.boundingBox;
83
+ nodes.push({
84
+ name:String(node.name||'').slice(0,100),
85
+ type:node.type, mesh:node.isMesh===true,
86
+ parent:node.parent?.name||null,
87
+ position:node.position?.toArray?.()||null,
88
+ geometryBounds:bounds ? {min:bounds.min.toArray(),max:bounds.max.toArray()} : null,
89
+ source:'runtime-observed'
90
+ });
91
+ });
92
+ return {nodes,truncated:nodes.length>=128};
93
+ }
94
+
95
+ /** A + C: observed Three.js hierarchy and declared, versioned capability intent.
96
+ * Source entries are private to the session, never treated as physics truth.
97
+ */
98
+ export class SceneObjectForge {
99
+ constructor(){this.entries=new Map();}
100
+ record(id,source,assetId,world,{originAssetId=null}={}){
101
+ if(!['agentscape.mechanical-draft','agentscape.asset-recipe'].includes(source?.schema)
102
+ && source?.kind!=='three-code') return;
103
+ const definition=parse(source);
104
+ this.entries.set(id,{definition,assetId,world,originAssetId,revision:1,preview:null});
105
+ }
106
+ fork(world,id,source,originAssetId){
107
+ if(this.entries.has(id)) throw fail('OBJECT_DEFINITION_ALREADY_TRACKED');
108
+ if(!world.store.has(id) || world.store.get(id).assetId!==originAssetId
109
+ || !/^pa_[a-f0-9]{64}$/.test(originAssetId))throw fail('OBJECT_DEFINITION_UNAVAILABLE');
110
+ this.record(id,source,originAssetId,world,{originAssetId});
111
+ return {status:'object-project-forked',id,originAssetId,revision:1,
112
+ globalVersionUnchanged:true,scope:'project-instance'};
113
+ }
114
+ get(world,id){
115
+ const entry=this.entries.get(id);
116
+ if(!entry || entry.world!==world || !world.store.has(id) || world.store.get(id).assetId!==entry.assetId)
117
+ throw fail('OBJECT_DEFINITION_UNAVAILABLE');
118
+ return entry;
119
+ }
120
+ analyze(world,id,definition){
121
+ const record=world.store.get(id);
122
+ const declared=declaredEvidence(definition),observed=runtimeGeometry(record?.object);
123
+ const known=new Set(observed.nodes.map(node=>node.name).filter(Boolean));
124
+ const references=new Set([
125
+ ...declared.motions.map(motion=>motion.node),
126
+ ...(definition.definition?.requiredNodes||[])
127
+ ].filter(Boolean));
128
+ const matched=[...references].filter(name=>known.has(name));
129
+ const missing=[...references].filter(name=>!known.has(name));
130
+ return {declared,observed,reconciliation:{matchedNodes:matched,missingNodes:missing,
131
+ status:missing.length?'needs-review':'matched',evidenceKind:'node-name-match'},
132
+ interpretation:'observed-geometry-is-not-physical-articulation'};
133
+ }
134
+ inspect(world,id){
135
+ const e=this.get(world,id);
136
+ return {
137
+ schema:'agentscape.object-definition',schemaVersion:1,id,
138
+ revision:e.revision,assetId:e.assetId,originAssetId:e.originAssetId||null,
139
+ definition:clone(e.definition),analysis:this.analyze(world,id,e.definition),
140
+ provenance:{definition:'ai-declared',geometry:'runtime-observed',
141
+ motions:'candidate-unless-verified-by-runtime'}
142
+ };
143
+ }
144
+ preview(world,id,expectedRevision,changes){
145
+ const e=this.get(world,id);
146
+ if(expectedRevision!==e.revision) throw fail('OBJECT_REVISION_CONFLICT');
147
+ if(!Array.isArray(changes)||!changes.length||changes.length>8
148
+ || JSON.stringify(changes).length>32768)throw fail('OBJECT_PATCH_LIMIT');
149
+ const copy=clone(e.definition),delta=changes.map(change=>changeAt(copy,change));
150
+ const parsed=parse(copy),previewId=globalThis.crypto.randomUUID();
151
+ e.preview={previewId,revision:e.revision,definition:parsed,changes:delta};
152
+ return {status:'object-patch-preview',id,revision:e.revision,previewId,
153
+ changes:delta,analysis:{declared:declaredEvidence(parsed)},
154
+ verification:'not-run'};
155
+ }
156
+ async apply(world,scene,id,expectedRevision,previewId,{executor}={}){
157
+ const e=this.get(world,id);
158
+ if(expectedRevision!==e.revision)throw fail('OBJECT_REVISION_CONFLICT');
159
+ const pending=e.preview;
160
+ if(!pending||pending.previewId!==previewId||pending.revision!==e.revision)
161
+ throw fail('OBJECT_PATCH_PREVIEW_NOT_FOUND');
162
+ e.preview=null;
163
+ const next=pending.definition,module=world.assetModule;
164
+ const level=module.getManifest(e.assetId).capabilityLevel||'physical';
165
+ let assetId,admission,replaced;
166
+ if(next.kind==='three-code'){
167
+ const prepared=await prepareThreeCodeAsset(module,executor,next,{
168
+ gltfLoader:module.loader.gltfLoader
169
+ });
170
+ assetId=prepared.manifest.id;
171
+ admission=prepared.validation;
172
+ replaced=await prepared.install(()=>scene.replaceAsset({id,asset:prepared.asset,level}));
173
+ }else{
174
+ // Mechanical drafts must pass their articulation verifier before any instance swap.
175
+ const imported=next.schema==='agentscape.mechanical-draft'
176
+ ? await module.importMechanicalDraft(next) : await module.importRecipe(next);
177
+ assetId=imported.manifest.id;
178
+ admission=imported.admission;
179
+ replaced=await scene.replaceAsset({id,asset:'asset://sha256/'+assetId.replace(/^asset_/,''),level});
180
+ }
181
+ e.definition=clone(next);
182
+ e.assetId=assetId;
183
+ e.revision++;
184
+ return {status:'object-patch-applied',id,revision:e.revision,
185
+ assetId,changes:pending.changes,
186
+ verification:{status:'compiled-and-admitted',admission,
187
+ runtimeActionVerification:'not-run'},replace:replaced.status};
188
+ }
189
+
190
+ /** Export editable source only for objects still bound to their original immutable asset. */
191
+ export(world) {
192
+ const entries = [];
193
+ for (const [id, entry] of this.entries) {
194
+ if (entry.world !== world || !world.store.has(id) || world.store.get(id).assetId !== entry.assetId) continue;
195
+ entries.push({id,assetId:entry.assetId,revision:entry.revision,definition:clone(entry.definition),
196
+ ...(entry.originAssetId?{originAssetId:entry.originAssetId}:{})});
197
+ }
198
+ return entries;
199
+ }
200
+ /** Validate complete source catalog before altering the live editor registry. */
201
+ static validateTransfer(snapshot, input = []) {
202
+ if (!Array.isArray(input) || input.length > 64 || JSON.stringify(input).length > 262144)
203
+ throw fail('OBJECT_DEFINITION_TRANSFER_LIMIT');
204
+ const objects = new Map(snapshot.objects.map(object => [object.id,object.assetId]));
205
+ const ids = new Set();
206
+ return input.map(item => {
207
+ if (!item || typeof item !== 'object' || Array.isArray(item) || typeof item.id !== 'string'
208
+ || !/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(item.id)
209
+ || !(/^(asset_|pa_)[a-f0-9]{64}$/.test(item.assetId))
210
+ || !Number.isSafeInteger(item.revision) || item.revision < 1 || item.revision > 1000000
211
+ || ids.has(item.id) || objects.get(item.id) !== item.assetId
212
+ || (item.originAssetId != null && !/^pa_[a-f0-9]{64}$/.test(item.originAssetId)))
213
+ throw fail('OBJECT_DEFINITION_TRANSFER_INVALID');
214
+ ids.add(item.id);
215
+ const definition=parse(item.definition);
216
+ return {id:item.id,assetId:item.assetId,revision:item.revision,definition,
217
+ ...(item.originAssetId?{originAssetId:item.originAssetId}:{})};
218
+ });
219
+ }
220
+ restore(world, input) {
221
+ const ready=SceneObjectForge.validateTransfer({
222
+ objects:world.store.list().map(([id,record])=>({id,assetId:record.assetId}))
223
+ },input);
224
+ const next=new Map(ready.map(item=>[
225
+ item.id,{assetId:item.assetId,definition:clone(item.definition),revision:item.revision,preview:null,world,
226
+ originAssetId:item.originAssetId||null}
227
+ ]));
228
+ this.entries=next;
229
+ return {restored:next.size};
230
+ }
231
+ clear(){this.entries.clear();}
232
+ }
@@ -0,0 +1,59 @@
1
+ import * as THREE from 'three';
2
+ import { createAssetModule } from '../../modules/asset/AssetModule.js';
3
+ import { createArtifactModule } from '../../modules/artifact/ArtifactModule.js';
4
+ import { assetAdmission } from '../../modules/asset/model/admission.js';
5
+ import { ArticulationVerifier } from '../../modules/world/verification/ArticulationVerifier.js';
6
+ import { createWorldAuthoringContext } from '../createWorldAuthoringContext.js';
7
+ import { createAuthoringAssetProducer } from '../world-authoring/AuthoringAssetProducer.js';
8
+ import { capturePromotionSource, exportPromotionGLB } from '../world-authoring/AuthoringPromotionSource.js';
9
+ import { disposeObject3D } from '../../modules/rendering/disposeObject3D.js';
10
+ import { parseDefinition } from './ProgrammaticAssetContract.js';
11
+
12
+ export class ProgrammaticAssetBuilder {
13
+ constructor({runner,gltfLoader}) {Object.assign(this,{runner,gltfLoader});}
14
+ async build({source,definition,assetId},{signal}={}) {
15
+ const draft=definition == null ? null : parseDefinition(definition);
16
+ let result;
17
+ try { result=await this.runner.run({mode:'procedural',source},{signal}); }
18
+ catch(error) {
19
+ error.details={...error.details,stage:'source-execution'};
20
+ throw error;
21
+ }
22
+ if(signal?.aborted)throw new Error('BUILD_CANCELLED');
23
+ const authoring=createWorldAuthoringContext({events:{emit(){}}},{executeCode:()=>{throw Error('SOURCE_EXECUTION_FORBIDDEN');}});
24
+ const assets=createAssetModule({manifests:{},manifestStore:null,libraryStore:null,gltfLoader:this.gltfLoader});
25
+ const artifacts=createArtifactModule({persistentStore:null});assets.configureProduction({artifacts});
26
+ assets.configureVerification({articulationVerifier:new ArticulationVerifier({assetRegistry:assets.registry,assetLoader:assets.loader})});
27
+ try {
28
+ authoring.load(result.document);
29
+ const object=authoring.get('asset-root');
30
+ const names=new Map();object.traverse(n=>{if(n.name)names.set(n.name,(names.get(n.name)||0)+1);});
31
+ const required=[...(draft?.requiredNodes||[]),...Object.values(draft?.parts||{}).map(p=>p.node)];
32
+ if(required.some(name=>names.get(name)!==1))throw Object.assign(new Error('PROCEDURAL_REQUIRED_NODE_INVALID'),{details:{invalidNodes:required.filter(name=>names.get(name)!==1),nodeCounts:Object.fromEntries(required.map(name=>[name,names.get(name)||0]))}});
33
+ const box=new THREE.Box3().setFromObject(object),size=box.getSize(new THREE.Vector3());
34
+ if(![size.x,size.y,size.z].every(v=>Number.isFinite(v)&&v>0&&v<=100))throw new Error('PROCEDURAL_DIMENSIONS_INVALID');
35
+ const captured=capturePromotionSource(authoring,'asset-root');
36
+ if (!draft) {
37
+ const bytes=await exportPromotionGLB(captured);
38
+ const output=await assets.importPackageAsset({bytes,id:assetId,definition:{capabilityLevel:'visual',label:'Code asset'}});
39
+ if(signal?.aborted)throw new Error('BUILD_CANCELLED');
40
+ return {bytes:(await assets.compiledStore.get(assetId)).bytes,manifest:output.manifest,environment:result.environment,security:result.security,
41
+ validation:{execution:'succeeded',runtime:{status:'not-requested'}},admission:assetAdmission(output.manifest)};
42
+ }
43
+ const resolved={...draft,id:assetId};
44
+ if(resolved.interactionContract)resolved.interactionContract={...resolved.interactionContract,entityId:assetId};
45
+ const produced=await createAuthoringAssetProducer({assets,artifacts})(captured,{usage:'interactive',definition:resolved,assetId});
46
+ if(produced.status==='asset-rejected')throw new Error('PROCEDURAL_ASSET_REJECTED');
47
+ const runtime=await assets.verifyAndUpdateArticulation(assetId,{requireRegistration:true});
48
+ if(!runtime.ok||!runtime.physicsRegistered)throw Object.assign(new Error('PROCEDURAL_RUNTIME_VERIFICATION_FAILED'),{details:runtime});
49
+ const manifest=assets.getManifest(assetId);
50
+ const loaded=await assets.instantiate(assetId);disposeObject3D(loaded.object);
51
+ const compiled=await assets.compiledStore.get(manifest.source.key);
52
+ if(!compiled?.bytes||compiled.bytes.byteLength>4194304)throw new Error('BUILD_OUTPUT_LIMIT');
53
+ if(signal?.aborted)throw new Error('BUILD_CANCELLED');
54
+ manifest.capabilityLevel=Object.keys(draft.parts||{}).length?'interactive':'physical';
55
+ return {bytes:compiled.bytes,manifest,environment:result.environment,security:result.security,validation:{execution:'succeeded',nodes:[...names.keys()],bounds:{min:box.min.toArray(),max:box.max.toArray()},runtime},admission:assetAdmission(manifest)};
56
+ } catch(error) {error.execution={status:'succeeded'};error.details={...error.details,stage:'asset-admission'};throw error;}
57
+ finally {authoring.dispose();}
58
+ }
59
+ }
@@ -0,0 +1,22 @@
1
+ import * as z from 'zod/v4';
2
+ import { validateAssetManifest } from '../../modules/asset/model/schema.js';
3
+
4
+ export const proceduralContract='agentscape.procedural-asset.v1';
5
+ const id=z.string().regex(/^[a-zA-Z0-9_-]{1,80}$/).refine(v=>!['__proto__','constructor','prototype'].includes(v));
6
+ const finite=z.number().finite().min(-100).max(100);
7
+ const vec=z.tuple([finite,finite,finite]);
8
+ const positive=z.number().min(.0001).max(50);
9
+ const actions=z.array(z.enum(['move','pickup','drop','place','open','close'])).max(8);
10
+ const collider=z.object({shape:z.enum(['box','cylinder','capsule','convexHull']),halfExtents:z.tuple([positive,positive,positive]).optional(),halfHeight:positive.optional(),radius:positive.optional(),translation:vec.optional(),rotation:z.tuple([finite,finite,finite,finite]).refine(q=>Math.abs(Math.hypot(...q)-1)<.0001).optional(),vertices:z.array(finite).max(768).optional()}).strict();
11
+ const physics=z.object({body:z.enum(['fixed','dynamic','kinematic']),mass:z.number().min(.0001).max(10000).optional(),friction:z.number().min(0).max(10).optional(),restitution:z.number().min(0).max(1).optional(),linearDamping:z.number().min(0).max(100).optional(),angularDamping:z.number().min(0).max(100).optional(),navigationObstacle:z.boolean().optional(),colliders:z.array(collider).min(1).max(32)}).strict();
12
+ const part=z.object({node:id,semantic:z.string().max(100).optional(),parent:id.optional(),actions,targets:z.record(z.enum(['open','close']),finite).optional(),physics,joint:z.object({type:z.enum(['revolute','prismatic','fixed']),axis:vec.optional(),limits:z.tuple([finite,finite]).optional(),parentAnchor:vec,childAnchor:vec,motor:z.object({stiffness:z.number().min(0).max(10000),damping:z.number().min(0).max(1000)}).strict().optional()}).strict().optional()}).strict();
13
+ export const definitionSchema=z.object({id,type:id,label:z.string().min(1).max(100),description:z.string().max(500).optional(),tags:z.array(z.string().max(50)).max(20).optional(),aliases:z.array(z.string().max(50)).max(20).optional(),requiredNodes:z.array(id).max(64).optional(),actions,physics,parts:z.record(id,part).refine(v=>Object.keys(v).length<=16).optional(),surfaces:z.array(z.object({id,localPosition:vec,size:z.tuple([positive,positive])}).strict()).max(16).optional(),receptacles:z.array(z.object({id,localPosition:vec,size:z.tuple([positive,positive,positive])}).strict()).max(16).optional(),interactionContract:z.record(z.string(),z.unknown()).optional()}).strict();
14
+ export function parseDefinition(input) {
15
+ let value;try{value=definitionSchema.parse(input);}catch{throw new Error('PROCEDURAL_MANIFEST_INVALID');}
16
+ if(JSON.stringify(value).length>24576)throw new Error('PROCEDURAL_MANIFEST_LIMIT');
17
+ if(new Set((value.surfaces||[]).map(s=>s.id)).size!==(value.surfaces||[]).length)throw new Error('PROCEDURAL_MANIFEST_INVALID');
18
+ const safe=(v,depth=0)=>{if(depth>16)throw new Error('PROCEDURAL_MANIFEST_INVALID');if(!v||typeof v!=='object')return;for(const[k,item]of Object.entries(v)){if(['__proto__','constructor','prototype'].includes(k))throw new Error('PROCEDURAL_MANIFEST_INVALID');safe(item,depth+1);}};safe(value);
19
+ try{validateAssetManifest({...value,source:{kind:'compiled',key:'pending'}});}catch{throw new Error('PROCEDURAL_MANIFEST_INVALID');}
20
+ return value;
21
+ }
22
+ export function canonical(value) {if(value===null||typeof value!=='object')return JSON.stringify(value);if(Array.isArray(value))return `[${value.map(canonical).join(',')}]`;return `{${Object.keys(value).sort().map(k=>`${JSON.stringify(k)}:${canonical(value[k])}`).join(',')}}`;}
@@ -0,0 +1,40 @@
1
+ import { ProgrammaticAssetBuilder } from './ProgrammaticAssetBuilder.js';
2
+ import { assetDigest, canonicalAssetJson } from '../../modules/asset/model/AssetInputContracts.js';
3
+ import { createAssetModule } from '../../modules/asset/AssetModule.js';
4
+ import { ArticulationVerifier } from '../../modules/world/verification/ArticulationVerifier.js';
5
+
6
+ // Published bytes cross the Studio bridge; compile and verify them locally before
7
+ // the existing Scene mutation, never accept a remote physics verdict as evidence.
8
+ export async function prepareEmbeddedCodeAsset(assets, input, { gltfLoader } = {}) {
9
+ const asset=`asset://sha256/${input.id.replace(/^(pa_|asset_)/,'')}`;
10
+ const sourceHash=await assetDigest(input.bytes);
11
+ const definitionHash=await assetDigest(new TextEncoder().encode(canonicalAssetJson(input.definition)));
12
+ if(assets.hasAsset(input.id)) {
13
+ const existing=assets.getManifest(input.id);
14
+ if(existing.provenance?.codeTransport?.sourceHash!==sourceHash || existing.provenance?.codeTransport?.definitionHash!==definitionHash)throw new Error('ASSET_ID_CONFLICT');
15
+ return {asset,install:operation=>operation()};
16
+ }
17
+ const scratch=createAssetModule({volatile:true,manifests:{},manifestStore:null,libraryStore:null,gltfLoader});
18
+ scratch.configureVerification({articulationVerifier:new ArticulationVerifier({assetRegistry:scratch.registry,assetLoader:scratch.loader})});
19
+ const {manifest}=await scratch.importPackageAsset({id:input.id,bytes:input.bytes,definition:input.definition});
20
+ manifest.provenance={...manifest.provenance,codeTransport:{sourceHash,definitionHash}};
21
+ const bytes=(await scratch.compiledStore.get(manifest.source.key)).bytes;
22
+ const expectedSourceHash=await assetDigest(bytes);
23
+ return {asset,install:operation=>assets.installPreparedAssets([{manifest,bytes,expectedDefinition:manifest,expectedSourceHash}],operation)};
24
+ }
25
+
26
+ export async function prepareThreeCodeAsset(assets, executor, input, { signal, gltfLoader } = {}) {
27
+ if (!executor) throw new Error('CODE_EXECUTION_DISABLED');
28
+ const environment = await executor.environment();
29
+ const version = await assetDigest(new TextEncoder().encode(canonicalAssetJson({ source: input.source, definition: input.definition || null, environment, contract: 'three-code-v1' })));
30
+ const id = `asset_${version}`, asset = `asset://sha256/${version}`;
31
+ if (signal?.aborted) throw new Error('BUILD_CANCELLED');
32
+ if (assets.hasAsset(id)) return { asset, manifest: assets.getManifest(id), install: operation => operation() };
33
+ const built = await new ProgrammaticAssetBuilder({ runner: executor, gltfLoader }).build({ ...input, assetId: id }, { signal });
34
+ if (signal?.aborted) throw new Error('BUILD_CANCELLED');
35
+ built.manifest.contentHash = version;
36
+ const bytesHash = await assetDigest(built.bytes);
37
+ return { asset, manifest: built.manifest, validation: built.validation,
38
+ install: operation => assets.installPreparedAssets([{manifest:built.manifest,bytes:built.bytes,
39
+ expectedDefinition:built.manifest,expectedSourceHash:bytesHash}],operation) };
40
+ }
@@ -0,0 +1,79 @@
1
+ import { sceneError } from './SceneContracts.js';
2
+
3
+ /**
4
+ * Read-only capability projection for assets, environment contracts and
5
+ * executable Code Project entities. The underlying owners retain their state.
6
+ */
7
+ export function describeCapabilities(inspection) {
8
+ return (inspection.actions || []).map(action => {
9
+ const name = action.name || action.action;
10
+ return {
11
+ id: [inspection.id, action.partName || '$root', name].join(':'),
12
+ target: inspection.id,
13
+ name,
14
+ action: 'invoke',
15
+ source: inspection.source,
16
+ executor: action.execution,
17
+ ...(action.partName ? { partName: action.partName } : {}),
18
+ ...(action.capabilitySource ? { capabilitySource: action.capabilitySource } : {}),
19
+ ...(action.graspVerified === false ? { graspVerified:false } : {}),
20
+ description: action.description || '',
21
+ parameters: structuredClone(action.parameters || {}),
22
+ available: action.available ?? null,
23
+ ...(action.reason ? { reason: action.reason } : {}),
24
+ ...(action.canApproach ? { canApproach: true } : {}),
25
+ verification: action.contract?.verifierTarget?.type
26
+ || action.verification || inspection.evidenceKind || 'unverified'
27
+ };
28
+ });
29
+ }
30
+
31
+ export function inspectCapabilities(world, target, { actor } = {}) {
32
+ const physical = world.affordances?.inspect(target, { actorId: actor }) || null;
33
+ const project = world.projectCapabilities?.has(target)
34
+ ? world.projectCapabilities.inspect(target, { actor }) : null;
35
+ if (!physical && !project) return null;
36
+ if (!physical || !project) {
37
+ const inspection = physical || project;
38
+ return { ...inspection, capabilities:describeCapabilities(inspection),
39
+ ...(world.thermal?.inspect?.(target)?{simulation:world.thermal.inspect(target)}:{}) };
40
+ }
41
+
42
+ // A single logical entity can expose independent physical and project state.
43
+ // No provider state is copied back into the other provider.
44
+ const stateProviders = { [physical.source]:structuredClone(physical.state || {}),
45
+ project:structuredClone(project.state || {}) };
46
+ const collisions = Object.keys(stateProviders.project).filter(key => Object.hasOwn(stateProviders[physical.source], key));
47
+ const state = { ...stateProviders[physical.source] };
48
+ for (const [key, value] of Object.entries(stateProviders.project)) {
49
+ if (!Object.hasOwn(state, key)) state[key] = value;
50
+ }
51
+ const entries = [...describeCapabilities(physical), ...describeCapabilities(project)];
52
+ const counts = new Map();
53
+ for (const entry of entries) counts.set(entry.id, (counts.get(entry.id) || 0) + 1);
54
+ const capabilities = entries.map(entry => ({
55
+ ...entry, ...(counts.get(entry.id) > 1 ? {id:entry.id + ':' + entry.source} : {})
56
+ }));
57
+ return { ...physical, source:'composite', providers:[physical.source,'project'],
58
+ state, stateProviders, stateConflicts:collisions,
59
+ actions:[...(physical.actions || []),...(project.actions || []).map(action => ({...action,source:'project'}))],
60
+ capabilities, ...(world.thermal?.inspect?.(target)?{simulation:world.thermal.inspect(target)}:{}) };
61
+ }
62
+
63
+ /** Resolve a registered action without ever inferring permission from its name. */
64
+ export function resolveCapability(world, { target, name, actor, partName, source }) {
65
+ const inspection = inspectCapabilities(world, target, { actor });
66
+ if (!inspection) throw sceneError('OBJECT_NOT_FOUND');
67
+ const matches = inspection.capabilities.filter(entry =>
68
+ entry.name === name && (partName == null || entry.partName === partName)
69
+ && (source == null || entry.source === source));
70
+ if (!matches.length) throw sceneError('ACTION_UNSUPPORTED');
71
+ if (matches.length !== 1) {
72
+ if (new Set(matches.map(item => item.source)).size > 1) throw sceneError('ACTION_SOURCE_REQUIRED');
73
+ throw sceneError('ACTION_PART_REQUIRED');
74
+ }
75
+ const capability = matches[0];
76
+ if (!['interaction', 'world-action', 'project-action'].includes(capability.executor))
77
+ throw sceneError('ACTION_NOT_INVOKABLE');
78
+ return { source: capability.source, capability };
79
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Session-local bounded idempotency: replay in-flight and recently settled
3
+ * requests. Oldest settled records may be evicted under pressure; never evict
4
+ * a running request. Callers must check capacity before starting a mutation.
5
+ */
6
+ export function createRequestWindow({
7
+ now = () => Date.now(), limit = 256, retentionMs = 300_000,
8
+ conflictCode = 'IDEMPOTENCY_CONFLICT', limitCode = 'REQUEST_BUDGET_EXHAUSTED'
9
+ } = {}) {
10
+ const records = new Map();
11
+ const issue = code => Object.assign(new Error(code), { code });
12
+
13
+ const prune = () => {
14
+ const current = now();
15
+ for (const [id, entry] of records) {
16
+ if (entry.settledAt !== null && current - entry.settledAt >= retentionMs)
17
+ records.delete(id);
18
+ }
19
+ };
20
+
21
+ return {
22
+ get size() { return records.size; },
23
+ replay(id, fingerprint) {
24
+ if (!id) return null;
25
+ prune();
26
+ const existing = records.get(id);
27
+ if (!existing) return null;
28
+ if (existing.fingerprint !== fingerprint) throw issue(conflictCode);
29
+ return existing.promise;
30
+ },
31
+ ensureCapacity() {
32
+ prune();
33
+ if (records.size >= limit) {
34
+ for (const [id, entry] of records) {
35
+ if (entry.settledAt !== null) {
36
+ records.delete(id);
37
+ if (records.size < limit) break;
38
+ }
39
+ }
40
+ }
41
+ if (records.size >= limit) throw issue(limitCode);
42
+ },
43
+ track(id, fingerprint, promise) {
44
+ if (!id) return;
45
+ const entry = { fingerprint, promise, settledAt: null };
46
+ records.set(id, entry);
47
+ const settled = () => { entry.settledAt = now(); };
48
+ // The failure handler is required; tracking must not create an
49
+ // unhandled rejection for an operation that the caller will catch.
50
+ void promise.then(settled, settled);
51
+ },
52
+ clear() { records.clear(); }
53
+ };
54
+ }
@@ -0,0 +1,21 @@
1
+ import { AgentTools } from '../AgentTools.js';
2
+ import { SCENE_LEGACY_SKILLS } from './SceneSkillNames.js';
3
+
4
+ const sceneSkillNames = new Set(SCENE_LEGACY_SKILLS);
5
+
6
+ /**
7
+ * Explicit Studio adapter for the legacy Scene skill surface.
8
+ * All other tool calls retain AgentTools' registry, context and observability behavior.
9
+ */
10
+ export class SceneAgentTools extends AgentTools {
11
+ constructor(runtime, scene, options = {}) {
12
+ super(runtime, options);
13
+ if (typeof scene?.executeSkill !== 'function') throw new TypeError('SceneAgentTools requires a Scene facade');
14
+ this.scene = scene;
15
+ }
16
+
17
+ call(name, args = {}, internalContext = {}) {
18
+ if (sceneSkillNames.has(name)) return this.scene.executeSkill(name, args);
19
+ return super.call(name, args, internalContext);
20
+ }
21
+ }
@@ -0,0 +1,45 @@
1
+ import * as z from 'zod/v4';
2
+ import { recipeSchema } from '../../modules/asset/model/AssetInputContracts.js';
3
+ import { mechanicalDraftSchema } from '../../modules/asset/model/MechanicalAssetDraft.js';
4
+ import { sceneObjectIdSchema as id, sceneTransformSchema, sceneVector3Schema } from './SceneProject.js';
5
+
6
+ export const sceneError = (code, message = code) => Object.assign(new Error(message), { code });
7
+ export const ref = z.string().regex(/^(builtin:\/\/[a-zA-Z][a-zA-Z0-9_-]{0,63}|asset:\/\/sha256\/[a-f0-9]{64})$/);
8
+ export const level = z.enum(['visual', 'physical', 'interactive']).default('physical');
9
+ export const modelSchema = z.object({ id, asset: ref, level, transform: sceneTransformSchema.optional(), position: sceneVector3Schema.optional() }).strict().refine(v => !v.transform || !v.position, 'Use transform or position');
10
+ export const sceneAgentModelSchema = z.object({ id, asset: z.union([ref, recipeSchema, mechanicalDraftSchema]), level: z.enum(['visual', 'physical', 'interactive']).optional(), transform: sceneTransformSchema.optional(), position: sceneVector3Schema.optional() }).strict().refine(v => !v.transform || !v.position, 'Use transform or position');
11
+ export const operations = z.discriminatedUnion('type', [
12
+ z.object({ type: z.literal('add'), model: modelSchema }).strict(),
13
+ z.object({ type: z.literal('setTransform'), id, transform: sceneTransformSchema }).strict(),
14
+ z.object({ type: z.literal('remove'), id }).strict(),
15
+ z.object({ type: z.literal('replaceAsset'), id, asset: ref, level }).strict()
16
+ ]);
17
+ export const applySchema = z.object({ requestId: z.union([id,z.uuid()]).optional(), expectedRevision: z.number().int().nonnegative().optional(), operations: z.array(operations).min(1).max(32) }).strict();
18
+ const operationVector = sceneVector3Schema.refine(value => Math.hypot(...value) > 1e-6, 'Direction must be nonzero');
19
+ const affordanceTarget = z.string().regex(/^[A-Za-z][A-Za-z0-9_:-]{0,255}$/);
20
+ export const sceneInteractionSchema = z.discriminatedUnion('action', [
21
+ z.object({ action:z.literal('invoke'), target:z.string().min(1).max(256), name:z.string().min(1).max(256), actor:id.optional(), partName:id.optional(), source:z.enum(['asset','environment','project']).optional(), args:z.record(z.string(),z.unknown()).default({}) }).strict(),
22
+ z.object({ action: z.literal('custom'), target: z.string().min(1).max(256), name: z.string().min(1).max(256), actor: id.optional(), args: z.record(z.string(), z.unknown()).default({}) }).strict(),
23
+ z.object({ action: z.literal('navigate'), actor: id, position: sceneVector3Schema }).strict(),
24
+ z.object({ action: z.literal('activate'), actor: id, target: affordanceTarget }).strict(),
25
+ z.object({ action: z.literal('pickup'), actor: id, target: affordanceTarget }).strict(),
26
+ z.object({ action: z.literal('place'), actor: id, target: affordanceTarget, surfaceId: id.optional() }).strict(),
27
+ z.object({ action: z.enum(['open', 'close']), actor: id, target: affordanceTarget, partName: id.optional() }).strict(),
28
+ z.object({ action: z.enum(['turn_on', 'turn_off', 'pull_out', 'return']), actor: id, target: affordanceTarget }).strict(),
29
+ z.object({ action: z.literal('write'), actor: id, target: affordanceTarget, args: z.object({ text: z.string().max(100) }).strict() }).strict(),
30
+ z.object({ action: z.enum(['push', 'drag']), actor: id, target: affordanceTarget, args: z.object({
31
+ direction: operationVector.refine(value => Math.abs(value[1]) < 1e-6, 'Linear contact operations require a horizontal direction'),
32
+ distance: z.number().positive().max(5), maxForce: z.number().positive().max(1000).default(100)
33
+ }).strict() }).strict(),
34
+ z.object({ action: z.literal('rotate'), actor: id, target: affordanceTarget, args: z.object({
35
+ axis: operationVector, angle: z.number().finite().min(-Math.PI).max(Math.PI).refine(value => value !== 0),
36
+ maxTorque: z.number().positive().max(1000).default(100)
37
+ }).strict() }).strict(),
38
+ z.object({ action: z.literal('slide'), actor: id, target: affordanceTarget, args: z.object({ part: id,
39
+ target: z.number().finite().optional(), distance: z.number().finite().optional()
40
+ }).strict().refine(value => (value.target != null) !== (value.distance != null), 'Use target or distance') }).strict(),
41
+ z.object({ action: z.literal('rotateJoint'), actor: id, target: affordanceTarget, args: z.object({ part: id,
42
+ target: z.number().finite().optional(), angle: z.number().finite().min(-Math.PI).max(Math.PI).optional()
43
+ }).strict().refine(value => (value.target != null) !== (value.angle != null), 'Use target or angle') }).strict()
44
+ ]);
45
+ export const diagnostic = error => ({ code: error.code || 'INVALID_OPERATION', message: error.code || 'Operation failed', stage: 'scene', retryable: false });