@craft_eco/craft-mcp 0.0.0-stage → 0.1.14
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 +32 -2
- package/bin/craft-mcp.mjs +7 -0
- package/dist-server/core/app-paths.mjs +15 -0
- package/dist-server/core/auth-store.mjs +70 -0
- package/dist-server/core/connector-auth.mjs +30 -0
- package/dist-server/core/http-utils.mjs +14 -0
- package/dist-server/game-workflow/asset-formats.mjs +76 -0
- package/dist-server/game-workflow/asset-import.mjs +113 -0
- package/dist-server/game-workflow/asset-inputs.mjs +10 -0
- package/dist-server/game-workflow/assets.mjs +161 -0
- package/dist-server/game-workflow/capture-worker.mjs +14 -0
- package/dist-server/game-workflow/check.mjs +74 -0
- package/dist-server/game-workflow/draft-archive.mjs +91 -0
- package/dist-server/game-workflow/draft-bindings.mjs +35 -0
- package/dist-server/game-workflow/draft-uploads.mjs +207 -0
- package/dist-server/game-workflow/engines.mjs +30 -0
- package/dist-server/game-workflow/library-assets.mjs +77 -0
- package/dist-server/game-workflow/library-candidates.mjs +37 -0
- package/dist-server/game-workflow/library-catalog.mjs +45 -0
- package/dist-server/game-workflow/project-leases.mjs +52 -0
- package/dist-server/game-workflow/projects.mjs +92 -0
- package/dist-server/game-workflow/publication-materials.mjs +67 -0
- package/dist-server/game-workflow/publications.mjs +146 -0
- package/dist-server/game-workflow/publish-capture-worker.mjs +57 -0
- package/dist-server/game-workflow/publish-capture.mjs +75 -0
- package/dist-server/game-workflow/request-store.mjs +52 -0
- package/dist-server/game-workflow/resource-catalog.mjs +97 -0
- package/dist-server/game-workflow/tasks.mjs +93 -0
- package/dist-server/mcp/asset-tools.mjs +42 -0
- package/dist-server/mcp/control-panel.html +17 -0
- package/dist-server/mcp/control-panel.mjs +40 -0
- package/dist-server/mcp/publication-tools.mjs +19 -0
- package/dist-server/mcp/server.mjs +297 -0
- package/dist-server/mcp/start.mjs +20 -0
- package/dist-server/preview/local-static-preview.mjs +71 -0
- package/dist-server/preview/preview-control.mjs +35 -0
- package/dist-server/preview/preview-launcher.mjs +26 -0
- package/dist-server/preview/preview-snapshot.mjs +35 -0
- package/dist-server/preview/preview-start.mjs +12 -0
- package/dist-server/preview/preview-worker.mjs +68 -0
- package/dist-server/upstream/craft-aigc.mjs +197 -0
- package/dist-server/upstream/library-url.mjs +14 -0
- package/dist-server/upstream/publication-transport.mjs +80 -0
- package/package.json +33 -4
- package/resources/craft-game-maker/SKILL.md +67 -0
- package/resources/craft-game-maker/js.md +9 -0
- package/resources/craft-game-maker/js3d.md +12 -0
- package/resources/game_visual_qa.mjs +1143 -0
- package/resources/js/context/CLAUDE.md +54 -0
- package/resources/js/context/agents/aigc-manager.md +91 -0
- package/resources/js/context/hooks/hooks.json +20 -0
- package/resources/js/context/knowledge/AigcEnabled.md +41 -0
- package/resources/js/context/knowledge/AigcWiring.md +200 -0
- package/resources/js/context/knowledge/AssetUrl.md +24 -0
- package/resources/js/context/knowledge/FrontendComponents.md +23 -0
- package/resources/js/context/knowledge/GameProbe.md +74 -0
- package/resources/js/context/knowledge/Lifecycle.md +27 -0
- package/resources/js/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -0
- package/resources/js/context/knowledge/Multiplayer/OverviewKnowledge.md +115 -0
- package/resources/js/context/knowledge/Multiplayer/StateSyncKnowledge.md +392 -0
- package/resources/js/context/knowledge/PlatformServices.md +184 -0
- package/resources/js/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -0
- package/resources/js/context/knowledge/Ui.md +11 -0
- package/resources/js/context/knowledge/UiEditorCompat.md +21 -0
- package/resources/js/context/rules/MultiplayerCapability.md +23 -0
- package/resources/js/context/rules/MultiplayerRoomEntryUX.md +63 -0
- package/resources/js/context/rules/PlatformBoundaryModules.md +43 -0
- package/resources/js/context/skills/aigc-generate/SKILL.md +301 -0
- package/resources/js/context/skills/aigc-generate/knowledge/audio.md +39 -0
- package/resources/js/context/skills/aigc-generate/knowledge/batch-replace.md +14 -0
- package/resources/js/context/skills/aigc-generate/knowledge/character2d.md +129 -0
- package/resources/js/context/skills/aigc-generate/knowledge/non-stepwise-aigc.md +54 -0
- package/resources/js/context/skills/aigc-generate/knowledge/texture-prop.md +50 -0
- package/resources/js/context/skills/aigc-generate/knowledge/texture-scene.md +201 -0
- package/resources/js/context/skills/aigc-generate/knowledge/texture-ui.md +53 -0
- package/resources/js/context/skills/aigc-generate/scripts/apply-results.mjs +83 -0
- package/resources/js/context/skills/aigc-generate/scripts/config.json +29 -0
- package/resources/js/context/skills/aigc-generate/scripts/generate.mjs +1016 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/client.mjs +228 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/ledger.mjs +119 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/nstep-handoff.mjs +100 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/pipelines.mjs +441 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/queue.mjs +283 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/submit.mjs +122 -0
- package/resources/js/context/skills/aigc-generate/scripts/worker.mjs +171 -0
- package/resources/js/context/skills/asset-search/SKILL.md +73 -0
- package/resources/js/context/skills/asset-search/scripts/asset_display.mjs +62 -0
- package/resources/js/context/skills/asset-search/scripts/config.json +5 -0
- package/resources/js/context/skills/asset-search/scripts/provided_assets.mjs +125 -0
- package/resources/js/context/skills/asset-search/scripts/recalled_sprite_paths.mjs +47 -0
- package/resources/js/context/skills/asset-search/scripts/search.mjs +749 -0
- package/resources/js/context/skills/asset-search/scripts/sprite_source_materializer.mjs +723 -0
- package/resources/js/context/skills/asset-search/strategies/audio.md +34 -0
- package/resources/js/context/skills/asset-search/strategies/character2d.md +33 -0
- package/resources/js/context/skills/asset-search/strategies/effect2d.md +31 -0
- package/resources/js/context/skills/asset-search/strategies/texture-prop.md +22 -0
- package/resources/js/context/skills/asset-search/strategies/texture-ui.md +35 -0
- package/resources/js/context/skills/asset-search/strategies/ui-common.md +40 -0
- package/resources/js/context/skills/asset-search/strategies/ui-style.md +28 -0
- package/resources/js/context/skills/display-info-setup/SKILL.md +32 -0
- package/resources/js/context/skills/display-info-setup/scripts/init_project.mjs +38 -0
- package/resources/js/context/skills/export-config/SKILL.md +20 -0
- package/resources/js/context/skills/export-config/scripts/assert-asset-wiring.mjs +72 -0
- package/resources/js/context/skills/export-config/scripts/export-config.mjs +43 -0
- package/resources/js/context/skills/export-config/scripts/panel-resource-path.mjs +106 -0
- package/resources/js/context/skills/export-config/scripts/sync-asset-controls.mjs +351 -0
- package/resources/js/context/skills/export-config/scripts/translate-asset-titles.mjs +163 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/SKILL.md +92 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/game-runtime.json +7 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/package.json +22 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/config.d.mts +19 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/config.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +39 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +25 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform.d.mts +79 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform.mjs +29 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.d.mts +49 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/release.json +37 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/cli.mjs +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.d.mts +8 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.mjs +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +3 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.mjs +8 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/assets.d.mts +24 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/assets.mjs +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/astc.d.mts +10 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/astc.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.d.mts +20 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +21 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.d.mts +17 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.d.mts +40 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.d.mts +10 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.d.mts +8 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/config-export.mjs +32 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/refresh-runtime.mjs +50 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/ui-stage.ts +121 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/viewport.ts +254 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/main.ts +99 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/platform.ts +14 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/screenUi.ts +172 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/style.css +165 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/tsconfig.json +20 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/vite.config.ts +4 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/scripts/install-template.mjs +109 -0
- package/resources/js/context/skills/mobile-adaptation/SKILL.md +260 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +50 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +881 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +134 -0
- package/resources/js/context/skills/mobile-adaptation/references/input-config.md +311 -0
- package/resources/js/context/skills/mobile-adaptation/references/verification.md +106 -0
- package/resources/js/context/skills/optimization-suggestions/SKILL.md +89 -0
- package/resources/js/context/skills/platform-services/SKILL.md +94 -0
- package/resources/js/context/skills/platform-services/assets/modules/MultiplayerManager.ts +783 -0
- package/resources/js/context/skills/platform-services/assets/modules/eventBus.ts +57 -0
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -0
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -0
- package/resources/js/context/skills/platform-services/assets/modules/log.ts +35 -0
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.d.mts +25 -0
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.mjs +1 -0
- package/resources/js/context/skills/platform-services/assets/modules/save.d.mts +49 -0
- package/resources/js/context/skills/platform-services/assets/modules/save.mjs +1 -0
- package/resources/js/context/skills/platform-services/assets/release.json +44 -0
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -0
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -0
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -0
- package/resources/js/context/skills/platform-services/references/SERVER_GUIDE.md +139 -0
- package/resources/js/context/skills/platform-services/references/api_reference.md +18 -0
- package/resources/js/context/skills/platform-services/scripts/install.mjs +134 -0
- package/resources/js/context/skills/resolution-adaptation/SKILL.md +202 -0
- package/resources/js/context/skills/resolution-adaptation/assets/display/ui-stage.ts +121 -0
- package/resources/js/context/skills/resolution-adaptation/assets/display/viewport.ts +254 -0
- package/resources/js/context/skills/resolution-adaptation/assets/example/main.ts +98 -0
- package/resources/js/context/skills/resolution-adaptation/assets/example/ui-tokens.css +200 -0
- package/resources/js/context/skills/resolution-adaptation/references/layout-rules.md +134 -0
- package/resources/js/context/skills/resolution-adaptation/references/viewport-api.md +119 -0
- package/resources/js/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +338 -0
- package/resources/js/context/skills/scene-editor-compat/SKILL.md +94 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.assets.json +13 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.scene-editor.json +6 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/game/sceneAdapter.ts +25 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/scenes/main.scene.json +18 -0
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/release.json +7 -0
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.d.mts +42 -0
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.mjs +144 -0
- package/resources/js/context/skills/scene-editor-compat/docs/contract.md +330 -0
- package/resources/js/context/skills/scene-editor-compat/docs/resource-sync.md +64 -0
- package/resources/js/context/skills/scene-editor-compat/docs/runtime-state.md +28 -0
- package/resources/js/context/skills/scene-editor-compat/docs/terrain-contract.md +47 -0
- package/resources/js/context/skills/scene-editor-compat/docs/visual-contract.md +64 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.assets.json +38 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.scene-editor.json +9 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneAdapter.ts +59 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneBlockers.ts +30 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneFileAssets.ts +66 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/Main.Scene.ts +20 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/SceneTypes.ts +26 -0
- package/resources/js/context/skills/scene-editor-compat/references/contract.md +73 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/apply_scene_marker.py +162 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_contract.py +853 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_resource_urls.py +173 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/scene-editor.mjs +427 -0
- package/resources/js/context/skills/scene-editor-compat/version.json +1 -0
- package/resources/js/context/skills/ui-editor-compat/SKILL.md +48 -0
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -0
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +74 -0
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -0
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -0
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -0
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/release.json +7 -0
- package/resources/js/context/skills/ui-editor-compat/references/contract.md +132 -0
- package/resources/js/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -0
- package/resources/js/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -0
- package/resources/js/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -0
- package/resources/js/context/skills/version-update/SKILL.md +192 -0
- package/resources/js/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -0
- package/resources/js/context/skills/version-update/scripts/feature_snapshot.mjs +159 -0
- package/resources/js/context/skills/version-update/scripts/update_feature_version.mjs +157 -0
- package/resources/js/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
- package/resources/js/context/skills/visual-qa/SKILL.md +36 -0
- package/resources/js/context/version/version.json +1 -0
- package/resources/js/project/.gitattributes +2 -0
- package/resources/js/project/README.md +99 -0
- package/resources/js/project/SPEC/assist/.gitkeep +0 -0
- package/resources/js/project/SPEC/guide/.gitkeep +0 -0
- package/resources/js/project/SPEC/plan/.gitkeep +0 -0
- package/resources/js/project/SPEC/readme.md +6 -0
- package/resources/js/project/SPEC/res/.gitkeep +0 -0
- package/resources/js/project/SPEC/task-item/.gitkeep +0 -0
- package/resources/js/project/configs/assets.json +1 -0
- package/resources/js/project/configs/game.controls.json +3 -0
- package/resources/js/project/configs/game.json +3 -0
- package/resources/js/project/game-runtime.json +7 -0
- package/resources/js/project/gameplay-probe.json +37 -0
- package/resources/js/project/index.html +20 -0
- package/resources/js/project/package-lock.json +1155 -0
- package/resources/js/project/package.json +23 -0
- package/resources/js/project/projectDisplayInfo.json +7 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/config.d.mts +19 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/config.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +39 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +25 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.d.mts +79 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.mjs +29 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/save.d.mts +49 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/save.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/release.json +37 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/cli.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.d.mts +8 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +3 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.mjs +8 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.d.mts +24 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.d.mts +10 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.d.mts +20 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +21 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/input.d.mts +17 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/input.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/three.d.mts +40 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/three.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.d.mts +10 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/video.d.mts +8 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/video.mjs +1 -0
- package/resources/js/project/scripts/config-export.mjs +32 -0
- package/resources/js/project/scripts/refresh-runtime.mjs +50 -0
- package/resources/js/project/src/display/ui-stage.ts +121 -0
- package/resources/js/project/src/display/viewport.ts +254 -0
- package/resources/js/project/src/main.ts +99 -0
- package/resources/js/project/src/platform.ts +14 -0
- package/resources/js/project/src/scenes/LoadScene.ts +89 -0
- package/resources/js/project/src/scenes/PlayScene.ts +17 -0
- package/resources/js/project/src/screenUi.ts +172 -0
- package/resources/js/project/src/style.css +165 -0
- package/resources/js/project/tsconfig.json +20 -0
- package/resources/js/project/unified_data_control_config.json +20 -0
- package/resources/js/project/vendor/core-manager-js/package.json +33 -0
- package/resources/js/project/vendor/core-manager-js/src/.versions.json +42 -0
- package/resources/js/project/vendor/core-manager-js/src/CoreManagerPlugin.ts +41 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AssetRef.ts +90 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcFirstImageFile.ts +203 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcTextureLoader.ts +106 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.test.ts +25 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.ts +21 -0
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.test.ts +65 -0
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.ts +340 -0
- package/resources/js/project/vendor/core-manager-js/src/configManager/FeatureConfig.ts +87 -0
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.d.mts +92 -0
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.mjs +271 -0
- package/resources/js/project/vendor/core-manager-js/src/index.ts +31 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputConfig.ts +81 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.test.ts +43 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.ts +32 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.test.ts +141 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.ts +20 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/KeyboardProvider.ts +183 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/TouchProvider.ts +304 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/VirtualJoystick.ts +351 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/_internal/InputManagerImpl.ts +180 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64 +13 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64.d.ts +14 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/input_config.example.json +68 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/DebugConsole.ts +433 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogCapture.ts +118 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogManager.ts +444 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCapture.ts +485 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.test.ts +66 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.ts +149 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/icons.b64 +9 -0
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/AssetUrlResolver.ts +29 -0
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.test.ts +88 -0
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.ts +122 -0
- package/resources/js/project/vendor/core-manager-js/src/runtime.ts +24 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterEntity.ts +318 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.test.ts +151 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.ts +235 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.test.ts +98 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.ts +94 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectEntity.ts +209 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.test.ts +106 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.ts +341 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.test.ts +68 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.ts +236 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.test.ts +22 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.ts +29 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteEntity.test.ts +197 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiContracts.ts +9 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiKit.ts +555 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.test.ts +112 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.ts +178 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/ui-base.css +246 -0
- package/resources/js/project/vendor/core-manager-js/src/videoManager/VideoManager.ts +139 -0
- package/resources/js/project/vendor/core-manager-js/tsconfig.json +15 -0
- package/resources/js/project/vendor/run.sh +107 -0
- package/resources/js/project/version/craft_feature_version.json +42 -0
- package/resources/js/project/version/project_feature_version.json +11 -0
- package/resources/js/project/vite.config.ts +4 -0
- package/resources/js3d/context/CLAUDE.md +50 -0
- package/resources/js3d/context/hooks/hooks.json +20 -0
- package/resources/js3d/context/knowledge/3D/PoseInterpolationKnowledge.md +87 -0
- package/resources/js3d/context/knowledge/CodingGuide/Pitfalls.md +69 -0
- package/resources/js3d/context/knowledge/CodingGuide/SceneEditableGuide.md +42 -0
- package/resources/js3d/context/knowledge/FrontendComponents.md +23 -0
- package/resources/js3d/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -0
- package/resources/js3d/context/knowledge/Multiplayer/OverviewKnowledge.md +117 -0
- package/resources/js3d/context/knowledge/Multiplayer/StateSyncKnowledge.md +430 -0
- package/resources/js3d/context/knowledge/PlatformServices.md +162 -0
- package/resources/js3d/context/knowledge/Runtime.md +30 -0
- package/resources/js3d/context/knowledge/SceneEditorCompat.md +34 -0
- package/resources/js3d/context/knowledge/StepByStep.md +21 -0
- package/resources/js3d/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -0
- package/resources/js3d/context/knowledge/UiEditorCompat.md +21 -0
- package/resources/js3d/context/rules/MultiplayerCapability.md +27 -0
- package/resources/js3d/context/rules/MultiplayerRoomEntryUX.md +63 -0
- package/resources/js3d/context/rules/PlatformBoundaryModules.md +43 -0
- package/resources/js3d/context/skills/aigc-integration/SKILL.md +176 -0
- package/resources/js3d/context/skills/aigc-integration/callback.md +56 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/README.md +22 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/audio-aigc-knowledge.md +38 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/staticmesh-aigc-knowledge.md +33 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-prop-aigc-knowledge.md +36 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-scene-aigc-knowledge.md +37 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-ui-aigc-knowledge.md +35 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/config.json +3 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/lib/submit.mjs +344 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/query-music.mjs +53 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/query-results.mjs +53 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-cover.mjs +44 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-image.mjs +48 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-music.mjs +34 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-staticmesh.mjs +39 -0
- package/resources/js3d/context/skills/asset-search/SKILL.md +159 -0
- package/resources/js3d/context/skills/asset-search/references/resource-config.md +56 -0
- package/resources/js3d/context/skills/asset-search/scripts/asset_display.mjs +62 -0
- package/resources/js3d/context/skills/asset-search/scripts/config.json +213 -0
- package/resources/js3d/context/skills/asset-search/scripts/manifest_pipeline.mjs +885 -0
- package/resources/js3d/context/skills/asset-search/scripts/preflight.mjs +79 -0
- package/resources/js3d/context/skills/asset-search/scripts/provided_assets.mjs +74 -0
- package/resources/js3d/context/skills/asset-search/scripts/search.mjs +597 -0
- package/resources/js3d/context/skills/export-config/scripts/assert-asset-wiring.mjs +83 -0
- package/resources/js3d/context/skills/export-config/scripts/export-config.mjs +53 -0
- package/resources/js3d/context/skills/export-config/scripts/panel-resource-path.mjs +106 -0
- package/resources/js3d/context/skills/export-config/scripts/sync-asset-controls.mjs +325 -0
- package/resources/js3d/context/skills/export-config/scripts/sync-scene-assets.mjs +181 -0
- package/resources/js3d/context/skills/export-config/scripts/translate-asset-titles.mjs +163 -0
- package/resources/js3d/context/skills/game-art-style/SKILL.md +60 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/cartoon.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/comic.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/cozy.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/cyber.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/horror.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/lowpoly.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/paper.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/voxel.png +0 -0
- package/resources/js3d/context/skills/game-art-style/references/art-parameters-lite.md +38 -0
- package/resources/js3d/context/skills/game-art-style/references/construction.md +111 -0
- package/resources/js3d/context/skills/game-art-style/references/materials-textures.md +105 -0
- package/resources/js3d/context/skills/game-art-style/references/sources.md +25 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/cartoon.md +175 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/comic.md +168 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/cozy.md +191 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/cyber.md +165 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/horror.md +173 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/lowpoly.md +185 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/paper.md +181 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/voxel.md +189 -0
- package/resources/js3d/context/skills/game-art-style/references/user-style-document.md +88 -0
- package/resources/js3d/context/skills/mobile-adaptation/SKILL.md +284 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +104 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +952 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +256 -0
- package/resources/js3d/context/skills/mobile-adaptation/references/input-config.md +311 -0
- package/resources/js3d/context/skills/mobile-adaptation/references/verification.md +106 -0
- package/resources/js3d/context/skills/optimization-suggestions/SKILL.md +74 -0
- package/resources/js3d/context/skills/platform-services/SKILL.md +94 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/MultiplayerManager.ts +783 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/eventBus.ts +57 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/log.ts +35 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.d.mts +25 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.mjs +1 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/save.d.mts +49 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/save.mjs +1 -0
- package/resources/js3d/context/skills/platform-services/assets/release.json +44 -0
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -0
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -0
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -0
- package/resources/js3d/context/skills/platform-services/references/SERVER_GUIDE.md +139 -0
- package/resources/js3d/context/skills/platform-services/references/api_reference.md +18 -0
- package/resources/js3d/context/skills/platform-services/scripts/install.mjs +134 -0
- package/resources/js3d/context/skills/resolution-adaptation/SKILL.md +170 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/ui-stage.ts +121 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/viewport.ts +244 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/main.ts +127 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/ui-tokens.css +188 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/layout-rules.md +124 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/viewport-api.md +117 -0
- package/resources/js3d/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +338 -0
- package/resources/js3d/context/skills/scene-editor-compat/SKILL.md +599 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/bundle-contract.md +141 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/editor-integration.md +92 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/scene-data-format.md +125 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/slots-rules.md +113 -0
- package/resources/js3d/context/skills/scene-editor-compat/scripts/scene-editor.mjs +1187 -0
- package/resources/js3d/context/skills/threejs-game-quality/SKILL.md +52 -0
- package/resources/js3d/context/skills/threejs-game-quality/agents/openai.yaml +4 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/01-build.md +94 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/02-avoid.md +50 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/03-detect.md +105 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-by-genre.md +147 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-distance.md +79 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-sources.md +56 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/character-motion-face.md +51 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/parameter-contract.md +55 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/refine-existing.md +78 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/rendering-stability.md +84 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/runtime-tools.md +120 -0
- package/resources/js3d/context/skills/threejs-game-quality/scripts/package.json +4 -0
- package/resources/js3d/context/skills/threejs-game-quality/scripts/runtime-audit.js +238 -0
- package/resources/js3d/context/skills/ui-editor-compat/SKILL.md +59 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +61 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/release.json +7 -0
- package/resources/js3d/context/skills/ui-editor-compat/references/contract.md +110 -0
- package/resources/js3d/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -0
- package/resources/js3d/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -0
- package/resources/js3d/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -0
- package/resources/js3d/context/skills/version-update/SKILL.md +191 -0
- package/resources/js3d/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -0
- package/resources/js3d/context/skills/version-update/scripts/feature_snapshot.mjs +159 -0
- package/resources/js3d/context/skills/version-update/scripts/update_feature_version.mjs +157 -0
- package/resources/js3d/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
- package/resources/js3d/context/version/version.json +1 -0
- package/resources/js3d/project/.gitattributes +2 -0
- package/resources/js3d/project/README.md +100 -0
- package/resources/js3d/project/configs/game.controls.json +3 -0
- package/resources/js3d/project/configs/game.json +3 -0
- package/resources/js3d/project/game-runtime.json +7 -0
- package/resources/js3d/project/gameplay-probe.json +38 -0
- package/resources/js3d/project/index.html +12 -0
- package/resources/js3d/project/package-lock.json +1204 -0
- package/resources/js3d/project/package.json +24 -0
- package/resources/js3d/project/projectDisplayInfo.json +7 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.d.mts +19 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +39 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +25 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.d.mts +79 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.mjs +30 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.d.mts +49 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/release.json +39 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/cli.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.d.mts +8 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +3 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.mjs +7 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.d.mts +24 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.d.mts +10 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.d.mts +20 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +21 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.d.mts +36 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.mjs +359 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.test.mjs +25 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.d.mts +17 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.d.mts +40 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.d.mts +10 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.d.mts +8 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.mjs +1 -0
- package/resources/js3d/project/scripts/config-export.mjs +32 -0
- package/resources/js3d/project/scripts/refresh-runtime.mjs +50 -0
- package/resources/js3d/project/src/display/ui-stage.ts +121 -0
- package/resources/js3d/project/src/display/viewport.ts +244 -0
- package/resources/js3d/project/src/main.ts +83 -0
- package/resources/js3d/project/src/platform.ts +14 -0
- package/resources/js3d/project/src/style.css +17 -0
- package/resources/js3d/project/tsconfig.json +20 -0
- package/resources/js3d/project/unified_data_control_config.json +20 -0
- package/resources/js3d/project/vendor/core-manager-three/package.json +12 -0
- package/resources/js3d/project/vendor/core-manager-three/src/index.ts +2 -0
- package/resources/js3d/project/vendor/run.sh +4 -0
- package/resources/js3d/project/version/craft_feature_version.json +42 -0
- package/resources/js3d/project/version/project_feature_version.json +11 -0
- package/resources/js3d/project/vite.config.ts +4 -0
- package/vendor/agent-cli/dist/runtime-tools/registry.json +6 -0
- package/vendor/agent-cli/dist/runtime-tools/tool-bundle-types.d.cts +15 -0
- package/vendor/agent-cli/dist/runtime-tools/tool-bundle.cjs +129 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/blender-cook-assets.cjs +296 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/context-adapter.cjs +48 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/scene-process-lock.cjs +110 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/tool-manifest.json +22 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/ue-asset-references.cjs +305 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts +3 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js +45 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts +57 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.js +198 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts +32 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js +146 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts +28 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.js +384 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts +15 -0
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/static.js +152 -0
- package/vendor/agent-cli/dist/src/artifacts/static.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.d.ts +4 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.js +24 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.d.ts +23 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.js +62 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.d.ts +9 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.js +15 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.d.ts +3 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.js +284 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.d.ts +11 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.js +161 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/options.d.ts +83 -0
- package/vendor/agent-cli/dist/src/cli/options.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/options.js +213 -0
- package/vendor/agent-cli/dist/src/cli/options.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts +5 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.js +276 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/registry.d.ts +55 -0
- package/vendor/agent-cli/dist/src/cli/registry.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/registry.js +99 -0
- package/vendor/agent-cli/dist/src/cli/registry.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.d.ts +44 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.js +83 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.d.ts +28 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.js +52 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli.d.ts +9 -0
- package/vendor/agent-cli/dist/src/cli.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli.js +54 -0
- package/vendor/agent-cli/dist/src/cli.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts +24 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/execution.js +131 -0
- package/vendor/agent-cli/dist/src/component/execution.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts +24 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.js +200 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.d.ts +31 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js +57 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation.d.ts +10 -0
- package/vendor/agent-cli/dist/src/component/preparation.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation.js +35 -0
- package/vendor/agent-cli/dist/src/component/preparation.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.d.ts +15 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.js +37 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime.d.ts +8 -0
- package/vendor/agent-cli/dist/src/component/runtime.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime.js +95 -0
- package/vendor/agent-cli/dist/src/component/runtime.js.map +1 -0
- package/vendor/agent-cli/dist/src/config/config-store.d.ts +50 -0
- package/vendor/agent-cli/dist/src/config/config-store.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/config/config-store.js +117 -0
- package/vendor/agent-cli/dist/src/config/config-store.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.d.ts +17 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.js +133 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.d.ts +9 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.js +51 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts +4 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.js +54 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.d.ts +12 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.js +100 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-budget.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/context-budget.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-budget.js +10 -0
- package/vendor/agent-cli/dist/src/context/context-budget.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-cache.d.ts +108 -0
- package/vendor/agent-cli/dist/src/context/context-cache.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-cache.js +357 -0
- package/vendor/agent-cli/dist/src/context/context-cache.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-project.d.ts +26 -0
- package/vendor/agent-cli/dist/src/context/context-project.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-project.js +113 -0
- package/vendor/agent-cli/dist/src/context/context-project.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-resource.d.ts +4 -0
- package/vendor/agent-cli/dist/src/context/context-resource.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-resource.js +11 -0
- package/vendor/agent-cli/dist/src/context/context-resource.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts +9 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js +134 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts +4 -0
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/local-skills.js +157 -0
- package/vendor/agent-cli/dist/src/context/local-skills.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-context.d.ts +19 -0
- package/vendor/agent-cli/dist/src/context/member-context.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-context.js +105 -0
- package/vendor/agent-cli/dist/src/context/member-context.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-documents.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/member-documents.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-documents.js +38 -0
- package/vendor/agent-cli/dist/src/context/member-documents.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.js +62 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile.d.ts +43 -0
- package/vendor/agent-cli/dist/src/context/member-profile.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile.js +91 -0
- package/vendor/agent-cli/dist/src/context/member-profile.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-selection.d.ts +7 -0
- package/vendor/agent-cli/dist/src/context/member-selection.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-selection.js +58 -0
- package/vendor/agent-cli/dist/src/context/member-selection.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts +6 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.js +24 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js +55 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-definition.d.ts +39 -0
- package/vendor/agent-cli/dist/src/context/team-definition.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-definition.js +78 -0
- package/vendor/agent-cli/dist/src/context/team-definition.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.d.ts +7 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.js +37 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-cache.d.ts +27 -0
- package/vendor/agent-cli/dist/src/context/template-cache.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-cache.js +100 -0
- package/vendor/agent-cli/dist/src/context/template-cache.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts +32 -0
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-seed.js +117 -0
- package/vendor/agent-cli/dist/src/context/template-seed.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.d.ts +19 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.js +292 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts +13 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.js +178 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.d.ts +54 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.js +184 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.d.ts +14 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.js +130 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.js.map +1 -0
- package/vendor/agent-cli/dist/src/index.d.ts +56 -0
- package/vendor/agent-cli/dist/src/index.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/index.js +82 -0
- package/vendor/agent-cli/dist/src/index.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.d.ts +68 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js +242 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.d.ts +40 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js +87 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.d.ts +134 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.js +152 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.d.ts +40 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.js +149 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/client.d.ts +12 -0
- package/vendor/agent-cli/dist/src/mcp/client.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/client.js +95 -0
- package/vendor/agent-cli/dist/src/mcp/client.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/connection.d.ts +14 -0
- package/vendor/agent-cli/dist/src/mcp/connection.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/connection.js +115 -0
- package/vendor/agent-cli/dist/src/mcp/connection.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/execute.d.ts +5 -0
- package/vendor/agent-cli/dist/src/mcp/execute.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/execute.js +26 -0
- package/vendor/agent-cli/dist/src/mcp/execute.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.d.ts +11 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.js +51 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/types.d.ts +27 -0
- package/vendor/agent-cli/dist/src/mcp/types.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/types.js +2 -0
- package/vendor/agent-cli/dist/src/mcp/types.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/input.d.ts +21 -0
- package/vendor/agent-cli/dist/src/protocol/input.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/input.js +95 -0
- package/vendor/agent-cli/dist/src/protocol/input.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.d.ts +58 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.js +337 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.d.ts +13 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.js +27 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.d.ts +57 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.js +93 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.d.ts +28 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.js +86 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.d.ts +14 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.js +40 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.d.ts +31 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.js +90 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.d.ts +32 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.js +106 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts +509 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js +131 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts +351 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js +103 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.d.ts +9 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.js +58 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-parse.d.ts +21 -0
- package/vendor/agent-cli/dist/src/security/command-parse.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-parse.js +395 -0
- package/vendor/agent-cli/dist/src/security/command-parse.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-translate.d.ts +30 -0
- package/vendor/agent-cli/dist/src/security/command-translate.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-translate.js +161 -0
- package/vendor/agent-cli/dist/src/security/command-translate.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.d.ts +18 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.js +121 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/guard.d.ts +41 -0
- package/vendor/agent-cli/dist/src/security/guard.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/guard.js +154 -0
- package/vendor/agent-cli/dist/src/security/guard.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts +47 -0
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/mount-table.js +164 -0
- package/vendor/agent-cli/dist/src/security/mount-table.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.d.ts +23 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.js +110 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.d.ts +5 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.js +16 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts +16 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.js +88 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts +116 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/client.js +376 -0
- package/vendor/agent-cli/dist/src/session/client.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/custom-context.d.ts +6 -0
- package/vendor/agent-cli/dist/src/session/custom-context.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/custom-context.js +100 -0
- package/vendor/agent-cli/dist/src/session/custom-context.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.d.ts +38 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.js +87 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.js +15 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-config.d.ts +13 -0
- package/vendor/agent-cli/dist/src/session/link-config.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-config.js +29 -0
- package/vendor/agent-cli/dist/src/session/link-config.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.d.ts +30 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.js +67 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts +76 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-session.js +412 -0
- package/vendor/agent-cli/dist/src/session/link-session.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/local-execution.d.ts +28 -0
- package/vendor/agent-cli/dist/src/session/local-execution.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/local-execution.js +119 -0
- package/vendor/agent-cli/dist/src/session/local-execution.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/member-tools.d.ts +22 -0
- package/vendor/agent-cli/dist/src/session/member-tools.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/member-tools.js +72 -0
- package/vendor/agent-cli/dist/src/session/member-tools.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.d.ts +7 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.js +30 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-environment.d.ts +3 -0
- package/vendor/agent-cli/dist/src/session/process-environment.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-environment.js +22 -0
- package/vendor/agent-cli/dist/src/session/process-environment.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-request.d.ts +36 -0
- package/vendor/agent-cli/dist/src/session/process-request.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-request.js +494 -0
- package/vendor/agent-cli/dist/src/session/process-request.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.d.ts +8 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.js +34 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-events.d.ts +81 -0
- package/vendor/agent-cli/dist/src/session/run-events.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-events.js +160 -0
- package/vendor/agent-cli/dist/src/session/run-events.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts +76 -0
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-setup.js +273 -0
- package/vendor/agent-cli/dist/src/session/run-setup.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts +41 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.js +64 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.d.ts +17 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.js +75 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.d.ts +37 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js +232 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-choice.d.ts +5 -0
- package/vendor/agent-cli/dist/src/session/user-choice.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-choice.js +80 -0
- package/vendor/agent-cli/dist/src/session/user-choice.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.d.ts +31 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js +104 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/app-id.d.ts +13 -0
- package/vendor/agent-cli/dist/src/shared/app-id.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/app-id.js +25 -0
- package/vendor/agent-cli/dist/src/shared/app-id.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.d.ts +13 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.js +16 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.d.ts +3 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.js +22 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.d.ts +14 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.js +29 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.d.ts +36 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.js +94 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.d.ts +3 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.js +11 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-types.d.ts +60 -0
- package/vendor/agent-cli/dist/src/shared/process-types.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-types.js +10 -0
- package/vendor/agent-cli/dist/src/shared/process-types.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.d.ts +7 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.js +113 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.d.ts +47 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.js +210 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts +458 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.js +2 -0
- package/vendor/agent-cli/dist/src/shared/types.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.d.ts +22 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.js +2 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.d.ts +9 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.js +85 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts +30 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.js +96 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.d.ts +16 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.js +104 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts +21 -0
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program.js +207 -0
- package/vendor/agent-cli/dist/src/tools/context-program.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts +61 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.js +477 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.d.ts +58 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.js +322 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.d.ts +24 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.js +160 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts +66 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js +65 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.d.ts +29 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.js +88 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.d.ts +42 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.js +34 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.js.map +1 -0
- package/vendor/agent-cli/package.json +29 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// ds/rooms/SyncRoom.mjs — 房间骨架。
|
|
2
|
+
//
|
|
3
|
+
// 照抄的部分只有**生命周期接线**(DSAgentPipe 注册 / 心跳 / 空房收尾 / 在场名单上报),这些是平台硬约束。
|
|
4
|
+
// 房间名、消息名、state 形状、玩法规则都是你的,按玩法自己定(约束见 ${CLAUDE_DIR}/skills/platform-services/references/SERVER_GUIDE.md)。
|
|
5
|
+
import { Room } from "@colyseus/core";
|
|
6
|
+
import { SyncState, SyncPlayer } from "./syncSchema.mjs";
|
|
7
|
+
|
|
8
|
+
/** 消息名:与客户端保持一致即可,平台不认识这些字面量。 */
|
|
9
|
+
export const SyncMsg = {
|
|
10
|
+
StateSet: "state.set",
|
|
11
|
+
Pub: "pub",
|
|
12
|
+
Evt: "evt",
|
|
13
|
+
RoomClosed: "room_closed",
|
|
14
|
+
/** 时钟标定:客户端 ping → DS 定向回 pong(详见下方 _onPing)。仅当玩法要做本地模拟+快照纠偏(收端形态 C)时才用得上。 */
|
|
15
|
+
Pong: "pong",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 真正的 4KB 限制在传输层:超限连接已被断开,根本进不到 onMessage。
|
|
19
|
+
// 这里只防自己代码构造出的超大包;有效检查在客户端发送前。
|
|
20
|
+
const MAX_PAYLOAD_BYTES = 4 * 1024;
|
|
21
|
+
|
|
22
|
+
export class SyncRoom extends Room {
|
|
23
|
+
/** 必须等于开房时的 max_players,且等于玩法人数。 */
|
|
24
|
+
maxClients = 8;
|
|
25
|
+
|
|
26
|
+
onCreate() {
|
|
27
|
+
this.setState(new SyncState());
|
|
28
|
+
/** @type {Map<string, number>} */
|
|
29
|
+
this._uidBySession = new Map();
|
|
30
|
+
|
|
31
|
+
globalThis.DSAgentPipe?.setSessionsProvider?.(() => this._sessionsPayload());
|
|
32
|
+
globalThis.DSAgentPipe?.hb?.();
|
|
33
|
+
|
|
34
|
+
// 只有需要服端按帧推演才开,不需要就删掉这行。
|
|
35
|
+
// 这个 50 与 patchRate 对齐(见 ${CLAUDE_DIR}/skills/platform-services/references/SERVER_GUIDE.md「patchRate」段):仿真 tick 频率 ≠ 快照写入频率,是两件独立的事。
|
|
36
|
+
// 需要更细的仿真(碰撞/隧穿)时可以把这里改小(如 20),但**写 state 根字段的间隔仍不得快于 50ms**——
|
|
37
|
+
// 快照写入要单独节流(例如攒够 50ms 再把 state 写一次),别顺手把 tick 和快照写入一起改快:
|
|
38
|
+
// patchRate 已把下行锁在 20Hz,同窗口内多写只发一次,多出的写入纯烧序列化、不会让画面更新鲜。
|
|
39
|
+
this.setSimulationInterval((dtMs) => this._tick(dtMs), 50);
|
|
40
|
+
|
|
41
|
+
// 持续态:骨架只存不改,写进 state 后由 Colyseus 按 patchRate(50ms)推给所有人。
|
|
42
|
+
this.onMessage(SyncMsg.StateSet, (client, msg) => {
|
|
43
|
+
const player = this.state.players.get(client.sessionId);
|
|
44
|
+
if (!player) return;
|
|
45
|
+
const raw = encodeData(msg?.data ?? msg);
|
|
46
|
+
if (raw == null) return;
|
|
47
|
+
player.data = raw;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 一次性事件:客户端 sendEvent(type, data) 把所有事件统一封进 pub 这一个消息发来,
|
|
51
|
+
// type 是 pub 的载荷字段,**不是** Colyseus 消息名。写 this.onMessage("ready", ...)
|
|
52
|
+
// 永远收不到,而且两端都不报错——这是最常踩的静默失效。
|
|
53
|
+
this.onMessage(SyncMsg.Pub, (client, msg) => {
|
|
54
|
+
const payload = normalizePayload(msg);
|
|
55
|
+
if (!payload) return;
|
|
56
|
+
|
|
57
|
+
// 需要服端说话的操作在这里分流:卡时机与合法性 → 改 state → 由 Colyseus 同步结果。
|
|
58
|
+
// 玩法的关键操作(落子 / 出牌 / 掷骰 / 命中 / 结算)都该有一个这样的 case;
|
|
59
|
+
// 要取参数就 JSON.parse(payload.data || "{}"),data 是字符串。
|
|
60
|
+
switch (payload.type) {
|
|
61
|
+
case "ready":
|
|
62
|
+
this._onReady(client);
|
|
63
|
+
return;
|
|
64
|
+
case "ping":
|
|
65
|
+
this._onPing(client, payload);
|
|
66
|
+
return;
|
|
67
|
+
default:
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 兜底是无裁决的原样转发,只适合"谁说了都算"的表现层消息(喊话 / 表情 / 特效)。
|
|
72
|
+
// 玩法状态别走这里:广播等于让客户端自己说了算,而且 evt 是一次性的,
|
|
73
|
+
// 后进房或断线重连的人收不到之前广播过的内容。
|
|
74
|
+
this.broadcast(SyncMsg.Evt, {
|
|
75
|
+
from: client.sessionId,
|
|
76
|
+
type: payload.type,
|
|
77
|
+
data: payload.data,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onJoin(client, options) {
|
|
83
|
+
const player = new SyncPlayer();
|
|
84
|
+
player.data = "{}";
|
|
85
|
+
this.state.players.set(client.sessionId, player);
|
|
86
|
+
this._uidBySession.set(client.sessionId, parseJoinUid(options));
|
|
87
|
+
globalThis.DSAgentPipe?.hb?.();
|
|
88
|
+
this._sendInitialState(client);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onLeave(client) {
|
|
92
|
+
this.state.players.delete(client.sessionId);
|
|
93
|
+
this._uidBySession.delete(client.sessionId);
|
|
94
|
+
// 走了的人不能继续占着准备名单,否则"人齐了吗"永远差一个。
|
|
95
|
+
this.state.readySids = JSON.stringify(this._readySids().filter((sid) => sid !== client.sessionId));
|
|
96
|
+
globalThis.DSAgentPipe?.hb?.();
|
|
97
|
+
// 空房收尾是硬约束,不能省。
|
|
98
|
+
if (this.state.players.size === 0) this.requestClose("empty");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onDispose() {
|
|
102
|
+
globalThis.DSAgentPipe?.setSessionsProvider?.(null);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 声明本局结束:平台随后 Kill 进程、删房记录、房号失效。幂等。 */
|
|
106
|
+
requestClose(reason) {
|
|
107
|
+
if (this._closing) return;
|
|
108
|
+
this._closing = true;
|
|
109
|
+
this.broadcast(SyncMsg.RoomClosed, { reason: String(reason || "finished") });
|
|
110
|
+
// 留一点时间让客户端收到 room_closed 再让平台杀进程。
|
|
111
|
+
setTimeout(() => globalThis.DSAgentPipe?.end?.(reason), 200);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 裁决样例:准备 → 人齐开局。**形状照抄,规则按玩法改。**
|
|
116
|
+
* 三件事缺一不可:卡住非法时机(不信客户端说的"现在可以了")、把结果写进 state 根字段、
|
|
117
|
+
* 不用回话——Colyseus 会把新状态推给所有人,**包括点"准备"的这个人自己**。
|
|
118
|
+
* 所以客户端不需要为本机状态另存一份,UI 一律从 onStateField 来的值渲染。
|
|
119
|
+
*/
|
|
120
|
+
_onReady(client) {
|
|
121
|
+
if (this.state.phase !== "waiting") return;
|
|
122
|
+
if (!this.state.players.has(client.sessionId)) return;
|
|
123
|
+
|
|
124
|
+
const sids = new Set(this._readySids());
|
|
125
|
+
if (sids.has(client.sessionId)) return;
|
|
126
|
+
sids.add(client.sessionId);
|
|
127
|
+
this.state.readySids = JSON.stringify([...sids]);
|
|
128
|
+
|
|
129
|
+
// 开局条件:在场的人全准备好了。单人也能开就去掉 sids.size >= 2。
|
|
130
|
+
if (sids.size >= 2 && sids.size >= this.state.players.size) {
|
|
131
|
+
this.state.phase = "playing";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** @returns {string[]} 已准备的 sessionId;readySids 是 JSON 字符串,坏值按空处理。 */
|
|
136
|
+
_readySids() {
|
|
137
|
+
try {
|
|
138
|
+
const arr = JSON.parse(this.state.readySids || "[]");
|
|
139
|
+
return Array.isArray(arr) ? arr.map(String) : [];
|
|
140
|
+
} catch {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 服端推演入口;产出用 broadcast(Evt, { from: "", ... }) 下发。 */
|
|
146
|
+
_tick(_dtMs) {}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 时钟标定:收到客户端 ping,定向回 pong。用于客户端算出「本机时钟 − DS 时钟」的偏移,
|
|
150
|
+
* 进而把收到的旧快照按年龄外推到当前时刻(收端形态 C,见客户端 StateSyncKnowledge.md「形态 C」)。
|
|
151
|
+
* 只做**测量应答**,不含任何玩法语义、不改 state;不需要形态 C 的玩法可以不接客户端的 ping,这段就是死代码。
|
|
152
|
+
*
|
|
153
|
+
* 回包字段:
|
|
154
|
+
* - `t`:原样回传客户端 ping 里的时间戳,客户端据此算 RTT(拿它匹配是自己哪一次 ping)。
|
|
155
|
+
* - `st`:DS 侧当前时钟(`Date.now()` ms),客户端用 `offset = st − (t + rtt/2)` 标定偏移。
|
|
156
|
+
* 走 pub 契约同一条回程(定向 send Pong 消息名),不绕开 normalizePayload / 不新开 onMessage 通道。
|
|
157
|
+
*/
|
|
158
|
+
_onPing(client, payload) {
|
|
159
|
+
let t = 0;
|
|
160
|
+
try {
|
|
161
|
+
const body = JSON.parse(payload.data || "{}");
|
|
162
|
+
t = Number(body?.t) || 0;
|
|
163
|
+
} catch {
|
|
164
|
+
t = 0;
|
|
165
|
+
}
|
|
166
|
+
// 定向回给发起者本人;不 broadcast(别人不需要这条测量应答)。
|
|
167
|
+
client.send(SyncMsg.Pong, { t, st: Date.now() });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 定向发给新连接。evt 是一次性的,后进房的人收不到之前 broadcast 过的内容,
|
|
172
|
+
* 需要补的初始数据在这里发(或者干脆放 state 根字段,握手自带)。
|
|
173
|
+
* @param {import("@colyseus/core").Client | null} only
|
|
174
|
+
*/
|
|
175
|
+
_sendInitialState(only = null) {
|
|
176
|
+
let data;
|
|
177
|
+
try {
|
|
178
|
+
data = JSON.stringify({});
|
|
179
|
+
} catch {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// 出站不受 maxPayload 限制,但仍要控体积:过大就砍字段再发,不要拆包。
|
|
183
|
+
const msg = { from: "", type: "init", data };
|
|
184
|
+
if (only) only.send(SyncMsg.Evt, msg);
|
|
185
|
+
else this.broadcast(SyncMsg.Evt, msg);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** 在场名单,壳每次心跳带给平台用于算 player_count。 */
|
|
189
|
+
_sessionsPayload() {
|
|
190
|
+
const out = [];
|
|
191
|
+
for (const [sid, uid] of this._uidBySession) {
|
|
192
|
+
out.push({ sid: String(sid), uid: Number(uid) || 0 });
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** 从 join options 取平台 uid(数字、数字串或 player_id "u123");仅用于上报。 */
|
|
199
|
+
function parseJoinUid(options) {
|
|
200
|
+
if (options == null || typeof options !== "object") return 0;
|
|
201
|
+
|
|
202
|
+
const raw = options.uid;
|
|
203
|
+
if (typeof raw === "number" && Number.isFinite(raw) && raw > 0) return Math.floor(raw);
|
|
204
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
205
|
+
const n = Number(raw);
|
|
206
|
+
if (Number.isFinite(n) && n > 0) return Math.floor(n);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const pid = options.player_id;
|
|
210
|
+
if (typeof pid === "string") {
|
|
211
|
+
const m = /^u(\d+)$/i.exec(pid.trim());
|
|
212
|
+
if (m) return Number(m[1]) || 0;
|
|
213
|
+
}
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** pub 归一为 { type: string, data: string };超限返回 null。 */
|
|
218
|
+
function normalizePayload(msg) {
|
|
219
|
+
if (msg == null) return null;
|
|
220
|
+
|
|
221
|
+
if (typeof msg !== "object") {
|
|
222
|
+
const data = String(msg);
|
|
223
|
+
return overBudget(data) ? null : { type: "", data };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const type = msg.type != null ? String(msg.type) : "";
|
|
227
|
+
let data = msg.data;
|
|
228
|
+
if (data != null && typeof data === "object") {
|
|
229
|
+
try {
|
|
230
|
+
data = JSON.stringify(data);
|
|
231
|
+
} catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
} else if (data == null && msg.data === undefined) {
|
|
235
|
+
const { type: _ignored, ...rest } = msg;
|
|
236
|
+
data = Object.keys(rest).length ? JSON.stringify(rest) : "";
|
|
237
|
+
} else {
|
|
238
|
+
data = data == null ? "" : String(data);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return overBudget(type + data) ? null : { type, data };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** state.set 的 data 归一为字符串;超限返回 null。 */
|
|
245
|
+
function encodeData(data) {
|
|
246
|
+
if (data == null) return "{}";
|
|
247
|
+
|
|
248
|
+
let raw;
|
|
249
|
+
if (typeof data === "string") {
|
|
250
|
+
raw = data;
|
|
251
|
+
} else {
|
|
252
|
+
try {
|
|
253
|
+
raw = JSON.stringify(data);
|
|
254
|
+
} catch {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return overBudget(raw) ? null : raw;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** 按字节判超限:中文 UTF-8 每字 3 字节,String.length 会低估。 */
|
|
262
|
+
function overBudget(text) {
|
|
263
|
+
return Buffer.byteLength(text, "utf8") > MAX_PAYLOAD_BYTES;
|
|
264
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// ds/rooms/syncSchema.mjs — 房间 state 形状。
|
|
2
|
+
// 玩家数据用一个字符串字段兜住,玩法字段进出都靠 JSON,改结构不用动 schema;
|
|
3
|
+
// 要强类型就把玩法字段直接 defineTypes 建模,客户端不用跟着改声明(0.17 握手时反射过去)。
|
|
4
|
+
import { Schema, MapSchema, defineTypes } from "@colyseus/schema";
|
|
5
|
+
|
|
6
|
+
/** 每名玩家一个槽位;data 是客户端上报的 JSON 字符串。 */
|
|
7
|
+
export class SyncPlayer extends Schema {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.data = "{}";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
defineTypes(SyncPlayer, {
|
|
14
|
+
data: "string",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export class SyncState extends Schema {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.players = new MapSchema(); // MapSchema 只能用 .set/.get/.has/.delete/.forEach 访问;下标(m[k]=v)在 4.0.30 下静默失效,读得回来但不同步、.size 恒 0,详见 ${CLAUDE_DIR}/skills/platform-services/references/SERVER_GUIDE.md 硬约束。
|
|
21
|
+
this.phase = "waiting";
|
|
22
|
+
this.readySids = "[]";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// 根字段是**权威状态**的家:客户端用 onStateField(字段名) 收,所有人(含改动的发起者自己)
|
|
26
|
+
// 看到的是同一份,后进房的人握手时就拿到当前值,不需要谁补发。
|
|
27
|
+
//
|
|
28
|
+
// players[sid].data 走的是另一条路(客户端 mp-peer-pose),且**不回推给发起者自己**,
|
|
29
|
+
// 所以"轮到谁 / 谁准备了 / 比分 / 棋盘"这类全局裁决结果放这里,别放 player.data ——
|
|
30
|
+
// 放错了本机就要自己另存一份,两份状态迟早对不齐。
|
|
31
|
+
//
|
|
32
|
+
// phase / readySids 是通用的房间生命周期字段(见 SyncRoom 的裁决样例);玩法自己的权威状态
|
|
33
|
+
// 按同样方式往下加,比如:turn: "string"(该谁行动)、board: "string"(局面 JSON)、
|
|
34
|
+
// scores: "string"。字段增删不用改客户端声明,0.17 握手时会把 schema 反射过去。
|
|
35
|
+
defineTypes(SyncState, {
|
|
36
|
+
players: { map: SyncPlayer },
|
|
37
|
+
phase: "string",
|
|
38
|
+
readySids: "string",
|
|
39
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# ds/ 目录规则(Agent 必读)
|
|
2
|
+
|
|
3
|
+
平台 DS 进程的代码。目录名 `ds` 与入口 `ds/main.mjs` 由平台规定,**不可改**。
|
|
4
|
+
|
|
5
|
+
版本快照与客户端同包上传,但 DS 壳(`js-ds-shell`)**只物化并执行 `ds/` 前缀下的文件**:`src/`、根 `package.json`、`configs/` 都不会出现在 DS 进程里。两端不能共享模块,需要的常量各写一份。
|
|
6
|
+
|
|
7
|
+
**玩法逻辑由你写。** 本文只描述壳与平台的行为契约——哪些写法会让进程起不来、哪些是硬上限、哪些 Colyseus 机制在这里失效。房间内怎么玩、状态怎么设计、谁权威,都不在这里规定。
|
|
8
|
+
|
|
9
|
+
## 运行模型(先理解这三条,下面的约束都是它的推论)
|
|
10
|
+
|
|
11
|
+
**一个平台房 = 一个 DS 进程。** 玩家在大厅 `create` 时平台拉起一个进程(所以刚开房的头一两秒可能还没 listen,客户端要重试),`DSAgentPipe.end()` 或心跳超时时整个进程被 Kill、房记录被删、房号失效。进程里只跑这一局,所以模块级变量天然是"本局独占"的,不需要按房隔离——但这个前提是 `maxClients` 配对了,否则同进程会出现第二间房来共享它们。
|
|
12
|
+
|
|
13
|
+
**撮合分两层,`room_id` 和房间名不是一回事。** 平台 Room HTTP 决定"进哪个进程"(返回 `room_id` + `connect`),Colyseus 只负责"进这个进程里的那一间房"(`joinOrCreate(<房间名>)`)。`room_id` **不会**传给 Colyseus,客户端那句 `joinOrCreate("sync")` 写的是本目录 `main.mjs` 导出的 key,不是房号——看着像 bug,其实是分层。另外 Colyseus 自己也有个 `room.roomId`(进程内房 id),与平台 `room_id` 同名不同物,打日志时别混。
|
|
14
|
+
|
|
15
|
+
**Colyseus 用来自治的机制,在这里只在进程内生效,平台看不见。** `autoDispose` 只析构进程内对象、`matchmaker` 只看得见自己进程、`allowReconnection` 只挂起自己的 `onLeave`——它们都不知道平台的房记录和进程。所以回收走 `DSAgentPipe.end()`、撮合走 Room HTTP、人数走 `setSessionsProvider`。**从 Colyseus 官方文档抄来的自治写法,先确认它要管的那件事是不是已经归平台管了。**
|
|
16
|
+
|
|
17
|
+
分工上:DS 进程 = 壳 + 你的 `ds/`。壳装好依赖、注入 `DSAgentPipe`(`main.mjs` 被 import 时已可用)、`gameServer.define()` 每个导出的房间并 `listen`。你只写 Room 类。
|
|
18
|
+
|
|
19
|
+
## 硬约束(违反 = 进程起不来 / 静默失败)
|
|
20
|
+
|
|
21
|
+
- **入口**:`ds/main.mjs` 必须 `export const rooms = { <房间名>: RoomClass }`;key 与客户端 `joinOrCreate(<房间名>)` 一致。缺入口时 DS 直接启动失败(`snapshot missing entry ds/main.mjs`);值必须是**类本身**,写成 `new SyncRoom()` 这样的实例会 `room <name> is not a constructor` 然后 exit(1)。
|
|
22
|
+
- **ESM only**:`ds/` 下一律 `.mjs`,禁止 CJS(`require`)。Node 运行时 ≥ 22。
|
|
23
|
+
- **没有依赖安装环节**:壳把自己的 `node_modules` 软链到工作目录根,所以 `ds/` 里直接 `import { Room } from "@colyseus/core"` / `import { Schema } from "@colyseus/schema"` 能解析。写 `ds/package.json` 声明依赖**不会被安装**(快照只被物化,全程不跑 `npm install`),任何第三方包都 import 失败——玩法要的算法只能用标准库自己实现。
|
|
24
|
+
- **不自己起服务**:禁止 `new Server()` / `listen()` / 选端口。端口由平台在 27000–27999 动态分配,壳已 `listen`。
|
|
25
|
+
- **没有可信身份**:壳不校验 token,也不把平台票传给 DS,所以 `onAuth` 里没有任何可信凭据可验(写了也只是在验客户端自报的东西)。准入由 Room HTTP(经网关鉴权)保证,因此**禁止**信任客户端自报的 `uid` 做权限判断——它只用于向平台上报在场名单。
|
|
26
|
+
- **入站单包 ≤ 4KB(只卡入站,出站不受此限)**:4KB = `@colyseus/ws-transport@0.17.13` 构造函数默认 `maxPayload = 4 * 1024`,且默认 `perMessageDeflate = false`(无压缩兜底);平台壳 `new WebSocketTransport({ server })` 未覆盖该项——**所以这不是平台的业务决策,是库默认值**(出处:`backend/game/js-ds-shell/src/runtime.mjs` + `@colyseus/ws-transport` build/WebSocketTransport.mjs)。这是 **DS 作为接收方**收下客户端消息的上限,超限时连接以 code 1009 被断开、`onMessage` 根本不会执行。有效检查在**客户端发送前**,且要按**字节**算(`TextEncoder`),不是 `String.length`。**反向的出站(DS → 客户端,`client.send` / `broadcast`)没有对应的 4KB 上限**——浏览器端不设等价接收限制,下行大包不会触发 1009。**不要把入站的这个 4KB 体积检查套到 DS 的下行发送上**(如在 `client.send` 前写 `if (over) return`):那会把本该送达的下行包静默丢掉,且毫无日志痕迹,是极难排查的一类 bug。onJoin 补全整局面、把某份大内容定向下发等场景下行本就会偏大,属正常;但下行大包只在这类**一次性时机**发,不要在每帧/定时路径整包广播(会队头阻塞,见客户端 `StateSyncKnowledge.md`「频率与包体」)。**注意区分**:上面这条「下行大包别高频」针对的是**手动 `broadcast` 全量**;state 根字段走 Colyseus **patch 通道**(自带同窗口合并,一个 patch 窗口内写多次只发一次),性质不同、不受那条约束——**不要拿"下行别高频整包"去否决合法的根字段写入**。
|
|
27
|
+
- **`maxClients` === 平台 `max_players` === 玩法人数**(平台侧取值 1–64,越界按 8):小于则 `joinOrCreate` 会在同一进程里再开一间房,两拨人互相看不见,且进程级 `DSAgentPipe` 的 `setSessionsProvider` 被后一间房覆盖。大于则大厅人数口径与玩法不一致。
|
|
28
|
+
- **`ds/main.mjs` 只 export 实际使用的 Room 类**,禁止留下未注册的模板 `SyncRoom`。
|
|
29
|
+
- **席位按 uid 认领时,`onJoin` 必须把 `parseJoinUid(options)` 写入该席位**。只放进 `_uidBySession` 不够:占座 uid 对不上连接 uid 时,平台人数 = 连接 + 未对齐占座,双人房会显示 2/2。
|
|
30
|
+
- **空房必须自己收尾**:`onLeave` 里人数归零 → `broadcast("room_closed")` → `DSAgentPipe.end("empty")`。只靠平台心跳超时(默认 15s)强杀是异常路径,不是正常路径。
|
|
31
|
+
- **`MapSchema` / `ArraySchema` 只能用方法访问**:`.set()` / `.get()` / `.has()` / `.delete()` / `.forEach()` / `.size`。下标(`m[k] = v`、`m[k]`、`delete m[k]`)在 `@colyseus/schema@4.0.30` 下**静默失效** —— Proxy 已于 2.0 移除,下标只会在实例上挂一个普通 JS 属性:**读得回来**(所以按 key 取的代码看着完全正常),但 `.size` 恒为 0、`.get(k)` 恒 `undefined`、**用下标写入的条目完全不进编码,客户端永远收不到**。`Object.entries()` / `Object.keys()` 同样无效,返回的是 `~refId` / `childType` / `$items` / `$indexes` / `deletedItems` 五个内部字段。**最危险的形态是同一文件里下标与方法混用**:按 key 取的路径正常、遍历与计数的路径全空,表现为「能连上、能同步一部分」,是本平台上最难定位的一类故障。注意区分:**用 `.set()` 正确填充的 MapSchema,`.forEach()` / `for...of` 迭代、`.size` 都是正常的**,不要因为它"看起来像普通 Map"就以为下标也能用;`JSON.stringify(mapSchema)` 也是正常的(会输出条目)。`onCreate` 里对容器**必须用 `new MapSchema()` / `new ArraySchema()`** 初始化,不能赋 `{}` / `[]` —— 普通对象 / 数组当不了 Colyseus 容器根字段。
|
|
32
|
+
- **不要用 `allowReconnection`**:Colyseus 官方教程里的这个写法在本平台上会打架——它让 `onLeave` 挂起、`players` 不减,于是空房永远不 `end`,同时在场名单里那个已断线的人还占着 `player_count`。断线重连在本平台是 HTTP 层的事:客户端重 `join`(对同一账号幂等)拿回原座位,那是一条**新的 Colyseus 连接**,`sessionId` 会变。
|
|
33
|
+
- **`DSAgentPipe` 是唯一上报通道**:`setSessionsProvider(fn)` 注册在场名单、`hb()` 在人数变化时补心跳、`end(reason)` 声明本局结束;`onDispose` 里 `setSessionsProvider(null)` 解绑。**不注册 provider 的后果**:心跳不带在场名单,平台只能回退按 HTTP 座位数算人数,DS 里的真实连接数不被采信。全部用 `?.` 保护:经壳启动时它一定存在(没有管道 fd 时壳装的是 no-op 桩,`end()` 只打日志),但直接 `node ds/main.mjs` 裸跑时没有。
|
|
34
|
+
- **骨架里的 `normalizePayload()` / `encodeData()` / `parseJoinUid()` / `requestClose()` 是两端契约与平台协议的载体,不是示例代码**:前三者分别锁定 pub 载荷形状(`{ type, data: 字符串 }`,业务字段在 `data` 里、不在顶层)、`state.set` 的字符串化、以及平台在场名单要求的 **uint32** `uid`;`requestClose()` 锁定空房收尾的**时序契约**——它先 `broadcast("room_closed", { reason })` 再**延迟 200ms** 才 `DSAgentPipe.end()`,这 200ms 是留给客户端收到 `room_closed` 的窗口。客户端模板(`multiplayerManager`)监听的正是 `room_closed` 这个消息名;**把延迟当冗余删掉、或改掉消息名,客户端就只拿到一个没有关闭码的空 `onError`**,玩家不知道为什么被踢。重写 Room 时这四个函数**连定义带调用一起照搬**,别当占位删掉或内联简化——历史上删 `parseJoinUid` 导致 `uid` 变字符串、平台解在场名单失败 15s 强杀,绕过 `normalizePayload` 直读 `payload.id` 导致伤害裁决 `NaN` 静默失效,删 `requestClose` 方法体只留调用点导致 `onLeave` 空房收尾抛 `TypeError`、后面的 `DSAgentPipe.end()` 永不执行、空房收不了尾,三次都零报错。
|
|
35
|
+
- **结构性规则(枚举永远会漏,认这条)**:骨架里凡是 `this.xxx()` 调用到、而 Colyseus `Room` 基类上找不到的方法,都是骨架自定义的**契约载体**(`requestClose` 就是其一,`Room` 上没有它)。重写时**要么连定义一起照搬,要么连调用点一起删**;只留调用点会在运行时抛 `TypeError`,而它往往埋在 `onLeave` / 空房收尾这类**不常走的分支**里——正常游玩测不到,一到真正散场才炸,且后面的 `DSAgentPipe.end()` 就永远执行不到,两端零报错。
|
|
36
|
+
|
|
37
|
+
## 与客户端的接口对应
|
|
38
|
+
|
|
39
|
+
房间名、消息名、state 形状、`from` 的含义都是**你和客户端之间的约定**,平台不认识这些名字,改的唯一要求是两端一致。骨架选了 `state.set` / `pub` / `evt` / `room_closed` 这组名字。
|
|
40
|
+
|
|
41
|
+
客户端模板(`multiplayerManager`)只提供三个收口,DS 侧数据放哪决定了客户端能不能收到:
|
|
42
|
+
|
|
43
|
+
| DS 侧 | 客户端收口 |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `players[sessionId].data`(字符串) | `bus.on('mp-peer-pose', (sid, pose) => ...)` |
|
|
46
|
+
| state **根字段** | `MultiplayerManager.onStateField(field, cb)`,字段已有值时立即回调一次 |
|
|
47
|
+
| `broadcast("evt", ...)` 或 `client.send("evt", ...)` 定向发 | `MultiplayerManager.onEvent((from, type, data) => ...)` |
|
|
48
|
+
|
|
49
|
+
模板在 player 上只监听 `data` 这一个字段;要用 player 级的其它真 schema 字段,得同时在客户端 `src/skill-modules/platform-services/MultiplayerManager.ts` 的 `_attachRoom()` 里、`players.onAdd` 回调中补 `$(player).listen('<字段>', ...)`,经 `bus.emit` 交给业务。
|
|
50
|
+
|
|
51
|
+
**反方向(客户端 → DS)上行只有两个消息名**,两者的 `data` **在线上都是 JSON 字符串**(客户端模板发送前已 `JSON.stringify`):
|
|
52
|
+
|
|
53
|
+
| 客户端调用 | 线上形状 | DS 侧读法 |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `sendPose(obj)` | `state.set` → `{ data: "<JSON 字符串>" }` | `payload.data` 原样存进 `players[sid].data`,**不要解析** |
|
|
56
|
+
| `sendEvent(type, obj)` | `pub` → `{ type, data: "<JSON 字符串>" }` | 用 `payload.type` 分流;业务字段必须 `JSON.parse(payload.data \|\| "{}")` 之后再取,**不在 `payload` 顶层** |
|
|
57
|
+
|
|
58
|
+
直读 `payload.<业务字段>`(如 `payload.id` / `payload.hp`)恒为 `undefined`,经 `Number()` 变 `NaN` 后被校验分支静默丢弃——两端都不 throw,`.mjs` 无类型也检不出,是本平台最难定位的一类故障。历史上就因为绕过归一化直读 `payload.id` 做伤害裁决,导致裁决静默失效、谁都没报错。
|
|
59
|
+
|
|
60
|
+
**方向不对称,别写反**:这条「data 是字符串、要先 parse」只约束**上行**。下行(DS → 客户端)客户端 `_parse` 对对象宽容(`broadcast("evt", { type, data: <对象> })` 直接可用),**不要**给下行也加「必须 stringify」的约束。
|
|
61
|
+
|
|
62
|
+
**权威快照带服务端时间戳 `t`(两端契约的一部分,做本地模拟纠偏时必须)**:连续运动玩法若客户端要跑「本地权威同款模拟 + 快照纠偏」(收端形态 C,见客户端 StateSyncKnowledge),**DS 写快照时必须带上写入那一刻的服务端单调时钟** `t`(`Date.now()` ms)——放进 `players[sid].data` 或对应根字段里随快照一起下发。客户端拿 `t` 算快照年龄 `age = getServerNow() − snap.t`,把旧快照外推到当前时刻再纠偏;没有 `t`,客户端只能拿「到达时刻」当基准,等于把单向网络延迟当 0,纠偏必飘。配套的时钟标定回程(客户端 ping → DS 回 pong 带 `st`)已在骨架 `SyncRoom.mjs` 的 `_onPing` 里,走 pub 契约同一条路,不需另开通道。**纯回合 / 棋牌玩法不做形态 C,可以不带 `t`**——这条只对「客户端本地模拟纠偏」的玩法是硬契约。
|
|
63
|
+
|
|
64
|
+
**三条路怎么选**(选错是"能连上、但状态对不齐"的头号成因):
|
|
65
|
+
|
|
66
|
+
> **state 根字段有两种形态,客户端收口完全不同,先分清再选**:
|
|
67
|
+
|
|
68
|
+
| 根字段形态 | 客户端收口 | 说明 |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| **标量**(string / number / boolean) | 现成 `onStateField(field, cb)`,**握手自带当前值**,后进房/重连即得 | `phase` / `readySids` / `seats:"string"`(JSON 字符串)都走这个 |
|
|
71
|
+
| **容器**(MapSchema / ArraySchema) | **收不到条目增删与嵌套字段变化** | 底层 `onStateField` 是 `$(room.state).listen(field)`,只在**引用被整体替换**时触发,对 map 字段看不到条目增删、更看不到嵌套字段变化 |
|
|
72
|
+
|
|
73
|
+
容器形态若确有必要(整表 ≥ 几 KB 或条目上百),必须【同时】给出客户端扩订阅写法,否则读者只能像本次一样自己发明一套 `evt` 增量广播来绕:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
// 客户端:加在 src/skill-modules/platform-services/MultiplayerManager.ts 的 _attachRoom() 里、players.onAdd 旁边。
|
|
77
|
+
// 该函数里已有 $,连上与重连都会执行;onStateField 收不到容器的嵌套变化。业务用 bus.on 订阅这些事件。
|
|
78
|
+
$(room.state).seats.onAdd((seat, playerId) => {
|
|
79
|
+
bus.emit("mp-seat-add", playerId, seat);
|
|
80
|
+
$(seat).listen("hp", (v) => bus.emit("mp-seat-hp", playerId, v)); // 字段级增量
|
|
81
|
+
});
|
|
82
|
+
$(room.state).seats.onRemove((_s, playerId) => bus.emit("mp-seat-remove", playerId));
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**选型判据按【三问】顺序**,不要写成「高频用 map、低频用字符串」(频率已被 patchRate 抹平):
|
|
86
|
+
|
|
87
|
+
> 第 1 问 · **owner 是谁?** DS 裁决的 → 根字段(高低频都一样)。玩家自报的连续态 → `players[sid].data`。这一问**优先于**体积和频率:`players[sid].data` 是客户端上报通道(DS 只存不改),且**不回推给发起者自己**,权威态放进去会导致本机必须另存一份,两份状态必然分叉。所以 `hp` / `score` / `kills` / `alive` 这类由 DS 裁决的量,**即使变化频繁,也必须走根字段**,不能因为「它变得快」就塞进 `players[sid].data`。
|
|
88
|
+
> 第 2 问 · **整表全量多大?** `patchRate` 已把下发频率锁在 20Hz(**同窗口内多次写入合并,写 10 次只发一次**),成本上限 = 全量 payload × 20Hz,与写入频率无关。≤ 约 1KB → JSON 字符串够用(现成 `onStateField`,零客户端改动);≥ 几 KB 或条目上百 → 用 MapSchema 字段级增量 + 上面的客户端扩订阅。
|
|
89
|
+
> 第 3 问 · **客户端要什么粒度?** 整表刷新即可 → 字符串。需要「只有 hp 变了才更新这一个血条」→ MapSchema。
|
|
90
|
+
|
|
91
|
+
- **权威状态 → state 根字段**。阶段、该谁行动、局面、比分、准备名单:凡是"全场只有一份、且必须服端说了算"的都放这里。根字段对所有人一致(**包括改动的发起者自己**),后进房与重连的人握手即得,不需要谁补发。骨架里的 `phase` / `readySids` 就是例子。
|
|
92
|
+
- **各自的连续态 → `players[sid].data`**。位置、朝向、动画状态这类每人一份、丢一帧无所谓的高频数据。它**不回推给发起者自己**(本机数据本机已经有了),所以别指望自己的状态绕一圈回来。
|
|
93
|
+
- **纯表现层的一次性通知 → `broadcast("evt")`**。喊话、表情、命中特效。它是一次性的:晚进房和重连的人都收不到,所以"错过就玩不下去"的东西不能只走这条路。
|
|
94
|
+
|
|
95
|
+
按玩法类型的默认选择:
|
|
96
|
+
|
|
97
|
+
- **回合制 / 棋牌 / 桌游**:几乎全部走根字段 + 服端裁决。客户端只发意图(`sendEvent('place', ...)`)、只读 state 渲染,非法操作由服端忽略。**别用 evt 广播落子/出牌**——两端各自推演必然分叉,且重连的人无法恢复局面。
|
|
98
|
+
- **实时同场(跑动 / 射击 / 赛车)**:位姿走 `players[].data` + `sendPose`(≤20Hz),但判定结果(命中、得分、胜负)仍然走根字段,因为它必须唯一。
|
|
99
|
+
- **合作 / 派对**:按上面两条混用,别让"谁赢了"这种事落在 evt 上。
|
|
100
|
+
|
|
101
|
+
`patchRate` 默认 **50ms(20Hz)**:state 增量按这个节奏推,所以客户端上行超过 20Hz 不会有额外效果。
|
|
102
|
+
|
|
103
|
+
**⚠️ 仿真 tick 频率 ≠ 快照写入频率,是两件独立的事**(真实项目栽过:把 `setSimulationInterval` 从 50ms 改成 20ms 时,顺手把写 state 的间隔也改成 20ms,还留下「50Hz 快照更新鲜」的错误注释):
|
|
104
|
+
|
|
105
|
+
- **仿真要多细就多细**(碰撞检测、防隧穿需要 `setSimulationInterval` 跑到 20ms 甚至更细,这是对的);但**「往 state 根字段写值」的间隔不得快于 patchRate(50ms)**。`patchRate` 已把下行锁在 20Hz,**同一个 50ms 窗口内多次写同一字段会被合并,只发最后一次**——写 10 次发 1 次,多出的 9 次写入纯烧序列化 CPU,**不会让任何客户端画面更新鲜**(下行还是 20Hz)。
|
|
106
|
+
- 所以 **tick 比 50ms 细时,快照写入要单独节流**:tick 里只推进物理,攒够 50ms 再把 state 写一次,别让写入跟着 tick 频率走。
|
|
107
|
+
- **不要用「提高 patchRate(`setPatchRate(...)` 调更小)」来治卡顿**:它成倍放大**所有**客户端的下行带宽和 DS 序列化开销(DS 一局一进程,直接顶到心跳超时被强杀、整房掉线),而**连续运动玩法的卡顿根因几乎都在收端纠偏数学**(见客户端 StateSyncKnowledge「形态 C」四条铁律:外推 / 时钟标定 / 积分同源),**不在下发频率**。先按形态 C 排查收端,别动 patchRate。
|
|
108
|
+
|
|
109
|
+
房主、准备、踢人、观战、队伍在平台侧**没有对应物**,平台 API 里找不到这些字段;要就在 Room 里自己实现。
|
|
110
|
+
|
|
111
|
+
## 环境变量(壳注入,只读)
|
|
112
|
+
|
|
113
|
+
`DS_PORT`(壳已 listen)、`DS_APP_ID` / `DS_VERSION_ID` / `DS_INSTANCE_ID`(打日志用)、`DS_WORKDIR`、`DS_ENGINE`、`DS_HEARTBEAT_INTERVAL_MS`。玩法参数**不要**依赖新环境变量(平台不会注入),要写死在 `ds/` 或由客户端上行。
|
|
114
|
+
|
|
115
|
+
## 平台运行时数值(写玩法/排查时按这些实际值算,勿凭感觉)
|
|
116
|
+
|
|
117
|
+
> 以下为平台仓库当前默认值,供设计容量、超时、重连宽限时对齐。**这些数字由平台侧维护、可能随版本调整**,改玩法逻辑前若涉及关键容量/超时,最好再核对一次平台仓库对应常量。出处均在 `backend/game/`(`room_server.go` / `pipe.mjs` / `runtime.mjs`,不在本引擎工作目录内,故此处记录的是平台侧核对值)。
|
|
118
|
+
|
|
119
|
+
- **`max_players` 有效范围 1–64,越界回落 8**:开房时平台对 `max_players` 取 1–64;不在范围内按 8 处理。`ds/` 里 `maxClients` 必须等于实际生效的 `max_players`(回落后是 8),且等于玩法人数。(出处:`room_server.go` 开房参数校验)
|
|
120
|
+
- **HTTP 占座宽限 `seatGrace` 默认 30s**:玩家在 Room HTTP 拿到座位、但还没建立 Colyseus 连接的这段时间,平台按「已占座」计数,默认 30s;超时未连上则释放座位。重连设计的等待窗别短于这个值。(出处:`room_server.go`)
|
|
121
|
+
- **`player_count` = Colyseus 有效连接数 + 有效 HTTP 占座数**:平台人数是这两者合计,不是单看连接。**同账号双开 = 2**(两条连接、两个 sessionId),不去重 uid。设计满员判断时按这个口径。(出处:`pipe.mjs` `setSessionsProvider` 上报聚合)
|
|
122
|
+
- **`join` 幂等前提**:房**未满**时,同 uid 重复 `join`(同一连接语义)幂等,返回原座位;房**已满**时,`join` 一律被拒(**含该 uid 已在房内的情况**——满员后即使是本人也不再放新连接进来)。重连要趁未被顶满时回来。(出处:`room_server.go` join 分支)
|
|
123
|
+
- **DS 空闲回收 `DS_IDLE_TIMEOUT_MS` 默认 60000ms(0 = 关闭)**:进程在无人且无占座后闲置超过此值被平台回收。这是**兜底回收**,正常收尾仍应由 `onLeave` 空房 `DSAgentPipe.end("empty")` 主动触发,别依赖闲置超时。(出处:`runtime.mjs`)
|
|
124
|
+
- **DS 心跳 `DS_HEARTBEAT_INTERVAL_MS` 默认 5000ms;连续 3 次未收到 → 强杀(≈15s)**:低于 500ms 的配置回落 5000ms。心跳超时强杀是**异常路径**,正常靠主动 `end()`;「默认 15s」= 3 × 5000ms 心跳窗,即空房检查里提到的那个 15s。(出处:`runtime.mjs` / `pipe.mjs`)
|
|
125
|
+
- **每游戏并发 DS 上限默认 8**:同一 App 同时存活的 DS 进程数默认封顶 8;超出时 `create` 返回 `DS_QUOTA_EXCEEDED`。客户端收到该错误应引导玩家 `list` / `join` 现有房,**不要立即重试 `create`**(重试仍会被拒且徒增压力)。(出处:`room_server.go` 配额分支)
|
|
126
|
+
|
|
127
|
+
## 目录归属
|
|
128
|
+
|
|
129
|
+
- `main.mjs` — 只做 `rooms` 导出,不写玩法逻辑
|
|
130
|
+
- `rooms/<玩法>Room.mjs` — 一个玩法一个 Room 类,与客户端玩法业务 System 对应
|
|
131
|
+
- `rooms/<玩法>Schema.mjs` — 该 Room 的 Schema 定义
|
|
132
|
+
|
|
133
|
+
## 收尾检查
|
|
134
|
+
|
|
135
|
+
- `ds/` 不参与客户端 `type-check`;**禁止** `npm run build` / `vite build`。
|
|
136
|
+
- 改动 `ds/` 后自检:入口导出形状、`maxClients` 是否等于开房时用的 `max_players` 且等于玩法人数、空房是否 `end()`、`onCreate`/`onJoin`/`onLeave` 是否补 `hb()`、`onDispose` 是否解绑 provider。
|
|
137
|
+
- **可机检**:`ds/` 全文 grep 不到 `this.state.<字段>[` 形式的下标访问;所有 **MapSchema / ArraySchema** 容器走 `.set/.get/.has/.delete/.forEach`(JS 原生 `Map`、JSON 解析出的普通对象不受此限,只查 `state.` 开的容器字段)。每个 state 根字段都能说出它是**标量还是容器**,以及**客户端从哪个收口拿到它**(标量 → 现成 `onStateField`;容器 → 客户端 `MultiplayerManager.ts` 的 `_attachRoom()` 里补的订阅,见「三条路怎么选」)。
|
|
138
|
+
- 从 pub 载荷取业务字段前先 `JSON.parse(payload.data || "{}")` 再取;`payload` 顶层只有 `type` / `data`,直读 `payload.<业务字段>` 恒 `undefined`(见硬约束段契约载体条)。
|
|
139
|
+
- **可机检(uid 写法层判定)**:`ds/` 内所有进入 `setSessionsProvider` 上报的 `uid`,取值**必须是 `parseJoinUid(options)` 的返回值或 `Number(x) || 0`**;出现 `sessionId`、`player_id`、任何字符串表达式即为错误。join options 里 `uid`(number)与 `player_id`(string)**并存且相邻**,协议要的是 `uid`;`player_id` 是账号字符串,只能经 `parseJoinUid` 的 `/^u(\d+)$/` 分支间接使用。这条必须停在**写法层可判定**——因为该错误可观测性为零:坏帧在平台入口被静默丢弃,DS 侧无异常、客户端只有空 `onError`、服务端无日志,Agent 自己跑不出来,只能靠 grep 写法拦。典型错法(在两个都像的字段间选错,不是忘了约束):`const uid = typeof options.player_id === 'string' && options.player_id ? options.player_id : client.sessionId;`。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 平台服务契约
|
|
2
|
+
|
|
3
|
+
Agent 工具脚本与游戏运行时是两条独立身份通道。Agent 脚本从当前命令环境读取宿主注入的 `PLATFORM_ACCESS_URL` / `PLATFORM_ACCESS_KEY`,只访问本机平台入口并用 `x-platform-run-key`;游戏内本模块只消费可信父页面发来的 `runtime-init` / `session-token-refresh`。禁止跨边界转交任一方的凭据,也不要将 Agent 凭据写入项目、游戏包或日志。
|
|
4
|
+
|
|
5
|
+
权威类型随能力包发布:`assets/modules/platform-service.d.mts`、`leaderboard.d.mts`、`save.d.mts`、`MultiplayerManager.ts`。安装后读取项目内同名文件,先确认接口再接线。只读这次装上的文件。
|
|
6
|
+
|
|
7
|
+
- `identity`、`leaderboard`、`save`、`multiplayer` 分开安装。后三个各自附带身份实现,因为它们调用 `PlatformServiceManager`;附带身份不会把排行榜、云存档、联机装在一起。
|
|
8
|
+
- 初始化只挂监听,不向父页面发送消息。预览桥发出 `ready` 后,父页面回复 `{ type: 'runtime-init', data }`;token 更新是 `session-token-refresh`。只接受已确定的父页面来源,生产环境优先显式设置 `targetOrigin`。
|
|
9
|
+
- 身份服务必须在预览 ready 前挂监听,不阻塞首帧和 ready。没有宿主或初始化超时时按原 API 降级。
|
|
10
|
+
- `getPlatformService()` 使用页面单例。这次装上的排行榜、存档、联机共享该实例。不同版本的服务不能同时接入。
|
|
11
|
+
- 保留 `@lightgame/save/v1/` 本地存储命名空间、同槽位队列、防抖、冲突令牌、云/本地降级规则,避免把已有存档当新数据覆盖。
|
|
12
|
+
- 请求错误按返回的 `ok/code/message` 处理。禁止输出 Bearer token 或完整身份消息。通信状态用 `console.info`,前缀 `[platform-service]`、`[leaderboard]`、`[save]`,不记录 token、app_id、player_id。排行榜日志含 `result`、`message`、`board_key`;`report` 另含 `configured=yes/no`。存档日志含 `result`、`message`、`source`、`slot_key`。
|
|
13
|
+
- 排行榜 `configure` 按 `boardKey` 暂存建榜参数和 `period`(`all_time` / `weekly` / `monthly`;`season` 暂未开放,服务端拒绝)。`period` 之后 `report` / `query` / `updateDisplay` 自动带上,漏设落回 `all_time`;`boardKey` 不会被记住,每次调用都传同一个,漏传落到 `default` 榜(未 `configure` 时首报回 `INVALID_BOARD_CONFIG`,日志 `configured=no`)。`report` / `reportBatch` 不能传 `seasonNumber`。`query` 的 `aroundSelf` 本地钳到 25。`BOARD_NOT_FOUND` 与 `ARCHIVED` 按空榜。`reportBatch` 逐榜看 `boards[i].result`。不要传 `period: 'season'` / `periodConfig`,周期需求用 `weekly` / `monthly`。
|
|
14
|
+
- 云存档 `CONFLICT` 带回服务端 `fields`、`updated_at`、`blob_size`,默认不带回 blob;需要时写选项传 `conflictIncludeBlob: true`。SDK 不刷新冲突令牌,禁止盲目重试覆盖另一台设备。单玩家最多 32 个槽,只有新建超出才返回 `QUOTA_EXCEEDED_SLOT_COUNT`。
|
|
15
|
+
- 联机对业务暴露 `createRoom` / `joinRoom` / `leaveRoom` / `sendPose` / `sendEvent` / `onEvent`。房间事件从同目录 `eventBus.ts` 导出的 `bus` 订阅。不要改这几个文件之间的 import,也不要删 `log.ts` / `eventBus.ts`。玩法需要的监听直接加在 `MultiplayerManager.ts` 的 `_attachRoom()`;重装会覆盖为当前版本,改过的文件备份为 `.previous`,按 SKILL「修改与重装」合入。服务端 Room 在项目 `ds/`:安装 `multiplayer` 时若没有 `ds/` 会写入骨架,之后归工程所有。约束见同目录 `SERVER_GUIDE.md`。
|
|
16
|
+
- 预览桥的 `dispose()` 不销毁服务。项目入口负责 HMR 清理;存档管理器和身份服务按使用顺序释放。
|
|
17
|
+
|
|
18
|
+
资源包沿用既有服务实现及其行为;它不提供游戏玩法、UI 或自动登录界面。
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { readFile, lstat, mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve, join, relative, isAbsolute, dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
|
|
6
|
+
const skillAssets = resolve(dirname(fileURLToPath(import.meta.url)), '../assets');
|
|
7
|
+
const assets = skillAssets;
|
|
8
|
+
const digest = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
9
|
+
const scaffold = { target: 'ds', files: ['main.mjs', 'rooms/SyncRoom.mjs', 'rooms/syncSchema.mjs'] };
|
|
10
|
+
const BACKUP_SUFFIX = '.previous';
|
|
11
|
+
const safeParts = value => typeof value === 'string' && value.split('/').every(part => /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(part));
|
|
12
|
+
|
|
13
|
+
async function checkedPath(root, name) {
|
|
14
|
+
if (!safeParts(name)) throw new Error(`Invalid package path: ${name}`);
|
|
15
|
+
const target = resolve(root, name);
|
|
16
|
+
const rel = relative(root, target);
|
|
17
|
+
if (isAbsolute(rel) || rel === '..' || rel.startsWith('../')) throw new Error(`Path escapes project: ${name}`);
|
|
18
|
+
let current = root;
|
|
19
|
+
for (const part of name.split('/')) {
|
|
20
|
+
current = join(current, part);
|
|
21
|
+
try {
|
|
22
|
+
const info = await lstat(current);
|
|
23
|
+
if (info.isSymbolicLink()) throw new Error(`Symbolic links are not allowed: ${current}`);
|
|
24
|
+
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
25
|
+
}
|
|
26
|
+
return target;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function readOptional(path) {
|
|
30
|
+
try {
|
|
31
|
+
return await readFile(path);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error.code === 'ENOENT') return null;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function readRecord(path) {
|
|
39
|
+
try {
|
|
40
|
+
const record = JSON.parse(await readFile(path, 'utf8'));
|
|
41
|
+
return record && typeof record === 'object' ? record : {};
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error.code === 'ENOENT') return {};
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 骨架只在目标目录不存在时整份写入;写入后归工程所有,重装不覆盖。
|
|
49
|
+
async function installScaffold(root, { target, files }) {
|
|
50
|
+
const dir = await checkedPath(root, target);
|
|
51
|
+
try {
|
|
52
|
+
await lstat(dir);
|
|
53
|
+
return { target, status: 'kept' };
|
|
54
|
+
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
55
|
+
const entries = [];
|
|
56
|
+
for (const name of files) {
|
|
57
|
+
const bytes = await readFile(await checkedPath(join(skillAssets, 'scaffold', target), name));
|
|
58
|
+
entries.push([await checkedPath(root, `${target}/${name}`), bytes]);
|
|
59
|
+
}
|
|
60
|
+
for (const [path, bytes] of entries) {
|
|
61
|
+
await mkdir(dirname(path), { recursive: true });
|
|
62
|
+
await writeFile(path, bytes, { flag: 'wx' });
|
|
63
|
+
}
|
|
64
|
+
return { target, status: 'created' };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function installPackage(project, modules, source = assets) {
|
|
68
|
+
const root = resolve(project);
|
|
69
|
+
const info = await lstat(root);
|
|
70
|
+
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error('Project root must be a real directory');
|
|
71
|
+
await readFile(await checkedPath(root, 'package.json'));
|
|
72
|
+
const release = JSON.parse(await readFile(join(source, 'release.json'), 'utf8'));
|
|
73
|
+
if (!safeParts(release.source) || !safeParts(release.target) || !release.version || !release.files || !release.groups) throw new Error('Invalid skill release');
|
|
74
|
+
if (!/^(src|scripts)\/skill-modules\//.test(release.target)) throw new Error('Skill modules must be installed outside platform runtime');
|
|
75
|
+
const selected = modules ?? release.defaults;
|
|
76
|
+
if (!Array.isArray(selected) || !selected.length) throw new Error('Select at least one module');
|
|
77
|
+
for (const module of selected) {
|
|
78
|
+
if (!Object.hasOwn(release.groups, module)) throw new Error(`Unknown module: ${module}`);
|
|
79
|
+
}
|
|
80
|
+
const recordPath = await checkedPath(root, `${release.target}/installed.json`);
|
|
81
|
+
const previous = await readRecord(recordPath);
|
|
82
|
+
const kept = Array.isArray(previous.modules) ? previous.modules.filter(module => Object.hasOwn(release.groups, module)) : [];
|
|
83
|
+
const installed = [...new Set([...kept, ...selected])].sort();
|
|
84
|
+
const files = [];
|
|
85
|
+
for (const name of new Set(installed.flatMap(module => release.groups[module]))) {
|
|
86
|
+
const target = await checkedPath(root, `${release.target}/${name}`);
|
|
87
|
+
const backup = await checkedPath(root, `${release.target}/${name}${BACKUP_SUFFIX}`);
|
|
88
|
+
const bytes = await readFile(await checkedPath(resolve(source, release.source), name));
|
|
89
|
+
if (digest(bytes) !== release.files[name]) throw new Error(`Bundled skill module is damaged: ${name}`);
|
|
90
|
+
const current = await readOptional(target);
|
|
91
|
+
files.push({ target, backup, bytes, current: current && !current.equals(bytes) ? current : null });
|
|
92
|
+
}
|
|
93
|
+
const changed = files.filter(file => file.current);
|
|
94
|
+
const unmerged = [];
|
|
95
|
+
for (const file of changed) if (await readOptional(file.backup)) unmerged.push(relative(root, file.backup));
|
|
96
|
+
if (unmerged.length) throw new Error(`Unmerged backup: ${unmerged.join(', ')}. Merge it into the installed file and delete it before reinstalling`);
|
|
97
|
+
for (const { backup, current } of changed) await writeFile(backup, current);
|
|
98
|
+
for (const { target, bytes } of files) {
|
|
99
|
+
await mkdir(dirname(target), { recursive: true });
|
|
100
|
+
await writeFile(target, bytes);
|
|
101
|
+
}
|
|
102
|
+
await writeFile(recordPath, `${JSON.stringify({ version: release.version, modules: installed, files: Object.fromEntries([...new Set(installed.flatMap(module => release.groups[module]))].map(name => [name, release.files[name]])) }, null, 2)}\n`);
|
|
103
|
+
const scaffolds = [];
|
|
104
|
+
for (const module of selected) {
|
|
105
|
+
if (module === 'multiplayer') scaffolds.push(await installScaffold(root, scaffold));
|
|
106
|
+
}
|
|
107
|
+
const previousVersion = typeof previous.version === 'string' ? previous.version : '';
|
|
108
|
+
const backups = changed.map(file => relative(root, file.backup));
|
|
109
|
+
return { root: release.target, version: release.version, previousVersion, modules: installed, backups, scaffolds };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function runCli(args = process.argv.slice(2)) {
|
|
113
|
+
let project, modules;
|
|
114
|
+
for (let index = 0; index < args.length; index++) {
|
|
115
|
+
const flag = args[index];
|
|
116
|
+
const value = args[++index];
|
|
117
|
+
if (!value || value.startsWith('--')) throw new Error(`Missing value for ${flag}`);
|
|
118
|
+
if (flag === '--project') project = value;
|
|
119
|
+
else if (flag === '--modules') modules = value.split(',');
|
|
120
|
+
else throw new Error(`Unknown option: ${flag}`);
|
|
121
|
+
}
|
|
122
|
+
if (!project) throw new Error('Usage: install.mjs --project <directory> [--modules <comma-separated names>]');
|
|
123
|
+
const result = await installPackage(project, modules);
|
|
124
|
+
const version = result.previousVersion && result.previousVersion !== result.version ? `${result.previousVersion} -> ${result.version}` : result.version;
|
|
125
|
+
console.log(`[skill] ${result.root}: ${result.modules.join(', ')} (${version})`);
|
|
126
|
+
for (const scaffold of result.scaffolds) console.log(`[skill] ${scaffold.target}/: ${scaffold.status}`);
|
|
127
|
+
for (const backup of result.backups) console.log(`[skill] BACKUP ${backup}`);
|
|
128
|
+
if (result.backups.length) console.log('[skill] Changed files were replaced. Re-apply project changes from each backup, then delete it.');
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
133
|
+
runCli().catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
134
|
+
}
|