agentscape3d-engine 0.0.0-stage → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/cli.mjs +53 -0
- package/dist/ArticulationVerifier-BfGxXY8V.js +337 -0
- package/dist/ArticulationVerifier-BfGxXY8V.js.map +1 -0
- package/dist/AssetCompiler-BLj09iu1.js +2424 -0
- package/dist/AssetCompiler-BLj09iu1.js.map +1 -0
- package/dist/AssetModule-DME-XaFS.js +2637 -0
- package/dist/AssetModule-DME-XaFS.js.map +1 -0
- package/dist/AssetRecipe-g8dZBhgJ.js +298 -0
- package/dist/AssetRecipe-g8dZBhgJ.js.map +1 -0
- package/dist/BrowserCodeWorker.js +53856 -0
- package/dist/BrowserCodeWorker.js.map +1 -0
- package/dist/CarryCapability-CXwHU5ay.js +104 -0
- package/dist/CarryCapability-CXwHU5ay.js.map +1 -0
- package/dist/KinematicHypothesisScreen-C3TKiuYR.js +241 -0
- package/dist/KinematicHypothesisScreen-C3TKiuYR.js.map +1 -0
- package/dist/ObjectTransform-BlQUNK7c.js +61 -0
- package/dist/ObjectTransform-BlQUNK7c.js.map +1 -0
- package/dist/RapierPhysicsBackend-B2wQe_Vl.js +3259 -0
- package/dist/RapierPhysicsBackend-B2wQe_Vl.js.map +1 -0
- package/dist/RenderingSystem-WIr1ZuGu.js +1042 -0
- package/dist/RenderingSystem-WIr1ZuGu.js.map +1 -0
- package/dist/ScenePresentation-LsYiDxbm.js +152 -0
- package/dist/ScenePresentation-LsYiDxbm.js.map +1 -0
- package/dist/SceneProject-K7HH1s8o.js +2687 -0
- package/dist/SceneProject-K7HH1s8o.js.map +1 -0
- package/dist/SceneSerializer-zOzbX4jZ.js +932 -0
- package/dist/SceneSerializer-zOzbX4jZ.js.map +1 -0
- package/dist/SimulationProfile-DSYZbBLQ.js +165 -0
- package/dist/SimulationProfile-DSYZbBLQ.js.map +1 -0
- package/dist/StylePack-DcRa_kU0.js +88 -0
- package/dist/StylePack-DcRa_kU0.js.map +1 -0
- package/dist/WorldArchive-BiFGLt--.js +451 -0
- package/dist/WorldArchive-BiFGLt--.js.map +1 -0
- package/dist/WorldCommands-Debj7V4L.js +2207 -0
- package/dist/WorldCommands-Debj7V4L.js.map +1 -0
- package/dist/WorldIO-Ch8QBfKY.js +151 -0
- package/dist/WorldIO-Ch8QBfKY.js.map +1 -0
- package/dist/admission-CVEvsrdz.js +121 -0
- package/dist/admission-CVEvsrdz.js.map +1 -0
- package/dist/blankWorld-B0MW6g7q.js +75 -0
- package/dist/blankWorld-B0MW6g7q.js.map +1 -0
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/disposeObject3D-DIMzy0FA.js +128 -0
- package/dist/disposeObject3D-DIMzy0FA.js.map +1 -0
- package/dist/environments-HOe3sJXH.js +567 -0
- package/dist/environments-HOe3sJXH.js.map +1 -0
- package/dist/gltfIO-BzVKLyaL.js +339 -0
- package/dist/gltfIO-BzVKLyaL.js.map +1 -0
- package/dist/grandUrbanBlock-DRndRZjF.js +515 -0
- package/dist/grandUrbanBlock-DRndRZjF.js.map +1 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.js +16952 -0
- package/dist/index.js.map +1 -0
- package/dist/magicCabin-CfBZjx2Q.js +11019 -0
- package/dist/magicCabin-CfBZjx2Q.js.map +1 -0
- package/dist/manifests-D0LwbJ36.js +866 -0
- package/dist/manifests-D0LwbJ36.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +1 -0
- package/dist/monumentHall-awZiGtda.js +403 -0
- package/dist/monumentHall-awZiGtda.js.map +1 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +26 -0
- package/dist/parts-DrEcfJRl.js +37 -0
- package/dist/parts-DrEcfJRl.js.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/ruinedCourtyard-DuF7NmUU.js +696 -0
- package/dist/ruinedCourtyard-DuF7NmUU.js.map +1 -0
- package/dist/runtime/application/AgentTools.js +28 -0
- package/dist/runtime/application/README.md +14 -0
- package/dist/runtime/application/agent/ProgressiveAgentTools.js +92 -0
- package/dist/runtime/application/agent/StudioMcpAllowlist.js +10 -0
- package/dist/runtime/application/agent/StudioProjectTools.js +18 -0
- package/dist/runtime/application/agent/TaskEvidence.js +199 -0
- package/dist/runtime/application/buildTaskObservation.js +117 -0
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +50 -0
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +35 -0
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +17 -0
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +82 -0
- package/dist/runtime/application/createSession.js +66 -0
- package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
- package/dist/runtime/application/generation/GenerationOrchestrator.js +630 -0
- package/dist/runtime/application/generation/GenerationRuntime.js +215 -0
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +289 -0
- package/dist/runtime/application/native-scene/CodeProject.js +215 -0
- package/dist/runtime/application/native-scene/CodeProjectModules.js +143 -0
- package/dist/runtime/application/native-scene/ExampleWorldCatalog.js +35 -0
- package/dist/runtime/application/native-scene/NativeArticulation.js +53 -0
- package/dist/runtime/application/native-scene/NativeEditableRegistry.js +150 -0
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +85 -0
- package/dist/runtime/application/native-scene/NativeLightingInspection.js +33 -0
- package/dist/runtime/application/native-scene/NativeMaterialInspection.js +52 -0
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
- package/dist/runtime/application/native-scene/NativePhysicsGeometry.js +64 -0
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
- package/dist/runtime/application/native-scene/NativeSceneHost.js +406 -0
- package/dist/runtime/application/native-scene/NativeSceneInspection.js +203 -0
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
- package/dist/runtime/application/native-scene/NativeSceneQuery.js +123 -0
- package/dist/runtime/application/native-scene/NativeSceneReview.js +132 -0
- package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
- package/dist/runtime/application/native-scene/SceneObserver.js +97 -0
- package/dist/runtime/application/native-scene/VisualCapturePolicy.js +4 -0
- package/dist/runtime/application/object-forge/SceneObjectForge.js +263 -0
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +59 -0
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +22 -0
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +40 -0
- package/dist/runtime/application/scene/CapabilityResolver.js +90 -0
- package/dist/runtime/application/scene/NativeEditableContracts.js +18 -0
- package/dist/runtime/application/scene/RequestWindow.js +54 -0
- package/dist/runtime/application/scene/SceneAgentTools.js +21 -0
- package/dist/runtime/application/scene/SceneContracts.js +49 -0
- package/dist/runtime/application/scene/SceneEditService.js +154 -0
- package/dist/runtime/application/scene/SceneFacade.js +356 -0
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +41 -0
- package/dist/runtime/application/scene/SceneJobController.js +320 -0
- package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
- package/dist/runtime/application/scene/ScenePackage.js +173 -0
- package/dist/runtime/application/scene/ScenePersistence.js +50 -0
- package/dist/runtime/application/scene/SceneProject.js +95 -0
- package/dist/runtime/application/scene/SceneSkillNames.js +5 -0
- package/dist/runtime/application/scene/StarterScene.js +56 -0
- package/dist/runtime/application/scene/WorldArchive.js +89 -0
- package/dist/runtime/application/scene/WorldDirectory.js +20 -0
- package/dist/runtime/application/scene/WorldDocument.js +76 -0
- package/dist/runtime/application/scene/WorldIO.js +103 -0
- package/dist/runtime/application/scene/WorldStorage.js +155 -0
- package/dist/runtime/application/skills/SkillRegistry.js +193 -0
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +32 -0
- package/dist/runtime/application/skills/packs/affordanceSkills.js +36 -0
- package/dist/runtime/application/skills/packs/assetSkills.js +46 -0
- package/dist/runtime/application/skills/packs/authoringSkills.js +16 -0
- package/dist/runtime/application/skills/packs/batchSkills.js +22 -0
- package/dist/runtime/application/skills/packs/codeSkills.js +106 -0
- package/dist/runtime/application/skills/packs/generationSkills.js +45 -0
- package/dist/runtime/application/skills/packs/interactionSkills.js +46 -0
- package/dist/runtime/application/skills/packs/recoverySkills.js +80 -0
- package/dist/runtime/application/skills/packs/sceneSkills.js +24 -0
- package/dist/runtime/application/skills/packs/spatialSkills.js +35 -0
- package/dist/runtime/application/skills/packs/verificationSkills.js +14 -0
- package/dist/runtime/application/skills/packs/worldSkills.js +45 -0
- package/dist/runtime/application/skills/registerCoreSkills.js +31 -0
- package/dist/runtime/application/skills/skillPrimitives.js +4 -0
- package/dist/runtime/application/tasks/CabinetCupTask.js +76 -0
- package/dist/runtime/application/tasks.jsonl +67 -0
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +42 -0
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +149 -0
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +825 -0
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +109 -0
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +17 -0
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +29 -0
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +118 -0
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +334 -0
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +126 -0
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +144 -0
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +92 -0
- package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
- package/dist/runtime/application/world-authoring/SceneGLBExport.js +88 -0
- package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
- package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +68 -0
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +1 -0
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +30 -0
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +17 -0
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +71 -0
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +42 -0
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +66 -0
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +159 -0
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +8 -0
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +47 -0
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +157 -0
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +6 -0
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +116 -0
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +60 -0
- package/dist/runtime/apps/mcp-server/README.md +269 -0
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +1 -0
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +13 -0
- package/dist/runtime/apps/mcp-server/SessionManager.js +148 -0
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +75 -0
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +246 -0
- package/dist/runtime/apps/mcp-server/StudioProjectToolContracts.js +58 -0
- package/dist/runtime/apps/mcp-server/TransferHttp.js +47 -0
- package/dist/runtime/apps/mcp-server/TransferLimits.js +6 -0
- package/dist/runtime/apps/mcp-server/TransferStore.js +134 -0
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +16 -0
- package/dist/runtime/apps/mcp-server/VALIDATION.md +45 -0
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +332 -0
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +32 -0
- package/dist/runtime/apps/mcp-server/examples/code-house.js +24 -0
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +85 -0
- package/dist/runtime/apps/mcp-server/main.mjs +82 -0
- package/dist/runtime/apps/mcp-server/registerTools.js +274 -0
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
- package/dist/runtime/apps/mcp-server/security.js +23 -0
- package/dist/runtime/apps/mcp-server/tasks.jsonl +9 -0
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +157 -0
- package/dist/runtime/apps/server/README.md +7 -0
- package/dist/runtime/apps/server/WorldRepository.js +338 -0
- package/dist/runtime/apps/server/WorldRepositoryHttp.js +96 -0
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +278 -0
- package/dist/runtime/apps/server/tasks.jsonl +10 -0
- package/dist/runtime/apps/shared/node/WorldDiskStorage.js +62 -0
- package/dist/runtime/foundation/EventBus.js +26 -0
- package/dist/runtime/foundation/JsonGateway.js +47 -0
- package/dist/runtime/foundation/PngRgba.js +99 -0
- package/dist/runtime/foundation/PolicyEngine.js +21 -0
- package/dist/runtime/foundation/README.md +7 -0
- package/dist/runtime/foundation/TraceRecorder.js +76 -0
- package/dist/runtime/foundation/errors.js +8 -0
- package/dist/runtime/foundation/simulation/SimulationProfile.js +143 -0
- package/dist/runtime/foundation/version.js +2 -0
- package/dist/runtime/modules/agent/README.md +11 -0
- package/dist/runtime/modules/agent/ToolCallingAgent.js +19 -0
- package/dist/runtime/modules/agent/bootstrapWorld.js +10 -0
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +533 -0
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +128 -0
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +55 -0
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +393 -0
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +40 -0
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +19 -0
- package/dist/runtime/modules/agent/prompt/index.js +52 -0
- package/dist/runtime/modules/agent/tasks.jsonl +94 -0
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +144 -0
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +280 -0
- package/dist/runtime/modules/artifact/ArtifactImporter.js +185 -0
- package/dist/runtime/modules/artifact/ArtifactModule.js +111 -0
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +197 -0
- package/dist/runtime/modules/artifact/IncrementalSha256.js +129 -0
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +115 -0
- package/dist/runtime/modules/artifact/README.md +7 -0
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +67 -0
- package/dist/runtime/modules/artifact/tasks.jsonl +31 -0
- package/dist/runtime/modules/asset/AssetModule.js +416 -0
- package/dist/runtime/modules/asset/README.md +67 -0
- package/dist/runtime/modules/asset/loading/AssetLoader.js +157 -0
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +61 -0
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +95 -0
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +33 -0
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +103 -0
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +139 -0
- package/dist/runtime/modules/asset/model/AssetRef.js +12 -0
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +172 -0
- package/dist/runtime/modules/asset/model/ProceduralTextureContract.js +24 -0
- package/dist/runtime/modules/asset/model/admission.js +117 -0
- package/dist/runtime/modules/asset/model/errors.js +6 -0
- package/dist/runtime/modules/asset/model/parts.js +27 -0
- package/dist/runtime/modules/asset/model/resourceBudget.js +10 -0
- package/dist/runtime/modules/asset/model/schema.js +150 -0
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +78 -0
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +84 -0
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +86 -0
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +81 -0
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +272 -0
- package/dist/runtime/modules/asset/production/AssetRecipe.js +91 -0
- package/dist/runtime/modules/asset/production/ProceduralTexture.js +85 -0
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +45 -0
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +590 -0
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +173 -0
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +124 -0
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +56 -0
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +6 -0
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +74 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +63 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +48 -0
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +16 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +30 -0
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +75 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +20 -0
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +34 -0
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +32 -0
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +116 -0
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +84 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +63 -0
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +16 -0
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +23 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +50 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +60 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +93 -0
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +32 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +55 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +203 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +43 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +33 -0
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +60 -0
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +23 -0
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +198 -0
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +72 -0
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +51 -0
- package/dist/runtime/modules/asset/registry/manifests/index.js +173 -0
- package/dist/runtime/modules/asset/tasks.jsonl +87 -0
- package/dist/runtime/modules/generation/README.md +9 -0
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +45 -0
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +169 -0
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +192 -0
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +167 -0
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +179 -0
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +202 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +239 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +99 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +91 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +50 -0
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +304 -0
- package/dist/runtime/modules/generation/tasks.jsonl +35 -0
- package/dist/runtime/modules/navigation/NavigationBackend.js +17 -0
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +263 -0
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +660 -0
- package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +414 -0
- package/dist/runtime/modules/rendering/README.md +7 -0
- package/dist/runtime/modules/rendering/RendererProbe.js +153 -0
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +140 -0
- package/dist/runtime/modules/rendering/captureStill.js +54 -0
- package/dist/runtime/modules/rendering/createRenderer.js +76 -0
- package/dist/runtime/modules/rendering/disposeObject3D.js +37 -0
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +74 -0
- package/dist/runtime/modules/rendering/spatial/ThreeBvhRuntime.js +107 -0
- package/dist/runtime/modules/rendering/style/StylePack.js +34 -0
- package/dist/runtime/modules/rendering/style/StyleSystem.js +173 -0
- package/dist/runtime/modules/rendering/tasks.jsonl +7 -0
- package/dist/runtime/modules/world/README.md +13 -0
- package/dist/runtime/modules/world/build/WorldBuilder.js +170 -0
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +32 -0
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +43 -0
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +68 -0
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +157 -0
- package/dist/runtime/modules/world/compiler/WorldComposer.js +201 -0
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +76 -0
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +356 -0
- package/dist/runtime/modules/world/compiler/WorldRetry.js +75 -0
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +379 -0
- package/dist/runtime/modules/world/content/blankWorld.js +35 -0
- package/dist/runtime/modules/world/content/environments.js +84 -0
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +189 -0
- package/dist/runtime/modules/world/content/magic-cabin/README.md +28 -0
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +64 -0
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +7078 -0
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +26 -0
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +20 -0
- package/dist/runtime/modules/world/content/magicCabin.js +190 -0
- package/dist/runtime/modules/world/content/monumentHall.js +154 -0
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +196 -0
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +141 -0
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +137 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +491 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +670 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +578 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +127 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +642 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +650 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +280 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +242 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +215 -0
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +192 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +36 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +351 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +490 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +505 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +101 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +435 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +169 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +245 -0
- package/dist/runtime/modules/world/errors.js +9 -0
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +50 -0
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +297 -0
- package/dist/runtime/modules/world/runtime/CommandHistory.js +111 -0
- package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +165 -0
- package/dist/runtime/modules/world/runtime/NativeNavigationGeometry.js +84 -0
- package/dist/runtime/modules/world/runtime/NativePhysicsSnapshot.js +245 -0
- package/dist/runtime/modules/world/runtime/ObjectStore.js +31 -0
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +62 -0
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +37 -0
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +240 -0
- package/dist/runtime/modules/world/runtime/SceneExtensions.js +36 -0
- package/dist/runtime/modules/world/runtime/ScenePresentation.js +101 -0
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +281 -0
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +41 -0
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +14 -0
- package/dist/runtime/modules/world/runtime/WorldCommands.js +503 -0
- package/dist/runtime/modules/world/runtime/WorldObservation.js +71 -0
- package/dist/runtime/modules/world/runtime/WorldQueries.js +340 -0
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +78 -0
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +806 -0
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +110 -0
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +130 -0
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +79 -0
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +195 -0
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +70 -0
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +115 -0
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +390 -0
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +214 -0
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +65 -0
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +244 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +147 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
- package/dist/runtime/modules/world/runtime/interaction/ManipulationActions.js +7 -0
- package/dist/runtime/modules/world/runtime/interaction/NativePhysicalTarget.js +31 -0
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +134 -0
- package/dist/runtime/modules/world/runtime/semantic/NativePhysicsState.js +89 -0
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +129 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +104 -0
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/simulation/WorldTimeline.js +110 -0
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
- package/dist/runtime/modules/world/runtime/spatial/VisualMeshBounds.js +41 -0
- package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +306 -0
- package/dist/runtime/modules/world/runtime/systems/Instrument.js +39 -0
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +806 -0
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +281 -0
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +561 -0
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1752 -0
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +527 -0
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +402 -0
- package/dist/runtime/modules/world/spec/WorldIR.js +165 -0
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +86 -0
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +51 -0
- package/dist/runtime/modules/world/spec/WorldRevision.js +231 -0
- package/dist/runtime/modules/world/spec/WorldSpec.js +86 -0
- package/dist/runtime/modules/world/tasks.jsonl +530 -0
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +254 -0
- package/dist/runtime/modules/world/verification/Finding.js +105 -0
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +73 -0
- package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
- package/dist/runtime/modules/world/verification/VisualLayoutAcceptance.js +58 -0
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +176 -0
- package/dist/runtime/modules/world/verification/WorldValidator.js +67 -0
- package/dist/runtime/package-lock.json +16071 -0
- package/dist/runtime/package.json +106 -0
- 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-DT7K9NjP.js +165 -0
- package/dist/schema-DT7K9NjP.js.map +1 -0
- package/dist/suzhouGarden-Y3hny8j6.js +6150 -0
- package/dist/suzhouGarden-Y3hny8j6.js.map +1 -0
- package/dist/version-CHc-i8ch.js +5 -0
- package/dist/version-CHc-i8ch.js.map +1 -0
- package/dist/woodlandWorkshop-DsScU-cx.js +483 -0
- package/dist/woodlandWorkshop-DsScU-cx.js.map +1 -0
- package/dist/yuanmingyuan-DsFnPzzR.js +4955 -0
- package/dist/yuanmingyuan-DsFnPzzR.js.map +1 -0
- package/package.json +75 -4
|
@@ -0,0 +1,86 @@
|
|
|
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,partName: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
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { assertFindingRevision, normalizeFinding } from '../verification/Finding.js';
|
|
2
|
+
import { normalizeWorldIR } from './WorldIR.js';
|
|
3
|
+
|
|
4
|
+
export const WORLD_REVISION_CONTEXT_SCHEMA='agentscape.world-revision-context';
|
|
5
|
+
export const WORLD_REVISION_PROPOSAL_SCHEMA='agentscape.world-revision-proposal';
|
|
6
|
+
export const WORLD_REVISION_VERSION=1;
|
|
7
|
+
|
|
8
|
+
const clean=v=>typeof v==='string'?v.trim():'';
|
|
9
|
+
const finiteVec3=v=>Array.isArray(v)&&v.length===3&&v.every(Number.isFinite)?v.map(Number):null;
|
|
10
|
+
|
|
11
|
+
const text={type:'string',minLength:1};
|
|
12
|
+
const scalar={anyOf:[{type:'string'},{type:'number'},{type:'boolean'},{type:'null'}]};
|
|
13
|
+
const strict=(properties,required=[])=>({type:'object',additionalProperties:false,properties,required});
|
|
14
|
+
const assetSchema=strict({assetId:text,query:text,prompt:text,type:text,generate:{type:'boolean'},provider:text});
|
|
15
|
+
assetSchema.anyOf=[{required:['assetId']},{required:['query']},{required:['prompt']},{required:['type']}];
|
|
16
|
+
const physicsRequirementSchema=strict({
|
|
17
|
+
bodyClass:{type:'string',enum:['transform','rigid','articulated','character','soft','cloth']},
|
|
18
|
+
requiredCapabilities:{type:'array',items:text,uniqueItems:true},
|
|
19
|
+
executionMode:{type:'string',enum:['render-only','realtime','validation-only']},
|
|
20
|
+
qualityPolicy:strict({deterministicRequired:{type:'boolean'},realtimeRequired:{type:'boolean'},fallbackPolicy:{type:'string',enum:['deny']}})
|
|
21
|
+
});
|
|
22
|
+
export const WORLD_REVISION_EDIT_TOOL_SCHEMA={oneOf:[
|
|
23
|
+
strict({kind:{type:'string',enum:['set-position']},entityId:text,position:{type:'array',items:{type:'number'},minItems:3,maxItems:3}},['kind','entityId','position']),
|
|
24
|
+
strict({kind:{type:'string',enum:['set-generation']},entityId:text,generate:{type:'boolean'}},['kind','entityId','generate']),
|
|
25
|
+
strict({kind:{type:'string',enum:['replace-asset']},entityId:text,asset:assetSchema},['kind','entityId','asset']),
|
|
26
|
+
strict({kind:{type:'string',enum:['set-initial-state']},entityId:text,state:{type:'object',additionalProperties:scalar}},['kind','entityId','state']),
|
|
27
|
+
strict({kind:{type:'string',enum:['set-capability-intent']},entityId:text,capabilities:{type:'array',items:text,uniqueItems:true}},['kind','entityId','capabilities']),
|
|
28
|
+
strict({kind:{type:'string',enum:['set-physics-requirement']},entityId:text,requirement:{anyOf:[physicsRequirementSchema,{type:'null'}]}},['kind','entityId','requirement'])
|
|
29
|
+
]};
|
|
30
|
+
export const WORLD_REVISION_REQUEST_TOOL_SCHEMA=strict({reason:{type:'string'},edits:{type:'array',items:WORLD_REVISION_EDIT_TOOL_SCHEMA,minItems:1}},['edits']);
|
|
31
|
+
export const WORLD_REVISION_PROPOSAL_TOOL_SCHEMA=strict({
|
|
32
|
+
schema:{type:'string',enum:[WORLD_REVISION_PROPOSAL_SCHEMA]},schemaVersion:{type:'integer',enum:[WORLD_REVISION_VERSION]},
|
|
33
|
+
status:{type:'string',enum:['changed-plan-required']},baseRevisionId:text,nextRevisionId:text,
|
|
34
|
+
findingIds:{type:'array',items:text,uniqueItems:true},affectedEntityIds:{type:'array',items:text,uniqueItems:true},
|
|
35
|
+
reason:text,edits:{type:'array',items:WORLD_REVISION_EDIT_TOOL_SCHEMA,minItems:1}
|
|
36
|
+
},['schema','schemaVersion','status','baseRevisionId','nextRevisionId','findingIds','affectedEntityIds','reason','edits']);
|
|
37
|
+
|
|
38
|
+
export function buildWorldRevisionContext(worldIR,findings=[]){
|
|
39
|
+
const ir=normalizeWorldIR(worldIR);
|
|
40
|
+
const normalized=(findings||[]).map((finding,index)=>normalizeFinding(finding,{index}));
|
|
41
|
+
const baseRevisionId=ir.revision.id;
|
|
42
|
+
assertFindingRevision(normalized,baseRevisionId);
|
|
43
|
+
|
|
44
|
+
const seedEntityIds=new Set(normalized.flatMap((finding)=>finding.affectedObjects||[]).filter(Boolean));
|
|
45
|
+
const contextEntityIds=new Set(seedEntityIds);
|
|
46
|
+
for(const relation of ir.spatial.relations){
|
|
47
|
+
if(seedEntityIds.has(relation.subject)||seedEntityIds.has(relation.object)){
|
|
48
|
+
contextEntityIds.add(relation.subject); contextEntityIds.add(relation.object);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for(const constraint of ir.spatial.constraints){
|
|
52
|
+
if(seedEntityIds.has(constraint.subject)||seedEntityIds.has(constraint.object)){
|
|
53
|
+
if(constraint.subject) contextEntityIds.add(constraint.subject);
|
|
54
|
+
if(constraint.object) contextEntityIds.add(constraint.object);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const knownEntityIds=new Set(ir.entities.map((entity)=>entity.id).filter(Boolean));
|
|
58
|
+
const editableEntityIds=[...seedEntityIds].filter((id)=>knownEntityIds.has(id));
|
|
59
|
+
const missingEntityIds=[...seedEntityIds].filter((id)=>!knownEntityIds.has(id));
|
|
60
|
+
return {
|
|
61
|
+
schema:WORLD_REVISION_CONTEXT_SCHEMA,schemaVersion:WORLD_REVISION_VERSION,
|
|
62
|
+
baseRevisionId,
|
|
63
|
+
findingIds:normalized.map((finding)=>finding.id),
|
|
64
|
+
findings:structuredClone(normalized),
|
|
65
|
+
affected:{
|
|
66
|
+
seedEntityIds:[...seedEntityIds],
|
|
67
|
+
contextEntityIds:[...contextEntityIds],
|
|
68
|
+
editableEntityIds,
|
|
69
|
+
missingEntityIds
|
|
70
|
+
},
|
|
71
|
+
subgraph:{
|
|
72
|
+
entities:ir.entities.filter((entity)=>entity.id&&contextEntityIds.has(entity.id)).map((entity)=>structuredClone(entity)),
|
|
73
|
+
spatial:{
|
|
74
|
+
relations:ir.spatial.relations.filter((relation)=>contextEntityIds.has(relation.subject)||contextEntityIds.has(relation.object)).map((relation)=>structuredClone(relation)),
|
|
75
|
+
constraints:ir.spatial.constraints.filter((constraint)=>contextEntityIds.has(constraint.subject)||contextEntityIds.has(constraint.object)).map((constraint)=>structuredClone(constraint))
|
|
76
|
+
},
|
|
77
|
+
interactions:ir.interactions.filter((item)=>[item.actorId,item.targetId,item.supportId].some((id)=>id&&contextEntityIds.has(id))).map((item)=>structuredClone(item)),
|
|
78
|
+
acceptance:ir.acceptance.filter((item)=>[item.targetId,item.subject,item.object].some((id)=>id&&contextEntityIds.has(id))).map((item)=>structuredClone(item))
|
|
79
|
+
},
|
|
80
|
+
rulesReviewRequired:Boolean(ir.rules.length&&contextEntityIds.size)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const normalizeEditedEntity=(context,entityId,mutate)=>{
|
|
86
|
+
const source=context.subgraph?.entities?.find((entity)=>entity.id===entityId);
|
|
87
|
+
if(!source){const error=new Error(`World revision context entity missing: ${entityId}`);error.code='WORLD_REVISION_CONTEXT_ENTITY_MISSING';throw error;}
|
|
88
|
+
const candidate=structuredClone(source);
|
|
89
|
+
mutate(candidate);
|
|
90
|
+
return normalizeWorldIR({
|
|
91
|
+
schema:'agentscape.world-ir',schemaVersion:1,
|
|
92
|
+
revision:{id:context.baseRevisionId},provenance:{source:'world-revision-normalization'},intent:{name:'World Revision'},
|
|
93
|
+
entities:[candidate],spatial:{relations:[],constraints:[]},interactions:[],rules:[],acceptance:[]
|
|
94
|
+
}).entities[0];
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export function createWorldRevisionProposal(context,{nextRevisionId,reason='bounded finding repair',edits=[]}={}){
|
|
98
|
+
if(context?.schema!==WORLD_REVISION_CONTEXT_SCHEMA||context.schemaVersion!==WORLD_REVISION_VERSION) throw new TypeError('Unsupported WorldRevision context');
|
|
99
|
+
const nextId=clean(nextRevisionId);
|
|
100
|
+
if(!nextId||nextId===context.baseRevisionId) throw new TypeError('World revision proposal requires a new nextRevisionId');
|
|
101
|
+
if(!Array.isArray(edits)) throw new TypeError('World revision edits must be an array');
|
|
102
|
+
if(!edits.length) throw new TypeError('World revision proposal requires at least one edit');
|
|
103
|
+
const editable=new Set(context.affected?.editableEntityIds||[]);
|
|
104
|
+
const seen=new Set();
|
|
105
|
+
const normalized=edits.map((edit,index)=>{
|
|
106
|
+
if(!edit||typeof edit!=='object'||Array.isArray(edit)) throw new TypeError(`World revision edit[${index}] must be an object`);
|
|
107
|
+
const kind=clean(edit.kind),entityId=clean(edit.entityId);
|
|
108
|
+
if(!entityId||!editable.has(entityId)){
|
|
109
|
+
const error=new Error(`World revision edit outside affected subgraph: ${entityId||'$missing'}`);
|
|
110
|
+
error.code='WORLD_REVISION_SCOPE_VIOLATION'; throw error;
|
|
111
|
+
}
|
|
112
|
+
const key=`${kind}:${entityId}`; if(seen.has(key)) throw new TypeError(`Duplicate world revision edit: ${key}`); seen.add(key);
|
|
113
|
+
if(kind==='set-position'){
|
|
114
|
+
const position=finiteVec3(edit.position); if(!position) throw new TypeError(`World revision edit[${index}] requires finite position[3]`);
|
|
115
|
+
return {kind,entityId,position};
|
|
116
|
+
}
|
|
117
|
+
if(kind==='set-generation'){
|
|
118
|
+
if(typeof edit.generate!=='boolean') throw new TypeError(`World revision edit[${index}] requires boolean generate`);
|
|
119
|
+
return {kind,entityId,generate:edit.generate};
|
|
120
|
+
}
|
|
121
|
+
if(kind==='replace-asset'){
|
|
122
|
+
if(!edit.asset||typeof edit.asset!=='object'||Array.isArray(edit.asset)) throw new TypeError(`World revision edit[${index}] requires asset object`);
|
|
123
|
+
const entity=normalizeEditedEntity(context,entityId,(candidate)=>{candidate.asset=structuredClone(edit.asset);});
|
|
124
|
+
return {kind,entityId,asset:structuredClone(entity.asset)};
|
|
125
|
+
}
|
|
126
|
+
if(kind==='set-initial-state'){
|
|
127
|
+
if(!edit.state||typeof edit.state!=='object'||Array.isArray(edit.state)) throw new TypeError(`World revision edit[${index}] requires state object`);
|
|
128
|
+
const entity=normalizeEditedEntity(context,entityId,(candidate)=>{candidate.initialState=structuredClone(edit.state);});
|
|
129
|
+
return {kind,entityId,state:structuredClone(entity.initialState)};
|
|
130
|
+
}
|
|
131
|
+
if(kind==='set-capability-intent'){
|
|
132
|
+
if(!Array.isArray(edit.capabilities)) throw new TypeError(`World revision edit[${index}] requires capabilities array`);
|
|
133
|
+
const entity=normalizeEditedEntity(context,entityId,(candidate)=>{candidate.capabilityIntent=structuredClone(edit.capabilities);});
|
|
134
|
+
return {kind,entityId,capabilities:[...entity.capabilityIntent]};
|
|
135
|
+
}
|
|
136
|
+
if(kind==='set-physics-requirement'){
|
|
137
|
+
if(edit.requirement!==null&&(!edit.requirement||typeof edit.requirement!=='object'||Array.isArray(edit.requirement))) throw new TypeError(`World revision edit[${index}] requires requirement object or null`);
|
|
138
|
+
const entity=normalizeEditedEntity(context,entityId,(candidate)=>{
|
|
139
|
+
if(edit.requirement===null) delete candidate.physicsRequirement;
|
|
140
|
+
else candidate.physicsRequirement=structuredClone(edit.requirement);
|
|
141
|
+
});
|
|
142
|
+
return {kind,entityId,requirement:entity.physicsRequirement?structuredClone(entity.physicsRequirement):null};
|
|
143
|
+
}
|
|
144
|
+
const error=new TypeError(`Unsupported world revision edit kind: ${kind}`); error.code='WORLD_REVISION_EDIT_UNSUPPORTED'; throw error;
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
schema:WORLD_REVISION_PROPOSAL_SCHEMA,schemaVersion:WORLD_REVISION_VERSION,
|
|
148
|
+
status:'changed-plan-required',baseRevisionId:context.baseRevisionId,nextRevisionId:nextId,
|
|
149
|
+
findingIds:[...(context.findingIds||[])],affectedEntityIds:[...(context.affected?.editableEntityIds||[])],
|
|
150
|
+
reason:clean(reason)||'bounded finding repair',edits:normalized
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
const REVISION_EDIT_DOMAINS={
|
|
156
|
+
'set-initial-state':['state','acceptance'],
|
|
157
|
+
'set-position':['transform','layout','spatial','physics','navigation','acceptance'],
|
|
158
|
+
'set-generation':['asset','generation','layout','behavior','physics','acceptance'],
|
|
159
|
+
'replace-asset':['asset','generation','layout','behavior','physics','spatial','navigation','acceptance'],
|
|
160
|
+
'set-capability-intent':['behavior','acceptance'],
|
|
161
|
+
'set-physics-requirement':['physics','acceptance']
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export function classifyWorldRevisionImpact(proposal={}){
|
|
165
|
+
const edits=Array.isArray(proposal.edits)?proposal.edits:[];
|
|
166
|
+
const editKinds=[...new Set(edits.map((edit)=>clean(edit.kind)).filter(Boolean))];
|
|
167
|
+
const affectedEntityIds=[...new Set(edits.map((edit)=>clean(edit.entityId)).filter(Boolean))];
|
|
168
|
+
const domains=[...new Set(editKinds.flatMap((kind)=>REVISION_EDIT_DOMAINS[kind]||['unknown']))];
|
|
169
|
+
const stateOnly=edits.length>0 && domains.every((domain)=>['state','acceptance'].includes(domain));
|
|
170
|
+
const behaviorOnly=edits.length>0 && domains.every((domain)=>['behavior','acceptance'].includes(domain));
|
|
171
|
+
const physicsOnly=edits.length>0 && domains.every((domain)=>['physics','acceptance'].includes(domain));
|
|
172
|
+
const singlePosition=edits.length===1 && editKinds.length===1 && editKinds[0]==='set-position';
|
|
173
|
+
return {
|
|
174
|
+
mode:stateOnly?'incremental-state':behaviorOnly?'incremental-behavior':physicsOnly?'incremental-physics':singlePosition?'incremental-position':'full',
|
|
175
|
+
editKinds,affectedEntityIds,domains
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function applyWorldRevisionProposal(worldIR,proposal,{acceptChangedPlan=false}={}){
|
|
180
|
+
const ir=normalizeWorldIR(worldIR);
|
|
181
|
+
if(proposal?.schema!==WORLD_REVISION_PROPOSAL_SCHEMA||proposal.schemaVersion!==WORLD_REVISION_VERSION) throw new TypeError('Unsupported WorldRevision proposal');
|
|
182
|
+
if(proposal.baseRevisionId!==ir.revision.id){ const error=new Error(`World revision base mismatch: ${proposal.baseRevisionId} != ${ir.revision.id}`); error.code='WORLD_REVISION_BASE_MISMATCH'; throw error; }
|
|
183
|
+
if(acceptChangedPlan!==true){ const error=new Error('World revision proposal requires explicit changed-plan acceptance'); error.code='WORLD_REVISION_CHANGE_NOT_ACCEPTED'; throw error; }
|
|
184
|
+
const allowed=new Set(proposal.affectedEntityIds||[]);
|
|
185
|
+
const next=structuredClone(ir);
|
|
186
|
+
let changed=false;
|
|
187
|
+
for(const edit of proposal.edits||[]){
|
|
188
|
+
if(!allowed.has(edit.entityId)){ const error=new Error(`World revision edit outside accepted scope: ${edit.entityId}`); error.code='WORLD_REVISION_SCOPE_VIOLATION'; throw error; }
|
|
189
|
+
const entity=next.entities.find((item)=>item.id===edit.entityId);
|
|
190
|
+
if(!entity){ const error=new Error(`World revision entity missing: ${edit.entityId}`); error.code='WORLD_REVISION_ENTITY_MISSING'; throw error; }
|
|
191
|
+
if(edit.kind==='set-position'){
|
|
192
|
+
if(JSON.stringify(entity.transform?.position||null)!==JSON.stringify(edit.position)){ entity.transform||={}; entity.transform.position=[...edit.position]; changed=true; }
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if(edit.kind==='set-generation'){
|
|
196
|
+
if(entity.asset.generate!==edit.generate){ entity.asset.generate=edit.generate; changed=true; }
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if(edit.kind==='replace-asset'){
|
|
200
|
+
if(JSON.stringify(entity.asset)!==JSON.stringify(edit.asset)){ entity.asset=structuredClone(edit.asset); changed=true; }
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if(edit.kind==='set-initial-state'){
|
|
204
|
+
if(JSON.stringify(entity.initialState)!==JSON.stringify(edit.state)){ entity.initialState=structuredClone(edit.state); changed=true; }
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if(edit.kind==='set-capability-intent'){
|
|
208
|
+
if(JSON.stringify(entity.capabilityIntent)!==JSON.stringify(edit.capabilities)){ entity.capabilityIntent=[...edit.capabilities]; changed=true; }
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if(edit.kind==='set-physics-requirement'){
|
|
212
|
+
const current=entity.physicsRequirement||null;
|
|
213
|
+
if(JSON.stringify(current)!==JSON.stringify(edit.requirement)){
|
|
214
|
+
if(edit.requirement===null) delete entity.physicsRequirement;
|
|
215
|
+
else entity.physicsRequirement=structuredClone(edit.requirement);
|
|
216
|
+
changed=true;
|
|
217
|
+
}
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const error=new TypeError(`Unsupported world revision edit kind: ${edit.kind}`); error.code='WORLD_REVISION_EDIT_UNSUPPORTED'; throw error;
|
|
221
|
+
}
|
|
222
|
+
if(!changed){ const error=new Error('World revision proposal does not change the plan'); error.code='WORLD_REVISION_NO_CHANGE'; throw error; }
|
|
223
|
+
next.revision={id:proposal.nextRevisionId,parentId:ir.revision.id,reason:proposal.reason};
|
|
224
|
+
next.provenance={
|
|
225
|
+
...next.provenance,
|
|
226
|
+
source:'finding-revision',
|
|
227
|
+
sourceId:proposal.findingIds?.[0] || ir.revision.id,
|
|
228
|
+
evidenceRefs:[...new Set([...(next.provenance.evidenceRefs||[]),...(proposal.findingIds||[])])]
|
|
229
|
+
};
|
|
230
|
+
return normalizeWorldIR(next);
|
|
231
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export const WORLD_SPEC_SCHEMA = {
|
|
2
|
+
type:'object',additionalProperties:false,
|
|
3
|
+
properties:{
|
|
4
|
+
name:{type:'string',description:'Human-readable world name.'},description:{type:'string',description:'World intent and task context; not executable truth.'},
|
|
5
|
+
generation:{type:'object',additionalProperties:false,properties:{provider:{type:'string',description:'Generator provider for missing assets.'},generate:{type:'boolean',description:'Allow generation only when reuse cannot resolve an asset.'}}},
|
|
6
|
+
assets:{type:'array',items:{type:'object',additionalProperties:false,properties:{
|
|
7
|
+
id:{type:'string',description:'Instance id inside the new world, e.g. table_01. This is not the asset catalog id.'},assetId:{type:'string',description:'Existing registered asset id, normally copied from searchAssets result.id when reusing an asset.'},query:{type:'string',description:'Asset-library lookup query when assetId is not known.'},prompt:{type:'string',description:'Generator prompt for a missing asset; does not imply verification.'},type:{type:'string',description:'Semantic asset type used for reuse lookup or generation intent.'},
|
|
8
|
+
position:{type:'array',items:{type:'number'},minItems:3,maxItems:3,description:'Optional exact world position. Omit unless the user explicitly constrains coordinates; Runtime composes omitted positions.'},generate:{type:'boolean',description:'Whether this request may generate if reuse fails.'},provider:{type:'string',description:'Per-asset generator provider override.'}
|
|
9
|
+
}}},
|
|
10
|
+
relations:{type:'array',items:{type:'object',additionalProperties:false,required:['subject','predicate','object'],properties:{
|
|
11
|
+
subject:{type:'string',description:'World instance id being placed/moved.'},predicate:{type:'string',enum:['ON','NEAR','INSIDE']},object:{type:'string',description:'World instance id used as support/near target.'},surfaceId:{type:'string'},receptacleId:{type:'string'},distance:{type:'number',exclusiveMinimum:0,description:'Optional center distance for NEAR. Omit to let Runtime derive safe spacing from collider footprints.'}
|
|
12
|
+
}}}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const finiteVec3 = (value, fallback = null) => {
|
|
17
|
+
if (value == null && fallback) return [...fallback];
|
|
18
|
+
if (!Array.isArray(value) || value.length !== 3 || !value.every(Number.isFinite)) return null;
|
|
19
|
+
return value.map(Number);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const clean = (value) => typeof value === 'string' ? value.trim() : '';
|
|
23
|
+
|
|
24
|
+
const assertKnownKeys = (value, allowed, label) => {
|
|
25
|
+
for (const key of Object.keys(value || {})) {
|
|
26
|
+
if (!allowed.has(key)) throw new TypeError(`${label} unknown field: ${key}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const TOP_LEVEL_KEYS=new Set(['name','description','generation','assets','relations']);
|
|
31
|
+
const GENERATION_KEYS=new Set(['provider','generate']);
|
|
32
|
+
const ASSET_KEYS=new Set(['id','assetId','query','prompt','type','position','generate','provider']);
|
|
33
|
+
const RELATION_KEYS=new Set(['subject','predicate','object','surfaceId','receptacleId','distance']);
|
|
34
|
+
|
|
35
|
+
export function normalizeWorldSpec(input = {}) {
|
|
36
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) throw new TypeError('WorldSpec must be an object');
|
|
37
|
+
assertKnownKeys(input,TOP_LEVEL_KEYS,'WorldSpec');
|
|
38
|
+
const generation = input.generation && typeof input.generation === 'object' ? input.generation : {};
|
|
39
|
+
assertKnownKeys(generation,GENERATION_KEYS,'WorldSpec generation');
|
|
40
|
+
const defaultProvider = clean(generation.provider) || null;
|
|
41
|
+
const defaultGenerate = generation.generate === true;
|
|
42
|
+
const ids = new Set();
|
|
43
|
+
const assets = (input.assets || []).map((request, index) => {
|
|
44
|
+
if (!request || typeof request !== 'object' || Array.isArray(request)) throw new TypeError(`WorldSpec asset[${index}] must be an object`);
|
|
45
|
+
assertKnownKeys(request,ASSET_KEYS,`WorldSpec asset[${index}]`);
|
|
46
|
+
const assetId = clean(request.assetId) || null;
|
|
47
|
+
const type = clean(request.type) || null;
|
|
48
|
+
const prompt = clean(request.prompt) || null;
|
|
49
|
+
const query = clean(request.query) || prompt || type || assetId;
|
|
50
|
+
if (!query) throw new TypeError(`WorldSpec asset[${index}] requires assetId, query, prompt, or type`);
|
|
51
|
+
const id = clean(request.id) || null;
|
|
52
|
+
if (id && ids.has(id)) throw new TypeError(`WorldSpec duplicate instance id: ${id}`);
|
|
53
|
+
if (id) ids.add(id);
|
|
54
|
+
const position = request.position == null ? null : finiteVec3(request.position);
|
|
55
|
+
if (request.position != null && !position) throw new TypeError(`WorldSpec asset[${index}] position requires finite [3]`);
|
|
56
|
+
const provider = clean(request.provider) || defaultProvider;
|
|
57
|
+
return {
|
|
58
|
+
...(id ? { id } : {}),
|
|
59
|
+
...(assetId ? { assetId } : {}),
|
|
60
|
+
query,
|
|
61
|
+
...(type ? { type } : {}),
|
|
62
|
+
...(prompt ? { prompt } : {}),
|
|
63
|
+
...(position ? { position } : {}),
|
|
64
|
+
generate: request.generate == null ? defaultGenerate : request.generate === true,
|
|
65
|
+
...(provider ? { provider } : {})
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const relations = (input.relations || []).map((relation, index) => {
|
|
69
|
+
if (!relation || typeof relation !== 'object' || Array.isArray(relation)) throw new TypeError(`WorldSpec relation[${index}] must be an object`);
|
|
70
|
+
assertKnownKeys(relation,RELATION_KEYS,`WorldSpec relation[${index}]`);
|
|
71
|
+
const subject = clean(relation.subject), predicate = clean(relation.predicate).toUpperCase(), object = clean(relation.object);
|
|
72
|
+
if (!subject || !predicate || !object) throw new TypeError(`WorldSpec relation[${index}] requires subject, predicate, object`);
|
|
73
|
+
if (!['ON','NEAR','INSIDE'].includes(predicate)) throw new TypeError(`WorldSpec relation[${index}] unsupported predicate: ${predicate}`);
|
|
74
|
+
const distance = relation.distance == null ? null : Number(relation.distance);
|
|
75
|
+
if (distance != null && (!Number.isFinite(distance) || distance <= 0)) throw new TypeError(`WorldSpec relation[${index}] distance must be positive finite`);
|
|
76
|
+
return { subject, predicate, object, ...(clean(relation.surfaceId) ? { surfaceId:clean(relation.surfaceId) } : {}), ...(clean(relation.receptacleId) ? { receptacleId:clean(relation.receptacleId) } : {}), ...(distance != null ? { distance } : {}) };
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
schema: 1,
|
|
80
|
+
name: clean(input.name) || 'Generated World',
|
|
81
|
+
description: clean(input.description),
|
|
82
|
+
generation: { ...(defaultProvider ? { provider:defaultProvider } : {}), generate:defaultGenerate },
|
|
83
|
+
assets,
|
|
84
|
+
relations
|
|
85
|
+
};
|
|
86
|
+
}
|