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

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 (457) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/cli.mjs +53 -0
  4. package/dist/ArticulationVerifier-BfGxXY8V.js +337 -0
  5. package/dist/ArticulationVerifier-BfGxXY8V.js.map +1 -0
  6. package/dist/AssetCompiler-BLj09iu1.js +2424 -0
  7. package/dist/AssetCompiler-BLj09iu1.js.map +1 -0
  8. package/dist/AssetModule-DME-XaFS.js +2637 -0
  9. package/dist/AssetModule-DME-XaFS.js.map +1 -0
  10. package/dist/AssetRecipe-g8dZBhgJ.js +298 -0
  11. package/dist/AssetRecipe-g8dZBhgJ.js.map +1 -0
  12. package/dist/BrowserCodeWorker.js +53856 -0
  13. package/dist/BrowserCodeWorker.js.map +1 -0
  14. package/dist/CarryCapability-CXwHU5ay.js +104 -0
  15. package/dist/CarryCapability-CXwHU5ay.js.map +1 -0
  16. package/dist/KinematicHypothesisScreen-C3TKiuYR.js +241 -0
  17. package/dist/KinematicHypothesisScreen-C3TKiuYR.js.map +1 -0
  18. package/dist/ObjectTransform-BlQUNK7c.js +61 -0
  19. package/dist/ObjectTransform-BlQUNK7c.js.map +1 -0
  20. package/dist/RapierPhysicsBackend-B2wQe_Vl.js +3259 -0
  21. package/dist/RapierPhysicsBackend-B2wQe_Vl.js.map +1 -0
  22. package/dist/RenderingSystem-WIr1ZuGu.js +1042 -0
  23. package/dist/RenderingSystem-WIr1ZuGu.js.map +1 -0
  24. package/dist/ScenePresentation-LsYiDxbm.js +152 -0
  25. package/dist/ScenePresentation-LsYiDxbm.js.map +1 -0
  26. package/dist/SceneProject-K7HH1s8o.js +2687 -0
  27. package/dist/SceneProject-K7HH1s8o.js.map +1 -0
  28. package/dist/SceneSerializer-zOzbX4jZ.js +932 -0
  29. package/dist/SceneSerializer-zOzbX4jZ.js.map +1 -0
  30. package/dist/SimulationProfile-DSYZbBLQ.js +165 -0
  31. package/dist/SimulationProfile-DSYZbBLQ.js.map +1 -0
  32. package/dist/StylePack-DcRa_kU0.js +88 -0
  33. package/dist/StylePack-DcRa_kU0.js.map +1 -0
  34. package/dist/WorldArchive-BiFGLt--.js +451 -0
  35. package/dist/WorldArchive-BiFGLt--.js.map +1 -0
  36. package/dist/WorldCommands-Debj7V4L.js +2207 -0
  37. package/dist/WorldCommands-Debj7V4L.js.map +1 -0
  38. package/dist/WorldIO-Ch8QBfKY.js +151 -0
  39. package/dist/WorldIO-Ch8QBfKY.js.map +1 -0
  40. package/dist/admission-CVEvsrdz.js +121 -0
  41. package/dist/admission-CVEvsrdz.js.map +1 -0
  42. package/dist/blankWorld-B0MW6g7q.js +75 -0
  43. package/dist/blankWorld-B0MW6g7q.js.map +1 -0
  44. package/dist/core.d.ts +68 -0
  45. package/dist/core.js +209 -0
  46. package/dist/core.js.map +1 -0
  47. package/dist/disposeObject3D-DIMzy0FA.js +128 -0
  48. package/dist/disposeObject3D-DIMzy0FA.js.map +1 -0
  49. package/dist/environments-HOe3sJXH.js +567 -0
  50. package/dist/environments-HOe3sJXH.js.map +1 -0
  51. package/dist/gltfIO-BzVKLyaL.js +339 -0
  52. package/dist/gltfIO-BzVKLyaL.js.map +1 -0
  53. package/dist/grandUrbanBlock-DRndRZjF.js +515 -0
  54. package/dist/grandUrbanBlock-DRndRZjF.js.map +1 -0
  55. package/dist/index.d.ts +345 -0
  56. package/dist/index.js +16952 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/magicCabin-CfBZjx2Q.js +11019 -0
  59. package/dist/magicCabin-CfBZjx2Q.js.map +1 -0
  60. package/dist/manifests-D0LwbJ36.js +866 -0
  61. package/dist/manifests-D0LwbJ36.js.map +1 -0
  62. package/dist/mcp.d.ts +2 -0
  63. package/dist/mcp.js +1 -0
  64. package/dist/monumentHall-awZiGtda.js +403 -0
  65. package/dist/monumentHall-awZiGtda.js.map +1 -0
  66. package/dist/node.d.ts +16 -0
  67. package/dist/node.js +26 -0
  68. package/dist/parts-DrEcfJRl.js +37 -0
  69. package/dist/parts-DrEcfJRl.js.map +1 -0
  70. package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
  71. package/dist/ruinedCourtyard-DuF7NmUU.js +696 -0
  72. package/dist/ruinedCourtyard-DuF7NmUU.js.map +1 -0
  73. package/dist/runtime/application/AgentTools.js +28 -0
  74. package/dist/runtime/application/README.md +14 -0
  75. package/dist/runtime/application/agent/ProgressiveAgentTools.js +92 -0
  76. package/dist/runtime/application/agent/StudioMcpAllowlist.js +10 -0
  77. package/dist/runtime/application/agent/StudioProjectTools.js +18 -0
  78. package/dist/runtime/application/agent/TaskEvidence.js +199 -0
  79. package/dist/runtime/application/buildTaskObservation.js +117 -0
  80. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +50 -0
  81. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +35 -0
  82. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +17 -0
  83. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +82 -0
  84. package/dist/runtime/application/createSession.js +66 -0
  85. package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
  86. package/dist/runtime/application/generation/GenerationOrchestrator.js +630 -0
  87. package/dist/runtime/application/generation/GenerationRuntime.js +215 -0
  88. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +289 -0
  89. package/dist/runtime/application/native-scene/CodeProject.js +215 -0
  90. package/dist/runtime/application/native-scene/CodeProjectModules.js +143 -0
  91. package/dist/runtime/application/native-scene/ExampleWorldCatalog.js +35 -0
  92. package/dist/runtime/application/native-scene/NativeArticulation.js +53 -0
  93. package/dist/runtime/application/native-scene/NativeEditableRegistry.js +150 -0
  94. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +85 -0
  95. package/dist/runtime/application/native-scene/NativeLightingInspection.js +33 -0
  96. package/dist/runtime/application/native-scene/NativeMaterialInspection.js +52 -0
  97. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
  98. package/dist/runtime/application/native-scene/NativePhysicsGeometry.js +64 -0
  99. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
  100. package/dist/runtime/application/native-scene/NativeSceneHost.js +406 -0
  101. package/dist/runtime/application/native-scene/NativeSceneInspection.js +203 -0
  102. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
  103. package/dist/runtime/application/native-scene/NativeSceneQuery.js +123 -0
  104. package/dist/runtime/application/native-scene/NativeSceneReview.js +132 -0
  105. package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
  106. package/dist/runtime/application/native-scene/SceneObserver.js +97 -0
  107. package/dist/runtime/application/native-scene/VisualCapturePolicy.js +4 -0
  108. package/dist/runtime/application/object-forge/SceneObjectForge.js +263 -0
  109. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +59 -0
  110. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +22 -0
  111. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +40 -0
  112. package/dist/runtime/application/scene/CapabilityResolver.js +90 -0
  113. package/dist/runtime/application/scene/NativeEditableContracts.js +18 -0
  114. package/dist/runtime/application/scene/RequestWindow.js +54 -0
  115. package/dist/runtime/application/scene/SceneAgentTools.js +21 -0
  116. package/dist/runtime/application/scene/SceneContracts.js +49 -0
  117. package/dist/runtime/application/scene/SceneEditService.js +154 -0
  118. package/dist/runtime/application/scene/SceneFacade.js +356 -0
  119. package/dist/runtime/application/scene/SceneInteractionAdapters.js +41 -0
  120. package/dist/runtime/application/scene/SceneJobController.js +320 -0
  121. package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
  122. package/dist/runtime/application/scene/ScenePackage.js +173 -0
  123. package/dist/runtime/application/scene/ScenePersistence.js +50 -0
  124. package/dist/runtime/application/scene/SceneProject.js +95 -0
  125. package/dist/runtime/application/scene/SceneSkillNames.js +5 -0
  126. package/dist/runtime/application/scene/StarterScene.js +56 -0
  127. package/dist/runtime/application/scene/WorldArchive.js +89 -0
  128. package/dist/runtime/application/scene/WorldDirectory.js +20 -0
  129. package/dist/runtime/application/scene/WorldDocument.js +76 -0
  130. package/dist/runtime/application/scene/WorldIO.js +103 -0
  131. package/dist/runtime/application/scene/WorldStorage.js +155 -0
  132. package/dist/runtime/application/skills/SkillRegistry.js +193 -0
  133. package/dist/runtime/application/skills/packs/acceptanceSkills.js +32 -0
  134. package/dist/runtime/application/skills/packs/affordanceSkills.js +36 -0
  135. package/dist/runtime/application/skills/packs/assetSkills.js +46 -0
  136. package/dist/runtime/application/skills/packs/authoringSkills.js +16 -0
  137. package/dist/runtime/application/skills/packs/batchSkills.js +22 -0
  138. package/dist/runtime/application/skills/packs/codeSkills.js +106 -0
  139. package/dist/runtime/application/skills/packs/generationSkills.js +45 -0
  140. package/dist/runtime/application/skills/packs/interactionSkills.js +46 -0
  141. package/dist/runtime/application/skills/packs/recoverySkills.js +80 -0
  142. package/dist/runtime/application/skills/packs/sceneSkills.js +24 -0
  143. package/dist/runtime/application/skills/packs/spatialSkills.js +35 -0
  144. package/dist/runtime/application/skills/packs/verificationSkills.js +14 -0
  145. package/dist/runtime/application/skills/packs/worldSkills.js +45 -0
  146. package/dist/runtime/application/skills/registerCoreSkills.js +31 -0
  147. package/dist/runtime/application/skills/skillPrimitives.js +4 -0
  148. package/dist/runtime/application/tasks/CabinetCupTask.js +76 -0
  149. package/dist/runtime/application/tasks.jsonl +67 -0
  150. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +42 -0
  151. package/dist/runtime/application/world-authoring/AuthoringDiff.js +149 -0
  152. package/dist/runtime/application/world-authoring/AuthoringDocument.js +825 -0
  153. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +109 -0
  154. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +17 -0
  155. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +29 -0
  156. package/dist/runtime/application/world-authoring/AuthoringPatch.js +118 -0
  157. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +334 -0
  158. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +126 -0
  159. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +144 -0
  160. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +92 -0
  161. package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
  162. package/dist/runtime/application/world-authoring/SceneGLBExport.js +88 -0
  163. package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
  164. package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +68 -0
  165. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +1 -0
  166. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +30 -0
  167. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +17 -0
  168. package/dist/runtime/apps/mcp-server/CodeExecutor.js +71 -0
  169. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +42 -0
  170. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +66 -0
  171. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +159 -0
  172. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +8 -0
  173. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +47 -0
  174. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +157 -0
  175. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +6 -0
  176. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +116 -0
  177. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +60 -0
  178. package/dist/runtime/apps/mcp-server/README.md +269 -0
  179. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +1 -0
  180. package/dist/runtime/apps/mcp-server/SandboxBundle.js +13 -0
  181. package/dist/runtime/apps/mcp-server/SessionManager.js +148 -0
  182. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +75 -0
  183. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +246 -0
  184. package/dist/runtime/apps/mcp-server/StudioProjectToolContracts.js +58 -0
  185. package/dist/runtime/apps/mcp-server/TransferHttp.js +47 -0
  186. package/dist/runtime/apps/mcp-server/TransferLimits.js +6 -0
  187. package/dist/runtime/apps/mcp-server/TransferStore.js +134 -0
  188. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +16 -0
  189. package/dist/runtime/apps/mcp-server/VALIDATION.md +45 -0
  190. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +332 -0
  191. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +32 -0
  192. package/dist/runtime/apps/mcp-server/examples/code-house.js +24 -0
  193. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +85 -0
  194. package/dist/runtime/apps/mcp-server/main.mjs +82 -0
  195. package/dist/runtime/apps/mcp-server/registerTools.js +274 -0
  196. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
  197. package/dist/runtime/apps/mcp-server/security.js +23 -0
  198. package/dist/runtime/apps/mcp-server/tasks.jsonl +9 -0
  199. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +157 -0
  200. package/dist/runtime/apps/server/README.md +7 -0
  201. package/dist/runtime/apps/server/WorldRepository.js +338 -0
  202. package/dist/runtime/apps/server/WorldRepositoryHttp.js +96 -0
  203. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +278 -0
  204. package/dist/runtime/apps/server/tasks.jsonl +10 -0
  205. package/dist/runtime/apps/shared/node/WorldDiskStorage.js +62 -0
  206. package/dist/runtime/foundation/EventBus.js +26 -0
  207. package/dist/runtime/foundation/JsonGateway.js +47 -0
  208. package/dist/runtime/foundation/PngRgba.js +99 -0
  209. package/dist/runtime/foundation/PolicyEngine.js +21 -0
  210. package/dist/runtime/foundation/README.md +7 -0
  211. package/dist/runtime/foundation/TraceRecorder.js +76 -0
  212. package/dist/runtime/foundation/errors.js +8 -0
  213. package/dist/runtime/foundation/simulation/SimulationProfile.js +143 -0
  214. package/dist/runtime/foundation/version.js +2 -0
  215. package/dist/runtime/modules/agent/README.md +11 -0
  216. package/dist/runtime/modules/agent/ToolCallingAgent.js +19 -0
  217. package/dist/runtime/modules/agent/bootstrapWorld.js +10 -0
  218. package/dist/runtime/modules/agent/buildRecoveryProposals.js +533 -0
  219. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +128 -0
  220. package/dist/runtime/modules/agent/execution/AgentRunResults.js +55 -0
  221. package/dist/runtime/modules/agent/execution/AgentRunSession.js +393 -0
  222. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +40 -0
  223. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +19 -0
  224. package/dist/runtime/modules/agent/prompt/index.js +52 -0
  225. package/dist/runtime/modules/agent/tasks.jsonl +94 -0
  226. package/dist/runtime/modules/artifact/ArtifactContentGate.js +144 -0
  227. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +280 -0
  228. package/dist/runtime/modules/artifact/ArtifactImporter.js +185 -0
  229. package/dist/runtime/modules/artifact/ArtifactModule.js +111 -0
  230. package/dist/runtime/modules/artifact/ArtifactRegistry.js +197 -0
  231. package/dist/runtime/modules/artifact/IncrementalSha256.js +129 -0
  232. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +115 -0
  233. package/dist/runtime/modules/artifact/README.md +7 -0
  234. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +67 -0
  235. package/dist/runtime/modules/artifact/tasks.jsonl +31 -0
  236. package/dist/runtime/modules/asset/AssetModule.js +416 -0
  237. package/dist/runtime/modules/asset/README.md +67 -0
  238. package/dist/runtime/modules/asset/loading/AssetLoader.js +157 -0
  239. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +61 -0
  240. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +95 -0
  241. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +33 -0
  242. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +103 -0
  243. package/dist/runtime/modules/asset/model/AssetInputContracts.js +139 -0
  244. package/dist/runtime/modules/asset/model/AssetRef.js +12 -0
  245. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +172 -0
  246. package/dist/runtime/modules/asset/model/ProceduralTextureContract.js +24 -0
  247. package/dist/runtime/modules/asset/model/admission.js +117 -0
  248. package/dist/runtime/modules/asset/model/errors.js +6 -0
  249. package/dist/runtime/modules/asset/model/parts.js +27 -0
  250. package/dist/runtime/modules/asset/model/resourceBudget.js +10 -0
  251. package/dist/runtime/modules/asset/model/schema.js +150 -0
  252. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +78 -0
  253. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +84 -0
  254. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +86 -0
  255. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +81 -0
  256. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +272 -0
  257. package/dist/runtime/modules/asset/production/AssetRecipe.js +91 -0
  258. package/dist/runtime/modules/asset/production/ProceduralTexture.js +85 -0
  259. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +45 -0
  260. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +590 -0
  261. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +173 -0
  262. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +124 -0
  263. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +56 -0
  264. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +6 -0
  265. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +74 -0
  266. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +63 -0
  267. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +48 -0
  268. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +16 -0
  269. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +30 -0
  270. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +75 -0
  271. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +20 -0
  272. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +34 -0
  273. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +32 -0
  274. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +116 -0
  275. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +84 -0
  276. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +63 -0
  277. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +16 -0
  278. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +23 -0
  279. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +50 -0
  280. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +60 -0
  281. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +93 -0
  282. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +32 -0
  283. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +55 -0
  284. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +203 -0
  285. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +43 -0
  286. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +33 -0
  287. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +60 -0
  288. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +23 -0
  289. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +198 -0
  290. package/dist/runtime/modules/asset/registry/AssetCatalog.js +72 -0
  291. package/dist/runtime/modules/asset/registry/AssetRegistry.js +51 -0
  292. package/dist/runtime/modules/asset/registry/manifests/index.js +173 -0
  293. package/dist/runtime/modules/asset/tasks.jsonl +87 -0
  294. package/dist/runtime/modules/generation/README.md +9 -0
  295. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +45 -0
  296. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +169 -0
  297. package/dist/runtime/modules/generation/connector/ConnectorClient.js +192 -0
  298. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +167 -0
  299. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +179 -0
  300. package/dist/runtime/modules/generation/connector/ConnectorSession.js +202 -0
  301. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +239 -0
  302. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +99 -0
  303. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +91 -0
  304. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +50 -0
  305. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +304 -0
  306. package/dist/runtime/modules/generation/tasks.jsonl +35 -0
  307. package/dist/runtime/modules/navigation/NavigationBackend.js +17 -0
  308. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +263 -0
  309. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
  310. package/dist/runtime/modules/physics/PhysicsApiSurface.js +660 -0
  311. package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
  312. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +414 -0
  313. package/dist/runtime/modules/rendering/README.md +7 -0
  314. package/dist/runtime/modules/rendering/RendererProbe.js +153 -0
  315. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +140 -0
  316. package/dist/runtime/modules/rendering/captureStill.js +54 -0
  317. package/dist/runtime/modules/rendering/createRenderer.js +76 -0
  318. package/dist/runtime/modules/rendering/disposeObject3D.js +37 -0
  319. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +74 -0
  320. package/dist/runtime/modules/rendering/spatial/ThreeBvhRuntime.js +107 -0
  321. package/dist/runtime/modules/rendering/style/StylePack.js +34 -0
  322. package/dist/runtime/modules/rendering/style/StyleSystem.js +173 -0
  323. package/dist/runtime/modules/rendering/tasks.jsonl +7 -0
  324. package/dist/runtime/modules/world/README.md +13 -0
  325. package/dist/runtime/modules/world/build/WorldBuilder.js +170 -0
  326. package/dist/runtime/modules/world/compiler/PipelineEngine.js +32 -0
  327. package/dist/runtime/modules/world/compiler/WorldAdmission.js +43 -0
  328. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +68 -0
  329. package/dist/runtime/modules/world/compiler/WorldCompilation.js +157 -0
  330. package/dist/runtime/modules/world/compiler/WorldComposer.js +201 -0
  331. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +76 -0
  332. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +356 -0
  333. package/dist/runtime/modules/world/compiler/WorldRetry.js +75 -0
  334. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +379 -0
  335. package/dist/runtime/modules/world/content/blankWorld.js +35 -0
  336. package/dist/runtime/modules/world/content/environments.js +84 -0
  337. package/dist/runtime/modules/world/content/grandUrbanBlock.js +189 -0
  338. package/dist/runtime/modules/world/content/magic-cabin/README.md +28 -0
  339. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +64 -0
  340. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +7078 -0
  341. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +26 -0
  342. package/dist/runtime/modules/world/content/magic-cabin/materials.js +20 -0
  343. package/dist/runtime/modules/world/content/magicCabin.js +190 -0
  344. package/dist/runtime/modules/world/content/monumentHall.js +154 -0
  345. package/dist/runtime/modules/world/content/ruinedCourtyard.js +196 -0
  346. package/dist/runtime/modules/world/content/suzhouGarden/README.md +141 -0
  347. package/dist/runtime/modules/world/content/suzhouGarden/index.js +137 -0
  348. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +491 -0
  349. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +670 -0
  350. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +578 -0
  351. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +127 -0
  352. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +642 -0
  353. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +650 -0
  354. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +280 -0
  355. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +242 -0
  356. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +215 -0
  357. package/dist/runtime/modules/world/content/woodlandWorkshop.js +192 -0
  358. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +36 -0
  359. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +351 -0
  360. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +490 -0
  361. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +505 -0
  362. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +101 -0
  363. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +435 -0
  364. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +169 -0
  365. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +245 -0
  366. package/dist/runtime/modules/world/errors.js +9 -0
  367. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +50 -0
  368. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +297 -0
  369. package/dist/runtime/modules/world/runtime/CommandHistory.js +111 -0
  370. package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +165 -0
  371. package/dist/runtime/modules/world/runtime/NativeNavigationGeometry.js +84 -0
  372. package/dist/runtime/modules/world/runtime/NativePhysicsSnapshot.js +245 -0
  373. package/dist/runtime/modules/world/runtime/ObjectStore.js +31 -0
  374. package/dist/runtime/modules/world/runtime/ObjectTransform.js +62 -0
  375. package/dist/runtime/modules/world/runtime/ObservedEntity.js +37 -0
  376. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +240 -0
  377. package/dist/runtime/modules/world/runtime/SceneExtensions.js +36 -0
  378. package/dist/runtime/modules/world/runtime/ScenePresentation.js +101 -0
  379. package/dist/runtime/modules/world/runtime/SceneSerializer.js +281 -0
  380. package/dist/runtime/modules/world/runtime/WorldAuthority.js +41 -0
  381. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +14 -0
  382. package/dist/runtime/modules/world/runtime/WorldCommands.js +503 -0
  383. package/dist/runtime/modules/world/runtime/WorldObservation.js +71 -0
  384. package/dist/runtime/modules/world/runtime/WorldQueries.js +340 -0
  385. package/dist/runtime/modules/world/runtime/WorldRecovery.js +78 -0
  386. package/dist/runtime/modules/world/runtime/WorldRuntime.js +806 -0
  387. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +110 -0
  388. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +130 -0
  389. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +79 -0
  390. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +195 -0
  391. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +70 -0
  392. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +115 -0
  393. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +390 -0
  394. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +214 -0
  395. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +65 -0
  396. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +244 -0
  397. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +147 -0
  398. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
  399. package/dist/runtime/modules/world/runtime/interaction/ManipulationActions.js +7 -0
  400. package/dist/runtime/modules/world/runtime/interaction/NativePhysicalTarget.js +31 -0
  401. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
  402. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +134 -0
  403. package/dist/runtime/modules/world/runtime/semantic/NativePhysicsState.js +89 -0
  404. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +129 -0
  405. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
  406. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +104 -0
  407. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
  408. package/dist/runtime/modules/world/runtime/simulation/WorldTimeline.js +110 -0
  409. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
  410. package/dist/runtime/modules/world/runtime/spatial/VisualMeshBounds.js +41 -0
  411. package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +306 -0
  412. package/dist/runtime/modules/world/runtime/systems/Instrument.js +39 -0
  413. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +806 -0
  414. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +281 -0
  415. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +561 -0
  416. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1752 -0
  417. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +527 -0
  418. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +402 -0
  419. package/dist/runtime/modules/world/spec/WorldIR.js +165 -0
  420. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +86 -0
  421. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +51 -0
  422. package/dist/runtime/modules/world/spec/WorldRevision.js +231 -0
  423. package/dist/runtime/modules/world/spec/WorldSpec.js +86 -0
  424. package/dist/runtime/modules/world/tasks.jsonl +530 -0
  425. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +254 -0
  426. package/dist/runtime/modules/world/verification/Finding.js +105 -0
  427. package/dist/runtime/modules/world/verification/InteractionEvidence.js +73 -0
  428. package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
  429. package/dist/runtime/modules/world/verification/VisualLayoutAcceptance.js +58 -0
  430. package/dist/runtime/modules/world/verification/WorldAcceptance.js +176 -0
  431. package/dist/runtime/modules/world/verification/WorldValidator.js +67 -0
  432. package/dist/runtime/package-lock.json +16071 -0
  433. package/dist/runtime/package.json +106 -0
  434. package/dist/runtime/public/assets/cabinet.glb +0 -0
  435. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  436. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  437. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  438. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  439. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  440. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  441. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  442. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  443. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  444. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  445. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  446. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  447. package/dist/schema-DT7K9NjP.js +165 -0
  448. package/dist/schema-DT7K9NjP.js.map +1 -0
  449. package/dist/suzhouGarden-Y3hny8j6.js +6150 -0
  450. package/dist/suzhouGarden-Y3hny8j6.js.map +1 -0
  451. package/dist/version-CHc-i8ch.js +5 -0
  452. package/dist/version-CHc-i8ch.js.map +1 -0
  453. package/dist/woodlandWorkshop-DsScU-cx.js +483 -0
  454. package/dist/woodlandWorkshop-DsScU-cx.js.map +1 -0
  455. package/dist/yuanmingyuan-DsFnPzzR.js +4955 -0
  456. package/dist/yuanmingyuan-DsFnPzzR.js.map +1 -0
  457. package/package.json +75 -4
