agentscape3d 1.0.0-beta.1 → 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 (386) hide show
  1. package/README.md +23 -48
  2. package/dist/core.d.ts +68 -0
  3. package/dist/core.js +209 -0
  4. package/dist/core.js.map +1 -0
  5. package/dist/index.d.ts +10 -229
  6. package/dist/index.js +192 -15462
  7. package/dist/index.js.map +1 -1
  8. package/package.json +11 -40
  9. package/cli.mjs +0 -27
  10. package/dist/AssetCompiler-CDFiElji.js +0 -2451
  11. package/dist/AssetCompiler-CDFiElji.js.map +0 -1
  12. package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
  13. package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
  14. package/dist/AssetRecipe-DmFpzxr-.js +0 -55
  15. package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
  16. package/dist/BrowserCodeWorker.js +0 -53615
  17. package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
  18. package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
  19. package/dist/SceneSerializer-DPVOyeRk.js +0 -353
  20. package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
  21. package/dist/StylePack-DNrdLeGI.js +0 -6314
  22. package/dist/StylePack-DNrdLeGI.js.map +0 -1
  23. package/dist/WorldArchive-pSBIGxLa.js +0 -420
  24. package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
  25. package/dist/WorldIO-wsDfZGM4.js +0 -150
  26. package/dist/WorldIO-wsDfZGM4.js.map +0 -1
  27. package/dist/blankWorld-CBWbwJGj.js +0 -76
  28. package/dist/blankWorld-CBWbwJGj.js.map +0 -1
  29. package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
  30. package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
  31. package/dist/environments-DgH66NqV.js +0 -4220
  32. package/dist/environments-DgH66NqV.js.map +0 -1
  33. package/dist/gltfIO-B87nJaat.js +0 -10
  34. package/dist/gltfIO-B87nJaat.js.map +0 -1
  35. package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
  36. package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
  37. package/dist/magicCabin-D64fD1E2.js +0 -11024
  38. package/dist/magicCabin-D64fD1E2.js.map +0 -1
  39. package/dist/mcp.d.ts +0 -2
  40. package/dist/mcp.js +0 -1
  41. package/dist/monumentHall-BKbs0UOQ.js +0 -404
  42. package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
  43. package/dist/node.d.ts +0 -16
  44. package/dist/node.js +0 -25
  45. package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
  46. package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
  47. package/dist/runtime/application/AgentTools.js +0 -25
  48. package/dist/runtime/application/README.md +0 -14
  49. package/dist/runtime/application/buildTaskObservation.js +0 -117
  50. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
  51. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
  52. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
  53. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
  54. package/dist/runtime/application/createSession.js +0 -66
  55. package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
  56. package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
  57. package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
  58. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
  59. package/dist/runtime/application/native-scene/CodeProject.js +0 -119
  60. package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
  61. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
  62. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
  63. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
  64. package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
  65. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
  66. package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
  67. package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
  68. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
  69. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
  70. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
  71. package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
  72. package/dist/runtime/application/scene/RequestWindow.js +0 -54
  73. package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
  74. package/dist/runtime/application/scene/SceneContracts.js +0 -45
  75. package/dist/runtime/application/scene/SceneEditService.js +0 -144
  76. package/dist/runtime/application/scene/SceneFacade.js +0 -267
  77. package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
  78. package/dist/runtime/application/scene/SceneJobController.js +0 -229
  79. package/dist/runtime/application/scene/ScenePackage.js +0 -162
  80. package/dist/runtime/application/scene/ScenePersistence.js +0 -50
  81. package/dist/runtime/application/scene/SceneProject.js +0 -95
  82. package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
  83. package/dist/runtime/application/scene/StarterScene.js +0 -56
  84. package/dist/runtime/application/scene/WorldArchive.js +0 -87
  85. package/dist/runtime/application/scene/WorldDirectory.js +0 -20
  86. package/dist/runtime/application/scene/WorldDocument.js +0 -74
  87. package/dist/runtime/application/scene/WorldIO.js +0 -103
  88. package/dist/runtime/application/scene/WorldStorage.js +0 -137
  89. package/dist/runtime/application/skills/SkillRegistry.js +0 -163
  90. package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
  91. package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
  92. package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
  93. package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
  94. package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
  95. package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
  96. package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
  97. package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
  98. package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
  99. package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
  100. package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
  101. package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
  102. package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
  103. package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
  104. package/dist/runtime/application/skills/skillPrimitives.js +0 -4
  105. package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
  106. package/dist/runtime/application/tasks.jsonl +0 -67
  107. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
  108. package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
  109. package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
  110. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
  111. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
  112. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
  113. package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
  114. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
  115. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
  116. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
  117. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
  118. package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
  119. package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
  120. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
  121. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
  122. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
  123. package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
  124. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
  125. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
  126. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
  127. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
  128. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
  129. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
  130. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
  131. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
  132. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
  133. package/dist/runtime/apps/mcp-server/README.md +0 -150
  134. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
  135. package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
  136. package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
  137. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
  138. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
  139. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
  140. package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
  141. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
  142. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
  143. package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
  144. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
  145. package/dist/runtime/apps/mcp-server/main.mjs +0 -56
  146. package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
  147. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
  148. package/dist/runtime/apps/mcp-server/security.js +0 -21
  149. package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
  150. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
  151. package/dist/runtime/apps/server/README.md +0 -7
  152. package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
  153. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
  154. package/dist/runtime/apps/server/tasks.jsonl +0 -10
  155. package/dist/runtime/foundation/EventBus.js +0 -18
  156. package/dist/runtime/foundation/JsonGateway.js +0 -47
  157. package/dist/runtime/foundation/PolicyEngine.js +0 -21
  158. package/dist/runtime/foundation/README.md +0 -7
  159. package/dist/runtime/foundation/TraceRecorder.js +0 -76
  160. package/dist/runtime/foundation/errors.js +0 -8
  161. package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
  162. package/dist/runtime/foundation/version.js +0 -2
  163. package/dist/runtime/modules/agent/README.md +0 -11
  164. package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
  165. package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
  166. package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
  167. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
  168. package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
  169. package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
  170. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
  171. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
  172. package/dist/runtime/modules/agent/prompt/index.js +0 -46
  173. package/dist/runtime/modules/agent/tasks.jsonl +0 -94
  174. package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
  175. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
  176. package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
  177. package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
  178. package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
  179. package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
  180. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
  181. package/dist/runtime/modules/artifact/README.md +0 -7
  182. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
  183. package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
  184. package/dist/runtime/modules/asset/AssetModule.js +0 -399
  185. package/dist/runtime/modules/asset/README.md +0 -54
  186. package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
  187. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
  188. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
  189. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
  190. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
  191. package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
  192. package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
  193. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
  194. package/dist/runtime/modules/asset/model/admission.js +0 -117
  195. package/dist/runtime/modules/asset/model/errors.js +0 -6
  196. package/dist/runtime/modules/asset/model/parts.js +0 -27
  197. package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
  198. package/dist/runtime/modules/asset/model/schema.js +0 -150
  199. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
  200. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
  201. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
  202. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
  203. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
  204. package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
  205. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
  206. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
  207. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
  208. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
  209. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
  210. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
  211. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
  212. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
  213. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
  214. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
  215. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
  216. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
  217. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
  218. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
  219. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
  220. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
  221. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
  222. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
  223. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
  224. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
  225. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
  226. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
  227. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
  228. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
  229. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
  230. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
  231. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
  232. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
  233. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
  234. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
  235. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
  236. package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
  237. package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
  238. package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
  239. package/dist/runtime/modules/asset/tasks.jsonl +0 -87
  240. package/dist/runtime/modules/generation/README.md +0 -9
  241. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
  242. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
  243. package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
  244. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
  245. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
  246. package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
  247. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
  248. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
  249. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
  250. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
  251. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
  252. package/dist/runtime/modules/generation/tasks.jsonl +0 -35
  253. package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
  254. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
  255. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
  256. package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
  257. package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
  258. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
  259. package/dist/runtime/modules/rendering/README.md +0 -7
  260. package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
  261. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
  262. package/dist/runtime/modules/rendering/createRenderer.js +0 -76
  263. package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
  264. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
  265. package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
  266. package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
  267. package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
  268. package/dist/runtime/modules/world/README.md +0 -13
  269. package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
  270. package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
  271. package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
  272. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
  273. package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
  274. package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
  275. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
  276. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
  277. package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
  278. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
  279. package/dist/runtime/modules/world/content/blankWorld.js +0 -35
  280. package/dist/runtime/modules/world/content/environments.js +0 -84
  281. package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
  282. package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
  283. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
  284. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
  285. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
  286. package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
  287. package/dist/runtime/modules/world/content/magicCabin.js +0 -190
  288. package/dist/runtime/modules/world/content/monumentHall.js +0 -154
  289. package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
  290. package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
  291. package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
  292. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
  293. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
  294. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
  295. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
  296. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
  297. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
  298. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
  301. package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
  302. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
  303. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
  304. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
  305. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
  306. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
  307. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
  308. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
  309. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
  310. package/dist/runtime/modules/world/errors.js +0 -9
  311. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
  312. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
  313. package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
  314. package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
  315. package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
  316. package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
  317. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
  318. package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
  319. package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
  320. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
  321. package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
  322. package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
  323. package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
  324. package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
  325. package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
  326. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
  327. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
  328. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
  329. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
  330. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
  331. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
  332. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
  333. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
  334. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
  335. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
  336. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
  337. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
  338. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
  339. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
  340. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
  341. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
  342. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
  343. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
  344. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
  345. package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
  346. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
  347. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
  348. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
  349. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
  350. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
  351. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
  352. package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
  353. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
  354. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
  355. package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
  356. package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
  357. package/dist/runtime/modules/world/tasks.jsonl +0 -530
  358. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
  359. package/dist/runtime/modules/world/verification/Finding.js +0 -105
  360. package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
  361. package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
  362. package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
  363. package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
  364. package/dist/runtime/package-lock.json +0 -6245
  365. package/dist/runtime/package.json +0 -91
  366. package/dist/runtime/public/assets/cabinet.glb +0 -0
  367. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  368. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  369. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  370. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  371. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  372. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  373. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  374. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  375. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  376. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  377. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  379. package/dist/schema-Dudvovhu.js +0 -364
  380. package/dist/schema-Dudvovhu.js.map +0 -1
  381. package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
  382. package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
  383. package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
  384. package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
  385. package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
  386. package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
