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,126 @@
1
+ import * as THREE from 'three';
2
+ import { parseAuthoringDocument } from './AuthoringDocument.js';
3
+ import { installHeadlessImageSupport } from './HeadlessImageExport.js';
4
+ import { uniformScaleValue } from '../../modules/world/runtime/ObjectTransform.js';
5
+ import { sha256ArtifactHash } from '../../modules/artifact/IncrementalSha256.js';
6
+
7
+ export const promotionError = (code, message) => Object.assign(new Error(message), { code });
8
+ export const promotionHash = (value) => sha256ArtifactHash([new TextEncoder().encode(JSON.stringify(value))]);
9
+
10
+ // Capture only the selected subtree and its resources, plus inherited placement.
11
+ // An unrelated edit must not invalidate a prepared asset.
12
+ export function capturePromotionSource(authoring, nodeId) {
13
+ const document = authoring.export();
14
+ const state = parseAuthoringDocument(document);
15
+ if (!state.nodesById[nodeId] || nodeId === state.rootId) {
16
+ throw promotionError('AUTHORING_SELECTION_INVALID', '请选择一个创作对象或分组,不能晋升整个创作根节点');
17
+ }
18
+ const ids = [];
19
+ const visit = id => { ids.push(id); for (const child of state.childIdsById[id] || []) visit(child); };
20
+ visit(nodeId);
21
+ const geometries = {}, materials = {};
22
+ for (const id of ids) {
23
+ const components = state.nodesById[id].components;
24
+ const geometryId = components.geometry?.properties?.geometryId;
25
+ const materialId = components.material?.properties?.materialId;
26
+ if (geometryId) geometries[geometryId] = state.geometries[geometryId];
27
+ if (materialId) materials[materialId] = state.materials[materialId];
28
+ }
29
+ const textures = {};
30
+ for (const material of Object.values(materials)) {
31
+ for (const value of Object.values(material)) {
32
+ if (typeof value === 'string' && state.textures[value]) textures[value] = state.textures[value];
33
+ }
34
+ }
35
+ const object = authoring.get(nodeId);
36
+ object.updateWorldMatrix(true, true);
37
+ const matrix = object.matrixWorld.clone();
38
+ const position = new THREE.Vector3(), quaternion = new THREE.Quaternion(), scale = new THREE.Vector3();
39
+ matrix.decompose(position, quaternion, scale);
40
+ const uniform = uniformScaleValue(scale.toArray());
41
+ const reconstructed = new THREE.Matrix4().compose(position, quaternion, scale);
42
+ if (matrix.elements.some((v, i) => !Number.isFinite(v) || Math.abs(v - reconstructed.elements[i]) > 1e-6)) {
43
+ throw promotionError('AUTHORING_TRANSFORM_UNSUPPORTED', '当前世界不支持带剪切的对象变换');
44
+ }
45
+ let ancestor = nodeId;
46
+ while (ancestor) {
47
+ if (state.nodesById[ancestor].visible === false) throw promotionError('AUTHORING_NODE_HIDDEN', '请先显示创作对象及其父分组');
48
+ ancestor = state.parentIdById[ancestor];
49
+ }
50
+ const nodes = ids.map(id => ({ ...state.nodesById[id], childIds:state.childIdsById[id] }));
51
+ const content = { nodes, geometries, materials, textures };
52
+ // Root placement does not change asset bytes; parent transforms still change sourceHash.
53
+ const assetContent = structuredClone(content);
54
+ delete assetContent.nodes[0].components.transform;
55
+ const transform = { position:position.toArray(), quaternion:quaternion.toArray(), scale:uniform };
56
+ return {
57
+ nodeId, name:object.name || nodeId, ids, object, transform,
58
+ reference:state.nodesById[nodeId].components.modelRef?.properties || null,
59
+ contentHash:promotionHash(assetContent), sourceHash:promotionHash({ content, transform }),
60
+ revisionId:authoring.currentRevision()?.id || null
61
+ };
62
+ }
63
+
64
+ export async function exportPromotionGLB(source) {
65
+ // Lazy load the exporter only when a visual subtree actually needs asset production.
66
+ const { GLTFExporter } = await import('three/addons/exporters/GLTFExporter.js');
67
+ const object = source.object.clone(true);
68
+ object.position.set(0, 0, 0);
69
+ object.quaternion.identity();
70
+ object.scale.set(1, 1, 1);
71
+ object.matrixAutoUpdate = true;
72
+ object.updateMatrix();
73
+ object.visible = true;
74
+ const materials = [];
75
+ const expand = node => {
76
+ for (const child of [...node.children]) {
77
+ if (child.isInstancedMesh) {
78
+ const group = new THREE.Group();
79
+ group.name = child.name;
80
+ group.position.copy(child.position);
81
+ group.quaternion.copy(child.quaternion);
82
+ group.scale.copy(child.scale);
83
+ group.visible = child.visible;
84
+ for (let i = 0; i < child.count; i++) {
85
+ let material = child.material;
86
+ if (child.instanceColor) {
87
+ material = material.clone();
88
+ material.color.multiply(new THREE.Color().fromBufferAttribute(child.instanceColor, i));
89
+ materials.push(material);
90
+ }
91
+ const mesh = new THREE.Mesh(child.geometry, material);
92
+ child.getMatrixAt(i, mesh.matrix);
93
+ mesh.matrixAutoUpdate = false;
94
+ group.add(mesh);
95
+ }
96
+ while (child.children.length) group.add(child.children[0]);
97
+ node.remove(child);
98
+ node.add(group);
99
+ expand(group);
100
+ } else expand(child);
101
+ }
102
+ };
103
+ const wrapper = new THREE.Group();
104
+ wrapper.add(object);
105
+ let meshes = 0;
106
+ // Headless hosts have no canvas; install a deterministic image encoder so
107
+ // Agent-authored DataTextures still compile. Browsers keep their real canvas.
108
+ const restoreImageSupport = installHeadlessImageSupport();
109
+ try {
110
+ expand(wrapper);
111
+ wrapper.traverse(node => {
112
+ if (node.isLight || node.isCamera || node.isSkinnedMesh || node.animations?.length) {
113
+ throw promotionError('AUTHORING_EXPORT_UNSUPPORTED', '请将灯光、相机、蒙皮或动画与待晋升对象分开');
114
+ }
115
+ if (node.isMesh) meshes++;
116
+ // Runtime and authoring IDs do not belong in reusable asset GLB extras.
117
+ node.userData = {};
118
+ });
119
+ if (!meshes) throw promotionError('AUTHORING_MODEL_UNRESOLVED', '对象没有可导出的网格,请先加载模型');
120
+ const bytes = await new GLTFExporter().parseAsync(wrapper, { binary:true, onlyVisible:true });
121
+ return new Uint8Array(bytes);
122
+ } finally {
123
+ restoreImageSupport?.();
124
+ for (const material of materials) material.dispose();
125
+ }
126
+ }
@@ -0,0 +1,144 @@
1
+ import {
2
+ canonicalizeAuthoringDocument,
3
+ diffAuthoringDocuments
4
+ } from './AuthoringDiff.js';
5
+ import { parseAuthoringDocument } from './AuthoringDocument.js';
6
+
7
+ function clone(value) {
8
+ return value == null ? value : JSON.parse(JSON.stringify(value));
9
+ }
10
+
11
+ function normalizeLimit(value) {
12
+ const limit = Number(value ?? 64);
13
+ if (!Number.isInteger(limit) || limit < 2) {
14
+ throw new TypeError('World Authoring revision history limit must be an integer >= 2');
15
+ }
16
+ return limit;
17
+ }
18
+
19
+ export class AuthoringRevisionHistory {
20
+ constructor({ limit = 64, now = () => new Date().toISOString() } = {}) {
21
+ this.limit = normalizeLimit(limit);
22
+ this.now = now;
23
+ this.entries = [];
24
+ this.cursor = -1;
25
+ this.sequence = 0;
26
+ }
27
+
28
+ reset(document, { label = 'Loaded world', source = 'load' } = {}) {
29
+ parseAuthoringDocument(document);
30
+ this.entries = [];
31
+ this.cursor = -1;
32
+ this.sequence = 0;
33
+ return this.commit(document, { label, source, force:true });
34
+ }
35
+
36
+ commit(document, {
37
+ label = '',
38
+ source = 'manual',
39
+ force = false
40
+ } = {}) {
41
+ parseAuthoringDocument(document);
42
+ const snapshot = clone(document);
43
+ const canonical = canonicalizeAuthoringDocument(snapshot);
44
+ const current = this.entries[this.cursor];
45
+
46
+ if (!force && current && canonicalizeAuthoringDocument(current.document) === canonical) {
47
+ return { created:false, revision:this.describe(current) };
48
+ }
49
+
50
+ if (this.cursor < this.entries.length - 1) {
51
+ this.entries.splice(this.cursor + 1);
52
+ }
53
+
54
+ const entry = {
55
+ id:`rev_${String(++this.sequence).padStart(6, '0')}`,
56
+ index:this.cursor + 1,
57
+ label:String(label || ''),
58
+ source:String(source || 'manual'),
59
+ createdAt:this.now(),
60
+ document:snapshot
61
+ };
62
+
63
+ this.entries.push(entry);
64
+ this.cursor = this.entries.length - 1;
65
+
66
+ while (this.entries.length > this.limit) {
67
+ this.entries.shift();
68
+ this.cursor -= 1;
69
+ }
70
+
71
+ this.reindex();
72
+ return { created:true, revision:this.describe(this.entries[this.cursor]) };
73
+ }
74
+
75
+ reindex() {
76
+ this.entries.forEach((entry, index) => {
77
+ entry.index = index;
78
+ });
79
+ }
80
+
81
+ describe(entry) {
82
+ if (!entry) return null;
83
+ return {
84
+ id:entry.id,
85
+ index:entry.index,
86
+ label:entry.label,
87
+ source:entry.source,
88
+ createdAt:entry.createdAt
89
+ };
90
+ }
91
+
92
+ list() {
93
+ return this.entries.map(entry => ({
94
+ ...this.describe(entry),
95
+ current:entry === this.entries[this.cursor]
96
+ }));
97
+ }
98
+
99
+ current() {
100
+ return this.describe(this.entries[this.cursor]);
101
+ }
102
+
103
+ currentDocument() {
104
+ return clone(this.entries[this.cursor]?.document || null);
105
+ }
106
+
107
+ getDocument(revisionId) {
108
+ const entry = this.entries.find(item => item.id === revisionId);
109
+ if (!entry) throw new TypeError(`World Authoring revision not found: ${revisionId}`);
110
+ return clone(entry.document);
111
+ }
112
+
113
+ canUndo() {
114
+ return this.cursor > 0;
115
+ }
116
+
117
+ canRedo() {
118
+ return this.cursor >= 0 && this.cursor < this.entries.length - 1;
119
+ }
120
+
121
+ undo() {
122
+ if (!this.canUndo()) return null;
123
+ this.cursor -= 1;
124
+ return {
125
+ revision:this.current(),
126
+ document:this.currentDocument()
127
+ };
128
+ }
129
+
130
+ redo() {
131
+ if (!this.canRedo()) return null;
132
+ this.cursor += 1;
133
+ return {
134
+ revision:this.current(),
135
+ document:this.currentDocument()
136
+ };
137
+ }
138
+
139
+ diff(fromRevisionId, toRevisionId) {
140
+ const before = this.getDocument(fromRevisionId);
141
+ const after = this.getDocument(toRevisionId);
142
+ return diffAuthoringDocuments(before, after);
143
+ }
144
+ }
@@ -0,0 +1,174 @@
1
+ // Deterministic image export for hosts without a DOM canvas.
2
+ //
3
+ // GLTFExporter encodes every texture through a canvas. Browsers always have one,
4
+ // but headless hosts (Node tools, CI) do not, so exporting an Agent-authored
5
+ // DataTexture - the only texture an authoring sandbox can create - would fail with
6
+ // "document is not defined". This module encodes RGBA pixel data straight to PNG
7
+ // bytes and exposes a minimal OffscreenCanvas/ImageData surface that GLTFExporter
8
+ // picks up automatically when the real canvas APIs are unavailable.
9
+
10
+ const PNG_SIGNATURE = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
11
+ const ZLIB_HEADER = new Uint8Array([0x78, 0x01]);
12
+ const STORED_BLOCK_MAX = 0xffff;
13
+
14
+ const CRC_TABLE = (() => {
15
+ const table = new Uint32Array(256);
16
+ for (let n = 0; n < 256; n++) {
17
+ let c = n;
18
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
19
+ table[n] = c >>> 0;
20
+ }
21
+ return table;
22
+ })();
23
+
24
+ function crc32(bytes, start, end) {
25
+ let crc = 0xffffffff;
26
+ for (let i = start; i < end; i++) crc = CRC_TABLE[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);
27
+ return (crc ^ 0xffffffff) >>> 0;
28
+ }
29
+
30
+ function adler32(bytes) {
31
+ let a = 1;
32
+ let b = 0;
33
+ for (let i = 0; i < bytes.length; i++) {
34
+ a = (a + bytes[i]) % 65521;
35
+ b = (b + a) % 65521;
36
+ }
37
+ return ((b << 16) | a) >>> 0;
38
+ }
39
+
40
+ function concat(parts) {
41
+ let length = 0;
42
+ for (const part of parts) length += part.length;
43
+ const out = new Uint8Array(length);
44
+ let offset = 0;
45
+ for (const part of parts) { out.set(part, offset); offset += part.length; }
46
+ return out;
47
+ }
48
+
49
+ function pngChunk(type, data) {
50
+ const out = new Uint8Array(12 + data.length);
51
+ const view = new DataView(out.buffer);
52
+ view.setUint32(0, data.length);
53
+ for (let i = 0; i < 4; i++) out[4 + i] = type.charCodeAt(i);
54
+ out.set(data, 8);
55
+ view.setUint32(8 + data.length, crc32(out, 4, 8 + data.length));
56
+ return out;
57
+ }
58
+
59
+ // zlib stream using stored (uncompressed) deflate blocks - no compression library needed.
60
+ function zlibStored(raw) {
61
+ const parts = [ZLIB_HEADER];
62
+ const blocks = Math.max(1, Math.ceil(raw.length / STORED_BLOCK_MAX));
63
+ for (let i = 0; i < blocks; i++) {
64
+ const start = i * STORED_BLOCK_MAX;
65
+ const length = Math.min(STORED_BLOCK_MAX, raw.length - start);
66
+ const header = new Uint8Array(5);
67
+ header[0] = i === blocks - 1 ? 0x01 : 0x00; // BFINAL | BTYPE=stored
68
+ header[1] = length & 0xff;
69
+ header[2] = (length >>> 8) & 0xff;
70
+ header[3] = ~length & 0xff;
71
+ header[4] = (~length >>> 8) & 0xff;
72
+ parts.push(header, raw.subarray(start, start + length));
73
+ }
74
+ const checksum = new Uint8Array(4);
75
+ new DataView(checksum.buffer).setUint32(0, adler32(raw));
76
+ parts.push(checksum);
77
+ return concat(parts);
78
+ }
79
+
80
+ // Encodes RGBA8 pixels (top-to-bottom, no premultiply) into a PNG image.
81
+ export function encodePngRgba(rgba, width, height) {
82
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
83
+ throw new TypeError('PNG dimensions must be positive integers');
84
+ }
85
+ if (rgba.length !== width * height * 4) {
86
+ throw new TypeError(`RGBA buffer must contain ${width * height * 4} bytes`);
87
+ }
88
+ const stride = width * 4;
89
+ const raw = new Uint8Array(height * (stride + 1));
90
+ for (let y = 0; y < height; y++) {
91
+ raw[y * (stride + 1)] = 0; // filter type: none
92
+ raw.set(rgba.subarray(y * stride, (y + 1) * stride), y * (stride + 1) + 1);
93
+ }
94
+ const ihdr = new Uint8Array(13);
95
+ const view = new DataView(ihdr.buffer);
96
+ view.setUint32(0, width);
97
+ view.setUint32(4, height);
98
+ ihdr[8] = 8; // bit depth
99
+ ihdr[9] = 6; // color type: RGBA
100
+ return concat([
101
+ PNG_SIGNATURE,
102
+ pngChunk('IHDR', ihdr),
103
+ pngChunk('IDAT', zlibStored(raw)),
104
+ pngChunk('IEND', new Uint8Array(0))
105
+ ]);
106
+ }
107
+
108
+ class HeadlessImageData {
109
+ constructor(dataOrWidth, widthOrHeight, height) {
110
+ if (typeof dataOrWidth === 'number') {
111
+ this.width = dataOrWidth;
112
+ this.height = widthOrHeight;
113
+ this.data = new Uint8ClampedArray(this.width * this.height * 4);
114
+ return;
115
+ }
116
+ this.data = dataOrWidth instanceof Uint8ClampedArray ? dataOrWidth : new Uint8ClampedArray(dataOrWidth);
117
+ this.width = widthOrHeight;
118
+ this.height = height;
119
+ }
120
+ }
121
+
122
+ class HeadlessOffscreenCanvas {
123
+ constructor(width = 1, height = 1) {
124
+ this.width = width;
125
+ this.height = height;
126
+ this.pixels = null;
127
+ }
128
+
129
+ getContext(type) {
130
+ if (type !== '2d') return null;
131
+ const canvas = this;
132
+ return {
133
+ canvas,
134
+ putImageData(image) {
135
+ canvas.pixels = { data: new Uint8ClampedArray(image.data), width: image.width, height: image.height };
136
+ },
137
+ drawImage(source) {
138
+ if (source?.pixels) canvas.pixels = {
139
+ data: new Uint8ClampedArray(source.pixels.data),
140
+ width: source.pixels.width,
141
+ height: source.pixels.height
142
+ };
143
+ },
144
+ scale() {},
145
+ translate() {},
146
+ clearRect() {},
147
+ fillRect() {}
148
+ };
149
+ }
150
+
151
+ convertToBlob({ type = 'image/png' } = {}) {
152
+ const image = this.pixels || {
153
+ data: new Uint8ClampedArray(this.width * this.height * 4),
154
+ width: this.width,
155
+ height: this.height
156
+ };
157
+ return Promise.resolve(new Blob([encodePngRgba(image.data, image.width, image.height)], { type }));
158
+ }
159
+ }
160
+
161
+ // Installs the canvas shim only when the host has no real canvas/image APIs,
162
+ // and returns a restore function (null when nothing was changed).
163
+ export function installHeadlessImageSupport(scope = globalThis) {
164
+ if (typeof scope.OffscreenCanvas !== 'undefined' && typeof scope.ImageData !== 'undefined') return null;
165
+ const previous = { OffscreenCanvas:scope.OffscreenCanvas, ImageData:scope.ImageData };
166
+ if (typeof scope.OffscreenCanvas === 'undefined') scope.OffscreenCanvas = HeadlessOffscreenCanvas;
167
+ if (typeof scope.ImageData === 'undefined') scope.ImageData = HeadlessImageData;
168
+ return () => {
169
+ if (previous.OffscreenCanvas === undefined) delete scope.OffscreenCanvas;
170
+ else scope.OffscreenCanvas = previous.OffscreenCanvas;
171
+ if (previous.ImageData === undefined) delete scope.ImageData;
172
+ else scope.ImageData = previous.ImageData;
173
+ };
174
+ }
@@ -0,0 +1,62 @@
1
+ function clone(value) {
2
+ return JSON.parse(JSON.stringify(value));
3
+ }
4
+
5
+ const modelRefs = new WeakMap();
6
+
7
+ function normalizeAssetRef(assetRef) {
8
+ const assetId = String(assetRef?.assetId ?? '').trim();
9
+ if (!assetId) throw new TypeError('World Authoring ModelRef requires a valid AssetRef');
10
+ return { assetId };
11
+ }
12
+
13
+ export function normalizeAuthoringModelRef(reference) {
14
+ const source = reference?.source || reference;
15
+
16
+ if (source?.type === 'url') {
17
+ const uri = String(source.uri || '').trim();
18
+ if (!uri) throw new TypeError('World Authoring ModelRef URL requires uri');
19
+ return { source:{ type:'url', uri } };
20
+ }
21
+
22
+ if (source?.type === 'asset') {
23
+ return {
24
+ source:{
25
+ type:'asset',
26
+ assetRef:normalizeAssetRef(source.assetRef)
27
+ }
28
+ };
29
+ }
30
+
31
+ if (reference?.assetRef) {
32
+ return {
33
+ source:{
34
+ type:'asset',
35
+ assetRef:normalizeAssetRef(reference.assetRef)
36
+ }
37
+ };
38
+ }
39
+
40
+ if (typeof reference?.uri === 'string' && reference.uri.trim()) {
41
+ return { source:{ type:'url', uri:reference.uri.trim() } };
42
+ }
43
+
44
+ throw new TypeError('World Authoring ModelRef requires a url or AssetRef source');
45
+ }
46
+
47
+ export function markAuthoringModelRef(object, reference) {
48
+ if (!object?.isObject3D) throw new TypeError('World Authoring ModelRef target must be an Object3D');
49
+ modelRefs.set(object, normalizeAuthoringModelRef(reference));
50
+ return object;
51
+ }
52
+
53
+ export function getAuthoringModelRef(object) {
54
+ const reference = object?.isObject3D
55
+ ? (modelRefs.get(object) || object.userData?.authoringModelRef)
56
+ : null;
57
+ return reference ? normalizeAuthoringModelRef(reference) : null;
58
+ }
59
+
60
+ export function cloneAuthoringModelRef(reference) {
61
+ return clone(normalizeAuthoringModelRef(reference));
62
+ }
@@ -0,0 +1,71 @@
1
+ # MCP 程序化创作 v0.2
2
+
3
+ v0.3 更新:这些接口继续保留,但远程执行现已要求 Docker OS 隔离;新增完整程序化资产文件持久化与可信世界恢复接口。下面的 Worker/WASM 描述是 v0.2 的执行基线,最新隔离及保存契约以 [PROGRAMMATIC-ASSETS.md](./PROGRAMMATIC-ASSETS.md) 为准。
4
+
5
+ AI 可以通过现有 `agentscape-world` 连接提交 Three.js,生成草稿、编译资产并晋升为当前私有世界中的实体。Studio 与 MCP 共用创作文档、资产编译器、晋升控制器和 WorldRuntime;无头创作不需要打开浏览器。
6
+
7
+ ## 接口
8
+
9
+ 所有接口要求 `worldSessionId`;写接口还要求 UUID `requestId`。相同请求重试复用原 ID,不同参数不能使用同一个 ID。
10
+
11
+ | 工具 | 其他参数 | 结果 |
12
+ |---|---|---|
13
+ | authoring_execute | code、label(可选)、requestId | 执行、提交草稿版本;失败保持上一个草稿 |
14
+ | authoring_observe | 无 | 节点 ID、资产/实体 ID、准入和验证状态 |
15
+ | authoring_prepare | nodeId、usage、requestId | 编译为本地资产;不放入世界 |
16
+ | authoring_promote | nodeId、usage、allowProvisional=false、requestId | 经放置和物理预检晋升 |
17
+ | authoring_update | 与 promote 相同 | 显式更新已晋升实体;失败回滚 |
18
+ | authoring_verify | nodeId | 检查物理及导航;未实际执行的交互保持未验证 |
19
+ | authoring_export | 无 | 原始成功代码、可编辑文档、晋升关联,原子保存到私有会话目录 |
20
+
21
+ `usage` 首版支持 `static`、`movable`。原来的九个工具继续可用,总计十六个。`action_execute.spawnAsset` 可以实例化本会话已注册的资产,不接受外部 URL 或其他会话资产。
22
+
23
+ ## 实际工作流
24
+
25
+ 先创建 `monument-hall` 会话,向 `authoring_execute.code` 提交:
26
+
27
+ ```js
28
+ const box = new THREE.Mesh(
29
+ new THREE.BoxGeometry(0.3, 0.3, 0.3),
30
+ new THREE.MeshStandardMaterial({ color: 0xff8844 })
31
+ );
32
+ box.name = 'AI Box';
33
+ box.userData.authoringId = 'ai-box';
34
+ box.position.set(0, 0.2, 5);
35
+ scene.add(box);
36
+ ```
37
+
38
+ 随后执行 `authoring_observe`、`authoring_prepare(nodeId="ai-box",usage="movable")`。默认编译得到粗碰撞代理,准入可能为 `provisional`;默认晋升会拒绝。只有显式选择 `allowProvisional=true` 才允许插入编辑态实体,不会伪称正式准入通过。
39
+
40
+ 读取晋升结果中的 `entityId`,通过 `action_execute` 执行 `approachAndPickup(actorId="agent_01",targetId=entityId)`,再执行 `approachAndPlace(actorId="agent_01",supportId="table_01",surfaceId="top")`。盒状、圆柱、胶囊碰撞体均走真实碰撞检测与搬运路径。
41
+
42
+ `world_verify` 新增可选 `criteria`,例如:
43
+
44
+ ```json
45
+ [
46
+ {"id":"exists","kind":"object-exists","targetId":"<entityId>"},
47
+ {"id":"picked","kind":"interaction-verified","targetId":"<entityId>","capability":"PICKUP"},
48
+ {"id":"on-table","kind":"relation-exists","subject":"<entityId>","predicate":"ON","object":"table_01","surfaceId":"top"}
49
+ ]
50
+ ```
51
+
52
+ criteria 省略时保留原开柜取杯和最终空手验收;显式空数组会被拒绝。自定义验收只证明请求中的检查,不自动要求空手,也不提升资产准入。草稿应用的 `accepted`、资产 `provisional` 和真实动作 `verified` 是不同证据。
53
+
54
+ ## 执行与支持范围
55
+
56
+ 远程代码在 Worker 中的 QuickJS WebAssembly JavaScript 引擎执行。没有把 Node 函数、模块加载器、环境变量、网络或文件接口注入引擎。Worker 提供额外的墙钟超时和终止能力,普通 Node 子进程或正则检查不是隔离保证。
57
+
58
+ - 使用本项目固定的 Three.js;代码可使用 `THREE`、`scene`、`clear`。
59
+ - 同步构建 Mesh、Group、Object3D;支持 Basic、Standard、Physical 材质及 RGBA Uint8 DataTexture。
60
+ - 支持原有草稿继续修改。成功代码经版本提交;失败、超时、内存超限不替换旧草稿。重试不会重复执行或重复记录源码。
61
+ - 明确拒绝外部资源、ModelRef、异步执行、定时器、onFrame、渲染回调、ShaderMaterial、相机、灯光、蒙皮、InstancedMesh 和动画;不宣称任意 Three.js 无损执行。
62
+ - 代码最多32768字符;默认执行时间1500ms、QuickJS分配预算96MiB、Worker墙钟上限12秒。预算不是整个服务的操作系统级硬内存隔离。
63
+ - 文档最多2Mi字符、128节点、16层;几何先物化为 BufferGeometry,再检查最多20000顶点/120000索引;拒绝原始几何参数,防止小文档引发无界分配。
64
+ - DataTexture 每边最多256像素,跨运行时只传递数据。Node 使用有像素预算的嵌入图片解码器加载编译纹理,不调用 DOM 或外部图片 URL。
65
+ - 每世界累计成功源码最多262144字符,注册资产预算32个,实体及动作仍受原会话预算控制。
66
+
67
+ ## 保存边界
68
+
69
+ `authoring_export` 是源码与创作文档导出,scope 为 `authoring-source-and-document-only`,包含成功代码、文档和晋升记录;不包含编译资产字节。原 `world_export` 仍只导出场景 JSON。
70
+
71
+ 本阶段尚未提供完整项目导入、重启后世界恢复、Studio 实时连接、截图、自定义行为或 Shader 扩展。内存世界重启即释放。完整资产打包与恢复是下一阶段,不能把上述两个导出接口描述为完整项目保存恢复。
@@ -0,0 +1,77 @@
1
+ import * as z from 'zod/v4';
2
+ import {registerTools} from './registerTools.js';
3
+
4
+ // Compatibility facade for 2025 MCP SDK clients such as DSH. This route
5
+ // does not own the world: all tools delegate to the existing audited handlers.
6
+ // Authorization, rate limiting and body caps are performed by main.mjs first.
7
+ function response(id,result,status=200) {
8
+ return {status,body:{jsonrpc:'2.0',id,result}};
9
+ }
10
+ function error(id,code,message,status=400) {
11
+ return {status,body:{jsonrpc:'2.0',id,error:{code,message}}};
12
+ }
13
+ function scopedSchema(name, input, projectScope) {
14
+ const schema=z.toJSONSchema(input,{target:'draft-7'});
15
+ if(projectScope && name==='studio_project'){
16
+ schema.properties.operation.enum=schema.properties.operation.enum.filter(op=>!['open','close','create_world'].includes(op));
17
+ delete schema.properties.create;
18
+ }
19
+ return schema;
20
+ }
21
+ export async function handleRestrictedAgentMcp({body,owner,manager,assets,studioBridge,signal,scope}={}) {
22
+ if(!body || body.jsonrpc!=='2.0' || typeof body.method!=='string')
23
+ return error(null,-32700,'Invalid JSON-RPC message');
24
+ const {id=null,method,params={}}=body;
25
+ // Explicitly refuse the 2026 discovery proposal so clients negotiate
26
+ // standard 2025-06-18 Streamable HTTP. No unaudited modern extensions.
27
+ if(method==='server/discover')
28
+ return error(id,-32601,'Method not found',404);
29
+ if(method==='initialize')
30
+ return response(id,{
31
+ protocolVersion:'2025-06-18',
32
+ capabilities:{tools:{listChanged:false}},
33
+ serverInfo:{name:'AgentScape Restricted MCP',version:'0.1.0'}
34
+ });
35
+ if(method==='notifications/initialized')return {status:202,body:null};
36
+ if(method==='ping')return response(id,{});
37
+ if(method!=='tools/list' && method!=='tools/call')
38
+ return error(id,-32601,'Method not found',404);
39
+ const match=scope == null ? null : /^([a-f0-9-]{36})\/(world_[a-f0-9]{32})$/.exec(scope);
40
+ if(scope != null && !match)return error(id,-32602,'Invalid project scope');
41
+ const projectScope=match && {worldSessionId:match[1],projectId:match[2]};
42
+ const definitions=new Map();
43
+ registerTools({registerTool(name,options,handler){
44
+ if(!projectScope || ['session_attach','studio_project','scene_observe','scene_verify'].includes(name))
45
+ definitions.set(name,{options,handler});
46
+ }},manager,owner,assets,studioBridge,{agentOnly:true,projectScope});
47
+ if(method==='tools/list'){
48
+ if(params?.cursor!=null)return error(id,-32602,'Unknown cursor');
49
+ return response(id,{tools:[...definitions].map(([name,{options}])=>({
50
+ name,description:projectScope && name==='studio_project'
51
+ ? 'Edit the prepared draft. Read first for the starter, API guide and revision. Use write with source, name and expectedRevision. Run the returned revision and save the running project. Use file operations only for additional source or resources.'
52
+ : options.description,
53
+ inputSchema:scopedSchema(name, options.inputSchema, projectScope)
54
+ }))});
55
+ }
56
+ const name=params?.name,entry=definitions.get(name);
57
+ if(!entry)return error(id,-32602,'Tool not available');
58
+ try{
59
+ const parsed=entry.options.inputSchema.safeParse(params.arguments || {});
60
+ if(!parsed.success){
61
+ const diagnostics=parsed.error.issues.flatMap(issue=>{
62
+ const fields=issue.code==='invalid_union' ? issue.errors?.[0] : null;
63
+ return fields?.length ? fields.map(field=>({path:[...issue.path,...field.path].join('.'),code:field.code}))
64
+ : [{path:issue.path.join('.'),code:issue.code}];
65
+ }).slice(0,12);
66
+ return response(id,{isError:true,content:[{type:'text',text:JSON.stringify({code:'INVALID_TOOL_INPUT',diagnostics})}]});
67
+ }
68
+ const args=parsed.data;
69
+ if(projectScope && name==='session_attach')args.worldSessionId=projectScope.worldSessionId;
70
+ const result=await entry.handler(args,{signal});
71
+ return response(id,result);
72
+ }catch(cause){
73
+ return response(id,{isError:true,content:[{
74
+ type:'text',text:JSON.stringify({code:'TOOL_EXECUTION_FAILED'})
75
+ }]});
76
+ }
77
+ }
@@ -0,0 +1 @@
1
+ export { execute, build, serializeAsset } from '../../application/code-execution/AuthoringSandboxEntry.js';