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.
- package/README.md +23 -48
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +10 -229
- package/dist/index.js +192 -15462
- package/dist/index.js.map +1 -1
- package/package.json +11 -40
- package/cli.mjs +0 -27
- package/dist/AssetCompiler-CDFiElji.js +0 -2451
- package/dist/AssetCompiler-CDFiElji.js.map +0 -1
- package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
- package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
- package/dist/AssetRecipe-DmFpzxr-.js +0 -55
- package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
- package/dist/BrowserCodeWorker.js +0 -53615
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
- package/dist/SceneSerializer-DPVOyeRk.js +0 -353
- package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
- package/dist/StylePack-DNrdLeGI.js +0 -6314
- package/dist/StylePack-DNrdLeGI.js.map +0 -1
- package/dist/WorldArchive-pSBIGxLa.js +0 -420
- package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
- package/dist/WorldIO-wsDfZGM4.js +0 -150
- package/dist/WorldIO-wsDfZGM4.js.map +0 -1
- package/dist/blankWorld-CBWbwJGj.js +0 -76
- package/dist/blankWorld-CBWbwJGj.js.map +0 -1
- package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
- package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
- package/dist/environments-DgH66NqV.js +0 -4220
- package/dist/environments-DgH66NqV.js.map +0 -1
- package/dist/gltfIO-B87nJaat.js +0 -10
- package/dist/gltfIO-B87nJaat.js.map +0 -1
- package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
- package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
- package/dist/magicCabin-D64fD1E2.js +0 -11024
- package/dist/magicCabin-D64fD1E2.js.map +0 -1
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -1
- package/dist/monumentHall-BKbs0UOQ.js +0 -404
- package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
- package/dist/node.d.ts +0 -16
- package/dist/node.js +0 -25
- package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
- package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
- package/dist/runtime/application/AgentTools.js +0 -25
- package/dist/runtime/application/README.md +0 -14
- package/dist/runtime/application/buildTaskObservation.js +0 -117
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
- package/dist/runtime/application/createSession.js +0 -66
- package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
- package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
- package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
- package/dist/runtime/application/native-scene/CodeProject.js +0 -119
- package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
- package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
- package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
- package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
- package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
- package/dist/runtime/application/scene/RequestWindow.js +0 -54
- package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
- package/dist/runtime/application/scene/SceneContracts.js +0 -45
- package/dist/runtime/application/scene/SceneEditService.js +0 -144
- package/dist/runtime/application/scene/SceneFacade.js +0 -267
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
- package/dist/runtime/application/scene/SceneJobController.js +0 -229
- package/dist/runtime/application/scene/ScenePackage.js +0 -162
- package/dist/runtime/application/scene/ScenePersistence.js +0 -50
- package/dist/runtime/application/scene/SceneProject.js +0 -95
- package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
- package/dist/runtime/application/scene/StarterScene.js +0 -56
- package/dist/runtime/application/scene/WorldArchive.js +0 -87
- package/dist/runtime/application/scene/WorldDirectory.js +0 -20
- package/dist/runtime/application/scene/WorldDocument.js +0 -74
- package/dist/runtime/application/scene/WorldIO.js +0 -103
- package/dist/runtime/application/scene/WorldStorage.js +0 -137
- package/dist/runtime/application/skills/SkillRegistry.js +0 -163
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
- package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
- package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
- package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
- package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
- package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
- package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
- package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
- package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
- package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
- package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
- package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
- package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
- package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
- package/dist/runtime/application/skills/skillPrimitives.js +0 -4
- package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
- package/dist/runtime/application/tasks.jsonl +0 -67
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
- package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
- package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
- package/dist/runtime/apps/mcp-server/README.md +0 -150
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
- package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
- package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
- package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
- package/dist/runtime/apps/mcp-server/main.mjs +0 -56
- package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
- package/dist/runtime/apps/mcp-server/security.js +0 -21
- package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
- package/dist/runtime/apps/server/README.md +0 -7
- package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
- package/dist/runtime/apps/server/tasks.jsonl +0 -10
- package/dist/runtime/foundation/EventBus.js +0 -18
- package/dist/runtime/foundation/JsonGateway.js +0 -47
- package/dist/runtime/foundation/PolicyEngine.js +0 -21
- package/dist/runtime/foundation/README.md +0 -7
- package/dist/runtime/foundation/TraceRecorder.js +0 -76
- package/dist/runtime/foundation/errors.js +0 -8
- package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
- package/dist/runtime/foundation/version.js +0 -2
- package/dist/runtime/modules/agent/README.md +0 -11
- package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
- package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
- package/dist/runtime/modules/agent/prompt/index.js +0 -46
- package/dist/runtime/modules/agent/tasks.jsonl +0 -94
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
- package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
- package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
- package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
- package/dist/runtime/modules/artifact/README.md +0 -7
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
- package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
- package/dist/runtime/modules/asset/AssetModule.js +0 -399
- package/dist/runtime/modules/asset/README.md +0 -54
- package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
- package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
- package/dist/runtime/modules/asset/model/admission.js +0 -117
- package/dist/runtime/modules/asset/model/errors.js +0 -6
- package/dist/runtime/modules/asset/model/parts.js +0 -27
- package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
- package/dist/runtime/modules/asset/model/schema.js +0 -150
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
- package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
- package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
- package/dist/runtime/modules/asset/tasks.jsonl +0 -87
- package/dist/runtime/modules/generation/README.md +0 -9
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
- package/dist/runtime/modules/generation/tasks.jsonl +0 -35
- package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
- package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
- package/dist/runtime/modules/rendering/README.md +0 -7
- package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
- package/dist/runtime/modules/rendering/createRenderer.js +0 -76
- package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
- package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
- package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
- package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
- package/dist/runtime/modules/world/README.md +0 -13
- package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
- package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
- package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
- package/dist/runtime/modules/world/content/blankWorld.js +0 -35
- package/dist/runtime/modules/world/content/environments.js +0 -84
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
- package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
- package/dist/runtime/modules/world/content/magicCabin.js +0 -190
- package/dist/runtime/modules/world/content/monumentHall.js +0 -154
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
- package/dist/runtime/modules/world/errors.js +0 -9
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
- package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
- package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
- package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
- package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
- package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
- package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
- package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
- package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
- package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
- package/dist/runtime/modules/world/tasks.jsonl +0 -530
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
- package/dist/runtime/modules/world/verification/Finding.js +0 -105
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
- package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
- package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
- package/dist/runtime/package-lock.json +0 -6245
- package/dist/runtime/package.json +0 -91
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-Dudvovhu.js +0 -364
- package/dist/schema-Dudvovhu.js.map +0 -1
- package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
- package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
- package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
- package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
- package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
- package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { WORLD_BLOCK_BYTES, checkHash, hashBytes, checkCancelled, worldStorageError } from './WorldStorage.js';
|
|
2
|
-
|
|
3
|
-
const encoder = new TextEncoder(), decoder = new TextDecoder('utf-8', { fatal: true });
|
|
4
|
-
const MAGIC = encoder.encode('ASWORLD1');
|
|
5
|
-
const u32 = value => { const bytes = new Uint8Array(4); new DataView(bytes.buffer).setUint32(0, value); return bytes; };
|
|
6
|
-
|
|
7
|
-
/** Uncompressed framed content blocks. No filenames, links, executable code or decompression. */
|
|
8
|
-
export async function exportWorldArchive(storage, root, writer, { linked = false, signal } = {}) {
|
|
9
|
-
if (!writer?.write) throw new TypeError('A backpressured binary writer is required');
|
|
10
|
-
const header = encoder.encode(JSON.stringify({ schema: 'agentscape.world-package', version: 1, root, linked }));
|
|
11
|
-
if (header.length > 4096) throw worldStorageError('WORLD_HEADER_BUDGET');
|
|
12
|
-
const write = async bytes => { checkCancelled(signal); await writer.write(bytes); };
|
|
13
|
-
await write(MAGIC); await write(u32(header.length)); await write(header);
|
|
14
|
-
const pending = [root], visited = new Set();
|
|
15
|
-
while (!linked && pending.length) {
|
|
16
|
-
const ref = pending.pop();
|
|
17
|
-
if (visited.has(ref.hash)) continue;
|
|
18
|
-
visited.add(ref.hash);
|
|
19
|
-
const bytes = await storage.read(ref, { signal });
|
|
20
|
-
const descriptor = encoder.encode(JSON.stringify(ref));
|
|
21
|
-
if (descriptor.length > 4096) throw worldStorageError('WORLD_HEADER_BUDGET');
|
|
22
|
-
await write(u32(descriptor.length)); await write(descriptor); await write(bytes);
|
|
23
|
-
if (ref.kind) pending.push(...(await storage.node(ref, { signal })).refs);
|
|
24
|
-
}
|
|
25
|
-
await write(u32(0));
|
|
26
|
-
return { root, blocks: visited.size, linked };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
class Reader {
|
|
30
|
-
constructor(source, signal) { this.source = source[Symbol.asyncIterator](); this.signal = signal; this.chunk = new Uint8Array(); this.offset = 0; }
|
|
31
|
-
async take(length) {
|
|
32
|
-
if (length > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');
|
|
33
|
-
const result = new Uint8Array(length); let written = 0;
|
|
34
|
-
while (written < length) {
|
|
35
|
-
checkCancelled(this.signal);
|
|
36
|
-
if (this.offset === this.chunk.length) {
|
|
37
|
-
const item = await this.source.next();
|
|
38
|
-
if (item.done) throw worldStorageError('WORLD_TRUNCATED');
|
|
39
|
-
if (!(item.value instanceof Uint8Array) || item.value.length > WORLD_BLOCK_BYTES || !item.value.length) throw worldStorageError('WORLD_SOURCE_CHUNK_BUDGET');
|
|
40
|
-
this.chunk = item.value; this.offset = 0;
|
|
41
|
-
}
|
|
42
|
-
const take = Math.min(length - written, this.chunk.length - this.offset);
|
|
43
|
-
result.set(this.chunk.subarray(this.offset, this.offset + take), written); written += take; this.offset += take;
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
async number() { return new DataView((await this.take(4)).buffer).getUint32(0); }
|
|
48
|
-
async json(length) {
|
|
49
|
-
if (!length || length > 4096) throw worldStorageError('WORLD_HEADER_BUDGET');
|
|
50
|
-
try { return JSON.parse(decoder.decode(await this.take(length))); }
|
|
51
|
-
catch (error) { if (error.code) throw error; throw worldStorageError('WORLD_HEADER_INVALID'); }
|
|
52
|
-
}
|
|
53
|
-
async end() { if (this.offset !== this.chunk.length || !(await this.source.next()).done) throw worldStorageError('WORLD_TRAILING_BYTES'); }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Writes immutable blocks only. Caller publishes the returned root after semantic validation/commit. */
|
|
57
|
-
export async function importWorldArchive(storage, source, { signal } = {}) {
|
|
58
|
-
const reader = new Reader(source, signal);
|
|
59
|
-
try {
|
|
60
|
-
if (decoder.decode(await reader.take(8)) !== 'ASWORLD1') throw worldStorageError('WORLD_FORMAT_UNSUPPORTED');
|
|
61
|
-
const header = await reader.json(await reader.number());
|
|
62
|
-
if (header.schema !== 'agentscape.world-package' || header.version !== 1 || typeof header.linked !== 'boolean') throw worldStorageError('WORLD_VERSION_UNSUPPORTED');
|
|
63
|
-
checkHash(header.root?.hash);
|
|
64
|
-
const visited = new Set();
|
|
65
|
-
while (true) {
|
|
66
|
-
const length = await reader.number(); if (!length) break;
|
|
67
|
-
if (header.linked) throw worldStorageError('WORLD_LINKED_PAYLOAD');
|
|
68
|
-
const ref = await reader.json(length); checkHash(ref?.hash);
|
|
69
|
-
if (visited.has(ref.hash)) throw worldStorageError('WORLD_DUPLICATE_BLOCK');
|
|
70
|
-
if (!Number.isSafeInteger(ref.bytes) || ref.bytes < 0 || ref.bytes > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');
|
|
71
|
-
const bytes = await reader.take(ref.bytes);
|
|
72
|
-
if (hashBytes(bytes) !== ref.hash) throw worldStorageError('WORLD_INTEGRITY_MISMATCH');
|
|
73
|
-
await storage.put(bytes, { signal }); visited.add(ref.hash);
|
|
74
|
-
}
|
|
75
|
-
await reader.end();
|
|
76
|
-
// Validate all declared graph edges, including linked packages, before returning a usable root.
|
|
77
|
-
const pending = [header.root], checked = new Set();
|
|
78
|
-
while (pending.length) {
|
|
79
|
-
const ref = pending.pop(); if (checked.has(ref.hash)) continue;
|
|
80
|
-
if (!header.linked && !visited.has(ref.hash)) throw worldStorageError('WORLD_DEPENDENCY_MISSING');
|
|
81
|
-
checked.add(ref.hash); await storage.read(ref, { signal });
|
|
82
|
-
if (ref.kind) pending.push(...(await storage.node(ref, { signal })).refs);
|
|
83
|
-
}
|
|
84
|
-
if (!header.linked && checked.size !== visited.size) throw worldStorageError('WORLD_UNREFERENCED_BLOCK');
|
|
85
|
-
return header;
|
|
86
|
-
} finally { await reader.source.return?.(); }
|
|
87
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { checkHash, WORLD_BLOCK_BYTES, worldStorageError } from './WorldStorage.js';
|
|
2
|
-
|
|
3
|
-
/** Browser File System Access / OPFS backend. Directory handles cannot represent symbolic links. */
|
|
4
|
-
export class WorldDirectory {
|
|
5
|
-
constructor(directory) { this.directory = directory; }
|
|
6
|
-
async read(hash, expectedBytes) {
|
|
7
|
-
checkHash(hash);
|
|
8
|
-
const file = await (await this.directory.getFileHandle(hash)).getFile();
|
|
9
|
-
if (file.size !== expectedBytes || file.size > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_SIZE_MISMATCH');
|
|
10
|
-
return new Uint8Array(await file.arrayBuffer());
|
|
11
|
-
}
|
|
12
|
-
async write(hash, bytes) {
|
|
13
|
-
checkHash(hash);
|
|
14
|
-
// Content is verified by WorldStorage; writes finish before roots may be published.
|
|
15
|
-
const file = await this.directory.getFileHandle(hash, { create: true });
|
|
16
|
-
const writer = await file.createWritable();
|
|
17
|
-
try { await writer.write(bytes); await writer.close(); }
|
|
18
|
-
catch (error) { await writer.abort().catch(() => {}); throw error; }
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { WORLD_BLOCK_BYTES, checkCancelled, worldStorageError } from './WorldStorage.js';
|
|
2
|
-
|
|
3
|
-
export const WORLD_SCHEMA = 'agentscape.world';
|
|
4
|
-
export const WORLD_VERSION = 1;
|
|
5
|
-
|
|
6
|
-
/** Only small metadata is in the root. Entity and asset pages are content-addressed chains. */
|
|
7
|
-
export async function writeWorldDocument(runtime, storage, { name = 'Untitled World', signal, includeCamera = true, includeStyle = true, includeEnvironmentState = true } = {}) {
|
|
8
|
-
if (runtime.mutationOwner) throw worldStorageError('WORLD_BUSY');
|
|
9
|
-
return runtime.exclusiveMutation('world:save', () => writeLocked(runtime, storage, { name, signal, includeCamera, includeStyle, includeEnvironmentState }));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async function writeLocked(runtime, storage, { name, signal, includeCamera, includeStyle, includeEnvironmentState }) {
|
|
13
|
-
const header = runtime.serializer.serialize(runtime, { name, includeRelations: false, includeObjects: false });
|
|
14
|
-
delete header.objects; delete header.assets;
|
|
15
|
-
if (!includeCamera) delete header.camera;
|
|
16
|
-
if (!includeStyle && header.metadata) delete header.metadata.stylePack;
|
|
17
|
-
if (!includeEnvironmentState && header.metadata) delete header.metadata.environmentState;
|
|
18
|
-
const assets = new Set();
|
|
19
|
-
async function* entities() {
|
|
20
|
-
let ordinal = 0;
|
|
21
|
-
for (const entity of runtime.serializer.objects(runtime)) {
|
|
22
|
-
assets.add(entity.assetId);
|
|
23
|
-
yield { ...entity, ordinal: ordinal++ };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const entitiesRef = await storage.writePages('entities', entities(), { signal });
|
|
27
|
-
async function* assetEntries() {
|
|
28
|
-
for (const id of assets) {
|
|
29
|
-
checkCancelled(signal);
|
|
30
|
-
const manifest = runtime.assetModule.getManifest(id);
|
|
31
|
-
if (manifest.source.kind === 'builtin') {
|
|
32
|
-
yield { id, builtin: true }; continue;
|
|
33
|
-
}
|
|
34
|
-
// This read is one decode unit, never all world resources. AssetModule must enforce its decode budget.
|
|
35
|
-
const bytes = await runtime.assetModule.readAssetBytes(id);
|
|
36
|
-
async function* chunks() {
|
|
37
|
-
for (let offset = 0; offset < bytes.length; offset += WORLD_BLOCK_BYTES) yield bytes.subarray(offset, offset + WORLD_BLOCK_BYTES);
|
|
38
|
-
}
|
|
39
|
-
const resource = await storage.putResource(chunks(), { format: 'model/gltf-binary', signal });
|
|
40
|
-
const definition = structuredClone(manifest);
|
|
41
|
-
delete definition.source; delete definition.compiler; delete definition.verification;
|
|
42
|
-
yield { id, resource, definition };
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const assetsRef = await storage.writePages('assets', assetEntries(), { signal });
|
|
46
|
-
return storage.putNode('world', { schema: WORLD_SCHEMA, version: WORLD_VERSION, header,
|
|
47
|
-
environment: { plugin: runtime.environment.id, version: 1 }, entities: entitiesRef, assets: assetsRef },
|
|
48
|
-
[entitiesRef, assetsRef].filter(Boolean), { signal });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function inspectWorldDocument(storage, root, { plugins, signal } = {}) {
|
|
52
|
-
if (root?.kind !== 'world') throw worldStorageError('WORLD_FORMAT_UNSUPPORTED');
|
|
53
|
-
const { data, refs } = await storage.node(root, { signal });
|
|
54
|
-
if (data.schema !== WORLD_SCHEMA || data.version !== WORLD_VERSION) throw worldStorageError('WORLD_VERSION_UNSUPPORTED');
|
|
55
|
-
if (JSON.stringify(refs) !== JSON.stringify([data.entities, data.assets].filter(Boolean))) throw worldStorageError('WORLD_DEPENDENCY_INVALID');
|
|
56
|
-
if (!data.environment || data.environment.version !== 1 || !plugins?.has(data.environment.plugin)) throw worldStorageError('WORLD_PLUGIN_UNAVAILABLE');
|
|
57
|
-
if (data.header?.metadata?.environment !== data.environment.plugin) throw worldStorageError('WORLD_ENVIRONMENT_MISMATCH');
|
|
58
|
-
return data;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Host explicitly registers trusted implementations. Package data never supplies executable source. */
|
|
62
|
-
export class EnvironmentPlugins {
|
|
63
|
-
constructor() { this.entries = new Map(); }
|
|
64
|
-
register(id, { version = 1, create }) {
|
|
65
|
-
if (!id || version !== 1 || typeof create !== 'function' || this.entries.has(id)) throw worldStorageError('WORLD_PLUGIN_INVALID');
|
|
66
|
-
this.entries.set(id, { version, create }); return this;
|
|
67
|
-
}
|
|
68
|
-
has(id) { return this.entries.has(id); }
|
|
69
|
-
async create(descriptor, options) {
|
|
70
|
-
const plugin = this.entries.get(descriptor.plugin);
|
|
71
|
-
if (!plugin || plugin.version !== descriptor.version) throw worldStorageError('WORLD_PLUGIN_UNAVAILABLE');
|
|
72
|
-
return plugin.create(options);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { createAssetModule } from '../../modules/asset/AssetModule.js';
|
|
2
|
-
import { assetManifests } from '../../modules/asset/registry/manifests/index.js';
|
|
3
|
-
import { SceneSerializer } from '../../modules/world/runtime/SceneSerializer.js';
|
|
4
|
-
import { inspectWorldDocument, writeWorldDocument, EnvironmentPlugins } from './WorldDocument.js';
|
|
5
|
-
import { importWorldArchive, exportWorldArchive } from './WorldArchive.js';
|
|
6
|
-
import { checkCancelled, worldStorageError } from './WorldStorage.js';
|
|
7
|
-
import { ENVIRONMENTS } from '../../modules/world/content/environments.js';
|
|
8
|
-
|
|
9
|
-
export function builtinEnvironmentPlugins() {
|
|
10
|
-
const plugins = new EnvironmentPlugins();
|
|
11
|
-
for (const environment of ENVIRONMENTS) plugins.register(environment.id, {
|
|
12
|
-
create: async options => (await environment.load())({ loadAssets: typeof document !== 'undefined', ...options })
|
|
13
|
-
});
|
|
14
|
-
return plugins;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Single data import lifecycle: inspect, prepare isolated resources/state, validate, commit. */
|
|
18
|
-
export async function prepareWorld(storage, root, {
|
|
19
|
-
plugins = builtinEnvironmentPlugins(), signal, active = 'saved', maxActiveEntities = 256, gltfLoader,
|
|
20
|
-
onStage = () => {}
|
|
21
|
-
} = {}) {
|
|
22
|
-
onStage('inspect');
|
|
23
|
-
const document = await inspectWorldDocument(storage, root, { plugins, signal });
|
|
24
|
-
if (!['saved', 'none', 'bounded'].includes(active) || !Number.isSafeInteger(maxActiveEntities) || maxActiveEntities < 0) throw worldStorageError('WORLD_ACTIVATION_BUDGET');
|
|
25
|
-
onStage('prepare');
|
|
26
|
-
const builtinManifests = Object.fromEntries(Object.entries(assetManifests).filter(([, manifest]) => manifest.source?.kind === 'builtin'));
|
|
27
|
-
const assets = createAssetModule({ volatile: true, manifests: builtinManifests, manifestStore: null, libraryStore: null, gltfLoader });
|
|
28
|
-
// A failed pre-commit preparation must release resources that were never installed.
|
|
29
|
-
let environment = null;
|
|
30
|
-
try {
|
|
31
|
-
const ids = new Set(), manifests = [];
|
|
32
|
-
for await (const page of storage.pages(document.assets, 'assets', { signal })) {
|
|
33
|
-
for (const item of page) {
|
|
34
|
-
if (typeof item.id !== 'string' || ids.has(item.id)) throw worldStorageError('WORLD_ASSET_ID_CONFLICT');
|
|
35
|
-
ids.add(item.id);
|
|
36
|
-
if (item.builtin === true) {
|
|
37
|
-
if (!assets.hasAsset(item.id) || assets.getManifest(item.id).source.kind !== 'builtin') throw worldStorageError('WORLD_ASSET_UNAVAILABLE');
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (assets.hasAsset(item.id) || item.definition?.id !== item.id || item.definition?.source) throw worldStorageError('WORLD_ASSET_ID_CONFLICT');
|
|
41
|
-
const resource = await storage.node(item.resource, { signal });
|
|
42
|
-
if (resource.data.format !== 'model/gltf-binary') throw worldStorageError('WORLD_RESOURCE_FORMAT');
|
|
43
|
-
// Fully validate stream before any Runtime mutation, but retain no resource bytes.
|
|
44
|
-
for await (const _chunk of storage.resource(item.resource, { signal })) checkCancelled(signal);
|
|
45
|
-
const key = resource.data.sha256;
|
|
46
|
-
if (!assets.compiledStore.sources.has(key)) assets.compiledStore.registerSource(key, {
|
|
47
|
-
bytes: resource.data.size, read: () => storage.resource(item.resource)
|
|
48
|
-
});
|
|
49
|
-
const manifest = { ...item.definition, source: { kind: 'compiled', key } };
|
|
50
|
-
assets.registry.registerManifest(manifest); manifests.push(manifest);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const objects = []; let activeCount = 0;
|
|
54
|
-
for await (const page of storage.pages(document.entities, 'entities', { signal })) {
|
|
55
|
-
for (const object of page) {
|
|
56
|
-
if (!ids.has(object.assetId)) throw worldStorageError('WORLD_DEPENDENCY_MISSING');
|
|
57
|
-
if (!Number.isSafeInteger(object.ordinal) || object.ordinal < 0) throw worldStorageError('WORLD_ENTITY_ORDINAL');
|
|
58
|
-
if (active === 'none' || (active === 'bounded' && activeCount >= maxActiveEntities)) object.active = false;
|
|
59
|
-
if (object.active !== false && ++activeCount > maxActiveEntities) throw worldStorageError('WORLD_ACTIVATION_BUDGET');
|
|
60
|
-
objects.push(object);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
objects.sort((a, b) => a.ordinal - b.ordinal);
|
|
64
|
-
const ordered = objects.map(({ ordinal, ...object }, index) => {
|
|
65
|
-
if (ordinal !== index) throw worldStorageError('WORLD_ENTITY_ORDINAL');
|
|
66
|
-
return object;
|
|
67
|
-
});
|
|
68
|
-
onStage('validate');
|
|
69
|
-
const snapshot = new SceneSerializer().validate({ ...document.header, objects: ordered, assets: manifests });
|
|
70
|
-
checkCancelled(signal);
|
|
71
|
-
environment = await plugins.create(document.environment, {});
|
|
72
|
-
checkCancelled(signal);
|
|
73
|
-
if (environment?.id !== document.environment.plugin) throw worldStorageError('WORLD_PLUGIN_ID_MISMATCH');
|
|
74
|
-
let state = 'prepared';
|
|
75
|
-
return {
|
|
76
|
-
summary: { entities: objects.length, assets: ids.size, activeEntities: activeCount, dormantEntities: objects.length - activeCount, environment: environment.id },
|
|
77
|
-
async commit(runtime) {
|
|
78
|
-
if (state !== 'prepared') throw worldStorageError('WORLD_PREPARED_STATE');
|
|
79
|
-
checkCancelled(signal); state = 'committing'; onStage('commit');
|
|
80
|
-
try { await runtime.installWorld({ snapshot, assetModule: assets, environment }); state = 'committed'; }
|
|
81
|
-
catch (error) { state = 'failed'; environment.dispose?.(); assets.loader.gltfLoader.dispose?.(); throw error; }
|
|
82
|
-
return { root, entities: objects.length };
|
|
83
|
-
},
|
|
84
|
-
dispose() { if (state === 'prepared') { state = 'disposed'; environment.dispose?.(); assets.loader.gltfLoader.dispose?.(); } }
|
|
85
|
-
};
|
|
86
|
-
} catch (error) {
|
|
87
|
-
environment?.dispose?.();
|
|
88
|
-
assets.loader.gltfLoader.dispose?.();
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export async function importWorld(runtime, storage, source, options = {}) {
|
|
94
|
-
const { root } = await importWorldArchive(storage, source, options);
|
|
95
|
-
const prepared = await prepareWorld(storage, root, options);
|
|
96
|
-
try { return await prepared.commit(runtime); } finally { prepared.dispose(); }
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export async function exportWorld(runtime, storage, writer, options = {}) {
|
|
100
|
-
const root = await writeWorldDocument(runtime, storage, options);
|
|
101
|
-
if (writer) await exportWorldArchive(storage, root, writer, options);
|
|
102
|
-
return root;
|
|
103
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { IncrementalSha256 } from '../../modules/artifact/IncrementalSha256.js';
|
|
2
|
-
|
|
3
|
-
export const WORLD_BLOCK_BYTES = 1024 * 1024;
|
|
4
|
-
const encoder = new TextEncoder(), decoder = new TextDecoder('utf-8', { fatal: true });
|
|
5
|
-
export const worldStorageError = code => Object.assign(new Error(code), { code });
|
|
6
|
-
export function checkHash(hash) {
|
|
7
|
-
if (!/^[a-f0-9]{64}$/.test(hash)) throw worldStorageError('WORLD_HASH_INVALID');
|
|
8
|
-
return hash;
|
|
9
|
-
}
|
|
10
|
-
export const hashBytes = bytes => new IncrementalSha256().update(bytes).digestHex();
|
|
11
|
-
export function checkCancelled(signal) { if (signal?.aborted) throw worldStorageError('WORLD_CANCELLED'); }
|
|
12
|
-
|
|
13
|
-
/** Immutable content-addressed blocks. Backend owns durable bytes, never a world/entity cache. */
|
|
14
|
-
export class WorldStorage {
|
|
15
|
-
constructor(backend) {
|
|
16
|
-
if (!backend?.read || !backend?.write) throw new TypeError('WorldStorage requires a block backend');
|
|
17
|
-
this.backend = backend;
|
|
18
|
-
}
|
|
19
|
-
async put(bytes, { signal } = {}) {
|
|
20
|
-
checkCancelled(signal);
|
|
21
|
-
if (!(bytes instanceof Uint8Array) || bytes.length > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');
|
|
22
|
-
const hash = hashBytes(bytes);
|
|
23
|
-
await this.backend.write(hash, bytes);
|
|
24
|
-
checkCancelled(signal);
|
|
25
|
-
return { hash, bytes: bytes.length };
|
|
26
|
-
}
|
|
27
|
-
async read(ref, { signal } = {}) {
|
|
28
|
-
checkCancelled(signal); checkHash(ref?.hash);
|
|
29
|
-
if (!Number.isSafeInteger(ref.bytes) || ref.bytes < 0 || ref.bytes > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');
|
|
30
|
-
const bytes = await this.backend.read(ref.hash, ref.bytes);
|
|
31
|
-
checkCancelled(signal);
|
|
32
|
-
if (!(bytes instanceof Uint8Array) || bytes.length !== ref.bytes || hashBytes(bytes) !== ref.hash) throw worldStorageError('WORLD_INTEGRITY_MISMATCH');
|
|
33
|
-
return bytes;
|
|
34
|
-
}
|
|
35
|
-
async putNode(kind, data, refs = [], options = {}) {
|
|
36
|
-
return { ...await this.put(encoder.encode(JSON.stringify({ kind, data, refs })), options), kind };
|
|
37
|
-
}
|
|
38
|
-
async node(ref, options = {}) {
|
|
39
|
-
let node;
|
|
40
|
-
try { node = JSON.parse(decoder.decode(await this.read(ref, options))); }
|
|
41
|
-
catch (error) { if (error.code) throw error; throw worldStorageError('WORLD_NODE_INVALID'); }
|
|
42
|
-
if (!node || node.kind !== ref.kind || !Array.isArray(node.refs) || node.refs.length > 2048) throw worldStorageError('WORLD_NODE_INVALID');
|
|
43
|
-
for (const link of node.refs) {
|
|
44
|
-
checkHash(link?.hash);
|
|
45
|
-
if (!Number.isSafeInteger(link.bytes) || link.bytes < 0 || link.bytes > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_BLOCK_BUDGET');
|
|
46
|
-
}
|
|
47
|
-
return node;
|
|
48
|
-
}
|
|
49
|
-
/** Page list is immutable; newest page points to its predecessor. No unbounded root index. */
|
|
50
|
-
async writePages(kind, items, { pageSize = 128, signal } = {}) {
|
|
51
|
-
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 1024) throw worldStorageError('WORLD_PAGE_BUDGET');
|
|
52
|
-
let previous = null, count = 0, page = [];
|
|
53
|
-
const flush = async () => {
|
|
54
|
-
const refs = [...page.flatMap(item => item.resource ? [item.resource] : []), ...(previous ? [previous] : [])];
|
|
55
|
-
previous = await this.putNode(kind, { items: page, previous, count }, refs, { signal });
|
|
56
|
-
page = [];
|
|
57
|
-
};
|
|
58
|
-
for await (const item of items) {
|
|
59
|
-
checkCancelled(signal); page.push(item); count++;
|
|
60
|
-
if (page.length === pageSize) await flush();
|
|
61
|
-
}
|
|
62
|
-
if (page.length) await flush();
|
|
63
|
-
return previous;
|
|
64
|
-
}
|
|
65
|
-
async *pages(ref, kind, options = {}) {
|
|
66
|
-
const visited = new Set();
|
|
67
|
-
while (ref) {
|
|
68
|
-
if (ref.kind !== kind || visited.has(ref.hash)) throw worldStorageError('WORLD_PAGE_INVALID');
|
|
69
|
-
visited.add(ref.hash);
|
|
70
|
-
const node = await this.node(ref, options), { items, previous } = node.data || {};
|
|
71
|
-
if (!Array.isArray(items) || items.length > 1024 || JSON.stringify(node.refs) !== JSON.stringify([...items.flatMap(item => item.resource ? [item.resource] : []), ...(previous ? [previous] : [])])) throw worldStorageError('WORLD_PAGE_INVALID');
|
|
72
|
-
yield items; ref = previous;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/** Consumes bounded chunks with backpressure. Large producer chunks are rejected before copying. */
|
|
76
|
-
async putResource(source, { format = 'application/octet-stream', signal } = {}) {
|
|
77
|
-
const digest = new IncrementalSha256();
|
|
78
|
-
let size = 0, previous = null, blocks = [], buffer = new Uint8Array(WORLD_BLOCK_BYTES), used = 0;
|
|
79
|
-
const flushIndex = async () => {
|
|
80
|
-
const refs = [...blocks, ...(previous ? [previous] : [])];
|
|
81
|
-
previous = await this.putNode('resource-blocks', { blocks, previous }, refs, { signal }); blocks = [];
|
|
82
|
-
};
|
|
83
|
-
const flushBlock = async () => {
|
|
84
|
-
blocks.push(await this.put(buffer.subarray(0, used), { signal })); used = 0;
|
|
85
|
-
if (blocks.length === 128) await flushIndex();
|
|
86
|
-
};
|
|
87
|
-
for await (const chunk of source) {
|
|
88
|
-
checkCancelled(signal);
|
|
89
|
-
if (!(chunk instanceof Uint8Array) || chunk.length > WORLD_BLOCK_BYTES) throw worldStorageError('WORLD_SOURCE_CHUNK_BUDGET');
|
|
90
|
-
digest.update(chunk); size += chunk.length;
|
|
91
|
-
if (!Number.isSafeInteger(size)) throw worldStorageError('WORLD_SIZE_INVALID');
|
|
92
|
-
let offset = 0;
|
|
93
|
-
while (offset < chunk.length) {
|
|
94
|
-
const take = Math.min(chunk.length - offset, buffer.length - used);
|
|
95
|
-
buffer.set(chunk.subarray(offset, offset + take), used); used += take; offset += take;
|
|
96
|
-
if (used === buffer.length) await flushBlock();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (used) await flushBlock();
|
|
100
|
-
if (blocks.length) await flushIndex();
|
|
101
|
-
return this.putNode('resource', { sha256: digest.digestHex(), size, format, blocks: previous }, previous ? [previous] : [], { signal });
|
|
102
|
-
}
|
|
103
|
-
async *resource(ref, options = {}) {
|
|
104
|
-
if (ref?.kind !== 'resource') throw worldStorageError('WORLD_RESOURCE_INVALID');
|
|
105
|
-
const { data, refs } = await this.node(ref, options);
|
|
106
|
-
if (JSON.stringify(refs) !== JSON.stringify(data.blocks ? [data.blocks] : [])) throw worldStorageError('WORLD_RESOURCE_INVALID');
|
|
107
|
-
checkHash(data.sha256);
|
|
108
|
-
if (!Number.isSafeInteger(data.size) || data.size < 0) throw worldStorageError('WORLD_SIZE_INVALID');
|
|
109
|
-
// Only small index descriptors are retained, not resource bytes.
|
|
110
|
-
const pages = [], seen = new Set(); let index = data.blocks;
|
|
111
|
-
while (index) {
|
|
112
|
-
if (index.kind !== 'resource-blocks' || seen.has(index.hash)) throw worldStorageError('WORLD_RESOURCE_INVALID');
|
|
113
|
-
seen.add(index.hash);
|
|
114
|
-
const node = await this.node(index, options);
|
|
115
|
-
if (!Array.isArray(node.data.blocks) || node.data.blocks.length > 128 || JSON.stringify(node.refs) !== JSON.stringify([...node.data.blocks, ...(node.data.previous ? [node.data.previous] : [])])) throw worldStorageError('WORLD_RESOURCE_INVALID');
|
|
116
|
-
pages.push(index); index = node.data.previous;
|
|
117
|
-
}
|
|
118
|
-
let size = 0; const digest = new IncrementalSha256();
|
|
119
|
-
for (const page of pages.reverse()) {
|
|
120
|
-
const node = await this.node(page, options);
|
|
121
|
-
for (const block of node.data.blocks) {
|
|
122
|
-
const bytes = await this.read(block, options); size += bytes.length;
|
|
123
|
-
if (size > data.size) throw worldStorageError('WORLD_SIZE_MISMATCH');
|
|
124
|
-
digest.update(bytes); yield bytes;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (size !== data.size || digest.digestHex() !== data.sha256) throw worldStorageError('WORLD_RESOURCE_INTEGRITY');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** File/Blob input, never file.arrayBuffer() on an entire world. */
|
|
132
|
-
export async function* blobChunks(blob, { signal } = {}) {
|
|
133
|
-
for (let offset = 0; offset < blob.size; offset += WORLD_BLOCK_BYTES) {
|
|
134
|
-
checkCancelled(signal);
|
|
135
|
-
yield new Uint8Array(await blob.slice(offset, offset + WORLD_BLOCK_BYTES).arrayBuffer());
|
|
136
|
-
}
|
|
137
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
const objectSchema = (skill) => ({
|
|
2
|
-
type: 'object',
|
|
3
|
-
properties: skill.properties || {},
|
|
4
|
-
required: skill.required || [],
|
|
5
|
-
additionalProperties: false
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
const VERIFIED_STATUSES = new Set(['action-completed', 'arrived', 'held', 'placed', 'dropped', 'recovery-cleaned', 'repair-applied']);
|
|
9
|
-
const BLOCKED_STATUSES = new Set(['blocked', 'unreachable', 'interaction-blocked', 'pickup-blocked', 'place-blocked']);
|
|
10
|
-
const FAILED_STATUSES = new Set(['action-failed', 'place-failed']);
|
|
11
|
-
const UNVERIFIED_STATUSES = new Set(['action-unverified', 'place-unverified', 'cancelled']);
|
|
12
|
-
const REQUESTED_STATUSES = new Set(['moving', 'interaction-requested']);
|
|
13
|
-
BLOCKED_STATUSES.add("connection-required");
|
|
14
|
-
for (const status of ["generation-failed","generation-cancelled","generation-expired"]) FAILED_STATUSES.add(status);
|
|
15
|
-
for (const status of ["provider-succeeded","artifact-imported"]) UNVERIFIED_STATUSES.add(status);
|
|
16
|
-
for (const status of ["generation-pending","generation-cancelling"]) REQUESTED_STATUSES.add(status);
|
|
17
|
-
|
|
18
|
-
function classifyResult(result) {
|
|
19
|
-
if (result && typeof result === 'object' && !Array.isArray(result)) {
|
|
20
|
-
if(result.schema==='agentscape.scene-result' && result.operation==='interact') {
|
|
21
|
-
const verified=result.status==='succeeded' && result.verification?.status==='verified';
|
|
22
|
-
if (result.status === 'succeeded' && result.value?.status === 'project-action-completed' && !verified)
|
|
23
|
-
return { state:result.value.verificationRequested ? 'unverified' : 'accepted', verified:false, status:result.status, reason:'PROJECT_ACTION_UNVERIFIED' };
|
|
24
|
-
return {state:verified?'verified':result.status==='cancelled'?'unverified':'failed',verified,status:result.status,
|
|
25
|
-
reason:verified?null:result.value?.reason || result.diagnostics?.[0]?.code || 'SCENE_INTERACTION_UNVERIFIED'};
|
|
26
|
-
}
|
|
27
|
-
const toolError = typeof result.error === 'string'
|
|
28
|
-
|| (result.error && typeof result.error === 'object' && (result.error.code || result.code));
|
|
29
|
-
if (toolError) return { state:'error', verified:false, reason:result.code || result.error?.code || 'TOOL_ERROR' };
|
|
30
|
-
if (result.committed === false || result.rolledBack === true) return { state:'failed', verified:false, reason:result.reason || 'BATCH_NOT_COMMITTED' };
|
|
31
|
-
if (result.accepted === false) return { state:'failed', verified:false, reason:result.reason || 'RESULT_NOT_ACCEPTED' };
|
|
32
|
-
if (result.committed === true && result.rolledBack === false) return { state:'verified', verified:true, status:'committed' };
|
|
33
|
-
const status = typeof result.status === 'string' ? result.status : null;
|
|
34
|
-
if (status) {
|
|
35
|
-
if (status === 'authoring-provisional') return { state:'unverified', verified:false, status, reason:'ASSET_PROVISIONAL' };
|
|
36
|
-
if (status === 'authoring-code-applied') return { state:'accepted', verified:null, status };
|
|
37
|
-
if (status === 'authoring-code-rejected') return { state:'failed', verified:false, status, reason:result.reason || 'AUTHORING_CODE_REJECTED' };
|
|
38
|
-
if (status === 'authoring-code-empty') return { state:'noop', verified:false, status, reason:'AUTHORING_CODE_NO_CHANGE' };
|
|
39
|
-
if (status === 'authoring-verified') {
|
|
40
|
-
const evidence = result.verification;
|
|
41
|
-
const verified = evidence?.physics?.registered === true && evidence.physics.placement?.checked === true
|
|
42
|
-
&& evidence.physics.placement.clear === true && evidence.navigation?.success === true
|
|
43
|
-
&& ['verified', 'not-applicable'].includes(evidence.interaction?.status);
|
|
44
|
-
return { state:verified ? 'verified' : 'unverified', verified, status };
|
|
45
|
-
}
|
|
46
|
-
if(status==='world-action-completed') return result.verified===true && typeof result.evidenceKind==='string' && result.after
|
|
47
|
-
? {state:'verified',verified:true,status} : {state:'unverified',verified:false,status,reason:'POST_CONDITION_NOT_VERIFIED'};
|
|
48
|
-
if (VERIFIED_STATUSES.has(status)) {
|
|
49
|
-
const contractVerified = status === 'action-completed'
|
|
50
|
-
? result.targetReached === true && result.settled === true
|
|
51
|
-
: status === 'placed'
|
|
52
|
-
? result.supportVerified === true && result.settled === true
|
|
53
|
-
: status === 'dropped'
|
|
54
|
-
? result.released === true && result.settled === true && result.stillHeld === false
|
|
55
|
-
: status === 'recovery-cleaned'
|
|
56
|
-
? result.released === true && result.settled === true && result.sweepClear === true && result.contactClear === true
|
|
57
|
-
: true;
|
|
58
|
-
return contractVerified
|
|
59
|
-
? { state:'verified', verified:true, status }
|
|
60
|
-
: { state:'unverified', verified:false, status, reason:'POST_CONDITION_NOT_VERIFIED' };
|
|
61
|
-
}
|
|
62
|
-
if (BLOCKED_STATUSES.has(status) || status.endsWith('-blocked')) return { state:'blocked', verified:false, status, reason:result.reason || null };
|
|
63
|
-
if (FAILED_STATUSES.has(status) || status.endsWith('-failed')) return { state:'failed', verified:false, status, reason:result.reason || null };
|
|
64
|
-
if (UNVERIFIED_STATUSES.has(status) || status.endsWith('-unverified')) return { state:'unverified', verified:false, status, reason:result.reason || null };
|
|
65
|
-
if (REQUESTED_STATUSES.has(status) || status.endsWith('-requested')) return { state:'requested', verified:false, status, reason:result.reason || null };
|
|
66
|
-
if (status === 'asset-ready') return { state:'verified', verified:true, status };
|
|
67
|
-
if (status === 'asset-provisional') return { state:'unverified', verified:false, status, reason:'ASSET_PROVISIONAL' };
|
|
68
|
-
if (status === 'asset-rejected') return { state:'failed', verified:false, status, reason:'ASSET_REJECTED' };
|
|
69
|
-
if (status === 'world-accepted') return { state:'verified', verified:true, status };
|
|
70
|
-
if (status === 'world-incomplete') return { state:'unverified', verified:false, status, reason:result.reason || result.replay?.reason || 'WORLD_ACCEPTANCE_INCOMPLETE' };
|
|
71
|
-
if (status === 'world-ready') return { state:'verified', verified:true, status };
|
|
72
|
-
if (status === 'world-provisional') return { state:'unverified', verified:false, status, reason:'WORLD_PROVISIONAL' };
|
|
73
|
-
if (status === 'world-rejected') return { state:'failed', verified:false, status, reason:result.reason || 'WORLD_REJECTED' };
|
|
74
|
-
if (status === 'empty') return { state:'noop', verified:false, status, reason:'NO_ACTIVE_OBJECT' };
|
|
75
|
-
if (status === 'recovery-stale') return { state:'noop', verified:false, status, reason:result.reason || 'RECOVERY_STALE' };
|
|
76
|
-
}
|
|
77
|
-
if (result.requested === true) return { state:'requested', verified:false, reason:'REQUEST_ONLY' };
|
|
78
|
-
if (result.ok === false) return { state:'failed', verified:false, reason:result.reason || 'RESULT_NOT_OK' };
|
|
79
|
-
}
|
|
80
|
-
return { state:'accepted', verified:null };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const BATCH_REJECT_STATES = new Set(['blocked', 'failed', 'unverified', 'requested', 'error', 'noop']);
|
|
84
|
-
|
|
85
|
-
export class SkillRegistry {
|
|
86
|
-
constructor({ policy, trace, runtime } = {}) {
|
|
87
|
-
this.policy = policy;
|
|
88
|
-
this.trace = trace;
|
|
89
|
-
this.runtime = runtime;
|
|
90
|
-
this.skills = new Map();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
register(skill) {
|
|
94
|
-
if (!skill?.name || typeof skill.handler !== 'function') throw new Error('Skill requires name and handler');
|
|
95
|
-
if (this.skills.has(skill.name)) throw new Error(`Skill already registered: ${skill.name}`);
|
|
96
|
-
this.skills.set(skill.name, { version:'1.0.0', permissions:[], required:[], properties:{}, mutates:false, history:true, manualMutation:false, batchable:true, auxiliary:false, agent:true, ...skill });
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
unregister(name) { return this.skills.delete(name); }
|
|
101
|
-
|
|
102
|
-
get(name) { return this.skills.get(name); }
|
|
103
|
-
|
|
104
|
-
definitions() {
|
|
105
|
-
return [...this.skills.values()]
|
|
106
|
-
.filter((skill) => skill.agent)
|
|
107
|
-
.map((skill) => ({ name:skill.name, description:skill.description, parameters:objectSchema(skill) }));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
authorization(name, context = {}) {
|
|
111
|
-
const skill=this.skills.get(name);
|
|
112
|
-
if (!skill) return {allow:false,profile:context.profile || 'builder',missing:[],required:[],reason:'SKILL_NOT_FOUND'};
|
|
113
|
-
const profile=context.profile || 'builder';
|
|
114
|
-
const decision=this.policy?.evaluate({profile,required:skill.permissions}) ?? {allow:true,profile,missing:[]};
|
|
115
|
-
return { ...decision, required:[...skill.permissions] };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
executionPolicy(name, result) {
|
|
119
|
-
const skill = this.skills.get(name);
|
|
120
|
-
const outcome = classifyResult(result);
|
|
121
|
-
const mutates = Boolean(skill?.mutates);
|
|
122
|
-
return {
|
|
123
|
-
mutates,
|
|
124
|
-
history:skill?.history !== false,
|
|
125
|
-
barrier:mutates,
|
|
126
|
-
auxiliary:Boolean(skill?.auxiliary),
|
|
127
|
-
tracksUnresolved:!skill?.auxiliary,
|
|
128
|
-
batchable:skill?.batchable !== false,
|
|
129
|
-
batchAcceptable:!BATCH_REJECT_STATES.has(outcome.state),
|
|
130
|
-
outcome
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async invoke(name, input = {}, context = {}) {
|
|
135
|
-
const skill = this.skills.get(name);
|
|
136
|
-
if (!skill) return { success:false, error:{ code:'not_found', message:`Unknown skill: ${name}` } };
|
|
137
|
-
|
|
138
|
-
const missing = skill.required.filter((key) => input?.[key] == null);
|
|
139
|
-
if (missing.length) return { success:false, error:{ code:'invalid_input', message:`Missing required fields: ${missing.join(', ')}` } };
|
|
140
|
-
const validation = skill.validate?.(input);
|
|
141
|
-
if (validation?.ok === false) return { success:false, error:{ code:'invalid_input', message:validation.message } };
|
|
142
|
-
|
|
143
|
-
const actor = context.actor || 'agent';
|
|
144
|
-
const decision = this.authorization(name,context);
|
|
145
|
-
const policyEvent = this.trace?.emit('policy.decision', { skill:name, allow:decision.allow, missing:decision.missing }, { actor });
|
|
146
|
-
if (!decision.allow) return { success:false, error:{ code:'forbidden', message:`Missing permissions: ${decision.missing.join(', ')}` } };
|
|
147
|
-
|
|
148
|
-
const execute = () => skill.handler(input, { runtime:this.runtime, registry:this, context });
|
|
149
|
-
try {
|
|
150
|
-
let result;
|
|
151
|
-
if (skill.mutates && !skill.manualMutation && !context.skipHistory) {
|
|
152
|
-
if (skill.history === false && this.runtime?.exclusiveMutation) result=await this.runtime.exclusiveMutation(`skill:${name}`,execute);
|
|
153
|
-
else if (this.runtime?.mutate) result=await this.runtime.mutate(`skill:${name}`, execute, { source:actor, skill:name, input });
|
|
154
|
-
else result=await execute();
|
|
155
|
-
} else result=await execute();
|
|
156
|
-
this.trace?.emit('skill.executed', { skill:name, version:skill.version, input, result:result ?? { ok:true } }, { actor, causedBy:policyEvent ? [policyEvent.seq] : [] });
|
|
157
|
-
return { success:true, result:result ?? { ok:true } };
|
|
158
|
-
} catch (error) {
|
|
159
|
-
this.trace?.emit('skill.failed', { skill:name, input, error:error.message, code:error.code }, { actor });
|
|
160
|
-
return { success:false, error:{ code:error.code || 'handler_error', message:error.message } };
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { buildAcceptanceEvidenceBundle, compileWorldAcceptance, evaluateWorldAcceptance, replayAcceptanceEvidence } from '../../../modules/world/verification/WorldAcceptance.js';
|
|
2
|
-
import { meta } from '../skillPrimitives.js';
|
|
3
|
-
|
|
4
|
-
export function registerAcceptanceSkills(add,runtime) {
|
|
5
|
-
add('evaluateWorldAcceptance', { ...meta('对当前世界执行显式 world-level acceptance criteria。只读;返回逐项证据和最终 world-accepted/world-incomplete。', ['world.read','physics.read'], ['criteria'], { criteria:{type:'array'} }), batchable:true, mutates:false }, async (a) => {
|
|
6
|
-
const graph=compileWorldAcceptance(a.criteria || []);
|
|
7
|
-
const task=runtime.lastTaskObservation || {};
|
|
8
|
-
const result=evaluateWorldAcceptance(runtime,graph,{unresolvedMutations:Array.isArray(task.unresolvedMutations)?task.unresolvedMutations:undefined});
|
|
9
|
-
const revision=runtime.currentWorldRevision;
|
|
10
|
-
const bundle=buildAcceptanceEvidenceBundle(graph,result,{source:'agent-tool',worldRevisionId:revision?.revision?.id || null,provenance:revision?.provenance || null});
|
|
11
|
-
runtime.lastAcceptanceBundle=structuredClone(bundle);
|
|
12
|
-
runtime.trace?.emit?.('world.acceptance',{bundle:structuredClone(bundle)},{actor:'agent'});
|
|
13
|
-
return {...result,acceptanceBundle:bundle};
|
|
14
|
-
});
|
|
15
|
-
add('replayWorldAcceptance', { ...meta('重新验证已保存的 acceptance evidence。restore 后的 evidence 仅是 historical;只有 revision 绑定一致且当前 Runtime 重跑 criteria 后仍为 world-accepted,才会生成新的 current acceptance bundle。', ['world.read','physics.read'], [], { evidence:{type:'object'} }), batchable:true, mutates:false }, async (a) => {
|
|
16
|
-
const source=a.evidence || runtime.restoredAcceptanceEvidence || runtime.lastAcceptanceBundle;
|
|
17
|
-
const task=runtime.lastTaskObservation || {};
|
|
18
|
-
let replay;
|
|
19
|
-
if(source){
|
|
20
|
-
replay=replayAcceptanceEvidence(runtime,source,{unresolvedMutations:Array.isArray(task.unresolvedMutations)?task.unresolvedMutations:undefined});
|
|
21
|
-
} else {
|
|
22
|
-
const graph=compileWorldAcceptance([]);
|
|
23
|
-
const result={schema:'agentscape.world-acceptance',schemaVersion:1,status:'world-incomplete',checks:[{id:'acceptance-evidence',kind:'evidence',verified:false,reason:'ACCEPTANCE_EVIDENCE_MISSING'}],verifiedCount:0,failedCount:1};
|
|
24
|
-
const revision=runtime.currentWorldRevision;
|
|
25
|
-
const bundle=buildAcceptanceEvidenceBundle(graph,result,{source:'acceptance-replay',worldRevisionId:revision?.revision?.id || null,provenance:revision?.provenance || null});
|
|
26
|
-
replay={...result,replay:{status:'unavailable',reason:'ACCEPTANCE_EVIDENCE_MISSING',evidenceRevisionId:null,currentRevisionId:revision?.revision?.id || null,previousStatus:null,changedCriteria:['acceptance-evidence']},acceptanceBundle:bundle};
|
|
27
|
-
}
|
|
28
|
-
runtime.lastAcceptanceBundle=structuredClone(replay.acceptanceBundle);
|
|
29
|
-
runtime.trace?.emit?.('world.acceptance-replayed',{replay:structuredClone(replay.replay),bundle:structuredClone(replay.acceptanceBundle)},{actor:'agent'});
|
|
30
|
-
return replay;
|
|
31
|
-
});
|
|
32
|
-
}
|