@@ -1,31 +0,0 @@
1
- import { Errors } from '../errors.js';
2
-
3
- export class ObjectStore {
4
- constructor() { this.items = new Map(); }
5
- get size() { return this.items.size; }
6
- add(id, value) {
7
- if (this.items.has(id)) throw new Error(`Duplicate object id: ${id}`);
8
- this.items.set(id, value); return value;
9
- }
10
- get(id) { const value = this.items.get(id); if (!value) throw Errors.objectNotFound(id); return value; }
11
- has(id) { return this.items.has(id); }
12
- delete(id) { return this.items.delete(id); }
13
- values() { return this.items.values(); }
14
- entries() { return this.items.entries(); }
15
- list() { return [...this.items.entries()]; }
16
- /** Bounded allocation; offset traversal is O(offset + limit). Live insertion order. */
17
- page({ offset = 0, limit = 100 } = {}) {
18
- if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1 || limit > 1000) {
19
- throw new RangeError('Invalid object page');
20
- }
21
- const entries = [];
22
- let index = 0;
23
- for (const entry of this.items) {
24
- if (index++ < offset) continue;
25
- entries.push(entry);
26
- if (entries.length === limit) break;
27
- }
28
- return { entries, nextOffset: offset + entries.length < this.size ? offset + entries.length : null };
29
- }
30
- clear() { this.items.clear(); }
31
- }
@@ -1,62 +0,0 @@
1
- const SCALE_EPSILON = 1e-6;
2
- export const MIN_UNIFORM_SCALE = 0.05;
3
- export const MAX_UNIFORM_SCALE = 20;
4
-
5
- const scaled = (values, factor) => Array.isArray(values) ? values.map((value) => value * factor) : values;
6
-
7
- export function uniformScaleValue(value, fallback = 1) {
8
- const values = typeof value === 'number' ? [value, value, value] : value;
9
- if (!Array.isArray(values) || values.length !== 3 || !values.every(Number.isFinite)) {
10
- const error = new TypeError('Object scale must be a finite uniform number or vec3');
11
- error.code = 'OBJECT_SCALE_INVALID';
12
- throw error;
13
- }
14
- const [x, y, z] = values;
15
- if (Math.max(Math.abs(x - y), Math.abs(x - z), Math.abs(y - z)) > SCALE_EPSILON) {
16
- const error = new Error('AgentScape currently supports uniform object scaling only');
17
- error.code = 'OBJECT_SCALE_NON_UNIFORM_UNSUPPORTED';
18
- throw error;
19
- }
20
- const scale = (x + y + z) / 3;
21
- if (!Number.isFinite(scale) || scale < MIN_UNIFORM_SCALE || scale > MAX_UNIFORM_SCALE) {
22
- const error = new RangeError(`Object scale must be within ${MIN_UNIFORM_SCALE}..${MAX_UNIFORM_SCALE}`);
23
- error.code = 'OBJECT_SCALE_OUT_OF_RANGE';
24
- throw error;
25
- }
26
- return Number.isFinite(scale) ? scale : fallback;
27
- }
28
-
29
- function scaleCollider(collider, factor) {
30
- const result = structuredClone(collider);
31
- if (Array.isArray(result.translation)) result.translation = scaled(result.translation, factor);
32
- if (result.shape === 'box' && Array.isArray(result.halfExtents)) result.halfExtents = scaled(result.halfExtents, factor);
33
- if (['cylinder', 'capsule'].includes(result.shape)) {
34
- if (Number.isFinite(result.radius)) result.radius *= factor;
35
- if (Number.isFinite(result.halfHeight)) result.halfHeight *= factor;
36
- }
37
- if (result.shape === 'convexHull' && Array.isArray(result.vertices)) result.vertices = scaled(result.vertices, factor);
38
- return result;
39
- }
40
-
41
- export function physicsManifestForUniformScale(manifest, scaleValue) {
42
- const factor = uniformScaleValue(scaleValue);
43
- const result = structuredClone(manifest);
44
- if (Math.abs(factor - 1) <= SCALE_EPSILON) return result;
45
-
46
- const articulatedParts = Object.values(result.parts || {}).filter((part) => part?.joint || part?.physics?.colliders?.length);
47
- if (articulatedParts.length) {
48
- const error = new Error(`Uniform scale is not yet supported for articulated asset: ${result.id || 'unknown'}`);
49
- error.code = 'OBJECT_SCALE_ARTICULATED_UNSUPPORTED';
50
- throw error;
51
- }
52
-
53
- if (result.physics) {
54
- result.physics.colliders = (result.physics.colliders || []).map((collider) => scaleCollider(collider, factor));
55
- if (Number.isFinite(result.physics.mass)) result.physics.mass *= factor ** 3;
56
- }
57
- return result;
58
- }
59
-
60
- export function scalesEqual(a, b) {
61
- return Math.abs(Number(a) - Number(b)) <= SCALE_EPSILON;
62
- }
@@ -1,37 +0,0 @@
1
- const clean = (value) => typeof value === 'string' ? value.trim() : '';
2
-
3
- const confidence = (value) => Number.isFinite(value?.confidence) ? value.confidence : -Infinity;
4
-
5
- export function serializeObservedEntityEdge(edge) {
6
- if (!edge) return null;
7
- const meta = structuredClone(edge.meta || {});
8
- const observationId = clean(meta.id) || null;
9
- delete meta.id;
10
- return { id:edge.object, observationId, ...meta };
11
- }
12
-
13
- export function listObservedEntities(sceneGraph, { label = null } = {}) {
14
- sceneGraph?.update?.();
15
- const wanted = clean(label).toLocaleLowerCase();
16
- return (sceneGraph?.list?.({ predicate:'HAS_INSTANCE' }) || [])
17
- .map(serializeObservedEntityEdge)
18
- .filter(Boolean)
19
- .filter((entity) => !wanted || clean(entity.label).toLocaleLowerCase() === wanted)
20
- .sort((a, b) => confidence(b) - confidence(a) || String(a.id).localeCompare(String(b.id)));
21
- }
22
-
23
- export function resolveObservedEntity(sceneGraph, selector = {}) {
24
- const id = clean(selector.id);
25
- const label = clean(selector.label).toLocaleLowerCase();
26
- const candidates = listObservedEntities(sceneGraph)
27
- .filter((entity) => !id || entity.id === id || entity.observationId === id)
28
- .filter((entity) => !label || clean(entity.label).toLocaleLowerCase() === label);
29
- if (!candidates.length) return {
30
- status:'missing', selector:{ ...(id ? {id} : {}), ...(label ? {label} : {}) },
31
- candidateCount:0, selection:'highest-confidence-then-id', entity:null
32
- };
33
- return {
34
- status:'resolved', selector:{ ...(id ? {id} : {}), ...(label ? {label} : {}) },
35
- candidateCount:candidates.length, selection:'highest-confidence-then-id', entity:structuredClone(candidates[0])
36
- };
37
- }
@@ -1,207 +0,0 @@
1
- import * as z from 'zod/v4';
2
- import { ProjectStateMachine } from './behavior/ProjectStateMachine.js';
3
-
4
- const fail = code => Object.assign(new Error(code), { code });
5
- const identifier = z.string().min(1).max(256);
6
- // Callback state remains owned by the project. Only JSON values cross tools/save boundaries.
7
- export function projectJson(value) {
8
- const visit = (item, ancestors = new Set()) => {
9
- if (item === null || ['string', 'boolean'].includes(typeof item)) return;
10
- if (typeof item === 'number' && Number.isFinite(item)) return;
11
- if (!item || typeof item !== 'object' || ancestors.has(item)
12
- || (!Array.isArray(item) && ![Object.prototype, null].includes(Object.getPrototypeOf(item)))) throw fail('PROJECT_VALUE_NOT_JSON');
13
- const next = new Set(ancestors).add(item);
14
- for (const value of Object.values(item)) visit(value, next);
15
- };
16
- visit(value);
17
- return structuredClone(value);
18
- }
19
-
20
- /** Project-defined behavior, not a second ObjectStore or physics engine. */
21
- export class ProjectCapabilities {
22
- constructor(runtime) { this.runtime = runtime; this.entities = new Map(); this.stateMachines = new Map(); this.closed = false; }
23
- assertOpen() { if (this.closed) throw fail('PROJECT_CAPABILITIES_CLOSED'); }
24
- has(id) { return this.entities.has(id); }
25
- attachmentOf(id) { return this.entities.get(id)?.attachedTo || null; }
26
- hasAction(id, name) { const entry=this.entities.get(id);
27
- return Boolean(entry && (!entry.attachedTo || this.attachmentRecord(entry))
28
- && [...entry.actions.keys()].some(value => value.toUpperCase() === String(name).toUpperCase())); }
29
- attachmentRecord(entry) {
30
- const current=entry.attachedTo === 'runtime' && this.runtime.store.has(entry.id)
31
- ? this.runtime.store.get(entry.id) : null;
32
- return current && current === entry.attachedRecord ? current : null;
33
- }
34
- /** Remember only live attachments before a trusted scene restore replaces ObjectStore records. */
35
- captureAttachments() {
36
- return [...this.entities.values()].filter(entry => entry.attachedTo === 'runtime' && this.attachmentRecord(entry))
37
- .map(entry => ({ entry, record:entry.attachedRecord, assetId:entry.attachedRecord.assetId }));
38
- }
39
- /** Rebind a preserved entity, never an already stale attachment or a different asset sharing its id. */
40
- rebindAttachments(attachments) {
41
- for (const { entry, record, assetId } of attachments) {
42
- if (this.entities.get(entry.id) !== entry || entry.attachedRecord !== record) continue;
43
- const current = this.runtime.store.get(entry.id);
44
- if (!current || current.assetId !== assetId) continue;
45
- if (entry.object === record.object) entry.object = current.object;
46
- const machine = this.stateMachines.get(entry.id);
47
- if (machine?.object === record.object) machine.object = current.object;
48
- entry.attachedRecord = current;
49
- }
50
- }
51
- actionObject(entry) { return entry.object || this.attachmentRecord(entry)?.object || null; }
52
- registerEntity({ id, label = id, description = '', object = null, read = () => ({}), attachTo = null }) {
53
- this.assertOpen(); identifier.parse(id);
54
- if (attachTo != null && attachTo !== 'runtime') throw fail('PROJECT_ATTACHMENT_INVALID');
55
- if (this.has(id) || this.runtime.affordances.get(id)) throw fail('PROJECT_ENTITY_CONFLICT');
56
- if (attachTo === 'runtime' ? !this.runtime.store.has(id) : this.runtime.store.has(id)) {
57
- throw fail(attachTo ? 'PROJECT_ATTACHMENT_TARGET_NOT_FOUND' : 'PROJECT_ENTITY_CONFLICT');
58
- }
59
- if (typeof read !== 'function' || (object && !object.isObject3D)) throw fail('PROJECT_ENTITY_INVALID');
60
- const entry = { id, label: z.string().parse(label), description: z.string().parse(description),
61
- object, read, attachedTo: attachTo,
62
- ...(attachTo ? {attachedRecord:this.runtime.store.get(id)} : {}), actions: new Map() };
63
- this.read(entry); this.entities.set(id, entry);
64
- return () => { if (this.entities.get(id) === entry) this.entities.delete(id); };
65
- }
66
- registerAction({ target, name, description = '', parameters = { type: 'object', properties: {}, additionalProperties: false }, execute, verify, available, timeoutMs = 60_000 }) {
67
- this.assertOpen(); identifier.parse(name);
68
- const entry = this.entities.get(target);
69
- if (!entry) throw fail('PROJECT_ENTITY_NOT_FOUND');
70
- if (entry.actions.has(name)) throw fail('PROJECT_ACTION_CONFLICT');
71
- if (typeof execute !== 'function' || (verify != null && typeof verify !== 'function') || (available != null && typeof available !== 'function')) throw fail('PROJECT_ACTION_INVALID');
72
- if (timeoutMs !== null && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) throw fail('PROJECT_ACTION_TIMEOUT_INVALID');
73
- const schema = projectJson(parameters);
74
- if (schema.type !== 'object') throw fail('PROJECT_ACTION_SCHEMA_INVALID');
75
- const action = { name, description: z.string().parse(description), parameters: schema,
76
- validate: z.fromJSONSchema(schema), execute, verify, available, timeoutMs };
77
- entry.actions.set(name, action);
78
- return () => { if (entry.actions.get(name) === action) entry.actions.delete(name); };
79
- }
80
- /** One declarative entity, arbitrary guarded transitions, and an optional simulation clock. */
81
- registerStateMachine({ id, label = id, description = '', object = null, attachTo = null, initialState, transitions, timers, ranges, onChange, verifyVisual }) {
82
- this.assertOpen();
83
- const machine = new ProjectStateMachine({ object, initialState, transitions, timers, ranges, onChange, verifyVisual });
84
- const removeEntity = this.registerEntity({ id, label, description, object, attachTo, read:() => machine.read() });
85
- const removeActions = [];
86
- try {
87
- for (const transition of machine.listedActions()) {
88
- const name = transition.name;
89
- removeActions.push(this.registerAction({ target:id, name, description:transition.description,
90
- available:() => machine.available(name),
91
- execute:() => {
92
- const result = machine.execute(name);
93
- if (result.changed) this.runtime.events.emit('project.machine.changed', {id,kind:'action',name,state:result.state});
94
- return result;
95
- },
96
- verify:({after,value}) => ({
97
- verified:value?.changed === true && JSON.stringify(after) === JSON.stringify(value.state),
98
- kind:'state-machine-transition', transition:name
99
- })
100
- }));
101
- }
102
- } catch (err) { for (const undo of removeActions.reverse()) undo(); removeEntity(); throw err; }
103
- this.stateMachines.set(id, machine);
104
- const dispose = () => {
105
- if (this.stateMachines.get(id) !== machine) return;
106
- this.stateMachines.delete(id);
107
- for (const undo of removeActions.reverse()) undo();
108
- removeEntity();
109
- };
110
- return Object.freeze({
111
- read:() => machine.read(),
112
- advance:seconds => {
113
- this.assertOpen();
114
- if (this.stateMachines.get(id) !== machine) throw fail('PROJECT_MACHINE_NOT_FOUND');
115
- const result = machine.advance(seconds);
116
- if (result.changed) this.runtime.events.emit('project.machine.changed', {id,kind:'clock',state:result.state,completed:result.completed});
117
- return result;
118
- },
119
- dispose
120
- });
121
- }
122
-
123
- exportStateMachines() {
124
- this.assertOpen();
125
- if (!this.stateMachines.size) return null;
126
- return {schema:'agentscape.project-machine-state',schemaVersion:1,
127
- entities:Object.fromEntries([...this.stateMachines].map(([id,machine]) => [id,machine.read()]))};
128
- }
129
-
130
- /** Validate every target first; failed visual sync restores prior machine states. */
131
- restoreStateMachines(snapshot) {
132
- this.assertOpen();
133
- if (!snapshot || snapshot.schema !== 'agentscape.project-machine-state' || snapshot.schemaVersion !== 1
134
- || !snapshot.entities || typeof snapshot.entities !== 'object' || Array.isArray(snapshot.entities)
135
- || Object.keys(snapshot).some(key => !['schema','schemaVersion','entities'].includes(key))) throw fail('PROJECT_MACHINE_SNAPSHOT_INVALID');
136
- projectJson(snapshot);
137
- const desired = [];
138
- for (const [id,state] of Object.entries(snapshot.entities)) {
139
- const machine = this.stateMachines.get(id);
140
- if (!machine) throw fail('PROJECT_MACHINE_NOT_FOUND');
141
- desired.push([id,machine,machine.validate(state)]);
142
- }
143
- // Avoid silently losing machines whose callbacks were not installed during setup.
144
- if (desired.length !== this.stateMachines.size) throw fail('PROJECT_MACHINE_SNAPSHOT_INVALID');
145
- const before = desired.map(([,machine]) => machine.read());
146
- try { for (const [,machine,state] of desired) machine.restore(state); }
147
- catch (failure) {
148
- for (let i=desired.length-1;i>=0;i--) try { desired[i][1].restore(before[i]); } catch { /* preserve failure */ }
149
- throw failure;
150
- }
151
- }
152
-
153
- read(entry) {
154
- const state = projectJson(entry.read());
155
- if (!state || Array.isArray(state) || typeof state !== 'object') throw fail('PROJECT_STATE_INVALID');
156
- return state;
157
- }
158
- readState(id) { const entry = this.entities.get(id); return entry && (!entry.attachedTo || this.attachmentRecord(entry)) ? this.read(entry) : null; }
159
- timeoutFor(target, name) { return this.entities.get(target)?.actions.get(name)?.timeoutMs; }
160
- inspect(id, { actor } = {}) {
161
- this.assertOpen(); const entry = this.entities.get(id);
162
- if (!entry) throw fail('PROJECT_ENTITY_NOT_FOUND');
163
- const attached = !entry.attachedTo || Boolean(this.attachmentRecord(entry));
164
- const context = { actor, target: id, object: this.actionObject(entry) };
165
- return { schema: 'agentscape.project-entity', schemaVersion: 1, source: 'project', id,
166
- ...(entry.attachedTo ? { attachedTo:entry.attachedTo, attachmentStatus:attached?'ready':'stale' } : {}),
167
- label: entry.label, description: entry.description, state:attached?this.read(entry):{},
168
- actions: [...entry.actions.values()].map(action => ({ action: 'custom', name: action.name,
169
- description: action.description, parameters: projectJson(action.parameters), execution: 'project-action',
170
- available:attached && (action.available ? action.available(context) === true : true),
171
- ...(!attached ? { reason:'PROJECT_ATTACHMENT_TARGET_MISSING' } : {}),
172
- verification: action.verify ? 'project-defined' : 'unverified' })), physicsVerified: false };
173
- }
174
- list(options) { this.assertOpen(); return { total: this.entities.size, entities: [...this.entities.keys()].map(id => this.inspect(id, options)) }; }
175
- async execute({ target, name, args = {}, actor }, { signal } = {}) {
176
- this.assertOpen(); const entry = this.entities.get(target), action = entry?.actions.get(name);
177
- if (!action) throw fail('PROJECT_ACTION_NOT_FOUND');
178
- const parsed = action.validate.safeParse(args);
179
- if (!parsed.success) throw fail('PROJECT_ACTION_ARGUMENTS_INVALID');
180
- const attachment = entry.attachedTo ? this.attachmentRecord(entry) : null;
181
- if (entry.attachedTo && !attachment) throw fail('PROJECT_ATTACHMENT_TARGET_MISSING');
182
- const context = { actor, target, object: this.actionObject(entry), signal };
183
- const assertStable = () => {
184
- if (entry.attachedTo && this.attachmentRecord(entry) !== attachment) throw fail('PROJECT_ATTACHMENT_TARGET_CHANGED');
185
- };
186
- if (signal?.aborted) throw fail('PROJECT_ACTION_CANCELLED');
187
- if (action.available && action.available(context) !== true) throw fail('PROJECT_ACTION_UNAVAILABLE');
188
- const before = this.read(entry);
189
- const value = await action.execute(parsed.data, context);
190
- if (signal?.aborted) throw fail('PROJECT_ACTION_CANCELLED');
191
- if (this.entities.get(target) !== entry || entry.actions.get(name) !== action) throw fail('PROJECT_ACTION_CHANGED');
192
- assertStable();
193
- const after = this.read(entry), output = value === undefined ? null : projectJson(value);
194
- const evidence = action.verify ? await action.verify({ args: parsed.data, before, after, value: output }, context) : null;
195
- if (signal?.aborted) throw fail('PROJECT_ACTION_CANCELLED');
196
- if (this.entities.get(target) !== entry || entry.actions.get(name) !== action) throw fail('PROJECT_ACTION_CHANGED');
197
- assertStable();
198
- const verified = evidence === true || (evidence?.verified === true);
199
- const result = { status: 'project-action-completed', targetId: target, action: name,
200
- executed: true, verified, physicsVerified: false, evidenceKind: action.verify ? 'project-defined' : 'none',
201
- verificationRequested: Boolean(action.verify), before, after, value: output,
202
- evidence: evidence == null ? null : projectJson(evidence) };
203
- this.runtime.events.emit('project.action.completed', result);
204
- return result;
205
- }
206
- dispose() { this.closed = true; this.stateMachines.clear(); this.entities.clear(); }
207
- }
@@ -1,246 +0,0 @@
1
- import { uniformScaleValue } from './ObjectTransform.js';
2
- import { thermalStateSchema,validateThermalStateForProfile } from '../../../foundation/simulation/SimulationProfile.js';
3
- import { compileRuleGraph } from './behavior/RuleGraph.js';
4
- import { captureWorldAuthority, restoreWorldAuthority } from './WorldAuthority.js';
5
-
6
- export const SCENE_SCHEMA = 'agentscape.scene';
7
- export const SCENE_VERSION = 1;
8
-
9
- const clone = (value) => JSON.parse(JSON.stringify(value));
10
- const isFiniteVec = (value, length) => Array.isArray(value) && value.length === length && value.every(Number.isFinite);
11
-
12
- export class SceneSerializer {
13
- *objects(runtime) {
14
- for (const [id, record] of runtime.store.entries()) {
15
- const object = record.object;
16
- const articulation = runtime.physics?.captureArticulationPose?.(id) || [];
17
- yield { id, assetId: record.assetId,
18
- transform: { position: object.position.toArray(), quaternion: object.quaternion.toArray(), scale: object.scale.toArray() },
19
- state: clone(record.state || {}), ...(runtime.thermal?.capture?.(id) ? { simulation:runtime.thermal.capture(id) } : {}),
20
- ...(record.active === false ? { active: false } : {}),
21
- ...(articulation.length ? { articulation } : record.dormantArticulation?.length ? { articulation: clone(record.dormantArticulation) } : {}) };
22
- }
23
- }
24
-
25
- serialize(runtime, { name = 'Untitled World', includeRelations = true, includeObjects = true } = {}) {
26
- if (includeRelations) runtime.sceneGraph?.update?.();
27
- const objects = includeObjects ? Array.from(this.objects(runtime)) : [];
28
- const usedAssets = new Set(objects.map(object => object.assetId));
29
- const assets = [...usedAssets].map(assetId => runtime.assetModule.getManifest(assetId))
30
- .filter(manifest => ['glb', 'compiled'].includes(manifest.source?.kind)).map(clone);
31
-
32
- const worldRevision=runtime.currentWorldRevision ? clone(runtime.currentWorldRevision) : null;
33
- const acceptanceEvidence=runtime.lastAcceptanceBundle ? clone(runtime.lastAcceptanceBundle) : null;
34
- const cameraState=runtime.rendering?.cameraState?.() || null;
35
- const stylePack=runtime.rendering?.serializeStyle?.() || null;
36
- return {
37
- schema: SCENE_SCHEMA,
38
- schemaVersion: SCENE_VERSION,
39
- metadata: {
40
- name,
41
- savedAt: new Date().toISOString(),
42
- generator: `AgentScape/${runtime.version || 'unknown'}`,
43
- environment: runtime.environment?.id || null,
44
- ...(stylePack?{stylePack}:{}),
45
- ...(runtime.environment?.snapshot ? {environmentState:clone(runtime.environment.snapshot())} : {}),
46
- ...(worldRevision?{worldRevision}:{})
47
- },
48
- assets,
49
- objects,
50
- configuration: {
51
- behaviorBundle: runtime.currentBehaviorBundle ? clone(runtime.currentBehaviorBundle) : null,
52
- physicsRequirements: runtime.currentPhysicsRequirements ? clone(runtime.currentPhysicsRequirements) : null
53
- },
54
- ...(includeRelations ? { relations:runtime.sceneGraph?.list?.() || [] } : {}),
55
- ...(acceptanceEvidence?{verification:{acceptanceEvidence}}:{}),
56
- ...(cameraState?{camera:cameraState}:{})
57
- };
58
- }
59
-
60
- validate(scene) {
61
- if (!scene || typeof scene !== 'object') throw new Error('Scene must be an object');
62
- if (scene.schema !== SCENE_SCHEMA) throw new Error(`Unsupported scene schema: ${scene.schema || 'missing'}`);
63
- if (scene.schemaVersion !== SCENE_VERSION) throw new Error(`Unsupported scene version: ${scene.schemaVersion}`);
64
- if (!Array.isArray(scene.objects)) throw new Error('Scene objects must be an array');
65
- if (!Array.isArray(scene.assets)) throw new Error('Scene assets must be an array');
66
- if (scene.camera != null && (!isFiniteVec(scene.camera.position,3) || !isFiniteVec(scene.camera.target,3))) throw new Error('Scene camera requires finite position and target');
67
- if (scene.relations != null && !Array.isArray(scene.relations)) throw new Error('Scene relations must be an array');
68
- const worldRevision=scene.metadata?.worldRevision;
69
- if (worldRevision != null) {
70
- if (!worldRevision || typeof worldRevision !== 'object' || Array.isArray(worldRevision)) throw new Error('Scene worldRevision must be an object');
71
- if (!worldRevision.revision?.id) throw new Error('Scene worldRevision requires revision.id');
72
- if (!worldRevision.provenance?.source) throw new Error('Scene worldRevision requires provenance.source');
73
- }
74
- const configuration = scene.configuration;
75
- if (configuration != null) {
76
- if (typeof configuration !== 'object' || Array.isArray(configuration)) throw new Error('Invalid scene configuration');
77
- for (const key of ['behaviorBundle', 'physicsRequirements']) {
78
- const value = configuration[key];
79
- if (value != null && (typeof value !== 'object' || Array.isArray(value))) throw new Error(`Invalid scene ${key}`);
80
- if (value?.worldRevisionId && value.worldRevisionId !== worldRevision?.revision?.id) {
81
- throw new Error(`Scene ${key} revision mismatch`);
82
- }
83
- }
84
- const graph = configuration.behaviorBundle?.ruleGraph || [];
85
- if (!Array.isArray(graph) && (graph.schema !== 'agentscape.rule-graph' || graph.schemaVersion !== 1)) {
86
- throw new Error('Invalid scene rule graph');
87
- }
88
- compileRuleGraph(Array.isArray(graph) ? graph : graph.rules);
89
- }
90
- const acceptanceEvidence=scene.verification?.acceptanceEvidence;
91
- if (acceptanceEvidence != null) {
92
- if (acceptanceEvidence.schema !== 'agentscape.acceptance-evidence' || acceptanceEvidence.schemaVersion !== 1) throw new Error('Unsupported acceptance evidence');
93
- if (!Array.isArray(acceptanceEvidence.criteria) || !acceptanceEvidence.result || typeof acceptanceEvidence.result !== 'object') throw new Error('Invalid acceptance evidence payload');
94
- const revisionId=worldRevision?.revision?.id || null;
95
- if (revisionId && acceptanceEvidence.worldRevisionId && acceptanceEvidence.worldRevisionId !== revisionId) throw new Error(`Acceptance evidence revision mismatch: ${acceptanceEvidence.worldRevisionId} != ${revisionId}`);
96
- }
97
- // 先只收集并校验标识,后续 heldBy 引用需要完整的 id 集合。
98
- const objectIds = new Set();
99
- for (const object of scene.objects) {
100
- if (!object.id || !object.assetId) throw new Error('Scene object requires id and assetId');
101
- if (object.active != null && typeof object.active !== 'boolean') throw new Error('Invalid entity activation');
102
- if (object.simulation != null) {
103
- if(!thermalStateSchema.safeParse(object.simulation).success)
104
- throw new Error('Invalid entity thermal state');
105
- }
106
- if (object.articulation != null) {
107
- if (!Array.isArray(object.articulation) || object.articulation.length > 128) throw new Error('Invalid articulation poses');
108
- const names = new Set();
109
- for (const part of object.articulation) {
110
- if (!part || typeof part.partName !== 'string' || names.has(part.partName) || !isFiniteVec(part.position,3) || !isFiniteVec(part.quaternion,4)
111
- || Math.abs(Math.hypot(...part.quaternion)-1) > .001 || (part.motorTarget != null && !Number.isFinite(part.motorTarget))) throw new Error('Invalid articulation pose');
112
- names.add(part.partName);
113
- }
114
- }
115
- if (objectIds.has(object.id)) throw new Error(`Duplicate scene object id: ${object.id}`);
116
- objectIds.add(object.id);
117
- }
118
- const heldOwners = new Set();
119
- for (const object of scene.objects) {
120
- if (!isFiniteVec(object.transform?.position, 3)) throw new Error(`${object.id}: invalid position`);
121
- if (!isFiniteVec(object.transform?.quaternion, 4)) throw new Error(`${object.id}: invalid quaternion`);
122
- if (!isFiniteVec(object.transform?.scale, 3)) throw new Error(`${object.id}: invalid scale`);
123
- uniformScaleValue(object.transform.scale);
124
- const heldBy = object.state?.heldBy;
125
- if (heldBy) {
126
- if (!['human','agent'].includes(heldBy.kind)) throw new Error(`${object.id}: invalid heldBy.kind`);
127
- const ownerKey = heldBy.kind === 'human' ? 'human' : `agent:${heldBy.id}`;
128
- if (heldBy.kind === 'agent' && (!heldBy.id || !objectIds.has(heldBy.id))) throw new Error(`${object.id}: heldBy agent is missing`);
129
- if (heldOwners.has(ownerKey)) throw new Error(`${ownerKey}: multiple held objects are not supported`);
130
- heldOwners.add(ownerKey);
131
- }
132
- }
133
- return scene;
134
- }
135
-
136
- async restore(runtime, input) {
137
- const scene = this.validate(clone(input));
138
- runtime.rendering?.validateStyle?.(scene.metadata?.stylePack || null);
139
- const sceneEnvironment = scene.metadata?.environment;
140
- const runtimeEnvironment = runtime.environment?.id;
141
- if (sceneEnvironment && runtimeEnvironment && sceneEnvironment !== runtimeEnvironment) {
142
- throw new Error(`Scene environment mismatch: ${sceneEnvironment} != ${runtimeEnvironment}`);
143
- }
144
-
145
- // 先完成所有不会破坏当前世界的检查。
146
- for (const manifest of scene.assets) runtime.assetModule.assertCompatibleManifest(manifest);
147
- for (const item of scene.objects) {
148
- if (!runtime.assetModule.hasAsset(item.assetId)) throw new Error(`Scene references unknown asset: ${item.assetId}`);
149
- if(item.simulation){
150
- const profile=runtime.assetModule.getManifest(item.assetId).simulation;
151
- if(!profile)throw new Error(`Scene has thermal state without a thermal asset: ${item.id}`);
152
- validateThermalStateForProfile(profile,item.simulation);
153
- }
154
- }
155
- if(scene.metadata?.environmentState)runtime.environment?.validateSnapshot?.(scene.metadata.environmentState);
156
-
157
- // 预检已通过,从这里开始才会破坏当前世界。失败时恢复加载前的场景,而不是留下半个世界。
158
- const previous = typeof runtime.snapshot === 'function' ? runtime.snapshot() : null;
159
- const previousAuthority = captureWorldAuthority(runtime);
160
- const previousPhysics = runtime.physics?.captureState?.();
161
- const attachments = runtime.projectCapabilities?.captureAttachments?.() || [];
162
- if (!previous) {
163
- const applied = await this.applyScene(runtime, scene);
164
- runtime.projectCapabilities?.rebindAttachments?.(attachments);
165
- return applied;
166
- }
167
- try {
168
- const applied = await this.applyScene(runtime, scene);
169
- runtime.projectCapabilities?.rebindAttachments?.(attachments);
170
- return applied;
171
- } catch (error) {
172
- try {
173
- await this.applyScene(runtime, previous);
174
- if (previousPhysics) {
175
- runtime.physics.restoreState(previousPhysics);
176
- runtime.sceneGraph?.invalidate?.();
177
- }
178
- restoreWorldAuthority(runtime, previousAuthority);
179
- runtime.projectCapabilities?.rebindAttachments?.(attachments);
180
- } catch (rollbackError) {
181
- const failure = new AggregateError([error, rollbackError], 'Scene restore rollback failed', { cause:error });
182
- failure.code = 'SCENE_RESTORE_ROLLBACK_FAILED';
183
- failure.rollbackError = rollbackError;
184
- throw failure;
185
- }
186
- throw error;
187
- }
188
- }
189
-
190
- // 破坏性应用。调用方必须保证 scene 已经 validate 并通过全部预检。
191
- async applyScene(runtime, scene) {
192
- runtime.affordances?.cancel('SCENE_RESTORE');
193
-
194
- if (typeof runtime.physics?.resetWorld === 'function') {
195
- runtime.locomotion?.cancelAll?.();
196
- runtime.interactions?.cancelPending?.('SCENE_RESTORE');
197
- runtime.physics.resetWorld();
198
- if (runtime.environment?.colliders?.length) {
199
- runtime.physics.addEnvironment(runtime.environment.colliders,{id:runtime.environment.id});
200
- }
201
- const characterOptions = runtime.environment?.physics?.characterController
202
- || runtime.environment?.characterController
203
- || null;
204
- if (characterOptions && typeof runtime.physics.setCharacterControllerOptions === 'function') {
205
- runtime.physics.setCharacterControllerOptions(characterOptions);
206
- }
207
- }
208
-
209
- await runtime.sceneGraph.batch(async () => {
210
- await runtime.clearObjects({silent:true});
211
- for (const item of scene.objects) {
212
- await runtime.spawn(item.assetId, {
213
- id:item.id,
214
- position:item.transform.position,
215
- quaternion:item.transform.quaternion,
216
- scale:item.transform.scale,
217
- active: item.active !== false
218
- });
219
- const record = runtime.store.get(item.id);
220
- if(item.simulation)runtime.thermal.restore(item.id,item.simulation);
221
- record.state = clone(item.state || {});
222
- runtime.restoreObjectState(item.id, record.state);
223
- if (item.articulation?.length) {
224
- if (record.active === false) record.dormantArticulation = clone(item.articulation);
225
- else runtime.physics.restoreArticulationPose(item.id, item.articulation);
226
- }
227
- }
228
- runtime.interactions?.rebuildHeldOwnership?.();
229
- runtime.sceneGraph.changed();
230
- });
231
-
232
- if(scene.metadata?.environmentState) runtime.environment?.restore?.(scene.metadata.environmentState);
233
- runtime.navigation?.invalidate?.('scene-restored');
234
- if (scene.camera) runtime.rendering?.applyCameraState?.(scene.camera);
235
- await runtime.rendering?.restoreStyle?.(scene.metadata?.stylePack || null);
236
- runtime.currentWorldRevision=scene.metadata?.worldRevision ? clone(scene.metadata.worldRevision) : null;
237
- runtime.restoredAcceptanceEvidence=scene.verification?.acceptanceEvidence ? clone(scene.verification.acceptanceEvidence) : null;
238
- runtime.lastAcceptanceBundle=null;
239
- runtime.currentBehaviorBundle=scene.configuration?.behaviorBundle ? clone(scene.configuration.behaviorBundle) : null;
240
- runtime.currentPhysicsRequirements=scene.configuration?.physicsRequirements ? clone(scene.configuration.physicsRequirements) : null;
241
- runtime.interactionEvidence?.clear?.();
242
- runtime.loadRuleGraph?.(runtime.currentBehaviorBundle?.ruleGraph || []);
243
- runtime.events.emit('scene.restored', { objects: scene.objects.length, worldRevisionId:runtime.currentWorldRevision?.revision?.id || null, hasAcceptanceEvidence:Boolean(runtime.restoredAcceptanceEvidence) });
244
- return scene;
245
- }
246
- }
@@ -1,41 +0,0 @@
1
- const clone = (value) => value == null ? value : structuredClone(value);
2
-
3
- export function captureWorldAuthority(runtime) {
4
- return {
5
- currentWorldRevision:clone(runtime.currentWorldRevision) || null,
6
- currentBehaviorBundle:clone(runtime.currentBehaviorBundle) || null,
7
- currentPhysicsRequirements:clone(runtime.currentPhysicsRequirements) || null,
8
- lastAcceptanceBundle:clone(runtime.lastAcceptanceBundle) || null,
9
- restoredAcceptanceEvidence:clone(runtime.restoredAcceptanceEvidence) || null,
10
- interactionEvidence:runtime.interactionEvidence instanceof Map
11
- ? [...runtime.interactionEvidence.entries()].map(([key,value]) => [key,clone(value)])
12
- : null
13
- };
14
- }
15
-
16
- export function restoreWorldAuthority(runtime, authority = {}) {
17
- runtime.currentWorldRevision = clone(authority.currentWorldRevision) || null;
18
- runtime.currentBehaviorBundle = clone(authority.currentBehaviorBundle) || null;
19
- runtime.currentPhysicsRequirements = clone(authority.currentPhysicsRequirements) || null;
20
- runtime.lastAcceptanceBundle = clone(authority.lastAcceptanceBundle) || null;
21
- runtime.restoredAcceptanceEvidence = clone(authority.restoredAcceptanceEvidence) || null;
22
- if (authority.interactionEvidence === null) delete runtime.interactionEvidence;
23
- else runtime.interactionEvidence = new Map((authority.interactionEvidence || []).map(([key,value]) => [key,clone(value)]));
24
- runtime.loadRuleGraph?.(authority.currentBehaviorBundle?.ruleGraph || []);
25
- }
26
-
27
- export function commitWorldAuthority(runtime, {
28
- worldIR,
29
- behaviorBundle,
30
- physicsRequirements,
31
- acceptanceBundle = null
32
- } = {}) {
33
- runtime.currentWorldRevision = worldIR
34
- ? { revision:clone(worldIR.revision), provenance:clone(worldIR.provenance) }
35
- : null;
36
- runtime.currentBehaviorBundle = clone(behaviorBundle) || null;
37
- runtime.currentPhysicsRequirements = clone(physicsRequirements) || null;
38
- runtime.lastAcceptanceBundle = clone(acceptanceBundle) || null;
39
- runtime.restoredAcceptanceEvidence = null;
40
- runtime.loadRuleGraph?.(behaviorBundle?.ruleGraph || []);
41
- }
@@ -1,14 +0,0 @@
1
- /** Compare effective collision shapes rather than visual geometry or material metadata. */
2
- const signature = manifest => JSON.stringify({
3
- body:manifest.physics?.body,
4
- colliders:manifest.physics?.colliders,
5
- parts:Object.fromEntries(Object.entries(manifest.parts||{}).sort(([a],[b])=>a.localeCompare(b)).map(([id,part])=>[
6
- id,{
7
- body:part.physics?.body,
8
- colliders:part.physics?.colliders,
9
- joint:part.joint
10
- }
11
- ]))
12
- });
13
-
14
- export const samePhysicalGeometry = (left,right) => signature(left)===signature(right);