agentscape3d 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/README.md +23 -48
  2. package/dist/core.d.ts +68 -0
  3. package/dist/core.js +209 -0
  4. package/dist/core.js.map +1 -0
  5. package/dist/index.d.ts +10 -229
  6. package/dist/index.js +192 -15462
  7. package/dist/index.js.map +1 -1
  8. package/package.json +11 -40
  9. package/cli.mjs +0 -27
  10. package/dist/AssetCompiler-CDFiElji.js +0 -2451
  11. package/dist/AssetCompiler-CDFiElji.js.map +0 -1
  12. package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
  13. package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
  14. package/dist/AssetRecipe-DmFpzxr-.js +0 -55
  15. package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
  16. package/dist/BrowserCodeWorker.js +0 -53615
  17. package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
  18. package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
  19. package/dist/SceneSerializer-DPVOyeRk.js +0 -353
  20. package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
  21. package/dist/StylePack-DNrdLeGI.js +0 -6314
  22. package/dist/StylePack-DNrdLeGI.js.map +0 -1
  23. package/dist/WorldArchive-pSBIGxLa.js +0 -420
  24. package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
  25. package/dist/WorldIO-wsDfZGM4.js +0 -150
  26. package/dist/WorldIO-wsDfZGM4.js.map +0 -1
  27. package/dist/blankWorld-CBWbwJGj.js +0 -76
  28. package/dist/blankWorld-CBWbwJGj.js.map +0 -1
  29. package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
  30. package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
  31. package/dist/environments-DgH66NqV.js +0 -4220
  32. package/dist/environments-DgH66NqV.js.map +0 -1
  33. package/dist/gltfIO-B87nJaat.js +0 -10
  34. package/dist/gltfIO-B87nJaat.js.map +0 -1
  35. package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
  36. package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
  37. package/dist/magicCabin-D64fD1E2.js +0 -11024
  38. package/dist/magicCabin-D64fD1E2.js.map +0 -1
  39. package/dist/mcp.d.ts +0 -2
  40. package/dist/mcp.js +0 -1
  41. package/dist/monumentHall-BKbs0UOQ.js +0 -404
  42. package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
  43. package/dist/node.d.ts +0 -16
  44. package/dist/node.js +0 -25
  45. package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
  46. package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
  47. package/dist/runtime/application/AgentTools.js +0 -25
  48. package/dist/runtime/application/README.md +0 -14
  49. package/dist/runtime/application/buildTaskObservation.js +0 -117
  50. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
  51. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
  52. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
  53. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
  54. package/dist/runtime/application/createSession.js +0 -66
  55. package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
  56. package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
  57. package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
  58. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
  59. package/dist/runtime/application/native-scene/CodeProject.js +0 -119
  60. package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
  61. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
  62. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
  63. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
  64. package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
  65. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
  66. package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
  67. package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
  68. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
  69. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
  70. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
  71. package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
  72. package/dist/runtime/application/scene/RequestWindow.js +0 -54
  73. package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
  74. package/dist/runtime/application/scene/SceneContracts.js +0 -45
  75. package/dist/runtime/application/scene/SceneEditService.js +0 -144
  76. package/dist/runtime/application/scene/SceneFacade.js +0 -267
  77. package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
  78. package/dist/runtime/application/scene/SceneJobController.js +0 -229
  79. package/dist/runtime/application/scene/ScenePackage.js +0 -162
  80. package/dist/runtime/application/scene/ScenePersistence.js +0 -50
  81. package/dist/runtime/application/scene/SceneProject.js +0 -95
  82. package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
  83. package/dist/runtime/application/scene/StarterScene.js +0 -56
  84. package/dist/runtime/application/scene/WorldArchive.js +0 -87
  85. package/dist/runtime/application/scene/WorldDirectory.js +0 -20
  86. package/dist/runtime/application/scene/WorldDocument.js +0 -74
  87. package/dist/runtime/application/scene/WorldIO.js +0 -103
  88. package/dist/runtime/application/scene/WorldStorage.js +0 -137
  89. package/dist/runtime/application/skills/SkillRegistry.js +0 -163
  90. package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
  91. package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
  92. package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
  93. package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
  94. package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
  95. package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
  96. package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
  97. package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
  98. package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
  99. package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
  100. package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
  101. package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
  102. package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
  103. package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
  104. package/dist/runtime/application/skills/skillPrimitives.js +0 -4
  105. package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
  106. package/dist/runtime/application/tasks.jsonl +0 -67
  107. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
  108. package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
  109. package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
  110. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
  111. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
  112. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
  113. package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
  114. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
  115. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
  116. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
  117. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
  118. package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
  119. package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
  120. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
  121. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
  122. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
  123. package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
  124. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
  125. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
  126. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
  127. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
  128. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
  129. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
  130. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
  131. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
  132. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
  133. package/dist/runtime/apps/mcp-server/README.md +0 -150
  134. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
  135. package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
  136. package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
  137. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
  138. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
  139. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
  140. package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
  141. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
  142. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
  143. package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
  144. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
  145. package/dist/runtime/apps/mcp-server/main.mjs +0 -56
  146. package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
  147. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
  148. package/dist/runtime/apps/mcp-server/security.js +0 -21
  149. package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
  150. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
  151. package/dist/runtime/apps/server/README.md +0 -7
  152. package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
  153. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
  154. package/dist/runtime/apps/server/tasks.jsonl +0 -10
  155. package/dist/runtime/foundation/EventBus.js +0 -18
  156. package/dist/runtime/foundation/JsonGateway.js +0 -47
  157. package/dist/runtime/foundation/PolicyEngine.js +0 -21
  158. package/dist/runtime/foundation/README.md +0 -7
  159. package/dist/runtime/foundation/TraceRecorder.js +0 -76
  160. package/dist/runtime/foundation/errors.js +0 -8
  161. package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
  162. package/dist/runtime/foundation/version.js +0 -2
  163. package/dist/runtime/modules/agent/README.md +0 -11
  164. package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
  165. package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
  166. package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
  167. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
  168. package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
  169. package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
  170. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
  171. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
  172. package/dist/runtime/modules/agent/prompt/index.js +0 -46
  173. package/dist/runtime/modules/agent/tasks.jsonl +0 -94
  174. package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
  175. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
  176. package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
  177. package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
  178. package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
  179. package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
  180. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
  181. package/dist/runtime/modules/artifact/README.md +0 -7
  182. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
  183. package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
  184. package/dist/runtime/modules/asset/AssetModule.js +0 -399
  185. package/dist/runtime/modules/asset/README.md +0 -54
  186. package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
  187. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
  188. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
  189. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
  190. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
  191. package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
  192. package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
  193. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
  194. package/dist/runtime/modules/asset/model/admission.js +0 -117
  195. package/dist/runtime/modules/asset/model/errors.js +0 -6
  196. package/dist/runtime/modules/asset/model/parts.js +0 -27
  197. package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
  198. package/dist/runtime/modules/asset/model/schema.js +0 -150
  199. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
  200. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
  201. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
  202. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
  203. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
  204. package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
  205. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
  206. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
  207. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
  208. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
  209. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
  210. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
  211. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
  212. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
  213. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
  214. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
  215. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
  216. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
  217. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
  218. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
  219. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
  220. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
  221. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
  222. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
  223. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
  224. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
  225. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
  226. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
  227. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
  228. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
  229. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
  230. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
  231. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
  232. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
  233. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
  234. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
  235. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
  236. package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
  237. package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
  238. package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
  239. package/dist/runtime/modules/asset/tasks.jsonl +0 -87
  240. package/dist/runtime/modules/generation/README.md +0 -9
  241. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
  242. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
  243. package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
  244. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
  245. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
  246. package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
  247. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
  248. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
  249. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
  250. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
  251. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
  252. package/dist/runtime/modules/generation/tasks.jsonl +0 -35
  253. package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
  254. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
  255. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
  256. package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
  257. package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
  258. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
  259. package/dist/runtime/modules/rendering/README.md +0 -7
  260. package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
  261. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
  262. package/dist/runtime/modules/rendering/createRenderer.js +0 -76
  263. package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
  264. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
  265. package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
  266. package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
  267. package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
  268. package/dist/runtime/modules/world/README.md +0 -13
  269. package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
  270. package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
  271. package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
  272. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
  273. package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
  274. package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
  275. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
  276. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
  277. package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
  278. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
  279. package/dist/runtime/modules/world/content/blankWorld.js +0 -35
  280. package/dist/runtime/modules/world/content/environments.js +0 -84
  281. package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
  282. package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
  283. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
  284. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
  285. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
  286. package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
  287. package/dist/runtime/modules/world/content/magicCabin.js +0 -190
  288. package/dist/runtime/modules/world/content/monumentHall.js +0 -154
  289. package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
  290. package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
  291. package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
  292. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
  293. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
  294. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
  295. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
  296. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
  297. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
  298. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
  301. package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
  302. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
  303. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
  304. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
  305. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
  306. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
  307. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
  308. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
  309. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
  310. package/dist/runtime/modules/world/errors.js +0 -9
  311. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
  312. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
  313. package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
  314. package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
  315. package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
  316. package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
  317. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
  318. package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
  319. package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
  320. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
  321. package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
  322. package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
  323. package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
  324. package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
  325. package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
  326. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
  327. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
  328. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
  329. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
  330. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
  331. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
  332. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
  333. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
  334. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
  335. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
  336. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
  337. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
  338. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
  339. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
  340. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
  341. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
  342. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
  343. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
  344. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
  345. package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
  346. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
  347. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
  348. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
  349. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
  350. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
  351. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
  352. package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
  353. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
  354. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
  355. package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
  356. package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
  357. package/dist/runtime/modules/world/tasks.jsonl +0 -530
  358. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
  359. package/dist/runtime/modules/world/verification/Finding.js +0 -105
  360. package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
  361. package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
  362. package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
  363. package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
  364. package/dist/runtime/package-lock.json +0 -6245
  365. package/dist/runtime/package.json +0 -91
  366. package/dist/runtime/public/assets/cabinet.glb +0 -0
  367. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  368. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  369. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  370. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  371. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  372. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  373. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  374. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  375. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  376. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  377. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  379. package/dist/schema-Dudvovhu.js +0 -364
  380. package/dist/schema-Dudvovhu.js.map +0 -1
  381. package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
  382. package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
  383. package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
  384. package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
  385. package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
  386. package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
