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,533 @@
|
|
|
1
|
+
const candidateKey = (candidate={}) => candidate.kind === 'object'
|
|
2
|
+
? `object:${candidate.objectId}:${candidate.partName || '$root'}`
|
|
3
|
+
: `environment:${candidate.environmentId}:${candidate.colliderIndex ?? -1}`;
|
|
4
|
+
|
|
5
|
+
const currentExternalEvidence = (runtime,targetId,partName) => {
|
|
6
|
+
const evidence=new Map();
|
|
7
|
+
for (const contact of runtime.recovery.contacts(targetId,partName)) {
|
|
8
|
+
if (!contact.external) continue;
|
|
9
|
+
const target=contact.target || {};
|
|
10
|
+
if (!['object','environment'].includes(target.kind)) continue;
|
|
11
|
+
const key=candidateKey(target);
|
|
12
|
+
const current=evidence.get(key) || {
|
|
13
|
+
pairCount:0,contactCount:0,activeContactCount:0,minDistance:null,totalImpulse:0,
|
|
14
|
+
impulseAvailable:true,evidenceKinds:new Set(),colliderIndices:new Set()
|
|
15
|
+
};
|
|
16
|
+
current.pairCount+=1;
|
|
17
|
+
current.contactCount+=Number(contact.contactCount) || 0;
|
|
18
|
+
current.activeContactCount+=Number(contact.activeContactCount) || 0;
|
|
19
|
+
if (Number.isFinite(contact.minDistance)) current.minDistance=current.minDistance == null
|
|
20
|
+
? contact.minDistance : Math.min(current.minDistance,contact.minDistance);
|
|
21
|
+
const impulseAvailable=contact.impulseAvailable!==false && Number.isFinite(contact.totalImpulse);
|
|
22
|
+
if(impulseAvailable) current.totalImpulse+=contact.totalImpulse;
|
|
23
|
+
else current.impulseAvailable=false;
|
|
24
|
+
current.evidenceKinds.add(contact.evidenceKind || 'contact');
|
|
25
|
+
if (target.colliderIndex != null) current.colliderIndices.add(target.colliderIndex);
|
|
26
|
+
evidence.set(key,current);
|
|
27
|
+
}
|
|
28
|
+
return new Map([...evidence].map(([key,value])=>[key,{
|
|
29
|
+
pairCount:value.pairCount,
|
|
30
|
+
contactCount:value.contactCount,
|
|
31
|
+
activeContactCount:value.activeContactCount,
|
|
32
|
+
minDistance:value.minDistance,
|
|
33
|
+
totalImpulse:value.impulseAvailable ? value.totalImpulse : null,
|
|
34
|
+
impulseAvailable:value.impulseAvailable,
|
|
35
|
+
evidenceKinds:[...value.evidenceKinds].sort(),
|
|
36
|
+
colliderIndices:[...value.colliderIndices].sort((a,b)=>a-b)
|
|
37
|
+
}]));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const candidateType = (candidate={}) => {
|
|
41
|
+
if (candidate.kind==='environment') return 'environment-collider';
|
|
42
|
+
if (candidate.kind==='object' && (candidate.partName || '$root')!=='$root') return 'articulated-part';
|
|
43
|
+
if (candidate.kind==='object') return 'object-root';
|
|
44
|
+
return 'unknown';
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const denied = (candidate, reason, details={}) => ({
|
|
48
|
+
blocker:structuredClone(candidate),candidateType:candidateType(candidate),eligible:false,status:'ineligible',reason,...details
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const routeCostOf = (proposal) => Number.isFinite(proposal?.preflight?.pose?.routeCost)
|
|
52
|
+
? proposal.preflight.pose.routeCost : Infinity;
|
|
53
|
+
|
|
54
|
+
const originalVerification = (actorId,targetId,failedPart,last) => ({
|
|
55
|
+
required:'retry-original-post-condition',
|
|
56
|
+
tool:'approachAndInteract',
|
|
57
|
+
args:{actorId,targetId,action:last.action || 'open',partName:failedPart.partName},
|
|
58
|
+
success:{status:'action-completed',targetReached:true,settled:true}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const boundsOverlap = (a,b) => {
|
|
62
|
+
if (!a?.min || !a?.max || !b?.min || !b?.max) return {available:false,intersects:false,volume:null};
|
|
63
|
+
const extents=[0,1,2].map((index)=>Math.max(0,Math.min(a.max[index],b.max[index])-Math.max(a.min[index],b.min[index])));
|
|
64
|
+
const intersects=extents.every((value)=>value>1e-9);
|
|
65
|
+
return {available:true,intersects,volume:intersects ? extents[0]*extents[1]*extents[2] : 0};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const currentSweepPersistence = (runtime,targetId,failedPart,last,candidate) => {
|
|
70
|
+
const action=last?.action || 'open';
|
|
71
|
+
let originalSweep;
|
|
72
|
+
try { originalSweep=runtime.recovery.actionSweepBounds(targetId,action,failedPart.partName); }
|
|
73
|
+
catch { return {checked:false,reason:'ORIGINAL_SWEEP_UNAVAILABLE'}; }
|
|
74
|
+
if (!originalSweep?.checked) return {checked:false,reason:originalSweep?.reason || 'ORIGINAL_SWEEP_UNAVAILABLE'};
|
|
75
|
+
|
|
76
|
+
let blockerBounds=null,blockerState=null;
|
|
77
|
+
if ((candidate.partName || '$root')==='$root') {
|
|
78
|
+
try {
|
|
79
|
+
const bounds=runtime.recovery.bounds(candidate.objectId);
|
|
80
|
+
if (bounds?.min && bounds?.max) blockerBounds={min:[...bounds.min],max:[...bounds.max]};
|
|
81
|
+
} catch {}
|
|
82
|
+
} else {
|
|
83
|
+
try {
|
|
84
|
+
blockerState=runtime.recovery.articulationStatus(candidate.objectId,candidate.partName).parts?.find((item)=>item.partName===candidate.partName) || null;
|
|
85
|
+
if (blockerState?.verifiedAction) {
|
|
86
|
+
const pose=runtime.recovery.actionSweepBounds(candidate.objectId,blockerState.verifiedAction,candidate.partName,1);
|
|
87
|
+
if (pose?.checked) blockerBounds=pose.bounds;
|
|
88
|
+
}
|
|
89
|
+
} catch {}
|
|
90
|
+
}
|
|
91
|
+
if (!blockerBounds) return {checked:false,reason:'BLOCKER_CURRENT_BOUNDS_UNAVAILABLE'};
|
|
92
|
+
const overlap=boundsOverlap(originalSweep.bounds,blockerBounds);
|
|
93
|
+
if (!overlap.available) return {checked:false,reason:'SWEEP_OVERLAP_UNAVAILABLE'};
|
|
94
|
+
return {
|
|
95
|
+
checked:true,source:'current-action-sweep-overlap',intersects:overlap.intersects,volume:overlap.volume,
|
|
96
|
+
action,partName:failedPart.partName,blocker:structuredClone(candidate),
|
|
97
|
+
...(blockerState?{blockerState:structuredClone(blockerState)}:{})
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const counterfactualTuple = (evidence) => [
|
|
102
|
+
evidence.targetSweepClear ? 1 : 0,
|
|
103
|
+
evidence.overlapReduction,
|
|
104
|
+
-evidence.targetOverlapVolume,
|
|
105
|
+
-evidence.actionSweepOverlapVolume
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
const compareCounterfactual = (a,b) => {
|
|
109
|
+
const ta=counterfactualTuple(a.counterfactual),tb=counterfactualTuple(b.counterfactual);
|
|
110
|
+
for(let i=0;i<ta.length;i++) if (ta[i]!==tb[i]) return tb[i]-ta[i];
|
|
111
|
+
return (a.pose?.routeCost ?? Infinity)-(b.pose?.routeCost ?? Infinity) || a.action.localeCompare(b.action);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const sameCounterfactualDecision = (a,b) => {
|
|
115
|
+
if (!a || !b) return false;
|
|
116
|
+
const ta=counterfactualTuple(a.counterfactual),tb=counterfactualTuple(b.counterfactual);
|
|
117
|
+
const routeA=a.pose?.routeCost ?? Infinity,routeB=b.pose?.routeCost ?? Infinity;
|
|
118
|
+
const sameRoute=Number.isFinite(routeA)&&Number.isFinite(routeB) ? Math.abs(routeA-routeB)<=1e-9 : routeA===routeB;
|
|
119
|
+
return ta.every((value,index)=>Math.abs(value-tb[index])<=1e-9) && sameRoute;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const physicsCounterfactualTuple = (evidence) => [
|
|
123
|
+
evidence.targetSweepClear ? 1 : 0,
|
|
124
|
+
evidence.conflictReduction,
|
|
125
|
+
-evidence.target.conflictSamples,
|
|
126
|
+
-evidence.target.pairIntersections,
|
|
127
|
+
-evidence.action.conflictSamplePairs,
|
|
128
|
+
-evidence.action.pairIntersections
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
const comparePhysicsCounterfactual = (a,b) => {
|
|
132
|
+
const ta=physicsCounterfactualTuple(a.physicsCounterfactual),tb=physicsCounterfactualTuple(b.physicsCounterfactual);
|
|
133
|
+
for(let i=0;i<ta.length;i++) if (ta[i]!==tb[i]) return tb[i]-ta[i];
|
|
134
|
+
return (a.pose?.routeCost ?? Infinity)-(b.pose?.routeCost ?? Infinity) || a.action.localeCompare(b.action);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const samePhysicsCounterfactualDecision = (a,b) => {
|
|
138
|
+
if (!a || !b) return false;
|
|
139
|
+
const ta=physicsCounterfactualTuple(a.physicsCounterfactual),tb=physicsCounterfactualTuple(b.physicsCounterfactual);
|
|
140
|
+
const routeA=a.pose?.routeCost ?? Infinity,routeB=b.pose?.routeCost ?? Infinity;
|
|
141
|
+
const sameRoute=Number.isFinite(routeA)&&Number.isFinite(routeB) ? Math.abs(routeA-routeB)<=1e-9 : routeA===routeB;
|
|
142
|
+
return ta.every((value,index)=>value===tb[index]) && sameRoute;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const articulatedRecovery = async (runtime,registry,{actorId,targetId,failedPart,last,candidate,currentContact,profile}) => {
|
|
146
|
+
const manifest=runtime.recovery.manifest(candidate.objectId);
|
|
147
|
+
const blockerPartName=candidate.partName;
|
|
148
|
+
const part=manifest?.parts?.[blockerPartName];
|
|
149
|
+
if (!part?.joint || !part.physics || !Object.keys(part.targets || {}).length) {
|
|
150
|
+
return denied(candidate,'ARTICULATED_PART_UNAVAILABLE',{currentContact});
|
|
151
|
+
}
|
|
152
|
+
let blockerStatus;
|
|
153
|
+
try {
|
|
154
|
+
blockerStatus=runtime.recovery.articulationStatus(candidate.objectId,blockerPartName).parts?.find((value)=>value.partName===blockerPartName) || null;
|
|
155
|
+
} catch {
|
|
156
|
+
return denied(candidate,'ARTICULATED_STATE_UNAVAILABLE',{currentContact});
|
|
157
|
+
}
|
|
158
|
+
if (!blockerStatus?.verifiedAction) return denied(candidate,'ARTICULATED_STATE_UNVERIFIED',{currentContact,blockerState:blockerStatus});
|
|
159
|
+
if (blockerStatus.requestedAction || blockerStatus.status==='moving') {
|
|
160
|
+
return denied(candidate,'ARTICULATED_ACTION_PENDING',{currentContact,blockerState:blockerStatus});
|
|
161
|
+
}
|
|
162
|
+
const actions=(part.actions || []).filter((action)=>
|
|
163
|
+
action!==blockerStatus.verifiedAction
|
|
164
|
+
&& ['open','close'].includes(action)
|
|
165
|
+
&& manifest.actions?.includes(action)
|
|
166
|
+
&& Number.isFinite(part.targets?.[action])
|
|
167
|
+
);
|
|
168
|
+
if (!actions.length) return denied(candidate,'NO_ALTERNATE_ARTICULATED_ACTION',{currentContact,blockerState:blockerStatus});
|
|
169
|
+
const authorization=registry.authorization('recoverArticulatedBlocker',{profile});
|
|
170
|
+
if (!authorization.allow) return {
|
|
171
|
+
blocker:structuredClone(candidate),candidateType:candidateType(candidate),eligible:false,status:'denied',reason:'POLICY_DENIED',currentContact,
|
|
172
|
+
blockerState:structuredClone(blockerStatus),
|
|
173
|
+
...(actions.length===1?{blockerAction:actions[0]}:{alternateActions:[...actions]}),
|
|
174
|
+
policy:{allow:false,profile:authorization.profile,missing:[...authorization.missing]}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
let actionCandidates=[];
|
|
178
|
+
if (actions.length===1) {
|
|
179
|
+
const blockerAction=actions[0];
|
|
180
|
+
let pose;
|
|
181
|
+
try {
|
|
182
|
+
pose=await runtime.recovery.findInteractionPose(actorId,candidate.objectId,{action:blockerAction,partName:blockerPartName});
|
|
183
|
+
} catch (error) {
|
|
184
|
+
return denied(candidate,error.details?.reason || error.code || 'ARTICULATED_RECOVERY_PREFLIGHT_FAILED',{
|
|
185
|
+
currentContact,blockerState:blockerStatus,blockerAction
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (!pose) return denied(candidate,'NO_INTERACTION_POSE',{currentContact,blockerState:blockerStatus,blockerAction});
|
|
189
|
+
let worldCounterfactual=null;
|
|
190
|
+
if (runtime.recovery.hasWorldCounterfactual()) {
|
|
191
|
+
try {
|
|
192
|
+
worldCounterfactual=runtime.recovery.worldCounterfactual(candidate.objectId,blockerPartName,part.targets[blockerAction],{
|
|
193
|
+
excludeObjectIds:[actorId],excludeParts:[{objectId:targetId,partName:failedPart.partName}]
|
|
194
|
+
});
|
|
195
|
+
} catch (error) {
|
|
196
|
+
worldCounterfactual={checked:false,reason:error.code || 'WORLD_COUNTERFACTUAL_ERROR'};
|
|
197
|
+
}
|
|
198
|
+
if (!worldCounterfactual?.checked) return denied(candidate,'WORLD_COUNTERFACTUAL_COVERAGE_UNAVAILABLE',{
|
|
199
|
+
currentContact,blockerState:blockerStatus,blockerAction,worldCounterfactual:worldCounterfactual || {checked:false,reason:'WORLD_COUNTERFACTUAL_UNAVAILABLE'}
|
|
200
|
+
});
|
|
201
|
+
if (worldCounterfactual.targetIntroducesNoCollision!==true || worldCounterfactual.actionIntroducesNoCollision!==true) {
|
|
202
|
+
return denied(candidate,'THIRD_OBJECT_COUNTERFACTUAL_BLOCKED',{currentContact,blockerState:blockerStatus,blockerAction,worldCounterfactual});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
actionCandidates=[{action:blockerAction,pose,counterfactual:null,...(worldCounterfactual?{worldCounterfactual}:{})}];
|
|
206
|
+
} else {
|
|
207
|
+
const originalAction=last.action || 'open';
|
|
208
|
+
const originalManifest=runtime.recovery.manifest(targetId);
|
|
209
|
+
const originalTarget=originalManifest?.parts?.[failedPart.partName]?.targets?.[originalAction];
|
|
210
|
+
const originalSweep=runtime.recovery.actionSweepBounds(targetId,originalAction,failedPart.partName);
|
|
211
|
+
const currentPose=runtime.recovery.actionSweepBounds(candidate.objectId,blockerStatus.verifiedAction,blockerPartName,1);
|
|
212
|
+
const visualAvailable=Boolean(originalSweep?.checked && currentPose?.checked);
|
|
213
|
+
const currentOverlap=visualAvailable ? boundsOverlap(originalSweep.bounds,currentPose.bounds) : {available:false,intersects:false,volume:null};
|
|
214
|
+
const physicsCapable=Number.isFinite(originalTarget) && runtime.recovery.hasPairCounterfactual();
|
|
215
|
+
const worldCounterfactualCapable=runtime.recovery.hasWorldCounterfactual();
|
|
216
|
+
if (!physicsCapable && (!visualAvailable || !currentOverlap.available || !currentOverlap.intersects || !(currentOverlap.volume>0))) {
|
|
217
|
+
return denied(candidate,visualAvailable?'COUNTERFACTUAL_EVIDENCE_INSUFFICIENT':'COUNTERFACTUAL_EVIDENCE_UNAVAILABLE',{
|
|
218
|
+
currentContact,blockerState:blockerStatus,alternateActions:[...actions],
|
|
219
|
+
counterfactual:{
|
|
220
|
+
causal:false,physicsFallbackReason:'PHYSICS_COUNTERFACTUAL_UNAVAILABLE',
|
|
221
|
+
...(visualAvailable?{currentOverlapVolume:currentOverlap.volume,originalSweep:structuredClone(originalSweep.bounds),currentPose:structuredClone(currentPose.bounds)}:{originalSweepChecked:Boolean(originalSweep?.checked),currentPoseChecked:Boolean(currentPose?.checked)})
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (const action of actions) {
|
|
227
|
+
const actionSweep=runtime.recovery.actionSweepBounds(candidate.objectId,action,blockerPartName);
|
|
228
|
+
const targetPose=runtime.recovery.actionSweepBounds(candidate.objectId,action,blockerPartName,1);
|
|
229
|
+
if (!actionSweep?.checked || !targetPose?.checked) {
|
|
230
|
+
actionCandidates.push({action,executable:false,reason:'ACTION_GEOMETRY_UNAVAILABLE'});
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
let pose=null;
|
|
234
|
+
try { pose=await runtime.recovery.findInteractionPose(actorId,candidate.objectId,{action,partName:blockerPartName}); }
|
|
235
|
+
catch (error) {
|
|
236
|
+
actionCandidates.push({action,executable:false,reason:error.details?.reason || error.code || 'ARTICULATED_RECOVERY_PREFLIGHT_FAILED'});
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (!pose) {
|
|
240
|
+
actionCandidates.push({action,executable:false,reason:'NO_INTERACTION_POSE'});
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const targetOverlap=visualAvailable ? boundsOverlap(originalSweep.bounds,targetPose.bounds) : {available:false,intersects:false,volume:null};
|
|
244
|
+
const actionOverlap=visualAvailable ? boundsOverlap(originalSweep.bounds,actionSweep.bounds) : {available:false,intersects:false,volume:null};
|
|
245
|
+
const visualCounterfactual=visualAvailable && currentOverlap.available && targetOverlap.available && actionOverlap.available ? {
|
|
246
|
+
causal:false,geometry:'three-aabb',
|
|
247
|
+
currentOverlapVolume:Number((currentOverlap.volume || 0).toFixed(6)),
|
|
248
|
+
targetOverlapVolume:Number((targetOverlap.volume || 0).toFixed(6)),
|
|
249
|
+
overlapReduction:Number(Math.max(0,(currentOverlap.volume || 0)-(targetOverlap.volume || 0)).toFixed(6)),
|
|
250
|
+
targetSweepClear:!targetOverlap.intersects,
|
|
251
|
+
actionSweepOverlapVolume:Number((actionOverlap.volume || 0).toFixed(6)),
|
|
252
|
+
targetBounds:structuredClone(targetPose.bounds),
|
|
253
|
+
actionSweepBounds:structuredClone(actionSweep.bounds)
|
|
254
|
+
} : null;
|
|
255
|
+
let physicsCounterfactual={checked:false,reason:'PHYSICS_COUNTERFACTUAL_UNAVAILABLE'};
|
|
256
|
+
if (physicsCapable) {
|
|
257
|
+
try {
|
|
258
|
+
physicsCounterfactual=runtime.recovery.pairCounterfactual(
|
|
259
|
+
targetId,failedPart.partName,originalTarget,
|
|
260
|
+
candidate.objectId,blockerPartName,part.targets[action]
|
|
261
|
+
) || physicsCounterfactual;
|
|
262
|
+
} catch (error) {
|
|
263
|
+
physicsCounterfactual={checked:false,reason:error.code || 'PHYSICS_COUNTERFACTUAL_ERROR'};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
let worldCounterfactual={checked:false,reason:'WORLD_COUNTERFACTUAL_UNAVAILABLE'};
|
|
267
|
+
if (worldCounterfactualCapable) {
|
|
268
|
+
try {
|
|
269
|
+
worldCounterfactual=runtime.recovery.worldCounterfactual(candidate.objectId,blockerPartName,part.targets[action],{
|
|
270
|
+
excludeObjectIds:[actorId],excludeParts:[{objectId:targetId,partName:failedPart.partName}]
|
|
271
|
+
}) || worldCounterfactual;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
worldCounterfactual={checked:false,reason:error.code || 'WORLD_COUNTERFACTUAL_ERROR'};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const recoveryEligible=!worldCounterfactualCapable || (
|
|
277
|
+
worldCounterfactual.checked
|
|
278
|
+
&& worldCounterfactual.targetIntroducesNoCollision===true
|
|
279
|
+
&& worldCounterfactual.actionIntroducesNoCollision===true
|
|
280
|
+
);
|
|
281
|
+
const worldReason=!worldCounterfactualCapable ? null
|
|
282
|
+
: !worldCounterfactual.checked ? (worldCounterfactual.reason || 'WORLD_COUNTERFACTUAL_UNAVAILABLE')
|
|
283
|
+
: recoveryEligible ? null : 'THIRD_OBJECT_COUNTERFACTUAL_BLOCKED';
|
|
284
|
+
actionCandidates.push({action,executable:true,recoveryEligible,pose,visualCounterfactual,physicsCounterfactual,worldCounterfactual,...(worldReason?{worldReason}:{})});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const interactionExecutable=actionCandidates.filter((item)=>item.executable);
|
|
288
|
+
const executable=interactionExecutable.filter((item)=>item.recoveryEligible!==false);
|
|
289
|
+
if (worldCounterfactualCapable && interactionExecutable.length && !executable.length) {
|
|
290
|
+
const hasKnownCollision=interactionExecutable.some((item)=>item.worldCounterfactual?.checked && (
|
|
291
|
+
item.worldCounterfactual.targetIntroducesNoCollision===false || item.worldCounterfactual.actionIntroducesNoCollision===false
|
|
292
|
+
));
|
|
293
|
+
return denied(candidate,hasKnownCollision?'THIRD_OBJECT_COUNTERFACTUAL_BLOCKED':'WORLD_COUNTERFACTUAL_COVERAGE_UNAVAILABLE',{
|
|
294
|
+
currentContact,blockerState:blockerStatus,alternateActions:[...actions],
|
|
295
|
+
worldCounterfactual:{causal:false,geometry:'rapier-world-shape-query',actions:interactionExecutable.map((item)=>({
|
|
296
|
+
action:item.action,executable:true,recoveryEligible:item.recoveryEligible,worldReason:item.worldReason || null,evidence:structuredClone(item.worldCounterfactual)
|
|
297
|
+
}))}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
const physicsCurrent=executable.map((item)=>item.physicsCounterfactual?.current).filter(Boolean);
|
|
301
|
+
const physicsBaselineConsistent=physicsCurrent.length===executable.length && physicsCurrent.every((value)=>
|
|
302
|
+
value.conflictSamples===physicsCurrent[0]?.conflictSamples && value.pairIntersections===physicsCurrent[0]?.pairIntersections
|
|
303
|
+
);
|
|
304
|
+
let physicsReady=Boolean(executable.length)
|
|
305
|
+
&& executable.every((item)=>item.physicsCounterfactual?.checked && item.physicsCounterfactual.current?.conflictSamples>0)
|
|
306
|
+
&& physicsBaselineConsistent;
|
|
307
|
+
let physicsConvergence=null,physicsConvergenceFallbackReason=null;
|
|
308
|
+
const physicsViable=physicsReady ? executable.filter((item)=>item.physicsCounterfactual.conflictReduction>0).sort(comparePhysicsCounterfactual) : [];
|
|
309
|
+
if (physicsReady && physicsViable.length && runtime.recovery.hasCounterfactualConvergence()) {
|
|
310
|
+
const top=physicsViable[0];
|
|
311
|
+
try {
|
|
312
|
+
const raw=runtime.recovery.counterfactualConvergence(
|
|
313
|
+
targetId,failedPart.partName,originalTarget,
|
|
314
|
+
candidate.objectId,blockerPartName,part.targets[top.action]
|
|
315
|
+
);
|
|
316
|
+
if (raw?.checked) {
|
|
317
|
+
physicsConvergence={
|
|
318
|
+
status:raw.status,causal:false,
|
|
319
|
+
qualitative:structuredClone(raw.qualitative),
|
|
320
|
+
samples:{base:structuredClone(raw.base?.samples || null),dense:structuredClone(raw.dense?.samples || null)},
|
|
321
|
+
ratios:structuredClone(raw.ratios || null),maxRatioDrift:raw.maxRatioDrift
|
|
322
|
+
};
|
|
323
|
+
if (raw.status!=='stable') {
|
|
324
|
+
physicsReady=false;
|
|
325
|
+
physicsConvergenceFallbackReason='PHYSICS_COUNTERFACTUAL_UNSTABLE';
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
physicsReady=false;
|
|
329
|
+
physicsConvergenceFallbackReason='PHYSICS_COUNTERFACTUAL_CONVERGENCE_UNAVAILABLE';
|
|
330
|
+
}
|
|
331
|
+
} catch {
|
|
332
|
+
physicsReady=false;
|
|
333
|
+
physicsConvergenceFallbackReason='PHYSICS_COUNTERFACTUAL_CONVERGENCE_ERROR';
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
let viable,rankedActions,strategy,criteria,basis,fallbackReason=null,currentEvidence;
|
|
337
|
+
if (physicsReady) {
|
|
338
|
+
viable=physicsViable;
|
|
339
|
+
rankedActions=actionCandidates.map((item)=>structuredClone(item));
|
|
340
|
+
strategy='articulated-rapier-shape-counterfactual-v2';
|
|
341
|
+
basis='rapier-shape-pairs';
|
|
342
|
+
criteria=['targetSweepClearDesc','conflictReductionDesc','targetConflictSamplesAsc','targetPairIntersectionsAsc','actionConflictSamplePairsAsc','actionPairIntersectionsAsc','routeCostAsc'];
|
|
343
|
+
currentEvidence={
|
|
344
|
+
action:blockerStatus.verifiedAction,
|
|
345
|
+
conflictSamples:executable[0].physicsCounterfactual.current.conflictSamples,
|
|
346
|
+
pairIntersections:executable[0].physicsCounterfactual.current.pairIntersections
|
|
347
|
+
};
|
|
348
|
+
} else {
|
|
349
|
+
fallbackReason=physicsConvergenceFallbackReason || (!executable.length ? 'NO_EXECUTABLE_ACTION'
|
|
350
|
+
: executable.some((item)=>!item.physicsCounterfactual?.checked) ? 'PHYSICS_COUNTERFACTUAL_PARTIAL_COVERAGE'
|
|
351
|
+
: !physicsBaselineConsistent ? 'PHYSICS_COUNTERFACTUAL_BASELINE_INCONSISTENT'
|
|
352
|
+
: 'PHYSICS_COUNTERFACTUAL_BASELINE_INSUFFICIENT');
|
|
353
|
+
if (!visualAvailable) return denied(candidate,'COUNTERFACTUAL_EVIDENCE_UNAVAILABLE',{
|
|
354
|
+
currentContact,blockerState:blockerStatus,alternateActions:[...actions],
|
|
355
|
+
counterfactual:{causal:false,physicsFallbackReason:fallbackReason,originalSweepChecked:Boolean(originalSweep?.checked),currentPoseChecked:Boolean(currentPose?.checked)}
|
|
356
|
+
});
|
|
357
|
+
if (!currentOverlap.available || !currentOverlap.intersects || !(currentOverlap.volume>0)) return denied(candidate,'COUNTERFACTUAL_EVIDENCE_INSUFFICIENT',{
|
|
358
|
+
currentContact,blockerState:blockerStatus,alternateActions:[...actions],
|
|
359
|
+
counterfactual:{causal:false,physicsFallbackReason:fallbackReason,currentOverlapVolume:currentOverlap.volume,originalSweep:structuredClone(originalSweep.bounds),currentPose:structuredClone(currentPose.bounds)}
|
|
360
|
+
});
|
|
361
|
+
viable=executable.filter((item)=>item.visualCounterfactual?.overlapReduction>1e-9).map((item)=>({...item,counterfactual:item.visualCounterfactual})).sort(compareCounterfactual);
|
|
362
|
+
rankedActions=actionCandidates.map((item)=>structuredClone(item));
|
|
363
|
+
strategy='articulated-target-sweep-counterfactual-v1';
|
|
364
|
+
basis='three-aabb-fallback';
|
|
365
|
+
criteria=['targetSweepClearDesc','overlapReductionDesc','targetOverlapVolumeAsc','actionSweepOverlapVolumeAsc','routeCostAsc'];
|
|
366
|
+
currentEvidence={action:blockerStatus.verifiedAction,overlapVolume:Number(currentOverlap.volume.toFixed(6)),bounds:structuredClone(currentPose.bounds)};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (!viable.length) return denied(candidate,'NO_COUNTERFACTUAL_CLEARANCE_GAIN',{
|
|
370
|
+
currentContact,blockerState:blockerStatus,alternateActions:[...actions],
|
|
371
|
+
actionRanking:{strategy,basis,causal:false,criteria,...(fallbackReason?{fallbackReason}:{}),...(physicsConvergence?{convergence:physicsConvergence}:{}),actions:rankedActions}
|
|
372
|
+
});
|
|
373
|
+
const tied=physicsReady ? samePhysicsCounterfactualDecision(viable[0],viable[1]) : sameCounterfactualDecision(viable[0],viable[1]);
|
|
374
|
+
if (tied) return denied(candidate,'COUNTERFACTUAL_ACTION_TIE',{
|
|
375
|
+
currentContact,blockerState:blockerStatus,alternateActions:[...actions],
|
|
376
|
+
actionRanking:{strategy,basis,causal:false,criteria,...(fallbackReason?{fallbackReason}:{}),...(physicsConvergence?{convergence:physicsConvergence}:{}),tiedActions:[viable[0].action,viable[1].action],actions:rankedActions}
|
|
377
|
+
});
|
|
378
|
+
viable.forEach((item,index)=>{ const target=rankedActions.find((entry)=>entry.action===item.action); if(target) target.rank=index+1; });
|
|
379
|
+
actionCandidates=[{...viable[0],actionRanking:{
|
|
380
|
+
strategy,basis,causal:false,criteria,...(fallbackReason?{fallbackReason}:{}),...(physicsConvergence?{convergence:physicsConvergence}:{}),
|
|
381
|
+
current:currentEvidence,
|
|
382
|
+
...(visualAvailable?{originalSweep:structuredClone(originalSweep.bounds)}:{}),
|
|
383
|
+
actions:rankedActions
|
|
384
|
+
}}];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const selected=actionCandidates[0];
|
|
388
|
+
const blockerAction=selected.action;
|
|
389
|
+
return {
|
|
390
|
+
blocker:structuredClone(candidate),candidateType:candidateType(candidate),eligible:true,status:'provisional',recovery:'articulated-blocker',
|
|
391
|
+
evidence:'current-contact-at-failure',currentContact,
|
|
392
|
+
blockerState:{
|
|
393
|
+
partName:blockerPartName,status:blockerStatus.status,requestedAction:null,verifiedAction:blockerStatus.verifiedAction,
|
|
394
|
+
...(blockerStatus.live ? {live:structuredClone(blockerStatus.live)} : {})
|
|
395
|
+
},
|
|
396
|
+
blockerAction,
|
|
397
|
+
...(selected.actionRanking?{actionRanking:selected.actionRanking}:{}),
|
|
398
|
+
...(selected.worldCounterfactual?{worldCounterfactual:structuredClone(selected.worldCounterfactual)}:{}),
|
|
399
|
+
policy:{allow:true,profile:authorization.profile,missing:[]},
|
|
400
|
+
preflight:{pose:structuredClone(selected.pose),actionSweep:{checked:true,clear:true,partName:blockerPartName}},
|
|
401
|
+
rankingEvidence:{causal:false,recoveryRouteCost:Number.isFinite(selected.pose.routeCost)?selected.pose.routeCost:null},
|
|
402
|
+
tool:'recoverArticulatedBlocker',
|
|
403
|
+
args:{actorId,targetId,partName:failedPart.partName,blockerId:candidate.objectId,blockerPartName,blockerAction},
|
|
404
|
+
verification:originalVerification(actorId,targetId,failedPart,last)
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
const rankProposals = (proposals) => {
|
|
410
|
+
const eligible=proposals.filter((proposal)=>proposal.eligible).sort((a,b)=>
|
|
411
|
+
routeCostOf(a)-routeCostOf(b) || candidateKey(a.blocker).localeCompare(candidateKey(b.blocker))
|
|
412
|
+
);
|
|
413
|
+
eligible.forEach((proposal,index)=>{proposal.rank=index+1;});
|
|
414
|
+
const ineligible=proposals.filter((proposal)=>!proposal.eligible).sort((a,b)=>
|
|
415
|
+
candidateKey(a.blocker).localeCompare(candidateKey(b.blocker))
|
|
416
|
+
);
|
|
417
|
+
return [...eligible,...ineligible];
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export async function buildRecoveryProposals(runtime,registry,{
|
|
421
|
+
actorId,targetId,partName=null,profile='builder'
|
|
422
|
+
}={}) {
|
|
423
|
+
if (!runtime.recovery) throw new TypeError('buildRecoveryProposals requires WorldRuntime.recovery');
|
|
424
|
+
const articulation=runtime.recovery.articulationStatus(targetId,partName);
|
|
425
|
+
const failedPart=(articulation.parts || []).find((part)=>partName ? part.partName===partName : part.last?.reason==='STALL');
|
|
426
|
+
const last=failedPart?.last;
|
|
427
|
+
if (!failedPart || last?.reason!=='STALL') return {
|
|
428
|
+
status:'recovery-unavailable',reason:'NO_STALL_FAILURE',actorId,targetId,partName:partName || failedPart?.partName || null,proposals:[]
|
|
429
|
+
};
|
|
430
|
+
const attribution=last.attribution;
|
|
431
|
+
if (attribution?.status!=='contact-evidence' || !(attribution.blockerCandidates || []).length) return {
|
|
432
|
+
status:'recovery-unavailable',reason:'NO_CONTACT_BLOCKER_CANDIDATE',actorId,targetId,partName:failedPart.partName,proposals:[]
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const currentEvidence=currentExternalEvidence(runtime,targetId,failedPart.partName);
|
|
436
|
+
const authorization=registry.authorization('recoverPickupBlocker',{profile});
|
|
437
|
+
const proposals=[];
|
|
438
|
+
for (const candidate of attribution.blockerCandidates) {
|
|
439
|
+
let currentContact=currentEvidence.get(candidateKey(candidate)) || null;
|
|
440
|
+
if (candidate.kind==='environment') {
|
|
441
|
+
proposals.push(denied(candidate,'ENVIRONMENT_IMMOVABLE',{currentContact}));
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (candidate.kind!=='object' || !candidate.objectId || !runtime.recovery.hasObject(candidate.objectId)) {
|
|
445
|
+
proposals.push(denied(candidate,'BLOCKER_OBJECT_UNAVAILABLE',{currentContact}));
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (!currentContact) {
|
|
449
|
+
const persistence=currentSweepPersistence(runtime,targetId,failedPart,last,candidate);
|
|
450
|
+
if (!persistence.checked || !persistence.intersects) {
|
|
451
|
+
proposals.push(denied(candidate,'CONTACT_EVIDENCE_STALE',{status:'stale',currentContact:null,persistence}));
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
currentContact={
|
|
455
|
+
source:'current-action-sweep-overlap',pairCount:0,contactCount:0,activeContactCount:0,minDistance:null,totalImpulse:null,
|
|
456
|
+
impulseAvailable:false,evidenceKinds:['geometric-sweep'],colliderIndices:[],persistence
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
if ((candidate.partName || '$root')!=='$root') {
|
|
460
|
+
proposals.push(await articulatedRecovery(runtime,registry,{actorId,targetId,failedPart,last,candidate,currentContact,profile}));
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (!authorization.allow) {
|
|
464
|
+
proposals.push({
|
|
465
|
+
blocker:structuredClone(candidate),candidateType:candidateType(candidate),eligible:false,status:'denied',reason:'POLICY_DENIED',currentContact,
|
|
466
|
+
policy:{allow:false,profile:authorization.profile,missing:[...authorization.missing]}
|
|
467
|
+
});
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
let pickupPlan;
|
|
471
|
+
try {
|
|
472
|
+
runtime.recovery.assertCarryable(actorId,candidate.objectId);
|
|
473
|
+
pickupPlan=await runtime.recovery.findPickupPlan(actorId,candidate.objectId);
|
|
474
|
+
} catch (error) {
|
|
475
|
+
proposals.push(denied(candidate,error.details?.reason || error.code || 'BLOCKER_NOT_CARRYABLE',{currentContact}));
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (!pickupPlan?.transfer?.clear) {
|
|
479
|
+
proposals.push(denied(candidate,'PICKUP_TRANSFER_BLOCKED',{currentContact}));
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const retryAction=last.action || 'open';
|
|
483
|
+
proposals.push({
|
|
484
|
+
blocker:structuredClone(candidate),candidateType:candidateType(candidate),eligible:true,status:'provisional',recovery:'pickup-blocker',
|
|
485
|
+
evidence:'current-contact-at-failure',currentContact,
|
|
486
|
+
policy:{allow:true,profile:authorization.profile,missing:[]},
|
|
487
|
+
preflight:{pose:structuredClone(pickupPlan.pose),transfer:{clear:true}},
|
|
488
|
+
rankingEvidence:{causal:false,pickupRouteCost:Number.isFinite(pickupPlan.pose?.routeCost)?pickupPlan.pose.routeCost:null},
|
|
489
|
+
tool:'recoverPickupBlocker',args:{actorId,targetId,partName:failedPart.partName,blockerId:candidate.objectId},
|
|
490
|
+
verification:originalVerification(actorId,targetId,failedPart,{...last,action:retryAction})
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
const ranked=rankProposals(proposals);
|
|
494
|
+
const eligible=ranked.filter((proposal)=>proposal.eligible);
|
|
495
|
+
let cleanupRecommended=null;
|
|
496
|
+
const heldRecovery=runtime.recovery.heldStatus(actorId);
|
|
497
|
+
if (!eligible.length && heldRecovery?.targetId===targetId && ranked.some((proposal)=>proposal.reason==='HANDS_FULL')) {
|
|
498
|
+
const cleanupAuthorization=registry.authorization('cleanupRecoveryBlocker',{profile});
|
|
499
|
+
if (!cleanupAuthorization.allow) {
|
|
500
|
+
cleanupRecommended={
|
|
501
|
+
status:'denied',reason:'POLICY_DENIED',blockerId:heldRecovery.blockerId,
|
|
502
|
+
policy:{allow:false,profile:cleanupAuthorization.profile,missing:[...cleanupAuthorization.missing]}
|
|
503
|
+
};
|
|
504
|
+
} else {
|
|
505
|
+
const cleanupPlan=await runtime.recovery.findCleanupPlan(actorId,targetId,{
|
|
506
|
+
partName:failedPart.partName,action:last.action || heldRecovery.action,blockerId:heldRecovery.blockerId
|
|
507
|
+
});
|
|
508
|
+
cleanupRecommended=cleanupPlan.status==='cleanup-proposed' ? {
|
|
509
|
+
status:'provisional',reason:'HANDS_FULL_WITH_RECOVERY_BLOCKER',
|
|
510
|
+
blockerId:heldRecovery.blockerId,
|
|
511
|
+
policy:{allow:true,profile:cleanupAuthorization.profile,missing:[]},
|
|
512
|
+
tool:'cleanupRecoveryBlocker',
|
|
513
|
+
args:{actorId,targetId,partName:failedPart.partName,action:last.action || heldRecovery.action,blockerId:heldRecovery.blockerId},
|
|
514
|
+
plan:cleanupPlan,
|
|
515
|
+
verification:{required:'replan-recovery-after-cleanup',cleanupStatus:'recovery-cleaned'}
|
|
516
|
+
} : {status:'unavailable',reason:cleanupPlan.reason || 'NO_SAFE_CLEANUP_SPACE',blockerId:heldRecovery.blockerId,plan:cleanupPlan};
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return {
|
|
520
|
+
status:eligible.length ? 'recovery-proposed' : (cleanupRecommended?.status==='provisional' ? 'recovery-cleanup-proposed' : 'recovery-unavailable'),
|
|
521
|
+
actorId,targetId,partName:failedPart.partName,originalAction:last.action || null,
|
|
522
|
+
evidence:'current-contact-at-failure',
|
|
523
|
+
ranking:{
|
|
524
|
+
strategy:'eligible-recovery-route-cost-v2',causal:false,
|
|
525
|
+
criteria:['eligible','recoveryRouteCostAsc','stableBlockerKeyAsc']
|
|
526
|
+
},
|
|
527
|
+
recommended:eligible[0] ? {
|
|
528
|
+
rank:1,blocker:structuredClone(eligible[0].blocker),tool:eligible[0].tool,args:structuredClone(eligible[0].args)
|
|
529
|
+
} : null,
|
|
530
|
+
...(cleanupRecommended ? {cleanupRecommended} : {}),
|
|
531
|
+
proposals:ranked
|
|
532
|
+
};
|
|
533
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
|
|
2
|
+
export const COMPLETE_OUTCOMES = new Set(['verified', 'accepted']);
|
|
3
|
+
|
|
4
|
+
export const stableValue = (value) => {
|
|
5
|
+
if (Array.isArray(value)) return `[${value.map(stableValue).join(',')}]`;
|
|
6
|
+
if (value && typeof value === 'object') return `{${Object.keys(value).sort().map((key)=>`${JSON.stringify(key)}:${stableValue(value[key])}`).join(',')}}`;
|
|
7
|
+
return JSON.stringify(value);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const EMBODIED_STRING_ARGS = Object.freeze({
|
|
11
|
+
approachAndInteract:['actorId','targetId','action','partName'],
|
|
12
|
+
approachAndPickup:['actorId','targetId'],
|
|
13
|
+
approachAndPlace:['actorId','supportId','targetId','surfaceId']
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const unwrapRedundantQuotedString = (value) => {
|
|
17
|
+
if (typeof value !== 'string') return value;
|
|
18
|
+
const trimmed=value.trim();
|
|
19
|
+
if (trimmed.length < 2 || trimmed[0] !== '"' || trimmed.at(-1) !== '"') return value;
|
|
20
|
+
try {
|
|
21
|
+
const parsed=JSON.parse(trimmed);
|
|
22
|
+
return typeof parsed === 'string' ? parsed : value;
|
|
23
|
+
} catch { return value; }
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const normalizeModelToolCall = (call) => {
|
|
27
|
+
if (!call || typeof call !== 'object') return call;
|
|
28
|
+
const args={...(call.args || {})};
|
|
29
|
+
for (const key of EMBODIED_STRING_ARGS[call.name] || []) {
|
|
30
|
+
if (key in args) args[key]=unwrapRedundantQuotedString(args[key]);
|
|
31
|
+
}
|
|
32
|
+
if (EMBODIED_STRING_ARGS[call.name] && args.actorId == null && args.agentId != null) {
|
|
33
|
+
args.actorId=unwrapRedundantQuotedString(args.agentId);
|
|
34
|
+
delete args.agentId;
|
|
35
|
+
}
|
|
36
|
+
if (call.name === 'approachAndPlace' && args.supportId == null && args.targetId != null) {
|
|
37
|
+
args.supportId=args.targetId;
|
|
38
|
+
delete args.targetId;
|
|
39
|
+
}
|
|
40
|
+
return {...call,args};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const mutationIdentity = (call, result = null) => {
|
|
44
|
+
const args = call.args || {};
|
|
45
|
+
if(call.name==='interactScene')return `interactScene:${stableValue(args.interaction || {})}`;
|
|
46
|
+
const keys = ['actorId','id','targetId','supportId','blockerId','blockerPartName','blockerAction','action','assetId','instanceId','end'];
|
|
47
|
+
const scope = Object.fromEntries(keys.filter((key)=>args[key] != null).map((key)=>[key,args[key]]));
|
|
48
|
+
if (call.name === 'addSceneModel' && args.model?.id != null) scope.modelId = args.model.id;
|
|
49
|
+
const partName = args.partName ?? result?.partName ?? result?.interaction?.part ?? result?.actionSweep?.partName;
|
|
50
|
+
if (partName != null) scope.partName=partName;
|
|
51
|
+
return `${call.name}:${stableValue(scope)}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const worldMutationRevisionId=(entry)=>{
|
|
55
|
+
if(entry?.tool==='runWorldPipeline') return entry.args?.plan?.revision?.id || null;
|
|
56
|
+
if(entry?.tool==='recompileWorldRevision') return entry.args?.proposal?.nextRevisionId || null;
|
|
57
|
+
return null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const worldPlanIdentity = (call) => {
|
|
61
|
+
if(call?.name!=='runWorldPipeline') return null;
|
|
62
|
+
const plan=call.args?.plan || {};
|
|
63
|
+
const {revision:_revision,provenance:_provenance,...semanticPlan}=plan;
|
|
64
|
+
return `runWorldPipeline:${stableValue({plan:semanticPlan})}`;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const worldProposalLineageFromExecution = (call,result) => {
|
|
68
|
+
const parentRevisionId=call?.args?.plan?.revision?.id || null;
|
|
69
|
+
if(!parentRevisionId) return null;
|
|
70
|
+
const rejected=result?.status!=='world-ready';
|
|
71
|
+
const revisionContext=result?.pipeline?.state?.artifacts?.revisionContext;
|
|
72
|
+
const acceptanceFindings=result?.pipeline?.state?.artifacts?.acceptanceEvidence?.findings || [];
|
|
73
|
+
const retryFindings=(result?.attempts || []).flatMap((attempt)=>attempt?.retry?.findings || []);
|
|
74
|
+
const evidenceRefs=[
|
|
75
|
+
...(revisionContext?.findingIds || []),
|
|
76
|
+
...acceptanceFindings.map((finding)=>finding?.id),
|
|
77
|
+
...retryFindings.map((finding)=>finding?.id)
|
|
78
|
+
].filter(Boolean);
|
|
79
|
+
return {
|
|
80
|
+
parentRevisionId,
|
|
81
|
+
...(rejected?{reason:result?.reason || result?.admission?.reasons?.[0] || 'world-revision'}:{}),
|
|
82
|
+
...(evidenceRefs.length?{evidenceRefs:[...new Set(evidenceRefs)]}:{})
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const worldRevisionRepairFromExecution=(result)=>{
|
|
87
|
+
if(result?.status!=='world-rejected') return null;
|
|
88
|
+
const baseWorldIR=result?.worldIR || result?.pipeline?.state?.artifacts?.worldIR;
|
|
89
|
+
const revisionContext=result?.pipeline?.state?.artifacts?.revisionContext;
|
|
90
|
+
if(!baseWorldIR||!revisionContext||revisionContext.baseRevisionId!==baseWorldIR.revision?.id) return null;
|
|
91
|
+
return {baseWorldIR:structuredClone(baseWorldIR),revisionContext:structuredClone(revisionContext)};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const identityScope = (identity) => {
|
|
95
|
+
const separator=identity?.indexOf(':') ?? -1;
|
|
96
|
+
if (separator < 0) return {};
|
|
97
|
+
try { return JSON.parse(identity.slice(separator + 1)); } catch { return {}; }
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const recoveryOriginIdentity = (call, unresolvedMutations) => {
|
|
101
|
+
if (!['recoverPickupBlocker','recoverArticulatedBlocker','cleanupRecoveryBlocker'].includes(call.name)) return null;
|
|
102
|
+
const args=call.args || {};
|
|
103
|
+
const matches=[...unresolvedMutations.values()].filter((entry)=>{
|
|
104
|
+
if (entry.tool !== 'approachAndInteract') return false;
|
|
105
|
+
const scope=identityScope(entry.identity);
|
|
106
|
+
return scope.actorId===args.actorId
|
|
107
|
+
&& scope.targetId===args.targetId
|
|
108
|
+
&& (!args.partName || scope.partName===args.partName);
|
|
109
|
+
});
|
|
110
|
+
return matches.at(-1)?.identity || null;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const recoveryMutationIdentity = (call, recoveryOf) => {
|
|
114
|
+
if (!recoveryOf) return mutationIdentity(call);
|
|
115
|
+
const originScope=identityScope(recoveryOf);
|
|
116
|
+
const args={...(call.args || {})};
|
|
117
|
+
if (args.partName == null && originScope.partName != null) args.partName=originScope.partName;
|
|
118
|
+
return mutationIdentity({...call,args});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const replanInstruction = (outcome) => COMPLETE_OUTCOMES.has(outcome?.state)
|
|
122
|
+
? 'World state changed. Replan from the fresh world before any further mutation.'
|
|
123
|
+
: 'This step did not verify completion. Do not advance to a later dependent mutation; diagnose, recover, retry, or report the task incomplete.';
|
|
124
|
+
|
|
125
|
+
export function annotateResult(result, sequence) {
|
|
126
|
+
if (result && typeof result === 'object' && !Array.isArray(result)) return { ...result, _sequence:sequence };
|
|
127
|
+
return { result, _sequence:sequence };
|
|
128
|
+
}
|