@@ -0,0 +1,263 @@
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
+ // The entire optional Recipe material may be added or replaced. Other
34
+ // paths still require an existing field; the complete recipe is revalidated.
35
+ const optionalRecipeMaterial=document.schema==='agentscape.asset-recipe'
36
+ && segments.length===3 && segments[0]==='parts' && key==='material'
37
+ && document.parts.includes(cursor) && Boolean(cursor.geometry);
38
+ if (!cursor || typeof cursor!=='object' || (!Object.hasOwn(cursor,key)&&!optionalRecipeMaterial))
39
+ throw fail('OBJECT_PATCH_PATH_NOT_FOUND');
40
+ const previous=clone(cursor[key]??null);
41
+ cursor[key]=clone(value);
42
+ return {path,previous,next:clone(value)};
43
+ }
44
+
45
+ function declaredEvidence(definition) {
46
+ if (definition.schema==='agentscape.mechanical-draft') {
47
+ return {
48
+ components:definition.components.map(node=>({
49
+ id:node.id,parent:node.parent,shape:node.shape,size:node.size,
50
+ position:node.position,collision:node.collision,source:'ai-declared'
51
+ })),
52
+ motions:definition.motions.map(motion=>({
53
+ id:motion.id,node:motion.node,type:motion.type,
54
+ axis:motion.axis,limits:motion.limits,source:'ai-declared',
55
+ status:'candidate',physicsVerified:false
56
+ }))
57
+ };
58
+ }
59
+ if (definition.schema==='agentscape.asset-recipe') {
60
+ return {
61
+ components:definition.parts.map(part=>({
62
+ id:part.id,parent:part.parent||null,
63
+ shape:part.geometry?.type||'group',position:part.position||[0,0,0],
64
+ source:'ai-declared'
65
+ })),motions:[]
66
+ };
67
+ }
68
+ return {
69
+ components:Object.entries(definition.definition?.parts||{}).map(([id,part])=>({
70
+ id,node:part.node,semantic:part.semantic||null,
71
+ source:'ai-declared'
72
+ })),
73
+ motions:Object.entries(definition.definition?.parts||{}).filter(([,part])=>part.joint).map(([id,part])=>({
74
+ id,node:part.node,type:part.joint.type,axis:part.joint.axis,
75
+ limits:part.joint.limits,status:'candidate',physicsVerified:false,
76
+ source:'ai-declared'
77
+ }))
78
+ };
79
+ }
80
+
81
+ /** Read only actual instantiated Three.js nodes. An Object3D hierarchy is not a joint. */
82
+ function runtimeGeometry(object) {
83
+ const nodes=[];
84
+ if (!object?.traverse) return {nodes, truncated:false};
85
+ object.traverse(node=>{
86
+ if (nodes.length>=128) return;
87
+ const bounds=node.geometry?.boundingBox;
88
+ nodes.push({
89
+ name:String(node.name||'').slice(0,100),
90
+ type:node.type, mesh:node.isMesh===true,
91
+ parent:node.parent?.name||null,
92
+ position:node.position?.toArray?.()||null,
93
+ geometryBounds:bounds ? {min:bounds.min.toArray(),max:bounds.max.toArray()} : null,
94
+ source:'runtime-observed'
95
+ });
96
+ });
97
+ return {nodes,truncated:nodes.length>=128};
98
+ }
99
+
100
+ /** A + C: observed Three.js hierarchy and declared, versioned capability intent.
101
+ * Source entries are private to the session, never treated as physics truth.
102
+ */
103
+ export class SceneObjectForge {
104
+ constructor(){this.entries=new Map();}
105
+ record(id,source,assetId,world,{originAssetId=null}={}){
106
+ if(!['agentscape.mechanical-draft','agentscape.asset-recipe'].includes(source?.schema)
107
+ && source?.kind!=='three-code') return;
108
+ const definition=parse(source);
109
+ this.entries.set(id,{definition,assetId,world,originAssetId,revision:1,preview:null});
110
+ }
111
+ fork(world,id,source,originAssetId){
112
+ if(this.entries.has(id)) throw fail('OBJECT_DEFINITION_ALREADY_TRACKED');
113
+ if(!world.store.has(id) || world.store.get(id).assetId!==originAssetId
114
+ || !/^pa_[a-f0-9]{64}$/.test(originAssetId))throw fail('OBJECT_DEFINITION_UNAVAILABLE');
115
+ this.record(id,source,originAssetId,world,{originAssetId});
116
+ return {status:'object-project-forked',id,originAssetId,revision:1,
117
+ globalVersionUnchanged:true,scope:'project-instance'};
118
+ }
119
+ get(world,id){
120
+ const entry=this.entries.get(id);
121
+ if(!entry || entry.world!==world)throw fail('OBJECT_DEFINITION_UNAVAILABLE');
122
+ if(!world.store.has(id) || world.store.get(id).assetId!==entry.assetId)
123
+ throw fail(entry.applying?'OBJECT_PATCH_BUSY':'OBJECT_DEFINITION_UNAVAILABLE');
124
+ return entry;
125
+ }
126
+ // Editor may keep the last committed draft visible while a replacement is in flight.
127
+ // It must not be presented as a fresh runtime observation or used to submit edits.
128
+ editorEntry(world,id){
129
+ const entry=this.entries.get(id);
130
+ return entry?.world===world && entry.applying ? entry : this.get(world,id);
131
+ }
132
+ async inspectWhenReady(world,id){
133
+ const entry=this.entries.get(id);
134
+ if(entry?.world===world && entry.applyPromise){
135
+ try{await entry.applyPromise;}catch{/* Inspect the actual retained definition, or report its absence. */}
136
+ }
137
+ return this.inspect(world,id);
138
+ }
139
+ analyze(world,id,definition){
140
+ const record=world.store.get(id);
141
+ const declared=declaredEvidence(definition),observed=runtimeGeometry(record?.object);
142
+ const known=new Set(observed.nodes.map(node=>node.name).filter(Boolean));
143
+ const references=new Set([
144
+ ...declared.motions.map(motion=>motion.node),
145
+ ...(definition.definition?.requiredNodes||[])
146
+ ].filter(Boolean));
147
+ const matched=[...references].filter(name=>known.has(name));
148
+ const missing=[...references].filter(name=>!known.has(name));
149
+ return {declared,observed,reconciliation:{matchedNodes:matched,missingNodes:missing,
150
+ status:missing.length?'needs-review':'matched',evidenceKind:'node-name-match'},
151
+ interpretation:'observed-geometry-is-not-physical-articulation'};
152
+ }
153
+ inspect(world,id){
154
+ const e=this.get(world,id);
155
+ return {
156
+ schema:'agentscape.object-definition',schemaVersion:1,id,
157
+ revision:e.revision,assetId:e.assetId,originAssetId:e.originAssetId||null,
158
+ definition:clone(e.definition),analysis:this.analyze(world,id,e.definition),
159
+ provenance:{definition:'ai-declared',geometry:'runtime-observed',
160
+ motions:'candidate-unless-verified-by-runtime'}
161
+ };
162
+ }
163
+ preview(world,id,expectedRevision,changes){
164
+ const e=this.get(world,id);
165
+ if(e.applying)throw fail('OBJECT_PATCH_BUSY');
166
+ if(expectedRevision!==e.revision) throw fail('OBJECT_REVISION_CONFLICT');
167
+ if(!Array.isArray(changes)||!changes.length||changes.length>8
168
+ || JSON.stringify(changes).length>32768)throw fail('OBJECT_PATCH_LIMIT');
169
+ const copy=clone(e.definition),delta=changes.map(change=>changeAt(copy,change));
170
+ const parsed=parse(copy),previewId=globalThis.crypto.randomUUID();
171
+ e.preview={previewId,revision:e.revision,definition:parsed,changes:delta};
172
+ return {status:'object-patch-preview',id,revision:e.revision,previewId,
173
+ changes:delta,analysis:{declared:declaredEvidence(parsed)},
174
+ verification:'not-run'};
175
+ }
176
+ async apply(world,scene,id,expectedRevision,previewId,{executor}={}){
177
+ const e=this.get(world,id);
178
+ if(e.applying)throw fail('OBJECT_PATCH_BUSY');
179
+ if(expectedRevision!==e.revision)throw fail('OBJECT_REVISION_CONFLICT');
180
+ const pending=e.preview;
181
+ if(!pending||pending.previewId!==previewId||pending.revision!==e.revision)
182
+ throw fail('OBJECT_PATCH_PREVIEW_NOT_FOUND');
183
+ e.preview=null;
184
+ e.applying=true;
185
+ const operation=(async()=>{
186
+ const next=pending.definition,module=world.assetModule;
187
+ const level=module.getManifest(e.assetId).capabilityLevel||'physical';
188
+ let assetId,admission,replaced;
189
+ if(next.kind==='three-code'){
190
+ const prepared=await prepareThreeCodeAsset(module,executor,next,{
191
+ gltfLoader:module.loader.gltfLoader
192
+ });
193
+ assetId=prepared.manifest.id;
194
+ admission=prepared.validation;
195
+ if(this.get(world,id)!==e)throw fail('OBJECT_REVISION_CONFLICT');
196
+ replaced=await prepared.install(()=>scene.replaceAsset({id,asset:prepared.asset,level}));
197
+ }else{
198
+ // Mechanical drafts must pass their articulation verifier before any instance swap.
199
+ const imported=next.schema==='agentscape.mechanical-draft'
200
+ ? await module.importMechanicalDraft(next) : await module.importRecipe(next);
201
+ assetId=imported.manifest.id;
202
+ admission=imported.admission;
203
+ if(this.get(world,id)!==e)throw fail('OBJECT_REVISION_CONFLICT');
204
+ replaced=await scene.replaceAsset({id,asset:'asset://sha256/'+assetId.replace(/^asset_/,''),level});
205
+ }
206
+ if(replaced.status!=='succeeded'||world.store.get(id)?.assetId!==assetId)
207
+ throw fail(replaced.diagnostics?.[0]?.code||'OBJECT_PATCH_REPLACE_FAILED');
208
+ e.definition=clone(next);
209
+ e.assetId=assetId;
210
+ e.revision++;
211
+ return {status:'object-patch-applied',id,revision:e.revision,
212
+ assetId,changes:pending.changes,
213
+ verification:{status:'compiled-and-admitted',admission,
214
+ runtimeActionVerification:'not-run'},replace:replaced.status};
215
+ })();
216
+ e.applyPromise=operation;
217
+ try{return await operation;}
218
+ finally{e.applying=false;e.applyPromise=null;}
219
+ }
220
+
221
+ /** Export editable source only for objects still bound to their original immutable asset. */
222
+ export(world) {
223
+ const entries = [];
224
+ for (const [id, entry] of this.entries) {
225
+ if (entry.world !== world || !world.store.has(id) || world.store.get(id).assetId !== entry.assetId) continue;
226
+ entries.push({id,assetId:entry.assetId,revision:entry.revision,definition:clone(entry.definition),
227
+ ...(entry.originAssetId?{originAssetId:entry.originAssetId}:{})});
228
+ }
229
+ return entries;
230
+ }
231
+ /** Validate complete source catalog before altering the live editor registry. */
232
+ static validateTransfer(snapshot, input = []) {
233
+ if (!Array.isArray(input) || input.length > 64 || JSON.stringify(input).length > 262144)
234
+ throw fail('OBJECT_DEFINITION_TRANSFER_LIMIT');
235
+ const objects = new Map(snapshot.objects.map(object => [object.id,object.assetId]));
236
+ const ids = new Set();
237
+ return input.map(item => {
238
+ if (!item || typeof item !== 'object' || Array.isArray(item) || typeof item.id !== 'string'
239
+ || !/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(item.id)
240
+ || !(/^(asset_|pa_)[a-f0-9]{64}$/.test(item.assetId))
241
+ || !Number.isSafeInteger(item.revision) || item.revision < 1 || item.revision > 1000000
242
+ || ids.has(item.id) || objects.get(item.id) !== item.assetId
243
+ || (item.originAssetId != null && !/^pa_[a-f0-9]{64}$/.test(item.originAssetId)))
244
+ throw fail('OBJECT_DEFINITION_TRANSFER_INVALID');
245
+ ids.add(item.id);
246
+ const definition=parse(item.definition);
247
+ return {id:item.id,assetId:item.assetId,revision:item.revision,definition,
248
+ ...(item.originAssetId?{originAssetId:item.originAssetId}:{})};
249
+ });
250
+ }
251
+ restore(world, input) {
252
+ const ready=SceneObjectForge.validateTransfer({
253
+ objects:world.store.list().map(([id,record])=>({id,assetId:record.assetId}))
254
+ },input);
255
+ const next=new Map(ready.map(item=>[
256
+ item.id,{assetId:item.assetId,definition:clone(item.definition),revision:item.revision,preview:null,world,
257
+ originAssetId:item.originAssetId||null}
258
+ ]));
259
+ this.entries=next;
260
+ return {restored:next.size};
261
+ }
262
+ clear(){this.entries.clear();}
263
+ }
@@ -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,90 @@
1
+ import { sceneError } from './SceneContracts.js';
2
+ import { inspectNativePhysics,nativeManipulationActions } from '../../modules/world/runtime/semantic/NativePhysicsState.js';
3
+
4
+ /**
5
+ * Read-only capability projection for assets, environment contracts and
6
+ * executable Code Project entities. The underlying owners retain their state.
7
+ */
8
+ export function describeCapabilities(inspection) {
9
+ return (inspection.actions || []).map(action => {
10
+ const name = action.name || action.action;
11
+ return {
12
+ id: [inspection.id, action.partName || '$root', name].join(':'),
13
+ target: inspection.id,
14
+ name,
15
+ action: 'invoke',
16
+ source: action.source || inspection.source,
17
+ executor: action.execution,
18
+ ...(action.partName ? { partName: action.partName } : {}),
19
+ ...(action.capabilitySource ? { capabilitySource: action.capabilitySource } : {}),
20
+ ...(action.graspVerified === false ? { graspVerified:false } : {}),
21
+ description: action.description || '',
22
+ parameters: structuredClone(action.parameters || {}),
23
+ available: action.available ?? null,
24
+ ...(action.reason ? { reason: action.reason } : {}),
25
+ ...(action.canApproach ? { canApproach: true } : {}),
26
+ verification: action.contract?.verifierTarget?.type
27
+ || action.verification || inspection.evidenceKind || 'unverified'
28
+ };
29
+ });
30
+ }
31
+
32
+ export function inspectCapabilities(world, target, { actor } = {}) {
33
+ const physical = world.affordances?.inspect(target, { actorId: actor }) || null;
34
+ const project = world.projectCapabilities?.has(target)
35
+ ? world.projectCapabilities.inspect(target, { actor }) : null;
36
+ if (!physical && !project) return null;
37
+ if (!physical || !project) {
38
+ const inspection = physical || project;
39
+ const nativePhysics=inspectNativePhysics(world,target);
40
+ const nativeActions=nativePhysics?nativeManipulationActions(world,target,actor):[];
41
+ const capabilities=[...describeCapabilities(inspection),
42
+ ...describeCapabilities({id:target,source:'native-physics',actions:nativeActions})];
43
+ const ids=new Map();
44
+ for(const entry of capabilities)ids.set(entry.id,(ids.get(entry.id)||0)+1);
45
+ return { ...inspection, actions:[...(inspection.actions||[]),...nativeActions],
46
+ capabilities:capabilities.map(entry=>ids.get(entry.id)>1?{...entry,id:entry.id+':'+entry.source}:entry),
47
+ ...(nativePhysics?{physics:nativePhysics,providers:['project','native-physics'],
48
+ stateProviders:{project:structuredClone(inspection.state||{}),'native-physics':nativePhysics.state},
49
+ stateConflicts:Object.keys(inspection.state||{}).filter(key=>Object.hasOwn(nativePhysics.state,key))}:{}),
50
+ ...(world.thermal?.inspect?.(target)?{simulation:world.thermal.inspect(target)}:{}) };
51
+ }
52
+
53
+ // A single logical entity can expose independent physical and project state.
54
+ // No provider state is copied back into the other provider.
55
+ const stateProviders = { [physical.source]:structuredClone(physical.state || {}),
56
+ project:structuredClone(project.state || {}) };
57
+ const collisions = Object.keys(stateProviders.project).filter(key => Object.hasOwn(stateProviders[physical.source], key));
58
+ const state = { ...stateProviders[physical.source] };
59
+ for (const [key, value] of Object.entries(stateProviders.project)) {
60
+ if (!Object.hasOwn(state, key)) state[key] = value;
61
+ }
62
+ const entries = [...describeCapabilities(physical), ...describeCapabilities(project)];
63
+ const counts = new Map();
64
+ for (const entry of entries) counts.set(entry.id, (counts.get(entry.id) || 0) + 1);
65
+ const capabilities = entries.map(entry => ({
66
+ ...entry, ...(counts.get(entry.id) > 1 ? {id:entry.id + ':' + entry.source} : {})
67
+ }));
68
+ return { ...physical, source:'composite', providers:[physical.source,'project'],
69
+ state, stateProviders, stateConflicts:collisions,
70
+ actions:[...(physical.actions || []),...(project.actions || []).map(action => ({...action,source:'project'}))],
71
+ capabilities, ...(world.thermal?.inspect?.(target)?{simulation:world.thermal.inspect(target)}:{}) };
72
+ }
73
+
74
+ /** Resolve a registered action without ever inferring permission from its name. */
75
+ export function resolveCapability(world, { target, name, actor, partName, source }) {
76
+ const inspection = inspectCapabilities(world, target, { actor });
77
+ if (!inspection) throw sceneError('OBJECT_NOT_FOUND');
78
+ const matches = inspection.capabilities.filter(entry =>
79
+ entry.name === name && (partName == null || entry.partName === partName)
80
+ && (source == null || entry.source === source));
81
+ if (!matches.length) throw sceneError('ACTION_UNSUPPORTED');
82
+ if (matches.length !== 1) {
83
+ if (new Set(matches.map(item => item.source)).size > 1) throw sceneError('ACTION_SOURCE_REQUIRED');
84
+ throw sceneError('ACTION_PART_REQUIRED');
85
+ }
86
+ const capability = matches[0];
87
+ if (!['interaction', 'world-action', 'project-action'].includes(capability.executor))
88
+ throw sceneError('ACTION_NOT_INVOKABLE');
89
+ return { source: capability.source, capability };
90
+ }
@@ -0,0 +1,18 @@
1
+ import * as z from 'zod/v4';
2
+ import { sceneObjectIdSchema, sceneVector3Schema } from './SceneProject.js';
3
+
4
+ // Pure schema: both SceneFacade and NativeSceneHost depend on this contract.
5
+ // Never import the native runtime into the generic Scene application layer.
6
+ const quaternion = z.tuple([z.number().finite(),z.number().finite(),z.number().finite(),z.number().finite()])
7
+ .refine(value=>Math.abs(Math.hypot(...value)-1)<1e-4);
8
+ const positiveScale = z.tuple([z.number().positive().max(100),z.number().positive().max(100),z.number().positive().max(100)]);
9
+ export const nativeEditableChangesSchema = z.object({
10
+ position:sceneVector3Schema.optional(),
11
+ quaternion:quaternion.optional(),
12
+ scale:positiveScale.optional(),
13
+ visible:z.boolean().optional()
14
+ }).strict().refine(value=>Object.keys(value).length>0,'At least one editable property is required');
15
+ export const nativeEditableSnapshotSchema = z.object({
16
+ schema:z.literal('agentscape.native-edits'),schemaVersion:z.literal(1),
17
+ overrides:z.record(sceneObjectIdSchema,nativeEditableChangesSchema)
18
+ }).strict();
@@ -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,49 @@
1
+ import * as z from 'zod/v4';
2
+ import { scenePresentationSchema } from '../../modules/world/runtime/ScenePresentation.js';
3
+ import { nativeEditableChangesSchema } from './NativeEditableContracts.js';
4
+ import { recipeSchema } from '../../modules/asset/model/AssetInputContracts.js';
5
+ import { mechanicalDraftSchema } from '../../modules/asset/model/MechanicalAssetDraft.js';
6
+ import { sceneObjectIdSchema as id, sceneTransformSchema, sceneVector3Schema } from './SceneProject.js';
7
+
8
+ export const sceneError = (code, message = code) => Object.assign(new Error(message), { code });
9
+ export const ref = z.string().regex(/^(builtin:\/\/[a-zA-Z][a-zA-Z0-9_-]{0,63}|asset:\/\/sha256\/[a-f0-9]{64})$/);
10
+ export const level = z.enum(['visual', 'physical', 'interactive']).default('physical');
11
+ 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');
12
+ 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');
13
+ export const operations = z.discriminatedUnion('type', [
14
+ z.object({ type: z.literal('add'), model: modelSchema }).strict(),
15
+ z.object({ type: z.literal('setTransform'), id, transform: sceneTransformSchema }).strict(),
16
+ z.object({ type: z.literal('remove'), id }).strict(),
17
+ z.object({ type: z.literal('replaceAsset'), id, asset: ref, level }).strict(),
18
+ z.object({ type: z.literal('setPresentation'), presentation:scenePresentationSchema }).strict(),
19
+ z.object({ type: z.literal('editNative'), id, changes:nativeEditableChangesSchema }).strict()
20
+ ]);
21
+ 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();
22
+ const operationVector = sceneVector3Schema.refine(value => Math.hypot(...value) > 1e-6, 'Direction must be nonzero');
23
+ const affordanceTarget = z.string().regex(/^[A-Za-z][A-Za-z0-9_:-]{0,255}$/);
24
+ export const sceneInteractionSchema = z.discriminatedUnion('action', [
25
+ 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','native-physics']).optional(), args:z.record(z.string(),z.unknown()).default({}) }).strict(),
26
+ 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(),
27
+ z.object({ action: z.literal('navigate'), actor: id, position: sceneVector3Schema }).strict(),
28
+ z.object({ action: z.literal('activate'), actor: id, target: affordanceTarget }).strict(),
29
+ z.object({ action: z.enum(['pickup','drop']), actor: id, target: affordanceTarget }).strict(),
30
+ z.object({ action: z.literal('place'), actor: id, target: affordanceTarget, surfaceId: id.optional() }).strict(),
31
+ z.object({ action: z.enum(['open', 'close']), actor: id, target: affordanceTarget, partName: id.optional() }).strict(),
32
+ z.object({ action: z.enum(['turn_on', 'turn_off', 'pull_out', 'return']), actor: id, target: affordanceTarget }).strict(),
33
+ z.object({ action: z.literal('write'), actor: id, target: affordanceTarget, args: z.object({ text: z.string().max(100) }).strict() }).strict(),
34
+ z.object({ action: z.enum(['push', 'drag']), actor: id, target: affordanceTarget, args: z.object({
35
+ direction: operationVector.refine(value => Math.abs(value[1]) < 1e-6, 'Linear contact operations require a horizontal direction'),
36
+ distance: z.number().positive().max(5), maxForce: z.number().positive().max(1000).default(100)
37
+ }).strict() }).strict(),
38
+ z.object({ action: z.literal('rotate'), actor: id, target: affordanceTarget, args: z.object({
39
+ axis: operationVector, angle: z.number().finite().min(-Math.PI).max(Math.PI).refine(value => value !== 0),
40
+ maxTorque: z.number().positive().max(1000).default(100)
41
+ }).strict() }).strict(),
42
+ z.object({ action: z.literal('slide'), actor: id, target: affordanceTarget, args: z.object({ part: id,
43
+ target: z.number().finite().optional(), distance: z.number().finite().optional()
44
+ }).strict().refine(value => (value.target != null) !== (value.distance != null), 'Use target or distance') }).strict(),
45
+ z.object({ action: z.literal('rotateJoint'), actor: id, target: affordanceTarget, args: z.object({ part: id,
46
+ target: z.number().finite().optional(), angle: z.number().finite().min(-Math.PI).max(Math.PI).optional()
47
+ }).strict().refine(value => (value.target != null) !== (value.angle != null), 'Use target or angle') }).strict()
48
+ ]);
49
+ export const diagnostic = error => ({ code: error.code || 'INVALID_OPERATION', message: error.code || 'Operation failed', stage: 'scene', retryable: false });