@@ -1,533 +0,0 @@
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
- }
@@ -1,127 +0,0 @@
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
- const partName = args.partName ?? result?.partName ?? result?.interaction?.part ?? result?.actionSweep?.partName;
49
- if (partName != null) scope.partName=partName;
50
- return `${call.name}:${stableValue(scope)}`;
51
- };
52
-
53
- export const worldMutationRevisionId=(entry)=>{
54
- if(entry?.tool==='runWorldPipeline') return entry.args?.plan?.revision?.id || null;
55
- if(entry?.tool==='recompileWorldRevision') return entry.args?.proposal?.nextRevisionId || null;
56
- return null;
57
- };
58
-
59
- export const worldPlanIdentity = (call) => {
60
- if(call?.name!=='runWorldPipeline') return null;
61
- const plan=call.args?.plan || {};
62
- const {revision:_revision,provenance:_provenance,...semanticPlan}=plan;
63
- return `runWorldPipeline:${stableValue({plan:semanticPlan})}`;
64
- };
65
-
66
- export const worldProposalLineageFromExecution = (call,result) => {
67
- const parentRevisionId=call?.args?.plan?.revision?.id || null;
68
- if(!parentRevisionId) return null;
69
- const rejected=result?.status!=='world-ready';
70
- const revisionContext=result?.pipeline?.state?.artifacts?.revisionContext;
71
- const acceptanceFindings=result?.pipeline?.state?.artifacts?.acceptanceEvidence?.findings || [];
72
- const retryFindings=(result?.attempts || []).flatMap((attempt)=>attempt?.retry?.findings || []);
73
- const evidenceRefs=[
74
- ...(revisionContext?.findingIds || []),
75
- ...acceptanceFindings.map((finding)=>finding?.id),
76
- ...retryFindings.map((finding)=>finding?.id)
77
- ].filter(Boolean);
78
- return {
79
- parentRevisionId,
80
- ...(rejected?{reason:result?.reason || result?.admission?.reasons?.[0] || 'world-revision'}:{}),
81
- ...(evidenceRefs.length?{evidenceRefs:[...new Set(evidenceRefs)]}:{})
82
- };
83
- };
84
-
85
- export const worldRevisionRepairFromExecution=(result)=>{
86
- if(result?.status!=='world-rejected') return null;
87
- const baseWorldIR=result?.worldIR || result?.pipeline?.state?.artifacts?.worldIR;
88
- const revisionContext=result?.pipeline?.state?.artifacts?.revisionContext;
89
- if(!baseWorldIR||!revisionContext||revisionContext.baseRevisionId!==baseWorldIR.revision?.id) return null;
90
- return {baseWorldIR:structuredClone(baseWorldIR),revisionContext:structuredClone(revisionContext)};
91
- };
92
-
93
- const identityScope = (identity) => {
94
- const separator=identity?.indexOf(':') ?? -1;
95
- if (separator < 0) return {};
96
- try { return JSON.parse(identity.slice(separator + 1)); } catch { return {}; }
97
- };
98
-
99
- export const recoveryOriginIdentity = (call, unresolvedMutations) => {
100
- if (!['recoverPickupBlocker','recoverArticulatedBlocker','cleanupRecoveryBlocker'].includes(call.name)) return null;
101
- const args=call.args || {};
102
- const matches=[...unresolvedMutations.values()].filter((entry)=>{
103
- if (entry.tool !== 'approachAndInteract') return false;
104
- const scope=identityScope(entry.identity);
105
- return scope.actorId===args.actorId
106
- && scope.targetId===args.targetId
107
- && (!args.partName || scope.partName===args.partName);
108
- });
109
- return matches.at(-1)?.identity || null;
110
- };
111
-
112
- export const recoveryMutationIdentity = (call, recoveryOf) => {
113
- if (!recoveryOf) return mutationIdentity(call);
114
- const originScope=identityScope(recoveryOf);
115
- const args={...(call.args || {})};
116
- if (args.partName == null && originScope.partName != null) args.partName=originScope.partName;
117
- return mutationIdentity({...call,args});
118
- };
119
-
120
- export const replanInstruction = (outcome) => COMPLETE_OUTCOMES.has(outcome?.state)
121
- ? 'World state changed. Replan from the fresh world before any further mutation.'
122
- : 'This step did not verify completion. Do not advance to a later dependent mutation; diagnose, recover, retry, or report the task incomplete.';
123
-
124
- export function annotateResult(result, sequence) {
125
- if (result && typeof result === 'object' && !Array.isArray(result)) return { ...result, _sequence:sequence };
126
- return { result, _sequence:sequence };
127
- }