agentscape3d 1.0.0-beta.1 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- 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 +16 -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,170 +0,0 @@
|
|
|
1
|
-
import { createCanonicalWorldPipeline } from '../compiler/createWorldPipeline.js';
|
|
2
|
-
import { buildWorldRetryPlan } from '../compiler/WorldRetry.js';
|
|
3
|
-
import { recompileWorldRevision } from '../compiler/WorldRecompiler.js';
|
|
4
|
-
import { captureWorldAuthority, restoreWorldAuthority } from '../runtime/WorldAuthority.js';
|
|
5
|
-
|
|
6
|
-
export class WorldBuilder {
|
|
7
|
-
constructor(runtime, { pipeline = null, retryBudget = 2 } = {}) {
|
|
8
|
-
if (!runtime) throw new TypeError('WorldBuilder requires a runtime');
|
|
9
|
-
if (!Number.isInteger(retryBudget) || retryBudget < 1) throw new TypeError('WorldBuilder retryBudget must be a positive integer');
|
|
10
|
-
this.runtime = runtime;
|
|
11
|
-
this.pipeline = pipeline || createCanonicalWorldPipeline(runtime);
|
|
12
|
-
this.retryBudget = retryBudget;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async run(plan) {
|
|
16
|
-
const runtime = this.runtime;
|
|
17
|
-
const before = runtime.snapshot();
|
|
18
|
-
const authorityBefore = captureWorldAuthority(runtime);
|
|
19
|
-
const attempts = [];
|
|
20
|
-
let candidate = plan;
|
|
21
|
-
|
|
22
|
-
const restoreBefore = async (cause = null) => {
|
|
23
|
-
try {
|
|
24
|
-
await runtime.restoreSnapshot(before);
|
|
25
|
-
restoreWorldAuthority(runtime,authorityBefore);
|
|
26
|
-
} catch (rollbackError) {
|
|
27
|
-
const failure = new AggregateError(
|
|
28
|
-
cause ? [cause, rollbackError] : [rollbackError],
|
|
29
|
-
'World build rollback failed',
|
|
30
|
-
cause ? { cause } : undefined
|
|
31
|
-
);
|
|
32
|
-
failure.code = 'WORLD_BUILD_ROLLBACK_FAILED';
|
|
33
|
-
failure.rollbackError = rollbackError;
|
|
34
|
-
throw failure;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const runCandidate = async (candidatePlan) => {
|
|
39
|
-
try {
|
|
40
|
-
runtime.loadRuleGraph?.([]);
|
|
41
|
-
await runtime.clearObjects({ silent:true });
|
|
42
|
-
return await this.pipeline.run(candidatePlan);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
await restoreBefore(error);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
for (let attempt = 1; attempt <= this.retryBudget; attempt++) {
|
|
50
|
-
const pipeline = await runCandidate(candidate);
|
|
51
|
-
const admission = pipeline.state?.reports?.worldAdmission;
|
|
52
|
-
if (!admission) {
|
|
53
|
-
const error = new Error('Canonical world pipeline produced no world admission');
|
|
54
|
-
error.code = 'WORLD_PIPELINE_ADMISSION_MISSING';
|
|
55
|
-
await restoreBefore(error);
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const record = { attempt, admission:structuredClone(admission) };
|
|
60
|
-
attempts.push(record);
|
|
61
|
-
if (admission.status !== 'rejected') {
|
|
62
|
-
return {
|
|
63
|
-
status:`world-${admission.status}`,
|
|
64
|
-
admission,
|
|
65
|
-
pipeline,
|
|
66
|
-
attempts,
|
|
67
|
-
retry:attempts.length > 1 ? attempts.at(-2).retry : null
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await restoreBefore();
|
|
72
|
-
const retry = buildWorldRetryPlan(pipeline, {
|
|
73
|
-
generatorConfigured:runtime.generation?.canGenerateAsset?.() === true,
|
|
74
|
-
attempt,
|
|
75
|
-
budget:this.retryBudget
|
|
76
|
-
});
|
|
77
|
-
record.retry = retry;
|
|
78
|
-
if (retry.status !== 'retry-proposed') {
|
|
79
|
-
return {
|
|
80
|
-
status:'world-rejected',
|
|
81
|
-
reason:admission.reasons?.[0] || 'WORLD_REJECTED',
|
|
82
|
-
rolledBack:true,
|
|
83
|
-
admission,
|
|
84
|
-
pipeline,
|
|
85
|
-
attempts,
|
|
86
|
-
retry
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const generation = await this.materializeRetryAssets(retry);
|
|
91
|
-
record.generation = generation.status === 'generated'
|
|
92
|
-
? { status:generation.status, assets:structuredClone(generation.assets) }
|
|
93
|
-
: { status:generation.status, reason:generation.reason, ...(generation.error ? { error:generation.error } : {}) };
|
|
94
|
-
if (generation.status !== 'generated') {
|
|
95
|
-
const failedRetry = { ...retry, status:'generation-failed', retriable:false, generation:record.generation };
|
|
96
|
-
record.retry = failedRetry;
|
|
97
|
-
return {
|
|
98
|
-
status:'world-rejected',
|
|
99
|
-
reason:generation.reason || 'GENERATION_FAILED',
|
|
100
|
-
rolledBack:true,
|
|
101
|
-
admission,
|
|
102
|
-
pipeline,
|
|
103
|
-
attempts,
|
|
104
|
-
retry:failedRetry
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
candidate = generation.plan;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
throw new Error('World retry loop exceeded its fixed budget');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
recompile(options = {}) {
|
|
114
|
-
return recompileWorldRevision(this.runtime, { ...options, pipeline:this.pipeline });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async materializeRetryAssets(retry) {
|
|
118
|
-
const runtime = this.runtime;
|
|
119
|
-
if (retry?.status !== 'retry-proposed') return { status:'not-requested', plan:retry?.nextIR || null, assets:[] };
|
|
120
|
-
if (typeof runtime.generation?.generateAsset !== 'function') {
|
|
121
|
-
return { status:'generation-failed', reason:'GENERATOR_UNAVAILABLE', plan:null, assets:[] };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const plan = structuredClone(retry.nextIR);
|
|
125
|
-
const generated = [];
|
|
126
|
-
for (const action of retry.actions || []) {
|
|
127
|
-
if (action.kind !== 'enable-generation') continue;
|
|
128
|
-
const entity = plan.entities.find((item) =>
|
|
129
|
-
(action.instanceId && item.id === action.instanceId)
|
|
130
|
-
|| (!action.instanceId && item.asset?.query === action.query)
|
|
131
|
-
);
|
|
132
|
-
if (!entity) {
|
|
133
|
-
return { status:'generation-failed', reason:'RETRY_ENTITY_NOT_FOUND', plan:null, assets:generated, action:structuredClone(action) };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const asset = entity.asset || {};
|
|
137
|
-
const prompt = asset.prompt || asset.query || asset.type || action.query || '';
|
|
138
|
-
let produced;
|
|
139
|
-
try {
|
|
140
|
-
produced = await runtime.generation.generateAsset(prompt, {
|
|
141
|
-
...(entity.id ? { instanceId:entity.id } : {}),
|
|
142
|
-
...(asset.provider ? { provider:asset.provider } : {})
|
|
143
|
-
});
|
|
144
|
-
} catch (error) {
|
|
145
|
-
return {
|
|
146
|
-
status:'generation-failed',
|
|
147
|
-
reason:error?.code || 'GENERATION_FAILED',
|
|
148
|
-
plan:null,
|
|
149
|
-
assets:generated,
|
|
150
|
-
error:{ code:error?.code || 'GENERATION_FAILED', message:error?.message || String(error) }
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const assetId = produced?.id || null;
|
|
155
|
-
if (!assetId || runtime.assetModule?.hasAsset?.(assetId) !== true) {
|
|
156
|
-
return {
|
|
157
|
-
status:'generation-failed',
|
|
158
|
-
reason:produced?.status || 'GENERATED_ASSET_NOT_PUBLISHED',
|
|
159
|
-
plan:null,
|
|
160
|
-
assets:generated,
|
|
161
|
-
result:produced ? structuredClone(produced) : null
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
entity.asset = { ...asset, assetId };
|
|
165
|
-
generated.push({ instanceId:entity.id || null, assetId, status:produced.status || 'generated' });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return { status:'generated', plan, assets:generated };
|
|
169
|
-
}
|
|
170
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export class PipelineEngine {
|
|
2
|
-
constructor({ events = null, trace = null } = {}) {
|
|
3
|
-
this.events = events;
|
|
4
|
-
this.trace = trace;
|
|
5
|
-
this.stages = new Map();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
register(name, handler) {
|
|
9
|
-
if (this.stages.has(name)) throw new Error(`Pipeline stage already exists: ${name}`);
|
|
10
|
-
this.stages.set(name, handler);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async run(input, { stages, context = {} } = {}) {
|
|
15
|
-
const selected = stages || [...this.stages.keys()];
|
|
16
|
-
let state = { input, artifacts: {}, reports: {}, ...context };
|
|
17
|
-
const timeline = [];
|
|
18
|
-
for (const name of selected) {
|
|
19
|
-
const handler = this.stages.get(name);
|
|
20
|
-
if (!handler) throw new Error(`Unknown pipeline stage: ${name}`);
|
|
21
|
-
const started = performance.now();
|
|
22
|
-
this.events?.emit('pipeline.stage.started', { name });
|
|
23
|
-
this.trace?.emit('pipeline.stage.started', { name }, { actor: 'pipeline' });
|
|
24
|
-
state = await handler(state) || state;
|
|
25
|
-
const elapsedMs = Math.round(performance.now() - started);
|
|
26
|
-
timeline.push({ name, elapsedMs });
|
|
27
|
-
this.events?.emit('pipeline.stage.completed', { name, elapsedMs });
|
|
28
|
-
this.trace?.emit('pipeline.stage.completed', { name, elapsedMs }, { actor: 'pipeline' });
|
|
29
|
-
}
|
|
30
|
-
return { state, timeline };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const clone = (value) => value == null ? value : structuredClone(value);
|
|
2
|
-
|
|
3
|
-
export function evaluateWorldAdmission({
|
|
4
|
-
validation = null,
|
|
5
|
-
acceptance = null,
|
|
6
|
-
assetAdmission = null,
|
|
7
|
-
layoutAdmission = null,
|
|
8
|
-
behaviorAdmission = null,
|
|
9
|
-
physicsAdmission = null,
|
|
10
|
-
relationAdmission = null
|
|
11
|
-
} = {}) {
|
|
12
|
-
const hard = validation?.counts?.hard || 0;
|
|
13
|
-
const advisory = validation?.counts?.advisory || 0;
|
|
14
|
-
const acceptanceRejected = acceptance?.status === 'world-incomplete';
|
|
15
|
-
const rejected = [assetAdmission, layoutAdmission, behaviorAdmission, physicsAdmission, relationAdmission]
|
|
16
|
-
.some((admission) => admission?.status === 'rejected');
|
|
17
|
-
const provisional = advisory
|
|
18
|
-
|| assetAdmission?.status === 'provisional'
|
|
19
|
-
|| layoutAdmission?.status === 'provisional';
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
status: hard || rejected || acceptanceRejected ? 'rejected' : provisional ? 'provisional' : 'ready',
|
|
23
|
-
reasons: [
|
|
24
|
-
...(hard ? [`VALIDATION_HARD:${hard}`] : []),
|
|
25
|
-
...(advisory ? [`VALIDATION_ADVISORY:${advisory}`] : []),
|
|
26
|
-
...(assetAdmission?.status === 'rejected' ? ['ASSET_UNRESOLVED'] : []),
|
|
27
|
-
...(assetAdmission?.status === 'provisional' ? ['ASSET_PROVISIONAL'] : []),
|
|
28
|
-
...(layoutAdmission?.status === 'rejected' ? [layoutAdmission.reason || 'LAYOUT_REJECTED'] : []),
|
|
29
|
-
...(layoutAdmission?.status === 'provisional' ? ['LAYOUT_PROVISIONAL'] : []),
|
|
30
|
-
...(behaviorAdmission?.status === 'rejected' ? [behaviorAdmission.reason || behaviorAdmission.issues?.[0]?.code || 'BEHAVIOR_REJECTED'] : []),
|
|
31
|
-
...(physicsAdmission?.status === 'rejected' ? [physicsAdmission.reason || physicsAdmission.issues?.[0]?.code || 'PHYSICS_REJECTED'] : []),
|
|
32
|
-
...(relationAdmission?.status === 'rejected' ? [relationAdmission.reason || 'RELATION_REJECTED'] : []),
|
|
33
|
-
...(acceptanceRejected ? ['WORLD_ACCEPTANCE_FAILED'] : [])
|
|
34
|
-
],
|
|
35
|
-
validation: { hard, advisory },
|
|
36
|
-
...(assetAdmission ? { assets:clone(assetAdmission) } : {}),
|
|
37
|
-
...(layoutAdmission ? { layout:clone(layoutAdmission) } : {}),
|
|
38
|
-
...(behaviorAdmission ? { behavior:clone(behaviorAdmission) } : {}),
|
|
39
|
-
...(physicsAdmission ? { physics:clone(physicsAdmission) } : {}),
|
|
40
|
-
...(relationAdmission ? { relations:clone(relationAdmission) } : {}),
|
|
41
|
-
...(acceptance ? { acceptance:clone(acceptance) } : {})
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { assetIdFromRef } from '../../asset/model/AssetRef.js';
|
|
2
|
-
import { inferCarryCapability, isCarryOperation } from '../runtime/interaction/CarryCapability.js';
|
|
3
|
-
import { compileBehaviorGraph } from '../runtime/behavior/BehaviorCompiler.js';
|
|
4
|
-
import { compileRuleGraph } from '../runtime/behavior/RuleGraph.js';
|
|
5
|
-
|
|
6
|
-
export const WORLD_BEHAVIOR_BUNDLE_SCHEMA='agentscape.world-behavior-bundle';
|
|
7
|
-
export const WORLD_BEHAVIOR_BUNDLE_VERSION=1;
|
|
8
|
-
|
|
9
|
-
export function compileWorldBehaviorBundle(worldIR){
|
|
10
|
-
const entityIds=new Set((worldIR?.entities||[]).map((entity)=>entity.id).filter(Boolean));
|
|
11
|
-
const behaviorGraph=compileBehaviorGraph(worldIR?.interactions||[],{worldRevisionId:worldIR?.revision?.id || null});
|
|
12
|
-
for(const command of behaviorGraph.commands){
|
|
13
|
-
for(const [field,id] of [['targetId',command.targetId],['supportId',command.supportId]]){
|
|
14
|
-
if(id&&!entityIds.has(id)){
|
|
15
|
-
const error=new Error(`Behavior ${field} is outside World IR entities: ${id}`);
|
|
16
|
-
error.code='WORLD_BEHAVIOR_REFERENCE_INVALID'; error.commandId=command.commandId; error.entityId=id; throw error;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const capabilityIntents=(worldIR?.entities||[])
|
|
21
|
-
.filter((entity)=>entity.id && entity.capabilityIntent?.length)
|
|
22
|
-
.map((entity)=>({entityId:entity.id,capabilities:[...entity.capabilityIntent]}));
|
|
23
|
-
const ruleGraph=compileRuleGraph(worldIR?.rules||[]);
|
|
24
|
-
for(const rule of ruleGraph.rules){
|
|
25
|
-
const refs=[rule.condition?.targetId,rule.effect?.targetId].filter(Boolean);
|
|
26
|
-
for(const id of refs){
|
|
27
|
-
if(!entityIds.has(id)){
|
|
28
|
-
const error=new Error(`Rule target is outside World IR entities: ${id}`);
|
|
29
|
-
error.code='WORLD_RULE_REFERENCE_INVALID'; error.ruleId=rule.id; error.entityId=id; throw error;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return {schema:WORLD_BEHAVIOR_BUNDLE_SCHEMA,schemaVersion:WORLD_BEHAVIOR_BUNDLE_VERSION,worldRevisionId:worldIR?.revision?.id || null,capabilityIntents,behaviorGraph,ruleGraph};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function admitWorldBehavior(bundle,{resolvedAssets=[],getManifest}={}){
|
|
37
|
-
if(bundle?.schema!==WORLD_BEHAVIOR_BUNDLE_SCHEMA||bundle.schemaVersion!==WORLD_BEHAVIOR_BUNDLE_VERSION) throw new TypeError('Unsupported WorldBehavior bundle');
|
|
38
|
-
const byId=new Map((resolvedAssets||[]).filter((item)=>item.id).map((item)=>[item.id,item]));
|
|
39
|
-
const issues=[];
|
|
40
|
-
for(const intent of bundle.capabilityIntents||[]){
|
|
41
|
-
const target=byId.get(intent.entityId);
|
|
42
|
-
if(!target){issues.push({code:'BEHAVIOR_INTENT_TARGET_MISSING',targetId:intent.entityId});continue;}
|
|
43
|
-
const assetId=assetIdFromRef(target.assetRef);
|
|
44
|
-
if(!assetId){issues.push({code:'BEHAVIOR_INTENT_TARGET_UNRESOLVED',targetId:intent.entityId});continue;}
|
|
45
|
-
const manifest=getManifest?.(assetId);
|
|
46
|
-
const actions=new Set((manifest?.actions||[]).map((action)=>String(action).toUpperCase()));
|
|
47
|
-
if (inferCarryCapability(manifest).eligible) for (const name of ['PICKUP','DROP','PLACE']) actions.add(name);
|
|
48
|
-
else if (manifest?.physics?.carryable === false) for (const name of ['PICKUP','DROP','PLACE']) actions.delete(name);
|
|
49
|
-
for(const capability of intent.capabilities){
|
|
50
|
-
if(!actions.has(capability)) issues.push({code:'BEHAVIOR_CAPABILITY_INTENT_UNSUPPORTED',targetId:intent.entityId,capability,assetId});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
for(const command of bundle.behaviorGraph.commands){
|
|
54
|
-
const targetId=command.targetId;
|
|
55
|
-
const target=targetId?byId.get(targetId):null;
|
|
56
|
-
if(targetId&&!target){issues.push({code:'BEHAVIOR_TARGET_MISSING',commandId:command.commandId,targetId});continue;}
|
|
57
|
-
const assetId=assetIdFromRef(target?.assetRef);
|
|
58
|
-
if(targetId&&!assetId){issues.push({code:'BEHAVIOR_TARGET_UNRESOLVED',commandId:command.commandId,targetId});continue;}
|
|
59
|
-
if(['OPEN','CLOSE','PICKUP'].includes(command.capability)){
|
|
60
|
-
const manifest=getManifest?.(assetId);
|
|
61
|
-
const action=command.capability.toLowerCase();
|
|
62
|
-
const supported = (manifest?.actions?.includes(action) || (isCarryOperation(action) && inferCarryCapability(manifest).eligible))
|
|
63
|
-
&& (!isCarryOperation(action) || manifest?.physics?.carryable !== false);
|
|
64
|
-
if(!supported) issues.push({code:'BEHAVIOR_CAPABILITY_UNSUPPORTED',commandId:command.commandId,targetId,capability:command.capability,assetId});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return {status:issues.length?'rejected':'ready',issues};
|
|
68
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { normalizeWorldIR, upgradeLegacyWorldSpec } from '../spec/WorldIR.js';
|
|
2
|
-
import { normalizeWorldSpec } from '../spec/WorldSpec.js';
|
|
3
|
-
import { compileWorldBehaviorBundle } from './WorldBehaviorCompiler.js';
|
|
4
|
-
import { compileWorldPhysicsRequirements } from './WorldPhysicsAdmission.js';
|
|
5
|
-
import { compileWorldAcceptance } from '../verification/WorldAcceptance.js';
|
|
6
|
-
import { createAssetRef } from '../../asset/model/AssetRef.js';
|
|
7
|
-
|
|
8
|
-
export const WORLD_COMPILATION_SCHEMA = 'agentscape.world-compilation';
|
|
9
|
-
export const WORLD_COMPILATION_VERSION = 2;
|
|
10
|
-
|
|
11
|
-
const clone = (value) => structuredClone(value);
|
|
12
|
-
const hasState = (entity) => Object.keys(entity.initialState || {}).length > 0;
|
|
13
|
-
|
|
14
|
-
const invalidReference = (path, entityId) => {
|
|
15
|
-
const error = new TypeError(`WorldIR ${path} references unknown entity: ${entityId}`);
|
|
16
|
-
error.code = 'WORLD_IR_REFERENCE_INVALID';
|
|
17
|
-
error.path = path;
|
|
18
|
-
error.entityId = entityId;
|
|
19
|
-
return error;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const requireEntity = (entityIds, path, entityId) => {
|
|
23
|
-
if (entityId && !entityIds.has(entityId)) throw invalidReference(path, entityId);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const unsupportedExecutionFeatures = (worldIR) => {
|
|
27
|
-
const features=[];
|
|
28
|
-
if(worldIR.spatial.constraints.length) features.push('spatial.constraints');
|
|
29
|
-
const fallback=worldIR.policy.physics?.fallbackPolicy;
|
|
30
|
-
if(fallback && fallback!=='deny') features.push('policy.physics.fallbackPolicy');
|
|
31
|
-
for(const entity of worldIR.entities){
|
|
32
|
-
const qualityFallback=entity.physicsRequirement?.qualityPolicy?.fallbackPolicy;
|
|
33
|
-
if(qualityFallback && qualityFallback!=='deny') features.push(`entities.${entity.id||'$anonymous'}.physicsRequirement.qualityPolicy.fallbackPolicy`);
|
|
34
|
-
}
|
|
35
|
-
if(features.length){
|
|
36
|
-
const error=new TypeError(`WorldIR features are not executable by the canonical pipeline: ${features.join(', ')}`);
|
|
37
|
-
error.code='WORLD_IR_FEATURE_UNSUPPORTED';
|
|
38
|
-
error.features=features;
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
return worldIR;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export function assertWorldIRReferences(worldIR) {
|
|
45
|
-
const entityIds = new Set(worldIR.entities.map((entity) => entity.id).filter(Boolean));
|
|
46
|
-
const entityById = new Map(worldIR.entities.filter((entity)=>entity.id).map((entity)=>[entity.id,entity]));
|
|
47
|
-
|
|
48
|
-
worldIR.entities.forEach((entity, index) => {
|
|
49
|
-
if (!entity.id && (entity.capabilityIntent.length || hasState(entity))) {
|
|
50
|
-
const error = new TypeError(`WorldIR entity[${index}] requires id for capabilityIntent or initialState`);
|
|
51
|
-
error.code = 'WORLD_IR_ENTITY_ID_REQUIRED';
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const anchoredSubjects=new Set();
|
|
57
|
-
worldIR.spatial.relations.forEach((relation, index) => {
|
|
58
|
-
requireEntity(entityIds, `spatial.relations[${index}].subject`, relation.subject);
|
|
59
|
-
if(relation.object) requireEntity(entityIds, `spatial.relations[${index}].object`, relation.object);
|
|
60
|
-
if(relation.anchor?.kind==='observation'){
|
|
61
|
-
if(anchoredSubjects.has(relation.subject)){
|
|
62
|
-
const error=new TypeError(`WorldIR entity ${relation.subject} has multiple observation anchors`);
|
|
63
|
-
error.code='WORLD_IR_OBSERVATION_ANCHOR_AMBIGUOUS';
|
|
64
|
-
error.entityId=relation.subject;
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
anchoredSubjects.add(relation.subject);
|
|
68
|
-
if(entityById.get(relation.subject)?.transform?.position){
|
|
69
|
-
const error=new TypeError(`WorldIR entity ${relation.subject} cannot combine explicit transform.position with an observation anchor`);
|
|
70
|
-
error.code='WORLD_IR_OBSERVATION_ANCHOR_POSITION_CONFLICT';
|
|
71
|
-
error.entityId=relation.subject;
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
worldIR.spatial.constraints.forEach((constraint, index) => {
|
|
77
|
-
requireEntity(entityIds, `spatial.constraints[${index}].subject`, constraint.subject);
|
|
78
|
-
requireEntity(entityIds, `spatial.constraints[${index}].object`, constraint.object);
|
|
79
|
-
});
|
|
80
|
-
worldIR.interactions.forEach((interaction, index) => {
|
|
81
|
-
requireEntity(entityIds, `interactions[${index}].targetId`, interaction.targetId);
|
|
82
|
-
requireEntity(entityIds, `interactions[${index}].supportId`, interaction.supportId);
|
|
83
|
-
});
|
|
84
|
-
worldIR.acceptance.forEach((criterion, index) => {
|
|
85
|
-
requireEntity(entityIds, `acceptance[${index}].targetId`, criterion.targetId);
|
|
86
|
-
requireEntity(entityIds, `acceptance[${index}].subject`, criterion.subject);
|
|
87
|
-
requireEntity(entityIds, `acceptance[${index}].object`, criterion.object);
|
|
88
|
-
});
|
|
89
|
-
return worldIR;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const assetRequests = (worldIR) => worldIR.entities.map((entity) => ({
|
|
93
|
-
...(entity.id ? { id:entity.id } : {}),
|
|
94
|
-
...clone(entity.asset)
|
|
95
|
-
}));
|
|
96
|
-
|
|
97
|
-
const executionEntities = (worldIR) => worldIR.entities.map((entity) => ({
|
|
98
|
-
...(entity.id ? { id:entity.id } : {}),
|
|
99
|
-
...(entity.asset.assetId ? { assetRef:createAssetRef(entity.asset.assetId) } : {}),
|
|
100
|
-
...(entity.transform.position ? { position:[...entity.transform.position] } : {}),
|
|
101
|
-
...(entity.capabilityIntent.length ? { capabilityIntent:[...entity.capabilityIntent] } : {}),
|
|
102
|
-
...(hasState(entity) ? { initialState:clone(entity.initialState) } : {})
|
|
103
|
-
}));
|
|
104
|
-
|
|
105
|
-
const compatibilityWorldSpec = (worldIR) => {
|
|
106
|
-
const anchored=worldIR.spatial.relations.find((relation)=>relation.anchor);
|
|
107
|
-
if(anchored){
|
|
108
|
-
const error=new TypeError('Legacy WorldSpec cannot represent observation-anchored relations');
|
|
109
|
-
error.code='WORLD_IR_COMPATIBILITY_UNSUPPORTED';
|
|
110
|
-
error.feature='spatial.relations.anchor';
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
return normalizeWorldSpec({
|
|
114
|
-
name:worldIR.intent.name,
|
|
115
|
-
description:worldIR.intent.description,
|
|
116
|
-
generation:clone(worldIR.policy.generation),
|
|
117
|
-
assets:worldIR.entities.map((entity) => ({
|
|
118
|
-
...(entity.id ? { id:entity.id } : {}),
|
|
119
|
-
...clone(entity.asset),
|
|
120
|
-
...(entity.transform.position ? { position:[...entity.transform.position] } : {})
|
|
121
|
-
})),
|
|
122
|
-
relations:worldIR.spatial.relations.map(clone)
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export function projectWorldIRToWorldSpec(input) {
|
|
127
|
-
return compatibilityWorldSpec(assertWorldIRReferences(normalizeWorldIR(input)));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function compileWorldInput(input) {
|
|
131
|
-
if(input?.schema==='agentscape.world-ir') return compileWorldIR(input);
|
|
132
|
-
const worldIR=upgradeLegacyWorldSpec(input);
|
|
133
|
-
return {
|
|
134
|
-
...compileWorldIR(worldIR),
|
|
135
|
-
compatibility:{source:'legacy-world-spec',worldSpec:compatibilityWorldSpec(worldIR)}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function compileWorldIR(input) {
|
|
140
|
-
const worldIR = unsupportedExecutionFeatures(assertWorldIRReferences(normalizeWorldIR(input)));
|
|
141
|
-
const behaviorBundle = compileWorldBehaviorBundle(worldIR);
|
|
142
|
-
const physicsRequirements = compileWorldPhysicsRequirements(worldIR);
|
|
143
|
-
const acceptanceGraph = worldIR.acceptance.length ? compileWorldAcceptance(worldIR.acceptance) : null;
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
schema:WORLD_COMPILATION_SCHEMA,
|
|
147
|
-
schemaVersion:WORLD_COMPILATION_VERSION,
|
|
148
|
-
worldRevisionId:worldIR.revision.id,
|
|
149
|
-
worldIR:clone(worldIR),
|
|
150
|
-
assetRequests:assetRequests(worldIR),
|
|
151
|
-
entities:executionEntities(worldIR),
|
|
152
|
-
relations:worldIR.spatial.relations.map(clone),
|
|
153
|
-
behaviorBundle,
|
|
154
|
-
physicsRequirements,
|
|
155
|
-
acceptanceGraph
|
|
156
|
-
};
|
|
157
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { assetIdFromRef } from '../../asset/model/AssetRef.js';
|
|
2
|
-
|
|
3
|
-
const rootColliderExtent = (spec) => {
|
|
4
|
-
const t=spec.translation || [0,0,0];
|
|
5
|
-
if (spec.shape==='box' && spec.halfExtents?.length===3) {
|
|
6
|
-
const [hx,hy,hz]=spec.halfExtents;
|
|
7
|
-
return {radius:Math.hypot(t[0],t[2])+Math.hypot(hx,hz),minY:t[1]-hy};
|
|
8
|
-
}
|
|
9
|
-
if (spec.shape==='cylinder' && Number.isFinite(spec.radius) && Number.isFinite(spec.halfHeight)) {
|
|
10
|
-
return {radius:Math.hypot(t[0],t[2])+spec.radius,minY:t[1]-spec.halfHeight};
|
|
11
|
-
}
|
|
12
|
-
if (spec.shape==='capsule' && Number.isFinite(spec.radius) && Number.isFinite(spec.halfHeight)) {
|
|
13
|
-
return {radius:Math.hypot(t[0],t[2])+spec.radius,minY:t[1]-(spec.halfHeight+spec.radius)};
|
|
14
|
-
}
|
|
15
|
-
if (spec.shape==='convexHull' && Array.isArray(spec.vertices)) {
|
|
16
|
-
let radius=0,minY=Infinity;
|
|
17
|
-
for(let i=0;i+2<spec.vertices.length;i+=3) {
|
|
18
|
-
radius=Math.max(radius,Math.hypot(t[0]+spec.vertices[i],t[2]+spec.vertices[i+2]));
|
|
19
|
-
minY=Math.min(minY,t[1]+spec.vertices[i+1]);
|
|
20
|
-
}
|
|
21
|
-
if (Number.isFinite(minY)) return {radius,minY};
|
|
22
|
-
}
|
|
23
|
-
return null;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export function manifestFootprint(manifest) {
|
|
27
|
-
const colliders=manifest?.physics?.colliders || [];
|
|
28
|
-
if (!colliders.length) return {checked:false,reason:'ROOT_COLLIDER_UNAVAILABLE'};
|
|
29
|
-
let radius=.01,minY=Infinity;
|
|
30
|
-
for(const collider of colliders) {
|
|
31
|
-
const extent=rootColliderExtent(collider);
|
|
32
|
-
if (!extent) return {checked:false,reason:'ROOT_COLLIDER_UNSUPPORTED',shape:collider.shape || null};
|
|
33
|
-
radius=Math.max(radius,extent.radius);
|
|
34
|
-
minY=Math.min(minY,extent.minY);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
checked:true,radius,minY,
|
|
38
|
-
coverage:Object.values(manifest.parts || {}).some((part)=>part.physics?.colliders?.length)?'root-only':'full-root'
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const candidatePoints = ({minX,maxX,minZ,maxZ,step=1}) => {
|
|
43
|
-
const cx=(minX+maxX)/2,cz=(minZ+maxZ)/2;
|
|
44
|
-
const nx=Math.max(0,Math.floor((maxX-minX)/(2*step)));
|
|
45
|
-
const nz=Math.max(0,Math.floor((maxZ-minZ)/(2*step)));
|
|
46
|
-
const values=[];
|
|
47
|
-
for(let ix=-nx;ix<=nx;ix++) for(let iz=-nz;iz<=nz;iz++) {
|
|
48
|
-
const x=cx+ix*step,z=cz+iz*step;
|
|
49
|
-
if(x<minX-1e-9||x>maxX+1e-9||z<minZ-1e-9||z>maxZ+1e-9) continue;
|
|
50
|
-
values.push({x,z,d2:(x-cx)**2+(z-cz)**2});
|
|
51
|
-
}
|
|
52
|
-
return values.sort((a,b)=>a.d2-b.d2 || a.z-b.z || a.x-b.x);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const circlesOverlap=(a,b,clearance)=>Math.hypot(a.x-b.x,a.z-b.z)<a.radius+b.radius+clearance-1e-9;
|
|
56
|
-
|
|
57
|
-
const normalizeLayout=(layout)=>{
|
|
58
|
-
if(!layout?.bounds || !Number.isFinite(layout.groundY)) return {checked:false,reason:'WORLD_LAYOUT_UNAVAILABLE'};
|
|
59
|
-
const [minX,minZ]=layout.bounds.min || [],[maxX,maxZ]=layout.bounds.max || [];
|
|
60
|
-
if(![minX,minZ,maxX,maxZ].every(Number.isFinite) || minX>=maxX || minZ>=maxZ) return {checked:false,reason:'WORLD_LAYOUT_INVALID'};
|
|
61
|
-
return {checked:true,minX,minZ,maxX,maxZ,groundY:layout.groundY,margin:Number.isFinite(layout.margin)?Math.max(0,layout.margin):.5};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const checkPosition=(manifest,footprint,position,{layout,reserved=[],poseClear,clearance=.35}={})=>{
|
|
65
|
-
const circle={x:position[0],z:position[2],radius:footprint.radius};
|
|
66
|
-
if(circle.x-footprint.radius<layout.minX+layout.margin || circle.x+footprint.radius>layout.maxX-layout.margin || circle.z-footprint.radius<layout.minZ+layout.margin || circle.z+footprint.radius>layout.maxZ-layout.margin) return {checked:true,clear:false,reason:'OUTSIDE_LAYOUT_BOUNDS',circle};
|
|
67
|
-
if(reserved.some((other)=>circlesOverlap(circle,other,clearance))) return {checked:true,clear:false,reason:'BATCH_FOOTPRINT_OVERLAP',circle};
|
|
68
|
-
const physics=poseClear?.(manifest,position);
|
|
69
|
-
if(!physics?.checked) return {checked:false,clear:false,reason:physics?.reason || 'LAYOUT_PHYSICS_UNAVAILABLE',circle,physics};
|
|
70
|
-
if(!physics.clear) return {checked:true,clear:false,reason:'WORLD_POSE_BLOCKED',blockedBy:physics.blockedBy || [],circle,physics};
|
|
71
|
-
return {checked:true,clear:true,circle,physics};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export function preflightWorldPosition(manifest,position,{layout,poseClear,occupied=[],clearance=.35}={}){
|
|
75
|
-
const normalized=normalizeLayout(layout);
|
|
76
|
-
if(!normalized.checked) return normalized;
|
|
77
|
-
if(!Array.isArray(position) || position.length!==3 || !position.every(Number.isFinite)) return {checked:false,reason:'WORLD_POSITION_INVALID'};
|
|
78
|
-
const footprint=manifestFootprint(manifest);
|
|
79
|
-
if(!footprint.checked) return footprint;
|
|
80
|
-
const reserved=[];
|
|
81
|
-
for(const item of occupied){
|
|
82
|
-
if(!item?.manifest || !Array.isArray(item.position) || item.position.length!==3) return {checked:false,reason:'OCCUPIED_POSITION_INVALID'};
|
|
83
|
-
const other=manifestFootprint(item.manifest);
|
|
84
|
-
if(!other.checked) return {checked:false,reason:other.reason,occupiedId:item.id || null};
|
|
85
|
-
reserved.push({x:item.position[0],z:item.position[2],radius:other.radius});
|
|
86
|
-
}
|
|
87
|
-
const verdict=checkPosition(manifest,footprint,position,{layout:normalized,reserved,poseClear,clearance});
|
|
88
|
-
return {...verdict,coverage:footprint.coverage,status:verdict.clear?(footprint.coverage==='root-only'?'provisional':'ready'):'rejected'};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function composeWorldLayout(requests,{getManifest,poseClear,layout,clearance=.35}={}) {
|
|
92
|
-
const normalized=normalizeLayout(layout);
|
|
93
|
-
if(!normalized.checked) return {status:'rejected',reason:normalized.reason,placements:[],issues:[]};
|
|
94
|
-
const {minX,minZ,maxX,maxZ,groundY,margin}=normalized;
|
|
95
|
-
const reserved=[]; const placements=[]; const issues=[];
|
|
96
|
-
let provisional=false;
|
|
97
|
-
|
|
98
|
-
for(const request of requests) {
|
|
99
|
-
const assetId=assetIdFromRef(request.assetRef);
|
|
100
|
-
if (!assetId) continue;
|
|
101
|
-
const manifest=getManifest(assetId);
|
|
102
|
-
const footprint=manifestFootprint(manifest);
|
|
103
|
-
if (!footprint.checked) return {status:'rejected',reason:footprint.reason,placements,issues:[...issues,{id:request.id || null,assetId,reason:footprint.reason}]};
|
|
104
|
-
if (footprint.coverage==='root-only') { provisional=true; issues.push({id:request.id || null,assetId,reason:'ARTICULATED_LAYOUT_ROOT_ONLY'}); }
|
|
105
|
-
const groundPositionY=groundY-footprint.minY+.01;
|
|
106
|
-
const test=(position)=>{
|
|
107
|
-
const verdict=checkPosition(manifest,footprint,position,{layout:normalized,reserved,poseClear,clearance});
|
|
108
|
-
return verdict.clear?{ok:true,circle:verdict.circle,physics:verdict.physics}:{ok:false,reason:verdict.reason,blockedBy:verdict.blockedBy || []};
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
let position=request.position ? [...request.position] : null;
|
|
112
|
-
let mode='explicit';
|
|
113
|
-
const explicitGroundY=groundY-footprint.minY;
|
|
114
|
-
if(position && Math.abs(position[1]-explicitGroundY)<=.03) {
|
|
115
|
-
position[1]=Number(groundPositionY.toFixed(4));
|
|
116
|
-
mode='explicit-grounded';
|
|
117
|
-
}
|
|
118
|
-
let verdict=position ? test(position) : null;
|
|
119
|
-
if (!position) {
|
|
120
|
-
mode='auto';
|
|
121
|
-
const autoY=groundPositionY;
|
|
122
|
-
const step=Math.max(.5,Math.min(2,footprint.radius));
|
|
123
|
-
for(const point of candidatePoints({minX:minX+margin+footprint.radius,maxX:maxX-margin-footprint.radius,minZ:minZ+margin+footprint.radius,maxZ:maxZ-margin-footprint.radius,step})) {
|
|
124
|
-
const candidate=[Number(point.x.toFixed(4)),Number(autoY.toFixed(4)),Number(point.z.toFixed(4))];
|
|
125
|
-
const result=test(candidate);
|
|
126
|
-
if (result.ok) { position=candidate; verdict=result; break; }
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (!position || !verdict?.ok) return {status:'rejected',reason:verdict?.reason || 'NO_LAYOUT_POSITION',placements,issues:[...issues,{id:request.id || null,assetId,reason:verdict?.reason || 'NO_LAYOUT_POSITION',blockedBy:verdict?.blockedBy || []}]};
|
|
130
|
-
reserved.push(verdict.circle);
|
|
131
|
-
placements.push({id:request.id || null,assetId,position,mode,radius:Number(footprint.radius.toFixed(4)),coverage:footprint.coverage});
|
|
132
|
-
}
|
|
133
|
-
return {status:provisional?'provisional':'ready',reason:provisional?'ARTICULATED_LAYOUT_ROOT_ONLY':null,placements,issues};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
export function composeNearPlacement(subjectManifest,targetManifest,targetPosition,{subjectY=0,distance=null,poseClear,clearance=.35}={}) {
|
|
138
|
-
const subject=manifestFootprint(subjectManifest),target=manifestFootprint(targetManifest);
|
|
139
|
-
if (!subject.checked) return {checked:false,reason:subject.reason,source:'subject-footprint'};
|
|
140
|
-
if (!target.checked) return {checked:false,reason:target.reason,source:'target-footprint'};
|
|
141
|
-
const minimum=subject.radius+target.radius+clearance;
|
|
142
|
-
const spacing=distance == null ? minimum : Number(distance);
|
|
143
|
-
if (!Number.isFinite(spacing) || spacing<=0) return {checked:false,reason:'NEAR_DISTANCE_INVALID'};
|
|
144
|
-
if (spacing+1e-9<minimum) return {checked:false,reason:'NEAR_DISTANCE_TOO_SMALL',minimumDistance:minimum,requestedDistance:spacing};
|
|
145
|
-
const [x,,z]=targetPosition;
|
|
146
|
-
const candidates=[[x+spacing,subjectY,z],[x-spacing,subjectY,z],[x,subjectY,z+spacing],[x,subjectY,z-spacing]];
|
|
147
|
-
const blocked=[];
|
|
148
|
-
for (const position of candidates) {
|
|
149
|
-
const result=poseClear(subjectManifest,position);
|
|
150
|
-
if (result?.checked && result.clear) return {
|
|
151
|
-
checked:true,position:position.map((v)=>Number(v.toFixed(4))),distance:Number(spacing.toFixed(4)),
|
|
152
|
-
mode:distance == null?'runtime-derived':'explicit',coverage:subject.coverage
|
|
153
|
-
};
|
|
154
|
-
blocked.push({position,reason:result?.reason || (result?.checked?'WORLD_POSE_BLOCKED':'LAYOUT_PHYSICS_UNAVAILABLE'),blockedBy:result?.blockedBy || []});
|
|
155
|
-
}
|
|
156
|
-
return {checked:false,reason:'NEAR_NO_CLEAR_POSE',distance:spacing,blocked};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const observedCenter=(observation)=>{
|
|
160
|
-
const point=observation?.localization?.kind==='point-scale' ? observation.localization.center : observation?.center;
|
|
161
|
-
return Array.isArray(point)&&point.length===3&&point.every(Number.isFinite) ? [...point] : null;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export function composeObservedNearPlacement(subjectManifest,observation,{layout,poseClear,distance=null,clearance=.35,maxDistance=3,occupied=[]}={}){
|
|
165
|
-
const normalized=normalizeLayout(layout);
|
|
166
|
-
if(!normalized.checked) return {checked:false,reason:normalized.reason};
|
|
167
|
-
const footprint=manifestFootprint(subjectManifest);
|
|
168
|
-
if(!footprint.checked) return {checked:false,reason:footprint.reason,source:'subject-footprint'};
|
|
169
|
-
const center=observedCenter(observation);
|
|
170
|
-
if(!center) return {checked:false,reason:'OBSERVATION_LOCALIZATION_UNAVAILABLE'};
|
|
171
|
-
if(typeof poseClear!=='function') return {checked:false,reason:'LAYOUT_PHYSICS_UNAVAILABLE'};
|
|
172
|
-
const reserved=[];
|
|
173
|
-
for(const item of occupied){
|
|
174
|
-
if(!item?.manifest || !Array.isArray(item.position) || item.position.length!==3) return {checked:false,reason:'OCCUPIED_POSITION_INVALID'};
|
|
175
|
-
const other=manifestFootprint(item.manifest);
|
|
176
|
-
if(!other.checked) return {checked:false,reason:other.reason,occupiedId:item.id || null};
|
|
177
|
-
reserved.push({x:item.position[0],z:item.position[2],radius:other.radius});
|
|
178
|
-
}
|
|
179
|
-
const explicit=distance!=null;
|
|
180
|
-
const observedScale=Number.isFinite(observation?.localization?.scale)&&observation.localization.scale>0 ? observation.localization.scale : 0;
|
|
181
|
-
const startDistance=explicit ? Number(distance) : Math.max(footprint.radius+clearance+.25,Math.min(1.5,observedScale+footprint.radius+clearance));
|
|
182
|
-
if(!Number.isFinite(startDistance)||startDistance<=0) return {checked:false,reason:'NEAR_DISTANCE_INVALID'};
|
|
183
|
-
const limit=Math.max(startDistance,Number.isFinite(maxDistance)?maxDistance:3);
|
|
184
|
-
const groundY=normalized.groundY-footprint.minY+.01;
|
|
185
|
-
const directions=[[1,0],[-1,0],[0,1],[0,-1],[Math.SQRT1_2,Math.SQRT1_2],[-Math.SQRT1_2,Math.SQRT1_2],[Math.SQRT1_2,-Math.SQRT1_2],[-Math.SQRT1_2,-Math.SQRT1_2]];
|
|
186
|
-
const blocked=[];
|
|
187
|
-
for(let radius=startDistance;radius<=limit+1e-9;radius+=.35){
|
|
188
|
-
for(const [dx,dz] of directions){
|
|
189
|
-
const position=[Number((center[0]+dx*radius).toFixed(4)),Number(groundY.toFixed(4)),Number((center[2]+dz*radius).toFixed(4))];
|
|
190
|
-
const bounds=checkPosition(subjectManifest,footprint,position,{layout:normalized,reserved,poseClear,clearance});
|
|
191
|
-
if(bounds.checked&&bounds.clear) return {
|
|
192
|
-
checked:true,status:footprint.coverage==='root-only'?'provisional':'ready',position,
|
|
193
|
-
distance:Number(Math.hypot(position[0]-center[0],position[2]-center[2]).toFixed(4)),
|
|
194
|
-
requestedDistance:explicit?startDistance:null,mode:explicit?'observation-explicit':'observation-auto',
|
|
195
|
-
observationId:observation?.id||null,anchor:[...center],radius:Number(footprint.radius.toFixed(4)),coverage:footprint.coverage,collisionVerified:true
|
|
196
|
-
};
|
|
197
|
-
blocked.push({position,reason:bounds.reason,blockedBy:bounds.blockedBy||[]});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return {checked:false,reason:'OBSERVATION_NEAR_NO_CLEAR_POSE',observationId:observation?.id||null,anchor:center,startDistance,maxDistance:limit,blocked};
|
|
201
|
-
}
|