agentscape3d-engine 0.0.0-stage → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/cli.mjs +53 -0
- package/dist/AssetCompiler-A99wKf7H.js +2424 -0
- package/dist/AssetCompiler-A99wKf7H.js.map +1 -0
- package/dist/AssetInputContracts-uKYeQu-X.js +245 -0
- package/dist/AssetInputContracts-uKYeQu-X.js.map +1 -0
- package/dist/AssetRecipe-DCaLLXvG.js +67 -0
- package/dist/AssetRecipe-DCaLLXvG.js.map +1 -0
- package/dist/BrowserCodeWorker.js +53850 -0
- package/dist/BrowserCodeWorker.js.map +1 -0
- package/dist/KinematicHypothesisScreen-4v7GBwdv.js +241 -0
- package/dist/KinematicHypothesisScreen-4v7GBwdv.js.map +1 -0
- package/dist/SceneSerializer-CLCzQjL_.js +350 -0
- package/dist/SceneSerializer-CLCzQjL_.js.map +1 -0
- package/dist/StylePack-CD_BC-Mv.js +6317 -0
- package/dist/StylePack-CD_BC-Mv.js.map +1 -0
- package/dist/WorldArchive-dYf1OpSe.js +417 -0
- package/dist/WorldArchive-dYf1OpSe.js.map +1 -0
- package/dist/WorldIO-Dqz4MqTQ.js +149 -0
- package/dist/WorldIO-Dqz4MqTQ.js.map +1 -0
- package/dist/blankWorld-OoOvN_IK.js +75 -0
- package/dist/blankWorld-OoOvN_IK.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-B3HCflvO.js +128 -0
- package/dist/disposeObject3D-B3HCflvO.js.map +1 -0
- package/dist/environments-B1WaICAN.js +4197 -0
- package/dist/environments-B1WaICAN.js.map +1 -0
- package/dist/gltfIO-BMK1hc2D.js +9 -0
- package/dist/gltfIO-BMK1hc2D.js.map +1 -0
- package/dist/grandUrbanBlock-Bdjgc6ZT.js +515 -0
- package/dist/grandUrbanBlock-Bdjgc6ZT.js.map +1 -0
- package/dist/index.d.ts +275 -0
- package/dist/index.js +16239 -0
- package/dist/index.js.map +1 -0
- package/dist/magicCabin-DPQi_jh-.js +11019 -0
- package/dist/magicCabin-DPQi_jh-.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +1 -0
- package/dist/monumentHall-IOLbRZQC.js +403 -0
- package/dist/monumentHall-IOLbRZQC.js.map +1 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +26 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/ruinedCourtyard-BtaF_aOi.js +696 -0
- package/dist/ruinedCourtyard-BtaF_aOi.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 +8 -0
- package/dist/runtime/application/buildTaskObservation.js +117 -0
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +46 -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 +72 -0
- package/dist/runtime/application/createSession.js +66 -0
- package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
- package/dist/runtime/application/generation/GenerationOrchestrator.js +629 -0
- package/dist/runtime/application/generation/GenerationRuntime.js +214 -0
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +285 -0
- package/dist/runtime/application/native-scene/CodeProject.js +119 -0
- package/dist/runtime/application/native-scene/CodeProjectModules.js +128 -0
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +62 -0
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
- package/dist/runtime/application/native-scene/NativeSceneHost.js +319 -0
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
- package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
- package/dist/runtime/application/object-forge/SceneObjectForge.js +232 -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 +79 -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 +45 -0
- package/dist/runtime/application/scene/SceneEditService.js +144 -0
- package/dist/runtime/application/scene/SceneFacade.js +261 -0
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +40 -0
- package/dist/runtime/application/scene/SceneJobController.js +229 -0
- package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
- package/dist/runtime/application/scene/ScenePackage.js +162 -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 +87 -0
- package/dist/runtime/application/scene/WorldDirectory.js +20 -0
- package/dist/runtime/application/scene/WorldDocument.js +74 -0
- package/dist/runtime/application/scene/WorldIO.js +103 -0
- package/dist/runtime/application/scene/WorldStorage.js +137 -0
- package/dist/runtime/application/skills/SkillRegistry.js +189 -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 +174 -0
- package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
- package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
- package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +77 -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 +132 -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 +150 -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 +80 -0
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +58 -0
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +190 -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 +65 -0
- package/dist/runtime/apps/mcp-server/registerTools.js +225 -0
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
- package/dist/runtime/apps/mcp-server/security.js +21 -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/WorldDiskStorage.js +51 -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/foundation/EventBus.js +18 -0
- package/dist/runtime/foundation/JsonGateway.js +47 -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 +399 -0
- package/dist/runtime/modules/asset/README.md +54 -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 +100 -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/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 +47 -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 +245 -0
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +651 -0
- package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +410 -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/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 +80 -0
- package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +150 -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 +207 -0
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +246 -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 +502 -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 +665 -0
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +107 -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 +305 -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 +222 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +130 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +120 -0
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +102 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +99 -0
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
- package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +125 -0
- package/dist/runtime/modules/world/runtime/systems/Instrument.js +38 -0
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +728 -0
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +469 -0
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1673 -0
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +457 -0
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +284 -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 +69 -0
- package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +158 -0
- package/dist/runtime/modules/world/verification/WorldValidator.js +65 -0
- package/dist/runtime/package-lock.json +16048 -0
- package/dist/runtime/package.json +105 -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-BWpTl0Wj.js +359 -0
- package/dist/schema-BWpTl0Wj.js.map +1 -0
- package/dist/suzhouGarden-H9tiPgxq.js +6150 -0
- package/dist/suzhouGarden-H9tiPgxq.js.map +1 -0
- package/dist/woodlandWorkshop-D6zzSbHr.js +483 -0
- package/dist/woodlandWorkshop-D6zzSbHr.js.map +1 -0
- package/dist/yuanmingyuan-D6IHqjZ-.js +4955 -0
- package/dist/yuanmingyuan-D6IHqjZ-.js.map +1 -0
- package/package.json +70 -4
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { ObjectStore } from '../runtime/ObjectStore.js';
|
|
3
|
+
import { PhysicsSystem } from '../runtime/systems/PhysicsSystem.js';
|
|
4
|
+
import { RapierPhysicsBackend } from '../../physics/RapierPhysicsBackend.js';
|
|
5
|
+
import { disposeObject3D } from '../../rendering/disposeObject3D.js';
|
|
6
|
+
|
|
7
|
+
const finiteVec3 = (v) => [v.x, v.y, v.z].every(Number.isFinite);
|
|
8
|
+
const finiteQuat = (q) => [q.x, q.y, q.z, q.w].every(Number.isFinite);
|
|
9
|
+
const angularDelta = (a, b) => 2 * Math.acos(Math.min(1, Math.abs(a.dot(b))));
|
|
10
|
+
const axisVector = (axis = [1, 0, 0]) => new THREE.Vector3(...axis).normalize();
|
|
11
|
+
const wrappedAngle = (angle) => Math.atan2(Math.sin(angle), Math.cos(angle));
|
|
12
|
+
const failure = (stage, code, details = {}) => ({ stage, code, ...details });
|
|
13
|
+
|
|
14
|
+
function jointCoordinate(node, reference, part) {
|
|
15
|
+
const axis = reference.axis;
|
|
16
|
+
if (part.joint.type === 'prismatic') {
|
|
17
|
+
return (node.position.x-reference.position.x)*axis.x + (node.position.y-reference.position.y)*axis.y + (node.position.z-reference.position.z)*axis.z;
|
|
18
|
+
}
|
|
19
|
+
const delta = node.quaternion.clone().multiply(reference.inverseRotation).normalize();
|
|
20
|
+
return wrappedAngle(2 * Math.atan2(delta.x*axis.x + delta.y*axis.y + delta.z*axis.z, delta.w));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function penetrationMap(physics, instanceId, partName, refresh = false) {
|
|
24
|
+
return new Map(physics.articulationPenetrations(instanceId, partName, { refresh }).map((item) => [item.key, item]));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class ArticulationVerifier {
|
|
28
|
+
constructor({
|
|
29
|
+
assetRegistry,
|
|
30
|
+
assetLoader,
|
|
31
|
+
physicsFactory = () => new PhysicsSystem({ backend:new RapierPhysicsBackend() }),
|
|
32
|
+
steps = 180,
|
|
33
|
+
dt = 1 / 60,
|
|
34
|
+
prismaticTolerance = 0.03,
|
|
35
|
+
revoluteTolerance = 0.08,
|
|
36
|
+
movementTolerance = 0.01,
|
|
37
|
+
collisionTolerance = 0.005,
|
|
38
|
+
stallWindow = 30,
|
|
39
|
+
stallTolerance = 0.002
|
|
40
|
+
} = {}) {
|
|
41
|
+
if (!assetRegistry?.getManifest) throw new TypeError('ArticulationVerifier requires AssetRegistry');
|
|
42
|
+
if (!assetLoader?.instantiate) throw new TypeError('ArticulationVerifier requires AssetLoader');
|
|
43
|
+
this.assetRegistry = assetRegistry;
|
|
44
|
+
this.assetLoader = assetLoader;
|
|
45
|
+
this.physicsFactory = physicsFactory;
|
|
46
|
+
this.steps = steps;
|
|
47
|
+
this.dt = dt;
|
|
48
|
+
this.prismaticTolerance = prismaticTolerance;
|
|
49
|
+
this.revoluteTolerance = revoluteTolerance;
|
|
50
|
+
this.movementTolerance = movementTolerance;
|
|
51
|
+
this.collisionTolerance = collisionTolerance;
|
|
52
|
+
this.stallWindow = stallWindow;
|
|
53
|
+
this.stallTolerance = stallTolerance;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async verify(assetId,{requireRegistration=false,manifest:override=null,instantiate=null,verifyRigidBody=false,requireSettled=false}={}) {
|
|
57
|
+
const manifest = override || this.assetRegistry.getManifest(assetId);
|
|
58
|
+
const parts = Object.entries(manifest.parts || {}).filter(([, part]) => part.joint && part.joint.type!=='fixed' && part.physics && (Object.keys(part.targets || {}).length || part.joint.limits?.length===2));
|
|
59
|
+
if (!parts.length && !requireRegistration) return { ok: true, assetId, tested: 0, parts: [], note: 'no executable articulation' };
|
|
60
|
+
|
|
61
|
+
const { object } = await (instantiate ? instantiate() : this.assetLoader.instantiate(assetId));
|
|
62
|
+
const physics = this.physicsFactory();
|
|
63
|
+
const store = new ObjectStore();
|
|
64
|
+
const instanceId = `verify_${assetId}`;
|
|
65
|
+
store.add(instanceId, { id: instanceId, assetId, object, manifest, state: {} });
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
await physics.init();
|
|
69
|
+
if(requireRegistration && (!physics.hasCapability('rigid-body') || !physics.hasCapability('collision'))) return {ok:false,assetId,tested:0,parts:[],physicsRegistered:false,reason:'PHYSICS_CAPABILITY_UNAVAILABLE'};
|
|
70
|
+
physics.addObject(instanceId, manifest, object);
|
|
71
|
+
const reports = [];
|
|
72
|
+
for (const [partName, part] of parts) reports.push(this.verifyPart({ physics, store, object, instanceId, partName, part, requireSettled }));
|
|
73
|
+
let rigidBody=null;
|
|
74
|
+
if(verifyRigidBody && !parts.length) {
|
|
75
|
+
const body=physics.manipulationBody(instanceId);
|
|
76
|
+
let exercised=true,displacement=0;
|
|
77
|
+
if(body.body==='dynamic') {
|
|
78
|
+
const bounds=new THREE.Box3().setFromObject(object),center=bounds.getCenter(new THREE.Vector3());
|
|
79
|
+
physics.addEnvironment([{shape:'box',halfExtents:[10,.1,10],translation:[center.x,bounds.min.y-.1,center.z]}]);
|
|
80
|
+
const before=physics.getPosition(instanceId);
|
|
81
|
+
exercised=physics.applyImpulse(instanceId,[Math.min(body.mass || 1,100)*.5,0,0]);
|
|
82
|
+
for(let step=0;step<15;step++) physics.step(this.dt,store);
|
|
83
|
+
const after=physics.getPosition(instanceId);
|
|
84
|
+
displacement=Math.hypot(...after.map((value,index)=>value-before[index]));
|
|
85
|
+
exercised=exercised && after.every(Number.isFinite) && Math.abs(after[0]-before[0])>1e-5;
|
|
86
|
+
}
|
|
87
|
+
rigidBody={ok:body.registered && body.colliderCount>0 && exercised,colliderCount:body.colliderCount,body:body.body,displacement};
|
|
88
|
+
}
|
|
89
|
+
return { ok: reports.every((report) => report.ok) && (!rigidBody || rigidBody.ok), assetId, tested: reports.length, parts: reports,
|
|
90
|
+
...(rigidBody?{rigidBody}:{}),physicsRegistered:Boolean(physics.getPosition(instanceId)) };
|
|
91
|
+
} finally {
|
|
92
|
+
physics.dispose();
|
|
93
|
+
disposeObject3D(object);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
verifyPart({ physics, store, object, instanceId, partName, part, requireSettled=false }) {
|
|
98
|
+
const node = object.getObjectByName(part.node);
|
|
99
|
+
if (!node) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
part: partName,
|
|
103
|
+
node: part.node,
|
|
104
|
+
failures: [failure('PRE_CONDITION', 'MISSING_NODE', { node:part.node })]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const reference = {
|
|
109
|
+
position:node.position.clone(),
|
|
110
|
+
rotation:node.quaternion.clone(),
|
|
111
|
+
inverseRotation:node.quaternion.clone().invert(),
|
|
112
|
+
axis:axisVector(part.joint.axis)
|
|
113
|
+
};
|
|
114
|
+
const declared=Object.entries(part.targets || {});
|
|
115
|
+
const probes=declared.length ? declared : [['probe',part.joint.limits.reduce((a,b)=>Math.abs(a)>Math.abs(b)?a:b)],['return',0]];
|
|
116
|
+
const actions = probes.sort((a, b) => Math.abs(b[1]) - Math.abs(a[1]));
|
|
117
|
+
const referencePenetrations = penetrationMap(physics, instanceId, partName, true);
|
|
118
|
+
const reports = [];
|
|
119
|
+
for (const [action, target] of actions) reports.push(this.verifyAction({
|
|
120
|
+
physics, store, node, reference, referencePenetrations, instanceId, partName, part, action, target,requireSettled
|
|
121
|
+
}));
|
|
122
|
+
|
|
123
|
+
const zeroAction = actions.find(([, target]) => Math.abs(target) <= 1e-8);
|
|
124
|
+
const returnPositionDelta = node.position.distanceTo(reference.position);
|
|
125
|
+
const returnRotationDelta = angularDelta(node.quaternion, reference.rotation);
|
|
126
|
+
const returnTolerance = part.joint.type === 'prismatic' ? this.prismaticTolerance : this.revoluteTolerance;
|
|
127
|
+
const returnMovement = part.joint.type === 'prismatic' ? returnPositionDelta : returnRotationDelta;
|
|
128
|
+
const reversibility = zeroAction
|
|
129
|
+
? { checked:true, ok:returnMovement <= returnTolerance, action:zeroAction[0], positionDelta:returnPositionDelta, rotationDelta:returnRotationDelta }
|
|
130
|
+
: { checked:false, ok:true };
|
|
131
|
+
const failures = reversibility.ok ? [] : [failure('RETURN', 'RETURN_FAILED', { movement:returnMovement, tolerance:returnTolerance })];
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
ok: reports.every((report) => report.ok) && reversibility.ok,
|
|
135
|
+
part: partName,
|
|
136
|
+
node: part.node,
|
|
137
|
+
jointType: part.joint.type,
|
|
138
|
+
limits: part.joint.limits ? [...part.joint.limits] : null,
|
|
139
|
+
actions: reports,
|
|
140
|
+
reversibility,
|
|
141
|
+
baselinePenetrations:[...referencePenetrations.values()],
|
|
142
|
+
failures
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
verifyAction({ physics, store, node, reference, referencePenetrations, instanceId, partName, part, action, target,requireSettled=false }) {
|
|
147
|
+
const tolerance = part.joint.type === 'prismatic' ? this.prismaticTolerance : this.revoluteTolerance;
|
|
148
|
+
const failures = [];
|
|
149
|
+
const limits = part.joint.limits || [];
|
|
150
|
+
if (!Number.isFinite(target)) failures.push(failure('PRE_CONDITION', 'TARGET_NON_FINITE', { target }));
|
|
151
|
+
if (limits.length === 2 && Number.isFinite(target) && (target < limits[0] - 1e-8 || target > limits[1] + 1e-8)) {
|
|
152
|
+
failures.push(failure('PRE_CONDITION', 'TARGET_OUT_OF_LIMITS', { target, limits:[...limits] }));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const beforePosition = node.position.clone();
|
|
156
|
+
const beforeRotation = node.quaternion.clone();
|
|
157
|
+
const initialCoordinate = jointCoordinate(node, reference, part);
|
|
158
|
+
const initialError = Number.isFinite(target) ? Math.abs(wrappedAngleIfNeeded(part, initialCoordinate - target)) : Infinity;
|
|
159
|
+
const baseline = referencePenetrations;
|
|
160
|
+
const collisions = new Map();
|
|
161
|
+
const coordinates = [initialCoordinate];
|
|
162
|
+
let finite = finiteVec3(node.position) && finiteQuat(node.quaternion);
|
|
163
|
+
let accepted = false;
|
|
164
|
+
|
|
165
|
+
if (!failures.length) {
|
|
166
|
+
accepted = physics.setArticulationTarget(instanceId, partName, target);
|
|
167
|
+
if (!accepted) failures.push(failure('PRE_CONDITION', 'TARGET_REJECTED', { target }));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let stepsRun = 0;
|
|
171
|
+
if (accepted) {
|
|
172
|
+
for (let i = 0; i < this.steps; i++) {
|
|
173
|
+
physics.step(this.dt, store);
|
|
174
|
+
stepsRun += 1;
|
|
175
|
+
finite = finiteVec3(node.position) && finiteQuat(node.quaternion);
|
|
176
|
+
if (!finite) {
|
|
177
|
+
failures.push(failure('EXECUTION', 'NON_FINITE_TRANSFORM', { step:i + 1 }));
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
coordinates.push(jointCoordinate(node, reference, part));
|
|
181
|
+
for (const hit of physics.articulationPenetrations(instanceId, partName)) {
|
|
182
|
+
const baseDepth = baseline.get(hit.key)?.depth || 0;
|
|
183
|
+
const regression = hit.depth - baseDepth;
|
|
184
|
+
if (regression > this.collisionTolerance) {
|
|
185
|
+
const previous = collisions.get(hit.key);
|
|
186
|
+
if (!previous || regression > previous.regression) collisions.set(hit.key, { ...hit, baseDepth, regression, step:i + 1 });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (collisions.size) failures.push(failure('EXECUTION', 'COLLISION_REGRESSION', { collisions:[...collisions.values()] }));
|
|
193
|
+
let minCoordinate = Infinity;
|
|
194
|
+
let maxCoordinate = -Infinity;
|
|
195
|
+
for (const coordinate of coordinates) { minCoordinate = Math.min(minCoordinate, coordinate); maxCoordinate = Math.max(maxCoordinate, coordinate); }
|
|
196
|
+
if (limits.length === 2 && finite && (minCoordinate < limits[0] - tolerance || maxCoordinate > limits[1] + tolerance)) {
|
|
197
|
+
failures.push(failure('EXECUTION', 'LIMIT_VIOLATION', { minCoordinate, maxCoordinate, limits:[...limits], tolerance }));
|
|
198
|
+
}
|
|
199
|
+
const finalCoordinate = coordinates.at(-1);
|
|
200
|
+
const targetError = Number.isFinite(target) && Number.isFinite(finalCoordinate)
|
|
201
|
+
? Math.abs(wrappedAngleIfNeeded(part, finalCoordinate - target))
|
|
202
|
+
: Infinity;
|
|
203
|
+
const alreadyAtTarget = initialError <= tolerance;
|
|
204
|
+
const positionDelta = node.position.distanceTo(beforePosition);
|
|
205
|
+
const rotationDelta = angularDelta(node.quaternion, beforeRotation);
|
|
206
|
+
const movement = part.joint.type === 'prismatic' ? positionDelta : rotationDelta;
|
|
207
|
+
const moved = movement > this.movementTolerance;
|
|
208
|
+
const window = Math.min(this.stallWindow, Math.max(0, coordinates.length - 1));
|
|
209
|
+
const recentMovement = window > 0 ? Math.abs(wrappedAngleIfNeeded(part, finalCoordinate - coordinates[coordinates.length - 1 - window])) : 0;
|
|
210
|
+
const stalled = accepted && finite && !alreadyAtTarget && targetError > tolerance && recentMovement < this.stallTolerance;
|
|
211
|
+
if (stalled) failures.push(failure('EXECUTION', 'STALL', { recentMovement, window, targetError }));
|
|
212
|
+
const targetReached = targetError <= tolerance;
|
|
213
|
+
const motion=physics.getMotion(instanceId,{partName});
|
|
214
|
+
const settled=targetReached && recentMovement<=tolerance*.25 && motion?.linearSpeed<.08 && motion?.angularSpeed<.08;
|
|
215
|
+
if(requireSettled && !settled) failures.push(failure('POST_CONDITION','NOT_SETTLED',{recentMovement,linearSpeed:motion?.linearSpeed,angularSpeed:motion?.angularSpeed}));
|
|
216
|
+
if (accepted && finite && !targetReached) failures.push(failure('POST_CONDITION', 'TARGET_NOT_REACHED', { target, coordinate:finalCoordinate, error:targetError, tolerance }));
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
ok: failures.length === 0,
|
|
220
|
+
action,
|
|
221
|
+
target,
|
|
222
|
+
accepted,
|
|
223
|
+
finite,
|
|
224
|
+
alreadyAtTarget,
|
|
225
|
+
positionDelta,
|
|
226
|
+
rotationDelta,
|
|
227
|
+
moved,
|
|
228
|
+
initialCoordinate,
|
|
229
|
+
finalCoordinate,
|
|
230
|
+
minCoordinate,
|
|
231
|
+
maxCoordinate,
|
|
232
|
+
initialError,
|
|
233
|
+
targetError,
|
|
234
|
+
targetReached,
|
|
235
|
+
settled,
|
|
236
|
+
progress: Number.isFinite(initialError) && Number.isFinite(targetError) ? initialError - targetError : null,
|
|
237
|
+
stepsRun,
|
|
238
|
+
stalled,
|
|
239
|
+
recentMovement,
|
|
240
|
+
collisionRegressions:[...collisions.values()],
|
|
241
|
+
failures,
|
|
242
|
+
coordinateReference:'initial-zero-pose',
|
|
243
|
+
phases:{
|
|
244
|
+
preCondition:{ ok:!failures.some((item) => item.stage === 'PRE_CONDITION') },
|
|
245
|
+
execution:{ ok:!failures.some((item) => item.stage === 'EXECUTION') },
|
|
246
|
+
postCondition:{ ok:!failures.some((item) => item.stage === 'POST_CONDITION'), targetReached }
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function wrappedAngleIfNeeded(part, value) {
|
|
253
|
+
return part.joint.type === 'revolute' ? wrappedAngle(value) : value;
|
|
254
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export const FINDING_SCHEMA='agentscape.finding';
|
|
2
|
+
export const FINDING_VERSION=1;
|
|
3
|
+
|
|
4
|
+
const clone=(value)=>value==null?value:structuredClone(value);
|
|
5
|
+
const clean=(value)=>typeof value==='string'?value.trim():'';
|
|
6
|
+
const REPAIR_STRATEGY={
|
|
7
|
+
G_BELOW_GROUND:'lift_to_ground',
|
|
8
|
+
P_OVERLAP:'separate_overlap'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function normalizeFinding(input,{index=0}={}){
|
|
12
|
+
if(!input||typeof input!=='object'||Array.isArray(input)) throw new TypeError('Finding must be an object');
|
|
13
|
+
if(input.schema!==FINDING_SCHEMA||input.schemaVersion!==FINDING_VERSION) throw new TypeError('Unsupported Finding contract');
|
|
14
|
+
const id=clean(input.id),source=clean(input.source),severity=clean(input.severity),code=clean(input.code);
|
|
15
|
+
if(!id||!source||!code||!['hard','advisory'].includes(severity)) throw new TypeError(`Finding[${index}] requires id/source/severity/code`);
|
|
16
|
+
const affectedObjects=Array.isArray(input.affectedObjects)?[...new Set(input.affectedObjects.map(clean).filter(Boolean))]:[];
|
|
17
|
+
const repair=input.repair&&typeof input.repair==='object'&&!Array.isArray(input.repair)?{
|
|
18
|
+
eligible:input.repair.eligible===true,
|
|
19
|
+
...(clean(input.repair.strategy)?{strategy:clean(input.repair.strategy)}:{})
|
|
20
|
+
}:{eligible:false};
|
|
21
|
+
if(repair.eligible&&!repair.strategy) throw new TypeError(`Finding ${id} repairable finding requires strategy`);
|
|
22
|
+
return {
|
|
23
|
+
schema:FINDING_SCHEMA,schemaVersion:FINDING_VERSION,id,source,severity,code,
|
|
24
|
+
...(clean(input.worldRevisionId)?{worldRevisionId:clean(input.worldRevisionId)}:{}),
|
|
25
|
+
affectedObjects,
|
|
26
|
+
message:clean(input.message),
|
|
27
|
+
evidence:clone(input.evidence||{}),
|
|
28
|
+
repair
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function compileValidationFindings(report,{worldRevisionId=null}={}){
|
|
33
|
+
const rows=[
|
|
34
|
+
...(report?.hard||[]).map((raw)=>({severity:'hard',raw})),
|
|
35
|
+
...(report?.advisory||[]).map((raw)=>({severity:'advisory',raw}))
|
|
36
|
+
];
|
|
37
|
+
return rows.map(({severity,raw},index)=>{
|
|
38
|
+
const affectedObjects=[raw.object,raw.other].map(clean).filter(Boolean);
|
|
39
|
+
const strategy=REPAIR_STRATEGY[raw.code]||null;
|
|
40
|
+
return normalizeFinding({
|
|
41
|
+
schema:FINDING_SCHEMA,schemaVersion:FINDING_VERSION,
|
|
42
|
+
id:`validation:${severity}:${raw.code||'UNKNOWN'}:${affectedObjects.join('+')||'$world'}:${index}`,
|
|
43
|
+
source:'world-validator',severity,code:raw.code||'UNKNOWN',
|
|
44
|
+
...(worldRevisionId?{worldRevisionId}:{}),affectedObjects,
|
|
45
|
+
message:raw.message||'',evidence:{...clone(raw)},
|
|
46
|
+
repair:{eligible:Boolean(strategy),...(strategy?{strategy}:{})}
|
|
47
|
+
},{index});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const admissionCode=(stage,item,report)=>{
|
|
53
|
+
const explicit=clean(item?.code||item?.reason||report?.reason);
|
|
54
|
+
if(explicit) return explicit.toUpperCase().replace(/[^A-Z0-9_]+/g,'_');
|
|
55
|
+
const status=clean(item?.status);
|
|
56
|
+
if(stage==='asset'&&status) return `ASSET_${status.toUpperCase().replace(/[^A-Z0-9_]+/g,'_')}`;
|
|
57
|
+
return `${clean(stage).toUpperCase()||'WORLD'}_ADMISSION_REJECTED`;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const admissionAffectedObjects=(item)=>[item?.entityId,item?.targetId,item?.supportId,item?.subject,item?.object,item?.instanceId,item?.id]
|
|
61
|
+
.map(clean).filter(Boolean);
|
|
62
|
+
|
|
63
|
+
export function compileAdmissionFindings(report,{stage='world',worldRevisionId=null}={}){
|
|
64
|
+
if(report?.status!=='rejected') return [];
|
|
65
|
+
const issues=Array.isArray(report.issues)&&report.issues.length ? report.issues
|
|
66
|
+
: Array.isArray(report.unresolved)&&report.unresolved.length ? report.unresolved
|
|
67
|
+
: [{}];
|
|
68
|
+
return issues.map((item,index)=>{
|
|
69
|
+
const code=admissionCode(stage,item,report);
|
|
70
|
+
const affectedObjects=[...new Set(admissionAffectedObjects(item))];
|
|
71
|
+
return normalizeFinding({
|
|
72
|
+
schema:FINDING_SCHEMA,schemaVersion:FINDING_VERSION,
|
|
73
|
+
id:`${clean(stage)||'world'}:hard:${code}:${affectedObjects.join('+')||'$world'}:${index}`,
|
|
74
|
+
source:`world-${clean(stage)||'world'}-admission`,severity:'hard',code,
|
|
75
|
+
...(worldRevisionId?{worldRevisionId}:{}),affectedObjects,
|
|
76
|
+
message:`${clean(stage)||'world'} admission rejected: ${code}`,
|
|
77
|
+
evidence:{stage:clean(stage)||'world',...clone(item),...(report?.reason?{admissionReason:report.reason}:{})},
|
|
78
|
+
repair:{eligible:false}
|
|
79
|
+
},{index});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function compileAcceptanceFindings(result,{worldRevisionId=null}={}){
|
|
84
|
+
return (result?.checks||[]).filter((check)=>check?.verified===false).map((check,index)=>normalizeFinding({
|
|
85
|
+
schema:FINDING_SCHEMA,schemaVersion:FINDING_VERSION,
|
|
86
|
+
id:`acceptance:hard:${check.id||check.kind||'check'}:${index}`,
|
|
87
|
+
source:'world-acceptance',severity:'hard',code:`A_${check.reason||'NOT_VERIFIED'}`,
|
|
88
|
+
...(worldRevisionId?{worldRevisionId}:{}),
|
|
89
|
+
affectedObjects:[check.targetId,check.subject,check.object].filter(Boolean),
|
|
90
|
+
message:`Acceptance criterion not verified: ${check.id||check.kind||'unknown'}`,
|
|
91
|
+
evidence:clone(check),repair:{eligible:false}
|
|
92
|
+
},{index}));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function assertFindingRevision(findings,currentWorldRevisionId){
|
|
96
|
+
for(const finding of findings.map((item,index)=>normalizeFinding(item,{index}))){
|
|
97
|
+
if(finding.worldRevisionId&¤tWorldRevisionId&&finding.worldRevisionId!==currentWorldRevisionId){
|
|
98
|
+
const error=new Error(`Finding revision mismatch: ${finding.worldRevisionId} != ${currentWorldRevisionId}`);
|
|
99
|
+
error.code='FINDING_REVISION_MISMATCH';
|
|
100
|
+
error.findingId=finding.id;
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const INTERACTION_EVIDENCE_SCHEMA='agentscape.interaction-evidence';
|
|
2
|
+
export const INTERACTION_EVIDENCE_VERSION=1;
|
|
3
|
+
|
|
4
|
+
const clean=(value)=>typeof value==='string'?value.trim():'';
|
|
5
|
+
const clone=(value)=>structuredClone(value);
|
|
6
|
+
const key=(revisionId,targetId,capability,source)=>`${revisionId}\u0000${targetId}\u0000${capability}\u0000${source}`;
|
|
7
|
+
const store=(runtime)=>runtime.interactionEvidence ||= new Map();
|
|
8
|
+
|
|
9
|
+
const summarizeResult=(result)=>{
|
|
10
|
+
if(!result||typeof result!=='object') return null;
|
|
11
|
+
const summary={};
|
|
12
|
+
for(const field of ['status','action','targetId','actorId','supportId','stateKey','evidenceKind']){
|
|
13
|
+
const value=clean(result[field]);
|
|
14
|
+
if(value) summary[field]=value;
|
|
15
|
+
}
|
|
16
|
+
for(const field of ['targetReached','settled','supportVerified','heldRequired','physicsVerified']){
|
|
17
|
+
if(typeof result[field]==='boolean') summary[field]=result[field];
|
|
18
|
+
}
|
|
19
|
+
if(Object.prototype.hasOwnProperty.call(result,'value') && (result.value===null||['string','number','boolean'].includes(typeof result.value))) summary.value=result.value;
|
|
20
|
+
return Object.keys(summary).length?summary:null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function clearInteractionEvidence(runtime){
|
|
24
|
+
runtime?.interactionEvidence?.clear?.();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function clearInteractionEvidenceForTarget(runtime,targetId){
|
|
28
|
+
const target=clean(targetId);
|
|
29
|
+
if(!target||!runtime?.interactionEvidence?.size) return;
|
|
30
|
+
for(const [entryKey,evidence] of runtime.interactionEvidence){
|
|
31
|
+
if(evidence?.targetId===target) runtime.interactionEvidence.delete(entryKey);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function recordInteractionEvidence(runtime,{targetId,capability,verified,source='runtime',commandId=null,result=null}={}){
|
|
36
|
+
if(verified!==true) return null;
|
|
37
|
+
// Code Project and ad-hoc worlds have no World IR revision. Use a transient,
|
|
38
|
+
// runtime-local evidence scope; it is not exported and cannot validate a reopened world.
|
|
39
|
+
const worldRevisionId=clean(runtime?.currentWorldRevision?.revision?.id)
|
|
40
|
+
|| (runtime.interactionEvidenceScope ||= 'session:' + crypto.randomUUID());
|
|
41
|
+
const target=clean(targetId),normalizedCapability=clean(capability).toUpperCase();
|
|
42
|
+
if(!worldRevisionId||!target||!normalizedCapability) return null;
|
|
43
|
+
const resultSummary=summarizeResult(result);
|
|
44
|
+
const evidence={
|
|
45
|
+
schema:INTERACTION_EVIDENCE_SCHEMA,schemaVersion:INTERACTION_EVIDENCE_VERSION,
|
|
46
|
+
worldRevisionId,targetId:target,capability:normalizedCapability,verified:true,source,
|
|
47
|
+
...(clean(commandId)?{commandId:clean(commandId)}:{}),
|
|
48
|
+
...(resultSummary?{result:resultSummary}:{})
|
|
49
|
+
};
|
|
50
|
+
store(runtime).set(key(worldRevisionId,target,normalizedCapability,source),evidence);
|
|
51
|
+
runtime.trace?.emit?.('interaction.verified',{evidence:clone(evidence)},{actor:'runtime'});
|
|
52
|
+
return clone(evidence);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getInteractionEvidence(runtime,targetId,capability,{worldRevisionId=null,source=null}={}){
|
|
56
|
+
const revisionId=clean(worldRevisionId)||clean(runtime?.currentWorldRevision?.revision?.id)
|
|
57
|
+
|| runtime?.interactionEvidenceScope;
|
|
58
|
+
const target=clean(targetId),normalizedCapability=clean(capability).toUpperCase();
|
|
59
|
+
if(!revisionId||!target||!normalizedCapability) return null;
|
|
60
|
+
if(source) {
|
|
61
|
+
const evidence=runtime?.interactionEvidence?.get?.(key(revisionId,target,normalizedCapability,source));
|
|
62
|
+
return evidence?.verified===true ? clone(evidence) : null;
|
|
63
|
+
}
|
|
64
|
+
// Legacy unscoped lookup remains supported when no provider is requested.
|
|
65
|
+
const matches=[...(runtime?.interactionEvidence?.values?.() || [])].filter(item=>
|
|
66
|
+
item?.verified===true && item.worldRevisionId===revisionId
|
|
67
|
+
&& item.targetId===target && item.capability===normalizedCapability);
|
|
68
|
+
return matches.length ? clone(matches[matches.length - 1]) : null;
|
|
69
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { assertFindingRevision, compileValidationFindings, normalizeFinding } from './Finding.js';
|
|
2
|
+
|
|
3
|
+
export class RepairEngine {
|
|
4
|
+
constructor(runtime) { this.runtime = runtime; }
|
|
5
|
+
|
|
6
|
+
async repair(report, { maxRepairs = 20, worldRevisionId = null, silent = false } = {}) {
|
|
7
|
+
const currentRevisionId=worldRevisionId || this.runtime.currentWorldRevision?.revision?.id || null;
|
|
8
|
+
const findings=(report?.findings?.length?report.findings:compileValidationFindings(report||{},{worldRevisionId:currentRevisionId})).map((item,index)=>normalizeFinding(item,{index}));
|
|
9
|
+
assertFindingRevision(findings,currentRevisionId);
|
|
10
|
+
const hardFindings=findings.filter((finding)=>finding.severity==='hard');
|
|
11
|
+
const beforeCounts=report?.counts || {hard:hardFindings.length,advisory:findings.filter((finding)=>finding.severity==='advisory').length};
|
|
12
|
+
const before = this.runtime.snapshot();
|
|
13
|
+
const applied = [];
|
|
14
|
+
const ignored=[];
|
|
15
|
+
for (const finding of hardFindings.slice(0, maxRepairs)) {
|
|
16
|
+
if (!finding.repair.eligible) { ignored.push({findingId:finding.id,code:finding.code,reason:'NOT_REPAIRABLE'}); continue; }
|
|
17
|
+
const objectId=finding.affectedObjects[0];
|
|
18
|
+
if (finding.repair.strategy === 'lift_to_ground') {
|
|
19
|
+
const record = this.runtime.store.get(objectId);
|
|
20
|
+
const bounds = this.runtime.spatial.getBounds(objectId);
|
|
21
|
+
const p = record.object.position.toArray();
|
|
22
|
+
p[1] += -bounds.min[1] + 0.01;
|
|
23
|
+
this.runtime.interactions.move(objectId, p,{silent});
|
|
24
|
+
applied.push({ findingId:finding.id,code: finding.code, object: objectId, action: 'lift_to_ground' });
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (finding.repair.strategy === 'separate_overlap') {
|
|
28
|
+
const record = this.runtime.store.get(objectId);
|
|
29
|
+
const p = record.object.position.toArray();
|
|
30
|
+
let solved = false;
|
|
31
|
+
for (const [dx, dz] of [[0.25,0],[-0.25,0],[0,0.25],[0,-0.25],[0.5,0],[0,0.5]]) {
|
|
32
|
+
this.runtime.interactions.move(objectId, [p[0]+dx, p[1], p[2]+dz],{silent});
|
|
33
|
+
if (!this.runtime.spatial.overlappingIds(objectId, { margin: 0.015 }).length) { solved = true; break; }
|
|
34
|
+
}
|
|
35
|
+
if (solved) applied.push({ findingId:finding.id,code: finding.code, object: objectId, action: 'separate_overlap' });
|
|
36
|
+
else { this.runtime.interactions.move(objectId, p,{silent}); ignored.push({findingId:finding.id,code:finding.code,reason:'REPAIR_SEARCH_EXHAUSTED'}); }
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
ignored.push({findingId:finding.id,code:finding.code,reason:'STRATEGY_UNSUPPORTED'});
|
|
40
|
+
}
|
|
41
|
+
this.runtime.sceneGraph.changed();
|
|
42
|
+
const after = this.runtime.validator.run({worldRevisionId:currentRevisionId});
|
|
43
|
+
if (after.counts.hard > beforeCounts.hard) {
|
|
44
|
+
await this.runtime.restoreSnapshot(before);
|
|
45
|
+
return { status:'repair-failed',accepted: false, reason: 'hard_findings_increased', before: beforeCounts, after: after.counts, applied: [], ignored, findingsConsumed:hardFindings.map((finding)=>finding.id) };
|
|
46
|
+
}
|
|
47
|
+
return { status:'repair-applied',accepted: true, before: beforeCounts, after: after.counts, applied, ignored, findingsConsumed:hardFindings.map((finding)=>finding.id) };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { compileAcceptanceFindings } from './Finding.js';
|
|
2
|
+
import { getInteractionEvidence } from './InteractionEvidence.js';
|
|
3
|
+
import { SemanticWorldView } from '../runtime/semantic/SemanticWorldView.js';
|
|
4
|
+
|
|
5
|
+
const SCHEMA='agentscape.world-acceptance';
|
|
6
|
+
const VERSION=1;
|
|
7
|
+
const scalar=v=>v===null||typeof v==='string'||typeof v==='number'||typeof v==='boolean';
|
|
8
|
+
const clean=v=>typeof v==='string'?v.trim():'';
|
|
9
|
+
|
|
10
|
+
export function compileWorldAcceptance(criteria=[]){
|
|
11
|
+
if(!Array.isArray(criteria)) throw new TypeError('Acceptance criteria must be an array');
|
|
12
|
+
const ids=new Set();
|
|
13
|
+
const checks=criteria.map((item,index)=>{
|
|
14
|
+
if(!item||typeof item!=='object'||Array.isArray(item)) throw new TypeError(`Acceptance[${index}] must be an object`);
|
|
15
|
+
const id=clean(item.id),kind=clean(item.kind);
|
|
16
|
+
if(!id||ids.has(id)) throw new TypeError(`Acceptance[${index}] requires unique id`); ids.add(id);
|
|
17
|
+
if(!kind) throw new TypeError(`Acceptance[${index}] requires kind`);
|
|
18
|
+
if(!['world-valid','object-exists','state-equals','interaction-verified','relation-exists','no-unresolved'].includes(kind)) throw new TypeError(`Acceptance[${index}] unsupported kind: ${kind}`);
|
|
19
|
+
const check={id,kind};
|
|
20
|
+
if(['object-exists','state-equals','interaction-verified'].includes(kind)) check.targetId=clean(item.targetId);
|
|
21
|
+
if(kind==='state-equals'){ check.stateKey=clean(item.stateKey); check.value=item.value; if(!check.targetId||!check.stateKey||!Object.prototype.hasOwnProperty.call(item,'value')||!scalar(item.value)) throw new TypeError(`Acceptance[${index}] state-equals requires targetId/stateKey/scalar value`); }
|
|
22
|
+
if(['state-equals','interaction-verified'].includes(kind) && item.source != null) {
|
|
23
|
+
check.source=clean(item.source);
|
|
24
|
+
if(!check.source) throw new TypeError(`Acceptance[${index}] source must be non-empty`);
|
|
25
|
+
}
|
|
26
|
+
if(kind==='interaction-verified'){ check.capability=clean(item.capability).toUpperCase(); if(!check.targetId||!check.capability) throw new TypeError(`Acceptance[${index}] interaction-verified requires targetId/capability`); }
|
|
27
|
+
if(kind==='relation-exists'){
|
|
28
|
+
check.subject=clean(item.subject); check.predicate=clean(item.predicate).toUpperCase(); check.object=clean(item.object);
|
|
29
|
+
if(item.objectAnyOf!=null) {
|
|
30
|
+
if(check.object || !Array.isArray(item.objectAnyOf) || !item.objectAnyOf.length || item.objectAnyOf.length>32 || item.objectAnyOf.some(value=>!clean(value))) throw new TypeError('Use object or a bounded objectAnyOf');
|
|
31
|
+
check.objectAnyOf=[...new Set(item.objectAnyOf.map(clean))];delete check.object;
|
|
32
|
+
}
|
|
33
|
+
if(clean(item.surfaceId)) check.surfaceId=clean(item.surfaceId);
|
|
34
|
+
if(!check.subject||!check.predicate||(!check.object&&!check.objectAnyOf)) throw new TypeError(`Acceptance[${index}] relation-exists requires subject/predicate/object`);
|
|
35
|
+
if(!['ON','NEAR','INSIDE','CONTAINS','SUPPORTS'].includes(check.predicate)) throw new TypeError(`Acceptance[${index}] unsupported relation predicate: ${check.predicate}`);
|
|
36
|
+
}
|
|
37
|
+
if(kind==='object-exists'&&!check.targetId) throw new TypeError(`Acceptance[${index}] object-exists requires targetId`);
|
|
38
|
+
if(clean(item.description)) check.description=clean(item.description);
|
|
39
|
+
return check;
|
|
40
|
+
});
|
|
41
|
+
return {schema:SCHEMA,schemaVersion:VERSION,checks};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function evaluateWorldAcceptance(runtime,graph,{unresolvedMutations=undefined,worldRevisionId=null,validationEvidence=null}={}){
|
|
45
|
+
if(graph?.schema!==SCHEMA||graph.schemaVersion!==VERSION) throw new TypeError('Unsupported WorldAcceptance graph');
|
|
46
|
+
const facts=runtime?.semantic || new SemanticWorldView(runtime);
|
|
47
|
+
const evidence=graph.checks.map(check=>{
|
|
48
|
+
if(check.kind==='world-valid'){
|
|
49
|
+
const validation=validationEvidence || runtime?.validator?.run?.();
|
|
50
|
+
return validation?.ok===true ? {id:check.id,kind:check.kind,verified:true,evidence:{validation:structuredClone(validation)}} : {id:check.id,kind:check.kind,verified:false,reason:'WORLD_VALIDATION_FAILED',evidence:validation?structuredClone(validation):null};
|
|
51
|
+
}
|
|
52
|
+
if(check.kind==='object-exists'){
|
|
53
|
+
const entity=facts.entity(check.targetId);
|
|
54
|
+
return {id:check.id,kind:check.kind,verified:entity.exists,targetId:check.targetId,source:entity.source,
|
|
55
|
+
...(!entity.exists?{reason:entity.reason}:{})};
|
|
56
|
+
}
|
|
57
|
+
if(check.kind==='state-equals'){
|
|
58
|
+
const fact=facts.state(check.targetId,check.stateKey,check.source ? {source:check.source} : {});
|
|
59
|
+
const base={id:check.id,kind:check.kind,targetId:check.targetId,stateKey:check.stateKey,expected:check.value,source:fact.source};
|
|
60
|
+
if(fact.status!=='known')return {...base,verified:false,truth:'unknown',reason:fact.reason};
|
|
61
|
+
const verified=Object.is(fact.value,check.value);
|
|
62
|
+
return {...base,verified,truth:verified?'true':'false',actual:fact.value,...(!verified?{reason:'STATE_MISMATCH'}:{})};
|
|
63
|
+
}
|
|
64
|
+
if(check.kind==='interaction-verified'){
|
|
65
|
+
const projectAction=runtime?.projectCapabilities?.hasAction?.(check.targetId,check.capability.toLowerCase());
|
|
66
|
+
const physicalAction=projectAction && runtime?.affordances?.inspect?.(check.targetId)?.actions?.some(action =>
|
|
67
|
+
action.action?.toUpperCase() === check.capability && ['interaction','world-action'].includes(action.execution));
|
|
68
|
+
if(!check.source && projectAction && physicalAction) {
|
|
69
|
+
return {id:check.id,kind:check.kind,verified:false,targetId:check.targetId,
|
|
70
|
+
expected:check.capability,reason:'INTERACTION_SOURCE_REQUIRED'};
|
|
71
|
+
}
|
|
72
|
+
const evidenceSource=check.source==='asset'?'physical-articulation'
|
|
73
|
+
:check.source==='project'?'project-defined':check.source || null;
|
|
74
|
+
const evidence=getInteractionEvidence(runtime,check.targetId,check.capability,
|
|
75
|
+
{worldRevisionId,...(evidenceSource?{source:evidenceSource}:{})});
|
|
76
|
+
const verified=Boolean(evidence);
|
|
77
|
+
return {id:check.id,kind:check.kind,verified,targetId:check.targetId,expected:check.capability,
|
|
78
|
+
...(check.source?{source:check.source}:{}),...(evidence?{evidence}:{reason:'INTERACTION_NOT_VERIFIED'})};
|
|
79
|
+
}
|
|
80
|
+
if(check.kind==='relation-exists'){
|
|
81
|
+
const fact=facts.relation(check);
|
|
82
|
+
return {id:check.id,kind:check.kind,verified:fact.truth==='true',subject:check.subject,predicate:check.predicate,
|
|
83
|
+
...(check.objectAnyOf?{objectAnyOf:check.objectAnyOf}:{object:check.object}),...(check.surfaceId?{surfaceId:check.surfaceId}:{}),
|
|
84
|
+
truth:fact.truth,source:fact.source,...(fact.evidenceKind?{evidenceKind:fact.evidenceKind}:{}),
|
|
85
|
+
...(fact.evidence?{evidence:fact.evidence}:{reason:fact.reason})};
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(unresolvedMutations)) return {id:check.id,kind:check.kind,verified:false,reason:'EVIDENCE_MISSING'};
|
|
88
|
+
const verified=unresolvedMutations.length===0;
|
|
89
|
+
return {id:check.id,kind:check.kind,verified,...(!verified?{reason:'UNRESOLVED_MUTATIONS',unresolvedCount:unresolvedMutations.length}:{})};
|
|
90
|
+
});
|
|
91
|
+
const failed=evidence.filter(x=>!x.verified);
|
|
92
|
+
return {schema:SCHEMA,schemaVersion:VERSION,status:failed.length?'world-incomplete':'world-accepted',checks:evidence,verifiedCount:evidence.length-failed.length,failedCount:failed.length};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {SCHEMA as WORLD_ACCEPTANCE_SCHEMA,VERSION as WORLD_ACCEPTANCE_VERSION};
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
export function buildAcceptanceEvidenceBundle(graph,result,{worldRevisionId=null,source='runtime',provenance=null}={}){
|
|
99
|
+
if(graph?.schema!==SCHEMA||graph.schemaVersion!==VERSION) throw new TypeError('Unsupported WorldAcceptance graph');
|
|
100
|
+
if(!result||typeof result!=='object') throw new TypeError('WorldAcceptance result is required');
|
|
101
|
+
return {
|
|
102
|
+
schema:'agentscape.acceptance-evidence',schemaVersion:1,required:true,
|
|
103
|
+
source,
|
|
104
|
+
...(worldRevisionId?{worldRevisionId}:{}),
|
|
105
|
+
...(provenance?{provenance:structuredClone(provenance)}:{}),
|
|
106
|
+
criteria:structuredClone(graph.checks),
|
|
107
|
+
result:structuredClone(result),
|
|
108
|
+
findings:compileAcceptanceFindings(result,{worldRevisionId})
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
export function replayAcceptanceEvidence(runtime,evidence,{unresolvedMutations=undefined}={}){
|
|
114
|
+
if(!evidence||typeof evidence!=='object'||evidence.schema!=='agentscape.acceptance-evidence'||evidence.schemaVersion!==1) throw new TypeError('Unsupported acceptance evidence bundle');
|
|
115
|
+
const graph=compileWorldAcceptance(evidence.criteria || []);
|
|
116
|
+
const evidenceRevisionId=clean(evidence.worldRevisionId)||null;
|
|
117
|
+
const currentRevisionId=clean(runtime?.currentWorldRevision?.revision?.id)||null;
|
|
118
|
+
let bindingReason=null;
|
|
119
|
+
if(evidenceRevisionId&&!currentRevisionId) bindingReason='CURRENT_REVISION_UNKNOWN';
|
|
120
|
+
else if(!evidenceRevisionId&¤tRevisionId) bindingReason='EVIDENCE_REVISION_MISSING';
|
|
121
|
+
else if(evidenceRevisionId&¤tRevisionId&&evidenceRevisionId!==currentRevisionId) bindingReason='WORLD_REVISION_CHANGED';
|
|
122
|
+
|
|
123
|
+
let result;
|
|
124
|
+
let changedCriteria=[];
|
|
125
|
+
if(bindingReason){
|
|
126
|
+
result={
|
|
127
|
+
schema:SCHEMA,schemaVersion:VERSION,status:'world-incomplete',
|
|
128
|
+
checks:[{id:'revision-binding',kind:'revision-binding',verified:false,reason:bindingReason,expected:evidenceRevisionId,actual:currentRevisionId}],
|
|
129
|
+
verifiedCount:0,failedCount:1
|
|
130
|
+
};
|
|
131
|
+
changedCriteria=['revision-binding'];
|
|
132
|
+
} else {
|
|
133
|
+
result=evaluateWorldAcceptance(runtime,graph,{unresolvedMutations});
|
|
134
|
+
const previous=new Map((evidence.result?.checks||[]).map((check)=>[check.id,check]));
|
|
135
|
+
changedCriteria=result.checks.filter((check)=>{
|
|
136
|
+
const before=previous.get(check.id);
|
|
137
|
+
if(!before) return true;
|
|
138
|
+
return JSON.stringify([before.verified,before.reason??null,before.actual??null])!==JSON.stringify([check.verified,check.reason??null,check.actual??null]);
|
|
139
|
+
}).map((check)=>check.id);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const bundle=buildAcceptanceEvidenceBundle(graph,result,{
|
|
143
|
+
worldRevisionId:currentRevisionId||evidenceRevisionId||null,
|
|
144
|
+
source:'acceptance-replay',
|
|
145
|
+
provenance:runtime?.currentWorldRevision?.provenance || evidence.provenance || null
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
...result,
|
|
149
|
+
replay:{
|
|
150
|
+
status:bindingReason?'stale':'replayed',
|
|
151
|
+
...(bindingReason?{reason:bindingReason}:{}),
|
|
152
|
+
evidenceRevisionId,currentRevisionId,
|
|
153
|
+
previousStatus:evidence.result?.status || null,
|
|
154
|
+
changedCriteria
|
|
155
|
+
},
|
|
156
|
+
acceptanceBundle:bundle
|
|
157
|
+
};
|
|
158
|
+
}
|