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.
- package/README.md +23 -48
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +10 -229
- package/dist/index.js +192 -15462
- package/dist/index.js.map +1 -1
- package/package.json +11 -40
- package/cli.mjs +0 -27
- package/dist/AssetCompiler-CDFiElji.js +0 -2451
- package/dist/AssetCompiler-CDFiElji.js.map +0 -1
- package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
- package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
- package/dist/AssetRecipe-DmFpzxr-.js +0 -55
- package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
- package/dist/BrowserCodeWorker.js +0 -53615
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
- package/dist/SceneSerializer-DPVOyeRk.js +0 -353
- package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
- package/dist/StylePack-DNrdLeGI.js +0 -6314
- package/dist/StylePack-DNrdLeGI.js.map +0 -1
- package/dist/WorldArchive-pSBIGxLa.js +0 -420
- package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
- package/dist/WorldIO-wsDfZGM4.js +0 -150
- package/dist/WorldIO-wsDfZGM4.js.map +0 -1
- package/dist/blankWorld-CBWbwJGj.js +0 -76
- package/dist/blankWorld-CBWbwJGj.js.map +0 -1
- package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
- package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
- package/dist/environments-DgH66NqV.js +0 -4220
- package/dist/environments-DgH66NqV.js.map +0 -1
- package/dist/gltfIO-B87nJaat.js +0 -10
- package/dist/gltfIO-B87nJaat.js.map +0 -1
- package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
- package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
- package/dist/magicCabin-D64fD1E2.js +0 -11024
- package/dist/magicCabin-D64fD1E2.js.map +0 -1
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -1
- package/dist/monumentHall-BKbs0UOQ.js +0 -404
- package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
- package/dist/node.d.ts +0 -16
- package/dist/node.js +0 -25
- package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
- package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
- package/dist/runtime/application/AgentTools.js +0 -25
- package/dist/runtime/application/README.md +0 -14
- package/dist/runtime/application/buildTaskObservation.js +0 -117
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
- package/dist/runtime/application/createSession.js +0 -66
- package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
- package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
- package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
- package/dist/runtime/application/native-scene/CodeProject.js +0 -119
- package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
- package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
- package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
- package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
- package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
- package/dist/runtime/application/scene/RequestWindow.js +0 -54
- package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
- package/dist/runtime/application/scene/SceneContracts.js +0 -45
- package/dist/runtime/application/scene/SceneEditService.js +0 -144
- package/dist/runtime/application/scene/SceneFacade.js +0 -267
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
- package/dist/runtime/application/scene/SceneJobController.js +0 -229
- package/dist/runtime/application/scene/ScenePackage.js +0 -162
- package/dist/runtime/application/scene/ScenePersistence.js +0 -50
- package/dist/runtime/application/scene/SceneProject.js +0 -95
- package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
- package/dist/runtime/application/scene/StarterScene.js +0 -56
- package/dist/runtime/application/scene/WorldArchive.js +0 -87
- package/dist/runtime/application/scene/WorldDirectory.js +0 -20
- package/dist/runtime/application/scene/WorldDocument.js +0 -74
- package/dist/runtime/application/scene/WorldIO.js +0 -103
- package/dist/runtime/application/scene/WorldStorage.js +0 -137
- package/dist/runtime/application/skills/SkillRegistry.js +0 -163
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
- package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
- package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
- package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
- package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
- package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
- package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
- package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
- package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
- package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
- package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
- package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
- package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
- package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
- package/dist/runtime/application/skills/skillPrimitives.js +0 -4
- package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
- package/dist/runtime/application/tasks.jsonl +0 -67
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
- package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
- package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
- package/dist/runtime/apps/mcp-server/README.md +0 -150
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
- package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
- package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
- package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
- package/dist/runtime/apps/mcp-server/main.mjs +0 -56
- package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
- package/dist/runtime/apps/mcp-server/security.js +0 -21
- package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
- package/dist/runtime/apps/server/README.md +0 -7
- package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
- package/dist/runtime/apps/server/tasks.jsonl +0 -10
- package/dist/runtime/foundation/EventBus.js +0 -18
- package/dist/runtime/foundation/JsonGateway.js +0 -47
- package/dist/runtime/foundation/PolicyEngine.js +0 -21
- package/dist/runtime/foundation/README.md +0 -7
- package/dist/runtime/foundation/TraceRecorder.js +0 -76
- package/dist/runtime/foundation/errors.js +0 -8
- package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
- package/dist/runtime/foundation/version.js +0 -2
- package/dist/runtime/modules/agent/README.md +0 -11
- package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
- package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
- package/dist/runtime/modules/agent/prompt/index.js +0 -46
- package/dist/runtime/modules/agent/tasks.jsonl +0 -94
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
- package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
- package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
- package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
- package/dist/runtime/modules/artifact/README.md +0 -7
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
- package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
- package/dist/runtime/modules/asset/AssetModule.js +0 -399
- package/dist/runtime/modules/asset/README.md +0 -54
- package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
- package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
- package/dist/runtime/modules/asset/model/admission.js +0 -117
- package/dist/runtime/modules/asset/model/errors.js +0 -6
- package/dist/runtime/modules/asset/model/parts.js +0 -27
- package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
- package/dist/runtime/modules/asset/model/schema.js +0 -150
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
- package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
- package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
- package/dist/runtime/modules/asset/tasks.jsonl +0 -87
- package/dist/runtime/modules/generation/README.md +0 -9
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
- package/dist/runtime/modules/generation/tasks.jsonl +0 -35
- package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
- package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
- package/dist/runtime/modules/rendering/README.md +0 -7
- package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
- package/dist/runtime/modules/rendering/createRenderer.js +0 -76
- package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
- package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
- package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
- package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
- package/dist/runtime/modules/world/README.md +0 -13
- package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
- package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
- package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
- package/dist/runtime/modules/world/content/blankWorld.js +0 -35
- package/dist/runtime/modules/world/content/environments.js +0 -84
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
- package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
- package/dist/runtime/modules/world/content/magicCabin.js +0 -190
- package/dist/runtime/modules/world/content/monumentHall.js +0 -154
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
- package/dist/runtime/modules/world/errors.js +0 -9
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
- package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
- package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
- package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
- package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
- package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
- package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
- package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
- package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
- package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
- package/dist/runtime/modules/world/tasks.jsonl +0 -530
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
- package/dist/runtime/modules/world/verification/Finding.js +0 -105
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
- package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
- package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
- package/dist/runtime/package-lock.json +0 -6245
- package/dist/runtime/package.json +0 -91
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-Dudvovhu.js +0 -364
- package/dist/schema-Dudvovhu.js.map +0 -1
- package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
- package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
- package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
- package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
- package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
- package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
3
|
-
boxesOverlap,
|
|
4
|
-
objectWorldPosition,
|
|
5
|
-
spatialEntryAtRootPosition,
|
|
6
|
-
spatialSnapshotEntry
|
|
7
|
-
} from '../spatial/SpatialSnapshot.js';
|
|
8
|
-
|
|
9
|
-
const roundVec = (vector) => vector.toArray().map((value) => Number(value.toFixed(3)));
|
|
10
|
-
|
|
11
|
-
export class SpatialSystem {
|
|
12
|
-
constructor({ store }) {
|
|
13
|
-
this.store = store;
|
|
14
|
-
this.raycaster = new THREE.Raycaster();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
snapshot() {
|
|
18
|
-
const snapshot = new Map();
|
|
19
|
-
for (const [id, record] of this.store.entries()) if (record.active !== false) snapshot.set(id, spatialSnapshotEntry(id, record.object));
|
|
20
|
-
return snapshot;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getBounds(id, snapshot = null) {
|
|
24
|
-
return snapshot?.get(id)?.bounds || spatialSnapshotEntry(id, this.store.get(id).object).bounds;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
debugSnapshot({ snapshot = this.snapshot(), overlapMargin = 0.01 } = {}) {
|
|
28
|
-
const bounds = [...snapshot.values()].map((entry) => structuredClone(entry.bounds));
|
|
29
|
-
const overlapPairs = this.overlapPairs({ margin: overlapMargin, snapshot });
|
|
30
|
-
return {
|
|
31
|
-
schemaVersion: 2,
|
|
32
|
-
source: 'spatial',
|
|
33
|
-
bounds,
|
|
34
|
-
overlapPairs,
|
|
35
|
-
metrics: {
|
|
36
|
-
objectCount: bounds.length,
|
|
37
|
-
overlapPairCount: overlapPairs.length,
|
|
38
|
-
overlapMargin
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
findNearby(id, radius = 2, snapshot = null) {
|
|
44
|
-
const localSnapshot = snapshot || this.snapshot();
|
|
45
|
-
const source = localSnapshot.get(id);
|
|
46
|
-
if (!source) return [];
|
|
47
|
-
const results = [];
|
|
48
|
-
for (const [otherId, record] of this.store.entries()) {
|
|
49
|
-
if (otherId === id) continue;
|
|
50
|
-
const other = localSnapshot.get(otherId);
|
|
51
|
-
if (!other) continue;
|
|
52
|
-
const distance = source.center.distanceTo(other.center);
|
|
53
|
-
if (distance <= radius) results.push({ id: otherId, asset: record.assetId, distance: Number(distance.toFixed(3)) });
|
|
54
|
-
}
|
|
55
|
-
return results.sort((left, right) => left.distance - right.distance);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
raycast(origin, direction, maxDistance = 100) {
|
|
59
|
-
const rayOrigin = new THREE.Vector3(...origin);
|
|
60
|
-
const rayDirection = new THREE.Vector3(...direction).normalize();
|
|
61
|
-
this.raycaster.set(rayOrigin, rayDirection);
|
|
62
|
-
this.raycaster.far = maxDistance;
|
|
63
|
-
const roots = this.store.list().map(([, record]) => record.object);
|
|
64
|
-
const hits = this.raycaster.intersectObjects(roots, true);
|
|
65
|
-
const results = [];
|
|
66
|
-
const seen = new Set();
|
|
67
|
-
for (const hit of hits) {
|
|
68
|
-
let current = hit.object;
|
|
69
|
-
while (current && !current.userData.instanceId) current = current.parent;
|
|
70
|
-
const id = current?.userData.instanceId ?? null;
|
|
71
|
-
if (!id || seen.has(id)) continue;
|
|
72
|
-
seen.add(id);
|
|
73
|
-
results.push({ id, distance: Number(hit.distance.toFixed(3)), point: roundVec(hit.point) });
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
overlappingIds(id, { ignore = [], margin = 0.01, snapshot = null } = {}) {
|
|
79
|
-
const localSnapshot = snapshot || this.snapshot();
|
|
80
|
-
const source = localSnapshot.get(id);
|
|
81
|
-
if (!source) return [];
|
|
82
|
-
const ignored = new Set([id, ...ignore]);
|
|
83
|
-
const overlaps = [];
|
|
84
|
-
for (const [otherId] of this.store.entries()) {
|
|
85
|
-
if (ignored.has(otherId)) continue;
|
|
86
|
-
const other = localSnapshot.get(otherId);
|
|
87
|
-
if (other && boxesOverlap(source.box, other.box, margin)) overlaps.push(otherId);
|
|
88
|
-
}
|
|
89
|
-
return overlaps;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
overlapPairs({ margin = 0.01, snapshot = this.snapshot() } = {}) {
|
|
93
|
-
const ids = [...snapshot.keys()];
|
|
94
|
-
const pairs = [];
|
|
95
|
-
for (let left = 0; left < ids.length; left++) {
|
|
96
|
-
for (let right = left + 1; right < ids.length; right++) {
|
|
97
|
-
if (boxesOverlap(snapshot.get(ids[left]).box, snapshot.get(ids[right]).box, margin)) pairs.push([ids[left], ids[right]]);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return pairs;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
getSupportSurface(targetId, surfaceId, snapshot = null) {
|
|
104
|
-
const record = this.store.get(targetId);
|
|
105
|
-
if (!snapshot?.has(targetId)) record.object.updateWorldMatrix(true, true);
|
|
106
|
-
const surface = surfaceId
|
|
107
|
-
? record.manifest.surfaces?.find((item) => item.id === surfaceId)
|
|
108
|
-
: record.manifest.surfaces?.[0];
|
|
109
|
-
if (!surface) return null;
|
|
110
|
-
|
|
111
|
-
const local = new THREE.Vector3(...surface.localPosition);
|
|
112
|
-
const center = local.clone().applyMatrix4(record.object.matrixWorld);
|
|
113
|
-
const size = surface.size || [1, 1];
|
|
114
|
-
const scaleX = Math.abs(record.object.scale.x || 1);
|
|
115
|
-
const scaleZ = Math.abs(record.object.scale.z || 1);
|
|
116
|
-
return { targetId, id: surface.id, center, size: [size[0] * scaleX, size[1] * scaleZ] };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
getReceptacle(targetId, receptacleId = null, snapshot = null) {
|
|
120
|
-
const record = this.store.get(targetId);
|
|
121
|
-
if (!snapshot?.has(targetId)) record.object.updateWorldMatrix(true, true);
|
|
122
|
-
const definition = receptacleId
|
|
123
|
-
? record.manifest.receptacles?.find((item) => item.id === receptacleId)
|
|
124
|
-
: record.manifest.receptacles?.[0];
|
|
125
|
-
if (!definition) return null;
|
|
126
|
-
const half = new THREE.Vector3(...definition.size).multiplyScalar(0.5);
|
|
127
|
-
const center = new THREE.Vector3(...definition.localPosition);
|
|
128
|
-
const box = new THREE.Box3(center.clone().sub(half), center.clone().add(half)).applyMatrix4(record.object.matrixWorld);
|
|
129
|
-
return {
|
|
130
|
-
targetId,
|
|
131
|
-
id: definition.id,
|
|
132
|
-
box,
|
|
133
|
-
center: box.getCenter(new THREE.Vector3()),
|
|
134
|
-
size: box.getSize(new THREE.Vector3())
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
containmentGeometry(subjectId, targetId, { receptacleId = null, tolerance = 0.02, snapshot = null } = {}) {
|
|
139
|
-
const localSnapshot = snapshot || this.snapshot();
|
|
140
|
-
const subject = localSnapshot.get(subjectId);
|
|
141
|
-
const target = localSnapshot.get(targetId);
|
|
142
|
-
if (!subject) return { inside: false, reason: 'SUBJECT_MISSING', evidence: 'spatial-geometry' };
|
|
143
|
-
if (!target) return { inside: false, reason: 'TARGET_MISSING', evidence: 'spatial-geometry' };
|
|
144
|
-
const record = this.store.get(targetId);
|
|
145
|
-
const receptacles = record.manifest.receptacles || [];
|
|
146
|
-
if (receptacles.length) {
|
|
147
|
-
const candidates = receptacleId ? receptacles.filter((item) => item.id === receptacleId) : receptacles;
|
|
148
|
-
if (!candidates.length) return { inside: false, reason: 'RECEPTACLE_MISSING', receptacleId, evidence: 'spatial-geometry' };
|
|
149
|
-
for (const definition of candidates) {
|
|
150
|
-
const receptacle = this.getReceptacle(targetId, definition.id, localSnapshot);
|
|
151
|
-
const box = receptacle.box.clone().expandByScalar(tolerance);
|
|
152
|
-
if (box.containsBox(subject.box)) return {
|
|
153
|
-
inside: true,
|
|
154
|
-
subjectId,
|
|
155
|
-
targetId,
|
|
156
|
-
receptacleId: definition.id,
|
|
157
|
-
mode: 'receptacle',
|
|
158
|
-
tolerance,
|
|
159
|
-
evidence: 'spatial-geometry'
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return { inside: false, reason: 'OUTSIDE_RECEPTACLE', subjectId, targetId, receptacleId, tolerance, evidence: 'spatial-geometry' };
|
|
163
|
-
}
|
|
164
|
-
const box = target.box.clone().expandByScalar(tolerance);
|
|
165
|
-
const inside = box.containsBox(subject.box);
|
|
166
|
-
return {
|
|
167
|
-
inside,
|
|
168
|
-
subjectId,
|
|
169
|
-
targetId,
|
|
170
|
-
receptacleId: null,
|
|
171
|
-
mode: 'bounds',
|
|
172
|
-
tolerance,
|
|
173
|
-
evidence: 'spatial-geometry',
|
|
174
|
-
...(inside ? {} : { reason: 'OUTSIDE_TARGET_BOUNDS' })
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
findFreeSpaceInside(objectId, targetId, { receptacleId = null, clearance = 0.03, grid = 3, ignore = [], poseClear = null } = {}) {
|
|
179
|
-
const objectRecord = this.store.get(objectId);
|
|
180
|
-
const snapshot = this.snapshot();
|
|
181
|
-
const receptacle = this.getReceptacle(targetId, receptacleId, snapshot);
|
|
182
|
-
if (!receptacle) return null;
|
|
183
|
-
const entry = snapshot.get(objectId);
|
|
184
|
-
const currentRoot = objectWorldPosition(objectRecord.object);
|
|
185
|
-
const { box: bounds, size } = entry;
|
|
186
|
-
if (size.x + clearance * 2 > receptacle.size.x || size.y + clearance * 2 > receptacle.size.y || size.z + clearance * 2 > receptacle.size.z) return null;
|
|
187
|
-
const rootToCenterX = currentRoot.x - entry.center.x;
|
|
188
|
-
const rootToCenterZ = currentRoot.z - entry.center.z;
|
|
189
|
-
const rootToBottomY = currentRoot.y - bounds.min.y;
|
|
190
|
-
const halfX = size.x / 2 + clearance;
|
|
191
|
-
const halfZ = size.z / 2 + clearance;
|
|
192
|
-
const usableX = Math.max(0, receptacle.size.x / 2 - halfX);
|
|
193
|
-
const usableZ = Math.max(0, receptacle.size.z / 2 - halfZ);
|
|
194
|
-
const candidates = [];
|
|
195
|
-
for (let x = 0; x < grid; x++) {
|
|
196
|
-
for (let z = 0; z < grid; z++) {
|
|
197
|
-
const nx = grid === 1 ? 0 : (x / (grid - 1)) * 2 - 1;
|
|
198
|
-
const nz = grid === 1 ? 0 : (z / (grid - 1)) * 2 - 1;
|
|
199
|
-
candidates.push(new THREE.Vector3(
|
|
200
|
-
receptacle.center.x + nx * usableX + rootToCenterX,
|
|
201
|
-
receptacle.box.min.y + clearance + rootToBottomY,
|
|
202
|
-
receptacle.center.z + nz * usableZ + rootToCenterZ
|
|
203
|
-
));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
candidates.sort((left, right) => left.distanceToSquared(receptacle.center) - right.distanceToSquared(receptacle.center));
|
|
207
|
-
for (const candidate of candidates) {
|
|
208
|
-
const candidateSnapshot = new Map(snapshot);
|
|
209
|
-
candidateSnapshot.set(objectId, spatialEntryAtRootPosition(entry, currentRoot, candidate));
|
|
210
|
-
const containment = this.containmentGeometry(objectId, targetId, { receptacleId: receptacle.id, tolerance: 0, snapshot: candidateSnapshot });
|
|
211
|
-
const overlaps = this.overlappingIds(objectId, { ignore: [targetId, ...ignore], margin: clearance / 2, snapshot: candidateSnapshot });
|
|
212
|
-
const physics = poseClear ? poseClear(candidate.toArray()) : { checked: true, clear: true };
|
|
213
|
-
if (containment.inside && !overlaps.length && physics?.checked && physics.clear) return candidate;
|
|
214
|
-
}
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
supportGeometry(subjectId, targetId, { surfaceId = null, tolerance = 0.12, snapshot = null } = {}) {
|
|
219
|
-
const localSnapshot = snapshot || this.snapshot();
|
|
220
|
-
const subject = localSnapshot.get(subjectId);
|
|
221
|
-
if (!subject) return { supported: false, reason: 'SUBJECT_MISSING', evidence: 'spatial-geometry' };
|
|
222
|
-
const surface = this.getSupportSurface(targetId, surfaceId, localSnapshot);
|
|
223
|
-
if (!surface) return { supported: false, reason: 'SURFACE_MISSING', evidence: 'spatial-geometry' };
|
|
224
|
-
const withinX = subject.box.min.x >= surface.center.x - surface.size[0] / 2 - 0.05 && subject.box.max.x <= surface.center.x + surface.size[0] / 2 + 0.05;
|
|
225
|
-
const withinZ = subject.box.min.z >= surface.center.z - surface.size[1] / 2 - 0.05 && subject.box.max.z <= surface.center.z + surface.size[1] / 2 + 0.05;
|
|
226
|
-
const verticalGap = subject.box.min.y - surface.center.y;
|
|
227
|
-
const gap = Math.abs(verticalGap);
|
|
228
|
-
const aboveSurface = verticalGap >= -0.03;
|
|
229
|
-
return {
|
|
230
|
-
supported: withinX && withinZ && aboveSurface && gap <= tolerance,
|
|
231
|
-
subjectId,
|
|
232
|
-
targetId,
|
|
233
|
-
surfaceId: surface.id,
|
|
234
|
-
withinX,
|
|
235
|
-
withinZ,
|
|
236
|
-
aboveSurface,
|
|
237
|
-
verticalGap: Number(verticalGap.toFixed(4)),
|
|
238
|
-
gap: Number(gap.toFixed(4)),
|
|
239
|
-
tolerance,
|
|
240
|
-
evidence: 'spatial-geometry'
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
findFreeSpace(objectId, targetId, { surfaceId, clearance = 0.03, grid = 5, ignore = [] } = {}) {
|
|
245
|
-
const objectRecord = this.store.get(objectId);
|
|
246
|
-
const snapshot = this.snapshot();
|
|
247
|
-
const surface = this.getSupportSurface(targetId, surfaceId, snapshot);
|
|
248
|
-
if (!surface) return null;
|
|
249
|
-
|
|
250
|
-
const entry = snapshot.get(objectId);
|
|
251
|
-
const currentRoot = objectWorldPosition(objectRecord.object);
|
|
252
|
-
const { box: bounds, size } = entry;
|
|
253
|
-
const halfX = size.x / 2 + clearance;
|
|
254
|
-
const halfZ = size.z / 2 + clearance;
|
|
255
|
-
if (surface.size[0] < halfX * 2 || surface.size[1] < halfZ * 2) return null;
|
|
256
|
-
const usableX = Math.max(0, surface.size[0] / 2 - halfX);
|
|
257
|
-
const usableZ = Math.max(0, surface.size[1] / 2 - halfZ);
|
|
258
|
-
const rootToCenterX = currentRoot.x - entry.center.x;
|
|
259
|
-
const rootToCenterZ = currentRoot.z - entry.center.z;
|
|
260
|
-
const rootToBottomY = currentRoot.y - bounds.min.y;
|
|
261
|
-
const candidates = [];
|
|
262
|
-
|
|
263
|
-
for (let x = 0; x < grid; x++) {
|
|
264
|
-
for (let z = 0; z < grid; z++) {
|
|
265
|
-
const nx = grid === 1 ? 0 : (x / (grid - 1)) * 2 - 1;
|
|
266
|
-
const nz = grid === 1 ? 0 : (z / (grid - 1)) * 2 - 1;
|
|
267
|
-
candidates.push(new THREE.Vector3(
|
|
268
|
-
surface.center.x + nx * usableX + rootToCenterX,
|
|
269
|
-
surface.center.y + clearance + rootToBottomY,
|
|
270
|
-
surface.center.z + nz * usableZ + rootToCenterZ
|
|
271
|
-
));
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
candidates.sort((left, right) => left.distanceToSquared(surface.center) - right.distanceToSquared(surface.center));
|
|
276
|
-
for (const candidate of candidates) {
|
|
277
|
-
const candidateSnapshot = new Map(snapshot);
|
|
278
|
-
candidateSnapshot.set(objectId, spatialEntryAtRootPosition(entry, currentRoot, candidate));
|
|
279
|
-
const overlaps = this.overlappingIds(objectId, { ignore: [targetId, ...ignore], margin: clearance / 2, snapshot: candidateSnapshot });
|
|
280
|
-
if (!overlaps.length) return candidate;
|
|
281
|
-
}
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { normalizeWorldSpec } from './WorldSpec.js';
|
|
2
|
-
|
|
3
|
-
export const WORLD_IR_SCHEMA = 'agentscape.world-ir';
|
|
4
|
-
export const WORLD_IR_VERSION = 1;
|
|
5
|
-
|
|
6
|
-
const TOP_LEVEL_KEYS=new Set(['schema','schemaVersion','revision','provenance','intent','policy','entities','spatial','interactions','rules','acceptance']);
|
|
7
|
-
const REVISION_KEYS=new Set(['id','parentId','reason']);
|
|
8
|
-
const PROVENANCE_KEYS=new Set(['source','sourceId','createdBy','evidenceRefs']);
|
|
9
|
-
const INTENT_KEYS=new Set(['name','description','task']);
|
|
10
|
-
const POLICY_KEYS=new Set(['generation','physics']);
|
|
11
|
-
const GENERATION_KEYS=new Set(['provider','generate']);
|
|
12
|
-
const PHYSICS_POLICY_KEYS=new Set(['fallbackPolicy']);
|
|
13
|
-
const ENTITY_KEYS=new Set(['id','asset','transform','physicsRequirement','capabilityIntent','initialState']);
|
|
14
|
-
const ASSET_KEYS=new Set(['assetId','query','prompt','type','generate','provider']);
|
|
15
|
-
const TRANSFORM_KEYS=new Set(['position']);
|
|
16
|
-
const PHYSICS_REQUIREMENT_KEYS=new Set(['bodyClass','requiredCapabilities','executionMode','qualityPolicy']);
|
|
17
|
-
const PHYSICS_QUALITY_KEYS=new Set(['deterministicRequired','realtimeRequired','fallbackPolicy']);
|
|
18
|
-
const SPATIAL_KEYS=new Set(['relations','constraints']);
|
|
19
|
-
const RELATION_KEYS=new Set(['subject','predicate','object','anchor','surfaceId','receptacleId','distance']);
|
|
20
|
-
const RELATION_ANCHOR_KEYS=new Set(['kind','id','label']);
|
|
21
|
-
const CONSTRAINT_KEYS=new Set(['id','kind','subject','object','description']);
|
|
22
|
-
const INTERACTION_KEYS=new Set(['id','actorId','targetId','supportId','capability','stateKey','value','description']);
|
|
23
|
-
const RULE_KEYS=new Set(['id','event','condition','effect','description']);
|
|
24
|
-
const ACCEPTANCE_KEYS=new Set(['id','kind','targetId','capability','stateKey','value','subject','predicate','object','surfaceId','description','source']);
|
|
25
|
-
|
|
26
|
-
const clean=(value)=>typeof value==='string'?value.trim():'';
|
|
27
|
-
const STATE_SCALAR=(value)=>value===null||['string','number','boolean'].includes(typeof value);
|
|
28
|
-
const RESERVED_INITIAL_STATE_KEYS=new Set(['heldBy','navigation','parts','partTargets','lastVerifiedAction','door']);
|
|
29
|
-
const plainObject=(value)=>Boolean(value&&typeof value==='object'&&!Array.isArray(value)&&Object.getPrototypeOf(value)===Object.prototype);
|
|
30
|
-
const assertObject=(value,label)=>{if(!plainObject(value)) throw new TypeError(`${label} must be an object`); return value;};
|
|
31
|
-
const assertKnownKeys=(value,allowed,label)=>{for(const key of Object.keys(value||{})) if(!allowed.has(key)) throw new TypeError(`${label} unknown field: ${key}`);};
|
|
32
|
-
const finiteVec3=(value)=>Array.isArray(value)&&value.length===3&&value.every(Number.isFinite)?value.map(Number):null;
|
|
33
|
-
const uniqueStrings=(value,label,{upper=false}={})=>{if(value==null) return []; if(!Array.isArray(value)) throw new TypeError(`${label} must be an array`); const result=[]; for(const item of value){const text=clean(item); if(!text) throw new TypeError(`${label} requires non-empty strings`); const normalized=upper?text.toUpperCase():text; if(!result.includes(normalized)) result.push(normalized);} return result;};
|
|
34
|
-
const assertJsonValue=(value,label)=>{if(value===null||typeof value==='string'||typeof value==='boolean') return; if(typeof value==='number'){if(!Number.isFinite(value)) throw new TypeError(`${label} numbers must be finite`); return;} if(Array.isArray(value)){value.forEach((item,index)=>assertJsonValue(item,`${label}[${index}]`)); return;} if(plainObject(value)){for(const [key,item] of Object.entries(value)) assertJsonValue(item,`${label}.${key}`); return;} throw new TypeError(`${label} must be JSON-serializable`);};
|
|
35
|
-
const normalizeInitialState=(value,label)=>{
|
|
36
|
-
if(value==null) return {};
|
|
37
|
-
assertObject(value,label);
|
|
38
|
-
const result={};
|
|
39
|
-
for(const [rawKey,item] of Object.entries(value)){
|
|
40
|
-
const key=clean(rawKey);
|
|
41
|
-
if(!key||key!==rawKey||key.includes('.')||key.startsWith('__')){const error=new TypeError(`${label} invalid state key: ${rawKey}`);error.code='WORLD_IR_INITIAL_STATE_KEY_INVALID';throw error;}
|
|
42
|
-
if(RESERVED_INITIAL_STATE_KEYS.has(key)){const error=new TypeError(`${label} reserved runtime state key: ${key}`);error.code='WORLD_IR_INITIAL_STATE_RESERVED';error.stateKey=key;throw error;}
|
|
43
|
-
if(!STATE_SCALAR(item)){const error=new TypeError(`${label}.${key} must be a JSON scalar`);error.code='WORLD_IR_INITIAL_STATE_VALUE_INVALID';error.stateKey=key;throw error;}
|
|
44
|
-
result[key]=item;
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
const uniqueId=(set,id,label)=>{if(!id) throw new TypeError(`${label} requires id`); if(set.has(id)) throw new TypeError(`${label} duplicate id: ${id}`); set.add(id); return id;};
|
|
49
|
-
|
|
50
|
-
const normalizePhysicsRequirement=(value,label)=>{
|
|
51
|
-
if(value==null) return null;
|
|
52
|
-
assertObject(value,label); assertKnownKeys(value,PHYSICS_REQUIREMENT_KEYS,label);
|
|
53
|
-
const bodyClass=clean(value.bodyClass).toLowerCase();
|
|
54
|
-
if(bodyClass&&!['transform','rigid','articulated','character','soft','cloth'].includes(bodyClass)) throw new TypeError(`${label} unsupported bodyClass: ${bodyClass}`);
|
|
55
|
-
const executionMode=clean(value.executionMode).toLowerCase();
|
|
56
|
-
if(executionMode&&!['render-only','realtime','validation-only'].includes(executionMode)) throw new TypeError(`${label} unsupported executionMode: ${executionMode}`);
|
|
57
|
-
const requiredCapabilities=uniqueStrings(value.requiredCapabilities,`${label} requiredCapabilities`);
|
|
58
|
-
let qualityPolicy={};
|
|
59
|
-
if(value.qualityPolicy!=null){
|
|
60
|
-
assertObject(value.qualityPolicy,`${label} qualityPolicy`); assertKnownKeys(value.qualityPolicy,PHYSICS_QUALITY_KEYS,`${label} qualityPolicy`);
|
|
61
|
-
qualityPolicy={
|
|
62
|
-
...(value.qualityPolicy.deterministicRequired===true?{deterministicRequired:true}:{}),
|
|
63
|
-
...(value.qualityPolicy.realtimeRequired===true?{realtimeRequired:true}:{}),
|
|
64
|
-
...(clean(value.qualityPolicy.fallbackPolicy)?{fallbackPolicy:clean(value.qualityPolicy.fallbackPolicy)}:{})
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return {...(bodyClass?{bodyClass}:{}),...(requiredCapabilities.length?{requiredCapabilities}:{}),...(executionMode?{executionMode}:{}),...(Object.keys(qualityPolicy).length?{qualityPolicy}:{})};
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const normalizeRelationAnchor=(value,label)=>{
|
|
71
|
-
if(value==null) return null;
|
|
72
|
-
assertObject(value,label); assertKnownKeys(value,RELATION_ANCHOR_KEYS,label);
|
|
73
|
-
const kind=clean(value.kind).toLowerCase(),id=clean(value.id),anchorLabel=clean(value.label);
|
|
74
|
-
if(kind!=='observation') throw new TypeError(`${label} unsupported kind: ${kind || '$empty'}`);
|
|
75
|
-
if(!id&&!anchorLabel) throw new TypeError(`${label} requires id or label`);
|
|
76
|
-
return {kind:'observation',...(id?{id}:{}),...(anchorLabel?{label:anchorLabel}:{})};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const normalizeRelation=(relation,index)=>{
|
|
80
|
-
const label=`WorldIR spatial relation[${index}]`;
|
|
81
|
-
assertObject(relation,label); assertKnownKeys(relation,RELATION_KEYS,label);
|
|
82
|
-
const subject=clean(relation.subject),predicate=clean(relation.predicate).toUpperCase(),object=clean(relation.object);
|
|
83
|
-
const anchor=normalizeRelationAnchor(relation.anchor,`${label} anchor`);
|
|
84
|
-
if(!subject||!predicate) throw new TypeError(`${label} requires subject and predicate`);
|
|
85
|
-
if(!['ON','NEAR','INSIDE'].includes(predicate)) throw new TypeError(`${label} unsupported predicate: ${predicate}`);
|
|
86
|
-
if(Boolean(object)===Boolean(anchor)) throw new TypeError(`${label} requires exactly one of object or anchor`);
|
|
87
|
-
if(anchor&&predicate!=='NEAR') throw new TypeError(`${label} observation anchor is only supported for NEAR`);
|
|
88
|
-
const distance=relation.distance==null?null:Number(relation.distance);
|
|
89
|
-
if(distance!=null&&(!Number.isFinite(distance)||distance<=0)) throw new TypeError(`${label} distance must be positive finite`);
|
|
90
|
-
return {subject,predicate,...(object?{object}:{}),...(anchor?{anchor}:{}),...(clean(relation.surfaceId)?{surfaceId:clean(relation.surfaceId)}:{}),...(clean(relation.receptacleId)?{receptacleId:clean(relation.receptacleId)}:{}),...(distance!=null?{distance}:{})};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const fromWorldSpec=(input)=>{
|
|
94
|
-
const spec=normalizeWorldSpec(input);
|
|
95
|
-
return {
|
|
96
|
-
schema:WORLD_IR_SCHEMA,schemaVersion:WORLD_IR_VERSION,
|
|
97
|
-
revision:{id:'legacy-root'},provenance:{source:'legacy-world-spec',evidenceRefs:[]},
|
|
98
|
-
intent:{name:spec.name,description:spec.description},policy:{generation:structuredClone(spec.generation),physics:{}},
|
|
99
|
-
entities:spec.assets.map((request)=>({
|
|
100
|
-
...(request.id?{id:request.id}:{}),asset:{...(request.assetId?{assetId:request.assetId}:{}),query:request.query,...(request.type?{type:request.type}:{}),...(request.prompt?{prompt:request.prompt}:{}),generate:request.generate===true,...(request.provider?{provider:request.provider}:{})},
|
|
101
|
-
transform:{...(request.position?{position:[...request.position]}:{})},capabilityIntent:[],initialState:{}
|
|
102
|
-
})),
|
|
103
|
-
spatial:{relations:spec.relations.map((item)=>structuredClone(item)),constraints:[]},interactions:[],rules:[],acceptance:[]
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export function upgradeLegacyWorldSpec(input={}){
|
|
108
|
-
if(!input||typeof input!=='object'||Array.isArray(input)) throw new TypeError('Legacy WorldSpec must be an object');
|
|
109
|
-
const legacy=input.schema===1?{...input}:input;
|
|
110
|
-
if(legacy!==input) delete legacy.schema;
|
|
111
|
-
return fromWorldSpec(legacy);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function normalizeWorldIR(input={}){
|
|
115
|
-
if(!input||typeof input!=='object'||Array.isArray(input)) throw new TypeError('WorldIR must be an object');
|
|
116
|
-
if(input.schema!==WORLD_IR_SCHEMA){
|
|
117
|
-
const error=new TypeError(`WorldIR schema must be ${WORLD_IR_SCHEMA}`);
|
|
118
|
-
error.code='WORLD_IR_SCHEMA_REQUIRED';
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
assertKnownKeys(input,TOP_LEVEL_KEYS,'WorldIR');
|
|
122
|
-
if(input.schemaVersion!==WORLD_IR_VERSION) throw new TypeError(`Unsupported WorldIR version: ${input.schemaVersion}`);
|
|
123
|
-
const revision=assertObject(input.revision||{},'WorldIR revision'); assertKnownKeys(revision,REVISION_KEYS,'WorldIR revision');
|
|
124
|
-
const revisionId=clean(revision.id); if(!revisionId) throw new TypeError('WorldIR revision requires id');
|
|
125
|
-
const parentId=clean(revision.parentId)||null; if(parentId===revisionId) throw new TypeError('WorldIR revision parentId must differ from id');
|
|
126
|
-
const provenance=assertObject(input.provenance||{},'WorldIR provenance'); assertKnownKeys(provenance,PROVENANCE_KEYS,'WorldIR provenance');
|
|
127
|
-
const source=clean(provenance.source); if(!source) throw new TypeError('WorldIR provenance requires source');
|
|
128
|
-
const evidenceRefs=uniqueStrings(provenance.evidenceRefs,'WorldIR provenance evidenceRefs');
|
|
129
|
-
const intent=assertObject(input.intent||{},'WorldIR intent'); assertKnownKeys(intent,INTENT_KEYS,'WorldIR intent');
|
|
130
|
-
const name=clean(intent.name)||'Generated World',description=clean(intent.description),task=clean(intent.task)||null;
|
|
131
|
-
const policy=assertObject(input.policy||{},'WorldIR policy'); assertKnownKeys(policy,POLICY_KEYS,'WorldIR policy');
|
|
132
|
-
const generation=assertObject(policy.generation||{},'WorldIR policy generation'); assertKnownKeys(generation,GENERATION_KEYS,'WorldIR policy generation');
|
|
133
|
-
const physicsPolicy=assertObject(policy.physics||{},'WorldIR policy physics'); assertKnownKeys(physicsPolicy,PHYSICS_POLICY_KEYS,'WorldIR policy physics');
|
|
134
|
-
const defaultProvider=clean(generation.provider)||null,defaultGenerate=generation.generate===true;
|
|
135
|
-
if(!Array.isArray(input.entities||[])) throw new TypeError('WorldIR entities must be an array');
|
|
136
|
-
const entityIds=new Set();
|
|
137
|
-
const entities=(input.entities||[]).map((entity,index)=>{
|
|
138
|
-
const label=`WorldIR entity[${index}]`; assertObject(entity,label); assertKnownKeys(entity,ENTITY_KEYS,label);
|
|
139
|
-
const id=clean(entity.id)||null; if(id){if(entityIds.has(id)) throw new TypeError(`WorldIR duplicate entity id: ${id}`); entityIds.add(id);}
|
|
140
|
-
const asset=assertObject(entity.asset||{},`${label} asset`); assertKnownKeys(asset,ASSET_KEYS,`${label} asset`);
|
|
141
|
-
const assetId=clean(asset.assetId)||null,type=clean(asset.type)||null,prompt=clean(asset.prompt)||null,query=clean(asset.query)||prompt||type||assetId;
|
|
142
|
-
if(!query) throw new TypeError(`${label} asset requires assetId, query, prompt, or type`);
|
|
143
|
-
const transform=assertObject(entity.transform||{},`${label} transform`); assertKnownKeys(transform,TRANSFORM_KEYS,`${label} transform`);
|
|
144
|
-
const position=transform.position==null?null:finiteVec3(transform.position); if(transform.position!=null&&!position) throw new TypeError(`${label} transform position requires finite [3]`);
|
|
145
|
-
const physicsRequirement=normalizePhysicsRequirement(entity.physicsRequirement,`${label} physicsRequirement`);
|
|
146
|
-
const capabilityIntent=uniqueStrings(entity.capabilityIntent,`${label} capabilityIntent`,{upper:true});
|
|
147
|
-
const initialState=normalizeInitialState(entity.initialState,`${label} initialState`);
|
|
148
|
-
const provider=clean(asset.provider)||defaultProvider;
|
|
149
|
-
return {...(id?{id}:{}),asset:{...(assetId?{assetId}:{}),query,...(type?{type}:{}),...(prompt?{prompt}:{}),generate:asset.generate==null?defaultGenerate:asset.generate===true,...(provider?{provider}:{})},transform:{...(position?{position}:{})},...(physicsRequirement&&Object.keys(physicsRequirement).length?{physicsRequirement}:{}),capabilityIntent,initialState};
|
|
150
|
-
});
|
|
151
|
-
const spatial=assertObject(input.spatial||{},'WorldIR spatial'); assertKnownKeys(spatial,SPATIAL_KEYS,'WorldIR spatial');
|
|
152
|
-
if(!Array.isArray(spatial.relations||[])) throw new TypeError('WorldIR spatial relations must be an array'); if(!Array.isArray(spatial.constraints||[])) throw new TypeError('WorldIR spatial constraints must be an array');
|
|
153
|
-
const relations=(spatial.relations||[]).map(normalizeRelation); const constraintIds=new Set();
|
|
154
|
-
const constraints=(spatial.constraints||[]).map((constraint,index)=>{const label=`WorldIR spatial constraint[${index}]`; assertObject(constraint,label); assertKnownKeys(constraint,CONSTRAINT_KEYS,label); const id=uniqueId(constraintIds,clean(constraint.id),label),kind=clean(constraint.kind); if(!kind) throw new TypeError(`${label} requires kind`); return {id,kind,...(clean(constraint.subject)?{subject:clean(constraint.subject)}:{}),...(clean(constraint.object)?{object:clean(constraint.object)}:{}),...(clean(constraint.description)?{description:clean(constraint.description)}:{})};});
|
|
155
|
-
const interactionIds=new Set(); if(!Array.isArray(input.interactions||[])) throw new TypeError('WorldIR interactions must be an array');
|
|
156
|
-
const interactions=(input.interactions||[]).map((item,index)=>{const label=`WorldIR interaction[${index}]`; assertObject(item,label); assertKnownKeys(item,INTERACTION_KEYS,label); const id=uniqueId(interactionIds,clean(item.id),label),targetId=clean(item.targetId),supportId=clean(item.supportId),capability=clean(item.capability).toUpperCase(),stateKey=clean(item.stateKey); if(!capability) throw new TypeError(`${label} requires capability`); if(['OPEN','CLOSE','PICKUP','SWITCH'].includes(capability)&&!targetId) throw new TypeError(`${label} ${capability} requires targetId`); if(capability==='PLACE'&&!supportId) throw new TypeError(`${label} PLACE requires supportId`); if(capability==='SWITCH'){if(!stateKey||!Object.prototype.hasOwnProperty.call(item,'value')) throw new TypeError(`${label} SWITCH requires stateKey/value`); const value=item.value; if(value!==null&&!['string','number','boolean'].includes(typeof value)) throw new TypeError(`${label} SWITCH value must be JSON scalar`);} return {id,...(clean(item.actorId)?{actorId:clean(item.actorId)}:{}),...(targetId?{targetId}:{}),...(supportId?{supportId}:{}),capability,...(stateKey?{stateKey}:{}),...(Object.prototype.hasOwnProperty.call(item,'value')?{value:item.value}:{}),...(clean(item.description)?{description:clean(item.description)}:{})};});
|
|
157
|
-
const ruleIds=new Set(); if(!Array.isArray(input.rules||[])) throw new TypeError('WorldIR rules must be an array');
|
|
158
|
-
const rules=(input.rules||[]).map((item,index)=>{const label=`WorldIR rule[${index}]`; assertObject(item,label); assertKnownKeys(item,RULE_KEYS,label); const id=uniqueId(ruleIds,clean(item.id),label),event=clean(item.event); if(!event||item.effect==null) throw new TypeError(`${label} requires event and effect`); assertJsonValue(item.effect,`${label} effect`); if(item.condition!=null) assertJsonValue(item.condition,`${label} condition`); const effect=typeof item.effect==='string'?clean(item.effect):structuredClone(item.effect); if(typeof effect==='string'&&!effect) throw new TypeError(`${label} requires effect`); const condition=item.condition==null?null:(typeof item.condition==='string'?clean(item.condition):structuredClone(item.condition)); return {id,event,...(condition?{condition}:{}),effect,...(clean(item.description)?{description:clean(item.description)}:{})};});
|
|
159
|
-
const acceptanceIds=new Set(); if(!Array.isArray(input.acceptance||[])) throw new TypeError('WorldIR acceptance must be an array');
|
|
160
|
-
const acceptance=(input.acceptance||[]).map((item,index)=>{const label=`WorldIR acceptance[${index}]`; assertObject(item,label); assertKnownKeys(item,ACCEPTANCE_KEYS,label); const id=uniqueId(acceptanceIds,clean(item.id),label),kind=clean(item.kind),descriptionText=clean(item.description); if(!kind) throw new TypeError(`${label} requires kind`); if(!['world-valid','object-exists','state-equals','interaction-verified','relation-exists','no-unresolved'].includes(kind)) throw new TypeError(`${label} unsupported kind: ${kind}`); const targetId=clean(item.targetId),capability=clean(item.capability).toUpperCase(),stateKey=clean(item.stateKey),source=clean(item.source),subject=clean(item.subject),predicate=clean(item.predicate).toUpperCase(),object=clean(item.object),surfaceId=clean(item.surfaceId); if(kind==='object-exists'&&!targetId) throw new TypeError(`${label} object-exists requires targetId`); if(kind==='state-equals'&&(!targetId||!stateKey||!Object.prototype.hasOwnProperty.call(item,'value'))) throw new TypeError(`${label} state-equals requires targetId/stateKey/value`); if(kind==='interaction-verified'&&(!targetId||!capability)) throw new TypeError(`${label} interaction-verified requires targetId/capability`); if(kind==='relation-exists'){if(!subject||!predicate||!object) throw new TypeError(`${label} relation-exists requires subject/predicate/object`); if(!['ON','NEAR','INSIDE','CONTAINS','SUPPORTS'].includes(predicate)) throw new TypeError(`${label} unsupported relation predicate: ${predicate}`);} return {id,kind,...(targetId?{targetId}:{}),...(capability?{capability}:{}),...(stateKey?{stateKey}:{}),...(source?{source}:{}),...(subject?{subject}:{}),...(predicate?{predicate}:{}),...(object?{object}:{}),...(surfaceId?{surfaceId}:{}),...(Object.prototype.hasOwnProperty.call(item,'value')?{value:item.value}:{}),...(descriptionText?{description:descriptionText}:{})};});
|
|
161
|
-
return {schema:WORLD_IR_SCHEMA,schemaVersion:WORLD_IR_VERSION,revision:{id:revisionId,...(parentId?{parentId}:{}),...(clean(revision.reason)?{reason:clean(revision.reason)}:{})},provenance:{source,...(clean(provenance.sourceId)?{sourceId:clean(provenance.sourceId)}:{}),...(clean(provenance.createdBy)?{createdBy:clean(provenance.createdBy)}:{}),evidenceRefs},intent:{name,description,...(task?{task}: {})},policy:{generation:{...(defaultProvider?{provider:defaultProvider}:{}),generate:defaultGenerate},physics:{...(clean(physicsPolicy.fallbackPolicy)?{fallbackPolicy:clean(physicsPolicy.fallbackPolicy)}:{})}},entities,spatial:{relations,constraints},interactions,rules,acceptance};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function serializeWorldIR(input){return JSON.stringify(normalizeWorldIR(input));}
|
|
165
|
-
export function parseWorldIR(serialized){if(typeof serialized!=='string') throw new TypeError('Serialized WorldIR must be a string'); let value; try{value=JSON.parse(serialized);}catch(cause){const error=new TypeError('Serialized WorldIR must contain valid JSON',{cause});error.code='WORLD_IR_JSON_INVALID';throw error;} return normalizeWorldIR(value);}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const text={type:'string',minLength:1};
|
|
2
|
-
const scalar={anyOf:[{type:'string'},{type:'number'},{type:'boolean'},{type:'null'}]};
|
|
3
|
-
const vec3={type:'array',items:{type:'number'},minItems:3,maxItems:3};
|
|
4
|
-
const strict=(properties,required=[])=>({type:'object',additionalProperties:false,properties,required});
|
|
5
|
-
|
|
6
|
-
const asset=strict({
|
|
7
|
-
assetId:text,query:text,prompt:text,type:text,generate:{type:'boolean'},provider:text
|
|
8
|
-
});
|
|
9
|
-
asset.anyOf=[{required:['assetId']},{required:['query']},{required:['prompt']},{required:['type']}];
|
|
10
|
-
|
|
11
|
-
const physicsRequirement=strict({
|
|
12
|
-
bodyClass:{type:'string',enum:['transform','rigid','articulated','character','soft','cloth']},
|
|
13
|
-
requiredCapabilities:{type:'array',items:text,uniqueItems:true},
|
|
14
|
-
executionMode:{type:'string',enum:['render-only','realtime','validation-only']},
|
|
15
|
-
qualityPolicy:strict({
|
|
16
|
-
deterministicRequired:{type:'boolean'},realtimeRequired:{type:'boolean'},fallbackPolicy:{type:'string',enum:['deny']}
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const entity=strict({
|
|
21
|
-
id:text,asset,
|
|
22
|
-
transform:strict({position:vec3}),
|
|
23
|
-
physicsRequirement,
|
|
24
|
-
capabilityIntent:{type:'array',items:text,uniqueItems:true},
|
|
25
|
-
initialState:{type:'object',additionalProperties:scalar}
|
|
26
|
-
},['id','asset']);
|
|
27
|
-
|
|
28
|
-
const observationAnchor=strict({
|
|
29
|
-
kind:{type:'string',enum:['observation']},id:text,label:text
|
|
30
|
-
},['kind']);
|
|
31
|
-
observationAnchor.anyOf=[{required:['id']},{required:['label']}];
|
|
32
|
-
|
|
33
|
-
const relationCommon={
|
|
34
|
-
subject:text,surfaceId:text,receptacleId:text,distance:{type:'number',exclusiveMinimum:0}
|
|
35
|
-
};
|
|
36
|
-
const relation={oneOf:[
|
|
37
|
-
strict({...relationCommon,predicate:{type:'string',enum:['ON','NEAR','INSIDE']},object:text},['subject','predicate','object']),
|
|
38
|
-
strict({...relationCommon,predicate:{type:'string',enum:['NEAR']},anchor:observationAnchor},['subject','predicate','anchor'])
|
|
39
|
-
]};
|
|
40
|
-
|
|
41
|
-
const interactionCommon={id:text,actorId:text,targetId:text,supportId:text,description:{type:'string'}};
|
|
42
|
-
const interaction={oneOf:[
|
|
43
|
-
strict({...interactionCommon,capability:{type:'string',enum:['OPEN','CLOSE','PICKUP']}},['id','targetId','capability']),
|
|
44
|
-
strict({...interactionCommon,capability:{type:'string',enum:['PLACE']}},['id','supportId','capability']),
|
|
45
|
-
strict({...interactionCommon,capability:{type:'string',enum:['SWITCH']},stateKey:text,value:scalar},['id','targetId','capability','stateKey','value'])
|
|
46
|
-
]};
|
|
47
|
-
|
|
48
|
-
const ruleCondition={oneOf:[
|
|
49
|
-
strict({kind:{type:'string',enum:['equals']},targetId:text,stateKey:text,value:scalar},['kind','targetId','stateKey','value']),
|
|
50
|
-
strict({kind:{type:'string',enum:['not-equals']},targetId:text,stateKey:text,value:scalar},['kind','targetId','stateKey','value'])
|
|
51
|
-
]};
|
|
52
|
-
const ruleEffect=strict({kind:{type:'string',enum:['set-state']},targetId:text,stateKey:text,value:scalar},['kind','targetId','stateKey','value']);
|
|
53
|
-
const rule=strict({id:text,event:text,condition:ruleCondition,effect:ruleEffect,description:{type:'string'}},['id','event','effect']);
|
|
54
|
-
|
|
55
|
-
const acceptance={oneOf:[
|
|
56
|
-
strict({id:text,kind:{type:'string',enum:['world-valid']},description:{type:'string'}},['id','kind']),
|
|
57
|
-
strict({id:text,kind:{type:'string',enum:['object-exists']},targetId:text,description:{type:'string'}},['id','kind','targetId']),
|
|
58
|
-
strict({id:text,kind:{type:'string',enum:['state-equals']},targetId:text,stateKey:text,value:scalar,source:text,description:{type:'string'}},['id','kind','targetId','stateKey','value']),
|
|
59
|
-
strict({id:text,kind:{type:'string',enum:['interaction-verified']},targetId:text,capability:text,source:text,description:{type:'string'}},['id','kind','targetId','capability']),
|
|
60
|
-
strict({id:text,kind:{type:'string',enum:['relation-exists']},subject:text,predicate:{type:'string',enum:['ON','NEAR','INSIDE','CONTAINS','SUPPORTS']},object:text,surfaceId:text,description:{type:'string'}},['id','kind','subject','predicate','object']),
|
|
61
|
-
strict({id:text,kind:{type:'string',enum:['no-unresolved']},description:{type:'string'}},['id','kind'])
|
|
62
|
-
]};
|
|
63
|
-
|
|
64
|
-
export const WORLD_IR_TOOL_SCHEMA=strict({
|
|
65
|
-
schema:{type:'string',enum:['agentscape.world-ir']},
|
|
66
|
-
schemaVersion:{type:'integer',enum:[1]},
|
|
67
|
-
revision:strict({id:text,parentId:text,reason:{type:'string'}},['id']),
|
|
68
|
-
provenance:strict({source:text,sourceId:text,createdBy:text,evidenceRefs:{type:'array',items:text,uniqueItems:true}},['source']),
|
|
69
|
-
intent:strict({name:text,description:{type:'string'},task:{type:'string'}},['name']),
|
|
70
|
-
policy:strict({
|
|
71
|
-
generation:strict({provider:text,generate:{type:'boolean'}}),
|
|
72
|
-
physics:strict({fallbackPolicy:{type:'string',enum:['deny']}})
|
|
73
|
-
}),
|
|
74
|
-
entities:{type:'array',items:entity},
|
|
75
|
-
spatial:strict({relations:{type:'array',items:relation}},['relations']),
|
|
76
|
-
interactions:{type:'array',items:interaction},
|
|
77
|
-
rules:{type:'array',items:rule},
|
|
78
|
-
acceptance:{type:'array',items:acceptance}
|
|
79
|
-
},['schema','schemaVersion','revision','provenance','intent','entities','spatial','interactions','rules','acceptance']);
|
|
80
|
-
|
|
81
|
-
const {schema: _schema, schemaVersion: _schemaVersion, revision: _revision, provenance: _provenance, ...plannerProperties}=WORLD_IR_TOOL_SCHEMA.properties;
|
|
82
|
-
export const WORLD_PLANNER_PROPOSAL_SCHEMA={
|
|
83
|
-
type:'object',additionalProperties:false,
|
|
84
|
-
properties:plannerProperties,
|
|
85
|
-
required:WORLD_IR_TOOL_SCHEMA.required.filter((key)=>!['schema','schemaVersion','revision','provenance'].includes(key))
|
|
86
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { compileWorldIR } from '../compiler/WorldCompilation.js';
|
|
2
|
-
|
|
3
|
-
export const WORLD_PROPOSAL_SCHEMA='agentscape.world-proposal';
|
|
4
|
-
export const WORLD_PROPOSAL_VERSION=1;
|
|
5
|
-
|
|
6
|
-
const BODY_KEYS=new Set(['intent','policy','entities','spatial','interactions','rules','acceptance']);
|
|
7
|
-
const clean=(value)=>typeof value==='string'?value.trim():'';
|
|
8
|
-
|
|
9
|
-
const assertProposalBody=(body)=>{
|
|
10
|
-
if(!body||typeof body!=='object'||Array.isArray(body)) throw new TypeError('World planner proposal must be an object');
|
|
11
|
-
for(const key of Object.keys(body)){
|
|
12
|
-
if(!BODY_KEYS.has(key)){
|
|
13
|
-
const error=new TypeError(`World planner proposal unknown field: ${key}`);
|
|
14
|
-
error.code='WORLD_PROPOSAL_FIELD_INVALID';
|
|
15
|
-
error.field=key;
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return body;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function buildWorldProposal(body,{revisionId,parentRevisionId=null,reason=null,source='agent-world-planner',sourceId=null,createdBy='agent',evidenceRefs=[]}={}){
|
|
23
|
-
assertProposalBody(body);
|
|
24
|
-
const id=clean(revisionId);
|
|
25
|
-
if(!id){const error=new TypeError('World proposal requires Runtime-issued revisionId');error.code='WORLD_PROPOSAL_REVISION_REQUIRED';throw error;}
|
|
26
|
-
const parent=clean(parentRevisionId),revisionReason=clean(reason);
|
|
27
|
-
const provenanceSource=clean(source);
|
|
28
|
-
if(!provenanceSource){const error=new TypeError('World proposal requires provenance source');error.code='WORLD_PROPOSAL_PROVENANCE_REQUIRED';throw error;}
|
|
29
|
-
if(!Array.isArray(evidenceRefs)){const error=new TypeError('World proposal evidenceRefs must be an array');error.code='WORLD_PROPOSAL_EVIDENCE_INVALID';throw error;}
|
|
30
|
-
const refs=[...new Set(evidenceRefs.map(clean).filter(Boolean))];
|
|
31
|
-
|
|
32
|
-
const worldIR={
|
|
33
|
-
schema:'agentscape.world-ir',schemaVersion:1,
|
|
34
|
-
revision:{id,...(parent?{parentId:parent}:{}),...(revisionReason?{reason:revisionReason}:{})},
|
|
35
|
-
provenance:{source:provenanceSource,...(clean(sourceId)?{sourceId:clean(sourceId)}:{}),...(clean(createdBy)?{createdBy:clean(createdBy)}:{}),...(refs.length?{evidenceRefs:refs}:{})},
|
|
36
|
-
...structuredClone(body)
|
|
37
|
-
};
|
|
38
|
-
const compilation=compileWorldIR(worldIR);
|
|
39
|
-
return {
|
|
40
|
-
schema:WORLD_PROPOSAL_SCHEMA,schemaVersion:WORLD_PROPOSAL_VERSION,status:'world-proposal-ready',
|
|
41
|
-
worldIR:compilation.worldIR,
|
|
42
|
-
summary:{
|
|
43
|
-
worldRevisionId:compilation.worldRevisionId,
|
|
44
|
-
entities:compilation.entities.length,
|
|
45
|
-
interactions:compilation.behaviorBundle.behaviorGraph.commands.length,
|
|
46
|
-
rules:compilation.behaviorBundle.ruleGraph.rules.length,
|
|
47
|
-
physicsRequirements:compilation.physicsRequirements.requirements.length,
|
|
48
|
-
acceptanceChecks:compilation.acceptanceGraph?.checks?.length || 0
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|