@playdrop/playdrop-cli 0.16.16 → 0.17.0
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/config/client-meta.json +4 -4
- package/dist/apiClient.d.ts +1 -2
- package/dist/apiClient.js +1 -16
- package/dist/appUrls.js +4 -0
- package/dist/apps/build.d.ts +12 -4
- package/dist/apps/build.js +55 -22
- package/dist/apps/index.d.ts +2 -1
- package/dist/apps/index.js +4 -1
- package/dist/apps/loadCheck.d.ts +5 -1
- package/dist/apps/loadCheck.js +52 -18
- package/dist/apps/serverBuild.d.ts +17 -0
- package/dist/apps/serverBuild.js +155 -0
- package/dist/apps/staticHtml.d.ts +1 -0
- package/dist/apps/staticHtml.js +19 -10
- package/dist/apps/upload.d.ts +12 -2
- package/dist/apps/upload.js +127 -46
- package/dist/catalogue.d.ts +23 -1
- package/dist/catalogue.js +126 -100
- package/dist/commandContext.d.ts +6 -3
- package/dist/commandContext.js +108 -18
- package/dist/commands/build.js +0 -7
- package/dist/commands/captureListing.d.ts +3 -0
- package/dist/commands/captureListing.js +48 -4
- package/dist/commands/chat.d.ts +4 -0
- package/dist/commands/chat.js +133 -8
- package/dist/commands/check.js +34 -1
- package/dist/commands/create.js +30 -263
- package/dist/commands/dev.js +37 -3
- package/dist/commands/devBrowser.js +2 -2
- package/dist/commands/devGameServer.d.ts +16 -0
- package/dist/commands/devGameServer.js +237 -0
- package/dist/commands/devRuntimeAssets.d.ts +1 -0
- package/dist/commands/devRuntimeAssets.js +2 -0
- package/dist/commands/devServer.d.ts +3 -0
- package/dist/commands/devServer.js +111 -5
- package/dist/commands/generation.d.ts +33 -4
- package/dist/commands/generation.js +304 -115
- package/dist/commands/login.js +23 -7
- package/dist/commands/review.d.ts +1 -1
- package/dist/commands/review.js +68 -95
- package/dist/commands/source.d.ts +19 -0
- package/dist/commands/source.js +142 -0
- package/dist/commands/tweaks.js +5 -11
- package/dist/commands/upload-content.d.ts +1 -1
- package/dist/commands/upload-content.js +16 -12
- package/dist/commands/upload.d.ts +17 -1
- package/dist/commands/upload.js +47 -10
- package/dist/commands/worker/archive-staging.d.ts +1 -0
- package/dist/commands/worker/archive-staging.js +13 -2
- package/dist/commands/worker/e2e-fixtures.d.ts +32 -0
- package/dist/commands/worker/e2e-fixtures.js +466 -0
- package/dist/commands/worker/game-server-infra.d.ts +80 -0
- package/dist/commands/worker/game-server-infra.js +595 -0
- package/dist/commands/worker/game-source-git.d.ts +126 -0
- package/dist/commands/worker/game-source-git.js +780 -0
- package/dist/commands/worker/generation.d.ts +94 -0
- package/dist/commands/worker/generation.js +1458 -0
- package/dist/commands/worker/runtime.d.ts +8 -10
- package/dist/commands/worker/runtime.js +51 -45
- package/dist/commands/worker.d.ts +79 -19
- package/dist/commands/worker.js +1796 -419
- package/dist/config.d.ts +2 -0
- package/dist/config.js +16 -3
- package/dist/environment.d.ts +0 -1
- package/dist/environment.js +0 -8
- package/dist/index.js +92 -13
- package/dist/workerAppProject.d.ts +1 -1
- package/dist/workerAppProject.js +15 -2
- package/node_modules/@playdrop/api-client/dist/client.d.ts +72 -25
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +33 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts +1 -0
- package/node_modules/@playdrop/api-client/dist/core/request.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/core/request.js +17 -11
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts +51 -6
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/agent-tasks.js +338 -41
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts +24 -1
- package/node_modules/@playdrop/api-client/dist/domains/ai.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/ai.js +20 -0
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts +13 -8
- package/node_modules/@playdrop/api-client/dist/domains/apps.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +158 -90
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts +4 -0
- package/node_modules/@playdrop/api-client/dist/domains/assets.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +27 -0
- package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts +35 -3
- package/node_modules/@playdrop/api-client/dist/domains/chat.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/chat.js +89 -7
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts +2 -1
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +9 -0
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts +1 -2
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/playtrade.js +0 -11
- package/node_modules/@playdrop/api-client/dist/domains/social.d.ts +29 -0
- package/node_modules/@playdrop/api-client/dist/domains/social.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/domains/social.js +79 -0
- package/node_modules/@playdrop/api-client/dist/index.d.ts +80 -29
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +217 -56
- package/node_modules/@playdrop/api-client/dist/runtime.d.ts +18 -0
- package/node_modules/@playdrop/api-client/dist/runtime.d.ts.map +1 -0
- package/node_modules/@playdrop/api-client/dist/runtime.js +54 -0
- package/node_modules/@playdrop/api-client/package.json +7 -0
- package/node_modules/@playdrop/config/client-meta.json +4 -4
- package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts +11 -0
- package/node_modules/@playdrop/config/dist/src/creator-plans.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/creator-plans.js +13 -1
- package/node_modules/@playdrop/config/dist/src/deployment.d.ts +0 -1
- package/node_modules/@playdrop/config/dist/src/deployment.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/deployment.js +0 -8
- package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts +0 -1
- package/node_modules/@playdrop/config/dist/src/public-deployment.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/public-deployment.js +0 -8
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.d.ts +1 -1
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.js +2 -2
- package/node_modules/@playdrop/config/dist/src/server/logging.d.ts.map +1 -1
- package/node_modules/@playdrop/config/dist/src/server/logging.js +31 -2
- package/node_modules/@playdrop/config/dist/test/creator-plans.test.js +10 -0
- package/node_modules/@playdrop/config/dist/test/deployment.test.js +0 -4
- package/node_modules/@playdrop/config/dist/test/runtime-service-origins.test.js +2 -0
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/config/package.json +6 -0
- package/node_modules/@playdrop/game-source-git/dist/src/archive.d.ts +9 -0
- package/node_modules/@playdrop/game-source-git/dist/src/archive.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/archive.js +107 -0
- package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.d.ts +29 -0
- package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/bundle-storage.js +64 -0
- package/node_modules/@playdrop/game-source-git/dist/src/export.d.ts +8 -0
- package/node_modules/@playdrop/game-source-git/dist/src/export.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/export.js +25 -0
- package/node_modules/@playdrop/game-source-git/dist/src/git.d.ts +39 -0
- package/node_modules/@playdrop/game-source-git/dist/src/git.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/git.js +195 -0
- package/node_modules/@playdrop/game-source-git/dist/src/ignore.d.ts +6 -0
- package/node_modules/@playdrop/game-source-git/dist/src/ignore.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/ignore.js +51 -0
- package/node_modules/@playdrop/game-source-git/dist/src/index.d.ts +10 -0
- package/node_modules/@playdrop/game-source-git/dist/src/index.d.ts.map +1 -0
- package/node_modules/@playdrop/{boxel-core/dist/src/humanoid/r15 → game-source-git/dist/src}/index.js +9 -4
- package/node_modules/@playdrop/game-source-git/dist/src/lock.d.ts +17 -0
- package/node_modules/@playdrop/game-source-git/dist/src/lock.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/lock.js +72 -0
- package/node_modules/@playdrop/game-source-git/dist/src/materialize.d.ts +10 -0
- package/node_modules/@playdrop/game-source-git/dist/src/materialize.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/materialize.js +99 -0
- package/node_modules/@playdrop/game-source-git/dist/src/paths.d.ts +24 -0
- package/node_modules/@playdrop/game-source-git/dist/src/paths.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/paths.js +207 -0
- package/node_modules/@playdrop/game-source-git/dist/src/repository.d.ts +66 -0
- package/node_modules/@playdrop/game-source-git/dist/src/repository.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/src/repository.js +213 -0
- package/node_modules/@playdrop/game-source-git/dist/test/core.test.d.ts +2 -0
- package/node_modules/@playdrop/game-source-git/dist/test/core.test.d.ts.map +1 -0
- package/node_modules/@playdrop/game-source-git/dist/test/core.test.js +441 -0
- package/node_modules/@playdrop/game-source-git/dist/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@playdrop/game-source-git/package.json +28 -0
- package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts +2 -2
- package/node_modules/@playdrop/types/dist/agent-task-terminal.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/agent-task-terminal.js +15 -9
- package/node_modules/@playdrop/types/dist/api.d.ts +728 -164
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/api.js +60 -11
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts +2 -0
- package/node_modules/@playdrop/types/dist/asset-pack.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.d.ts +22 -8
- package/node_modules/@playdrop/types/dist/asset.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/asset.js +26 -26
- package/node_modules/@playdrop/types/dist/chat.d.ts +107 -3
- package/node_modules/@playdrop/types/dist/chat.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/chat.js +33 -4
- package/node_modules/@playdrop/types/dist/index.d.ts +3 -0
- package/node_modules/@playdrop/types/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/index.js +7 -1
- package/node_modules/@playdrop/types/dist/public-cache-tags.d.ts +11 -0
- package/node_modules/@playdrop/types/dist/public-cache-tags.d.ts.map +1 -0
- package/node_modules/@playdrop/types/dist/public-cache-tags.js +78 -0
- package/node_modules/@playdrop/types/dist/realtime.d.ts +3 -15
- package/node_modules/@playdrop/types/dist/realtime.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/social.d.ts +64 -0
- package/node_modules/@playdrop/types/dist/social.d.ts.map +1 -0
- package/node_modules/@playdrop/{boxel-three/dist/src/types.js → types/dist/social.js} +14 -2
- package/node_modules/@playdrop/types/dist/spritesheet.d.ts +51 -0
- package/node_modules/@playdrop/types/dist/spritesheet.d.ts.map +1 -0
- package/node_modules/@playdrop/types/dist/spritesheet.js +73 -0
- package/node_modules/@playdrop/types/dist/version.d.ts +86 -58
- package/node_modules/@playdrop/types/dist/version.d.ts.map +1 -1
- package/node_modules/@playdrop/types/dist/version.js +111 -0
- package/node_modules/@playdrop/types/package.json +14 -0
- package/node_modules/@playdrop/vox-three/dist/src/index.d.ts +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/index.js +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/index.js.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/src/vox.d.ts +0 -3
- package/node_modules/@playdrop/vox-three/dist/src/vox.js +0 -110
- package/node_modules/@playdrop/vox-three/dist/src/vox.js.map +1 -1
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js +0 -18
- package/node_modules/@playdrop/vox-three/dist/test/vox.test.js.map +1 -1
- package/node_modules/@playdrop/vox-three/package.json +8 -4
- package/package.json +9 -11
- package/dist/assets/model-artifacts.d.ts +0 -8
- package/dist/assets/model-artifacts.js +0 -382
- package/dist/assets/model-worker.d.ts +0 -22
- package/dist/assets/model-worker.js +0 -123
- package/node_modules/@playdrop/ai-client/dist/index.d.ts +0 -441
- package/node_modules/@playdrop/ai-client/dist/index.d.ts.map +0 -1
- package/node_modules/@playdrop/ai-client/dist/index.js +0 -499
- package/node_modules/@playdrop/ai-client/package.json +0 -22
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.d.ts +0 -13
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js +0 -141
- package/node_modules/@playdrop/boxel-core/dist/src/entity-cleaner.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.d.ts +0 -47
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js +0 -313
- package/node_modules/@playdrop/boxel-core/dist/src/entity-utils.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js +0 -36
- package/node_modules/@playdrop/boxel-core/dist/src/format-utils.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.d.ts +0 -23
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.js +0 -11
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/geometry.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.js +0 -21
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.js +0 -24
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/common.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js +0 -387
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/textured-builder.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.d.ts +0 -6
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.js +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/types.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js +0 -373
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r15/voxel-builder.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.d.ts +0 -12
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js +0 -215
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/builder.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js +0 -18
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.d.ts +0 -42
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js +0 -145
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/scanner.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.d.ts +0 -26
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js +0 -65
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/artifacts.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.d.ts +0 -33
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js +0 -175
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/r6/textures/face-map.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/humanoid_r15.json +0 -1517
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/humanoid_r6.json +0 -61
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.d.ts +0 -10
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js +0 -23
- package/node_modules/@playdrop/boxel-core/dist/src/humanoid/templates/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/index.d.ts +0 -19
- package/node_modules/@playdrop/boxel-core/dist/src/index.js +0 -36
- package/node_modules/@playdrop/boxel-core/dist/src/index.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/materials.d.ts +0 -26
- package/node_modules/@playdrop/boxel-core/dist/src/materials.js +0 -184
- package/node_modules/@playdrop/boxel-core/dist/src/materials.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.d.ts +0 -68
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js +0 -488
- package/node_modules/@playdrop/boxel-core/dist/src/palette_tools.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.d.ts +0 -4
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.js +0 -380
- package/node_modules/@playdrop/boxel-core/dist/src/serialization.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/textures.d.ts +0 -29
- package/node_modules/@playdrop/boxel-core/dist/src/textures.js +0 -208
- package/node_modules/@playdrop/boxel-core/dist/src/textures.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.d.ts +0 -9
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js +0 -312
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/infer-face.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.d.ts +0 -9
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js +0 -154
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/layer-mode.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.d.ts +0 -2
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js +0 -121
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/merge-overlay.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.d.ts +0 -20
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js +0 -389
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/textured-boxes/slice.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.d.ts +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js +0 -206
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/upscale.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.d.ts +0 -12
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js +0 -81
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/slice.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.d.ts +0 -12
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js +0 -318
- package/node_modules/@playdrop/boxel-core/dist/src/transforms/voxels/textured-to-voxel.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/types.d.ts +0 -168
- package/node_modules/@playdrop/boxel-core/dist/src/types.js +0 -3
- package/node_modules/@playdrop/boxel-core/dist/src/types.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/validation.d.ts +0 -24
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js +0 -620
- package/node_modules/@playdrop/boxel-core/dist/src/validation.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.d.ts +0 -11
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js +0 -135
- package/node_modules/@playdrop/boxel-core/dist/src/voxels/greedy-mesher.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.d.ts +0 -23
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.js +0 -52
- package/node_modules/@playdrop/boxel-core/dist/src/voxels.js.map +0 -1
- package/node_modules/@playdrop/boxel-core/package.json +0 -19
- package/node_modules/@playdrop/boxel-three/dist/src/animations.d.ts +0 -4
- package/node_modules/@playdrop/boxel-three/dist/src/animations.js +0 -92
- package/node_modules/@playdrop/boxel-three/dist/src/builders.d.ts +0 -8
- package/node_modules/@playdrop/boxel-three/dist/src/builders.js +0 -363
- package/node_modules/@playdrop/boxel-three/dist/src/context.d.ts +0 -24
- package/node_modules/@playdrop/boxel-three/dist/src/context.js +0 -58
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.d.ts +0 -100
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +0 -927
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.d.ts +0 -18
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +0 -294
- package/node_modules/@playdrop/boxel-three/dist/src/index.d.ts +0 -17
- package/node_modules/@playdrop/boxel-three/dist/src/index.js +0 -64
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.d.ts +0 -40
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +0 -96
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.d.ts +0 -8
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +0 -88
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.d.ts +0 -7
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +0 -123
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.d.ts +0 -4
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +0 -48
- package/node_modules/@playdrop/boxel-three/dist/src/scene.d.ts +0 -3
- package/node_modules/@playdrop/boxel-three/dist/src/scene.js +0 -168
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.d.ts +0 -29
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +0 -623
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.d.ts +0 -13
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +0 -133
- package/node_modules/@playdrop/boxel-three/dist/src/textures.d.ts +0 -17
- package/node_modules/@playdrop/boxel-three/dist/src/textures.js +0 -216
- package/node_modules/@playdrop/boxel-three/dist/src/types.d.ts +0 -112
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.d.ts +0 -28
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +0 -344
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.d.ts +0 -24
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +0 -113
- package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +0 -137
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.d.ts +0 -20
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +0 -85
- package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +0 -104
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +0 -30
- package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +0 -88
- package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +0 -42
- package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +0 -73
- package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +0 -85
- package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +0 -73
- package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +0 -136
- package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.d.ts +0 -1
- package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +0 -42
- package/node_modules/@playdrop/boxel-three/package.json +0 -28
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.emitGameSourceWorkerEvent = emitGameSourceWorkerEvent;
|
|
7
|
+
exports.setupGameSourceWorkspace = setupGameSourceWorkspace;
|
|
8
|
+
exports.checkpointFailedGameSourceWorkspace = checkpointFailedGameSourceWorkspace;
|
|
9
|
+
exports.reconcileGameSourceWorkspace = reconcileGameSourceWorkspace;
|
|
10
|
+
exports.finalizeGameSourceRepository = finalizeGameSourceRepository;
|
|
11
|
+
exports.uploadFinalizedGameSource = uploadFinalizedGameSource;
|
|
12
|
+
exports.maintainGameSourceCaches = maintainGameSourceCaches;
|
|
13
|
+
exports.cleanupCompletedGameSourceWorkspace = cleanupCompletedGameSourceWorkspace;
|
|
14
|
+
exports.readGameSourceWorkerInventory = readGameSourceWorkerInventory;
|
|
15
|
+
const game_source_git_1 = require("@playdrop/game-source-git");
|
|
16
|
+
const node_crypto_1 = require("node:crypto");
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const promises_1 = require("node:fs/promises");
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
const REPO_CACHE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
21
|
+
const BLOB_CACHE_LIMIT_BYTES = 25 * 1024 * 1024 * 1024;
|
|
22
|
+
const FAILED_WORKSPACE_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
23
|
+
const INVENTORY_LIMIT = 2000;
|
|
24
|
+
const git = (0, game_source_git_1.createGitRunner)();
|
|
25
|
+
function emitGameSourceWorkerEvent(event, fields, write = console.log) {
|
|
26
|
+
try {
|
|
27
|
+
write(JSON.stringify({ event, at: new Date().toISOString(), ...fields }));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Operational visibility must never interrupt creator work.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function cacheRoot(workerHomeDir) {
|
|
34
|
+
return node_path_1.default.join(workerHomeDir, "game-source");
|
|
35
|
+
}
|
|
36
|
+
function repoCacheRoot(workerHomeDir) {
|
|
37
|
+
return node_path_1.default.join(cacheRoot(workerHomeDir), "repos");
|
|
38
|
+
}
|
|
39
|
+
function blobCacheRoot(workerHomeDir) {
|
|
40
|
+
return node_path_1.default.join(cacheRoot(workerHomeDir), "files");
|
|
41
|
+
}
|
|
42
|
+
function blobCachePath(workerHomeDir, key) {
|
|
43
|
+
const parts = key.split("/");
|
|
44
|
+
return node_path_1.default.join(blobCacheRoot(workerHomeDir), parts[parts.length - 2], parts[parts.length - 1]);
|
|
45
|
+
}
|
|
46
|
+
function normalizeRelativePath(root, absolutePath) {
|
|
47
|
+
return node_path_1.default.relative(root, absolutePath).split(node_path_1.default.sep).join("/");
|
|
48
|
+
}
|
|
49
|
+
function semanticVersion(version) {
|
|
50
|
+
return { major: version.major, minor: version.minor, patch: version.patch };
|
|
51
|
+
}
|
|
52
|
+
async function downloadBuffer(url, expectedBytes, expectedSha256) {
|
|
53
|
+
const response = await fetch(url);
|
|
54
|
+
if (!response.ok)
|
|
55
|
+
throw new Error(`game_source_download_failed:${response.status}`);
|
|
56
|
+
const content = Buffer.from(await response.arrayBuffer());
|
|
57
|
+
if (expectedBytes !== undefined && content.length !== expectedBytes)
|
|
58
|
+
throw new Error("game_source_download_size_mismatch");
|
|
59
|
+
if (expectedSha256 !== undefined && (0, game_source_git_1.sha256)(content) !== expectedSha256) {
|
|
60
|
+
throw new Error("game_source_download_hash_mismatch");
|
|
61
|
+
}
|
|
62
|
+
return content;
|
|
63
|
+
}
|
|
64
|
+
async function uploadBuffer(upload, content) {
|
|
65
|
+
const response = await fetch(upload.url, {
|
|
66
|
+
method: "PUT",
|
|
67
|
+
headers: { ...upload.headers, "content-type": upload.contentType },
|
|
68
|
+
body: Uint8Array.from(content),
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok)
|
|
71
|
+
throw new Error(`game_source_upload_failed:${response.status}`);
|
|
72
|
+
}
|
|
73
|
+
function expectedRefs(assignment) {
|
|
74
|
+
if (!assignment.baseRepository)
|
|
75
|
+
throw new Error("game_source_expected_head_missing");
|
|
76
|
+
return {
|
|
77
|
+
headSha: assignment.baseRepository.expectedHeadSha,
|
|
78
|
+
versions: assignment.authoritativeVersions.map((version) => ({
|
|
79
|
+
version: { major: version.major, minor: version.minor, patch: version.patch },
|
|
80
|
+
commitSha: version.commitSha,
|
|
81
|
+
})),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function createBareCache(input) {
|
|
85
|
+
if (!input.assignment.baseRepository)
|
|
86
|
+
throw new Error("game_source_bundle_url_missing");
|
|
87
|
+
const bundlePath = node_path_1.default.join(input.workspaceDir, ".playdrop", `canonical-${(0, node_crypto_1.randomUUID)()}.bundle`);
|
|
88
|
+
const temporary = `${input.destination}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
89
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(bundlePath), { recursive: true });
|
|
90
|
+
try {
|
|
91
|
+
await (0, promises_1.writeFile)(bundlePath, await downloadBuffer(input.assignment.baseRepository.bundleDownloadUrl));
|
|
92
|
+
await git.run(["bundle", "verify", bundlePath]);
|
|
93
|
+
await git.run(["clone", "--bare", bundlePath, temporary]);
|
|
94
|
+
await reconcileCachedCanonicalRefs(temporary, input.assignment);
|
|
95
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(input.destination), { recursive: true });
|
|
96
|
+
try {
|
|
97
|
+
await (0, promises_1.rename)(temporary, input.destination);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (error.code !== "EEXIST" && error.code !== "ENOTEMPTY") {
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
await (0, promises_1.rm)(bundlePath, { force: true });
|
|
107
|
+
await (0, promises_1.rm)(temporary, { recursive: true, force: true });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function reconcileCachedCanonicalRefs(bareRepoPath, assignment) {
|
|
111
|
+
const expectedTags = new Set(assignment.authoritativeVersions.map((version) => (0, game_source_git_1.versionTagRef)(semanticVersion(version))));
|
|
112
|
+
const refs = await git.run(["--git-dir", bareRepoPath, "for-each-ref", "--format=%(refname)"], bareRepoPath);
|
|
113
|
+
for (const ref of refs.toString("utf8").trim().split("\n").filter(Boolean)) {
|
|
114
|
+
if (ref === "refs/heads/main")
|
|
115
|
+
continue;
|
|
116
|
+
if (/^refs\/heads\/task\/[1-9][0-9]*$/.test(ref))
|
|
117
|
+
continue;
|
|
118
|
+
if (!/^refs\/tags\/v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(ref)) {
|
|
119
|
+
throw new Error(`game_source_cache_unexpected_ref:${ref}`);
|
|
120
|
+
}
|
|
121
|
+
if (!expectedTags.has(ref))
|
|
122
|
+
await git.run(["--git-dir", bareRepoPath, "update-ref", "-d", ref], bareRepoPath);
|
|
123
|
+
}
|
|
124
|
+
await (0, game_source_git_1.validateCanonicalRefTargets)(bareRepoPath, expectedRefs(assignment), git);
|
|
125
|
+
}
|
|
126
|
+
async function prepareExistingBareCache(input) {
|
|
127
|
+
const repository = input.assignment.baseRepository;
|
|
128
|
+
if (!repository)
|
|
129
|
+
throw new Error("game_source_repository_identity_missing");
|
|
130
|
+
const { appId, repoGeneration } = repository;
|
|
131
|
+
const destination = node_path_1.default.join(repoCacheRoot(input.workerHomeDir), String(appId), `${repoGeneration}.git`);
|
|
132
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
133
|
+
if (!(0, node_fs_1.existsSync)(destination))
|
|
134
|
+
await createBareCache({ ...input, destination });
|
|
135
|
+
try {
|
|
136
|
+
await reconcileCachedCanonicalRefs(destination, input.assignment);
|
|
137
|
+
return destination;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const quarantine = `${destination}.quarantine-${Date.now()}-${(0, node_crypto_1.randomUUID)()}`;
|
|
141
|
+
await (0, promises_1.rename)(destination, quarantine).catch(() => undefined);
|
|
142
|
+
if (attempt === 1)
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
throw new Error("game_source_cache_setup_failed");
|
|
147
|
+
}
|
|
148
|
+
async function prepareRemixBareRepository(input) {
|
|
149
|
+
if ((0, node_fs_1.existsSync)(input.destination))
|
|
150
|
+
return input.destination;
|
|
151
|
+
const temporary = `${input.destination}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
152
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(input.destination), { recursive: true });
|
|
153
|
+
try {
|
|
154
|
+
await git.run(["clone", "--bare", "--no-local", input.sourceBareRepoPath, temporary]);
|
|
155
|
+
const refs = await git.run(["--git-dir", temporary, "for-each-ref", "--format=%(refname)"], temporary);
|
|
156
|
+
for (const ref of refs.toString("utf8").trim().split("\n").filter(Boolean)) {
|
|
157
|
+
await git.run(["--git-dir", temporary, "update-ref", "-d", ref], temporary);
|
|
158
|
+
}
|
|
159
|
+
await (0, promises_1.rename)(temporary, input.destination);
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
await (0, promises_1.rm)(temporary, { recursive: true, force: true });
|
|
163
|
+
}
|
|
164
|
+
return input.destination;
|
|
165
|
+
}
|
|
166
|
+
async function addTaskWorktree(input) {
|
|
167
|
+
await git.run(["--git-dir", input.bareRepoPath, "worktree", "prune"]);
|
|
168
|
+
await git.run(["--git-dir", input.bareRepoPath, "branch", "-D", input.taskBranch]).catch(() => Buffer.alloc(0));
|
|
169
|
+
await (0, promises_1.rm)(input.projectDir, { recursive: true, force: true });
|
|
170
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(input.projectDir), { recursive: true });
|
|
171
|
+
if (input.startSha) {
|
|
172
|
+
await git.run(["--git-dir", input.bareRepoPath, "worktree", "add", "-b", input.taskBranch, input.projectDir, input.startSha]);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
await git.run(["--git-dir", input.bareRepoPath, "worktree", "add", "--orphan", "-b", input.taskBranch, input.projectDir]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function linkedWorktreeAdminPath(projectDir, gitLink) {
|
|
179
|
+
const match = /^gitdir: (.+)\s*$/.exec(gitLink);
|
|
180
|
+
if (!match)
|
|
181
|
+
throw new Error("game_source_retained_workspace_link_invalid");
|
|
182
|
+
return node_path_1.default.resolve(projectDir, match[1]);
|
|
183
|
+
}
|
|
184
|
+
async function retainedWorktreeIsUsable(input) {
|
|
185
|
+
try {
|
|
186
|
+
const commonDir = await (0, promises_1.realpath)(node_path_1.default.resolve(input.projectDir, (await git.run(["rev-parse", "--git-common-dir"], input.projectDir)).toString("utf8").trim()));
|
|
187
|
+
const expectedCommonDir = await (0, promises_1.realpath)(input.bareRepoPath);
|
|
188
|
+
const branch = (await git.run(["symbolic-ref", "--short", "HEAD"], input.projectDir)).toString("utf8").trim();
|
|
189
|
+
return commonDir === expectedCommonDir && branch === input.taskBranch;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function reattachRetainedWorktree(input) {
|
|
196
|
+
const staleGitLink = await (0, promises_1.readFile)(node_path_1.default.join(input.projectDir, ".git"), "utf8");
|
|
197
|
+
const staleAdminPath = linkedWorktreeAdminPath(input.projectDir, staleGitLink);
|
|
198
|
+
const expectedAdminRoot = `${node_path_1.default.join(await (0, promises_1.realpath)(input.bareRepoPath), "worktrees")}${node_path_1.default.sep}`;
|
|
199
|
+
if (!staleAdminPath.startsWith(expectedAdminRoot)) {
|
|
200
|
+
throw new Error("game_source_retained_workspace_repository_mismatch");
|
|
201
|
+
}
|
|
202
|
+
const temporaryProjectDir = `${input.projectDir}.reattach-${(0, node_crypto_1.randomUUID)()}`;
|
|
203
|
+
await addTaskWorktree({
|
|
204
|
+
bareRepoPath: input.bareRepoPath,
|
|
205
|
+
projectDir: temporaryProjectDir,
|
|
206
|
+
taskBranch: input.taskBranch,
|
|
207
|
+
startSha: input.startSha,
|
|
208
|
+
});
|
|
209
|
+
try {
|
|
210
|
+
const freshGitLink = await (0, promises_1.readFile)(node_path_1.default.join(temporaryProjectDir, ".git"), "utf8");
|
|
211
|
+
const freshAdminPath = linkedWorktreeAdminPath(temporaryProjectDir, freshGitLink);
|
|
212
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(freshAdminPath, "gitdir"), `${node_path_1.default.join(input.projectDir, ".git")}\n`);
|
|
213
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(input.projectDir, ".git"), freshGitLink);
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
await (0, promises_1.rm)(temporaryProjectDir, { recursive: true, force: true });
|
|
217
|
+
}
|
|
218
|
+
if (!await retainedWorktreeIsUsable(input)) {
|
|
219
|
+
throw new Error("game_source_retained_workspace_reattach_failed");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function materializeCurrentLock(input) {
|
|
223
|
+
const lock = (0, game_source_git_1.parseGameSourceLock)(await (0, promises_1.readFile)(node_path_1.default.join(input.projectDir, ".playdrop", "files.lock")));
|
|
224
|
+
const requestedByKey = new Map();
|
|
225
|
+
for (const entry of Object.values(lock.files)) {
|
|
226
|
+
const existing = requestedByKey.get(entry.key);
|
|
227
|
+
if (existing && (existing.sha256 !== entry.sha256 || existing.bytes !== entry.bytes)) {
|
|
228
|
+
throw new Error("game_source_material_lock_conflict");
|
|
229
|
+
}
|
|
230
|
+
requestedByKey.set(entry.key, { sha256: entry.sha256, bytes: entry.bytes, key: entry.key });
|
|
231
|
+
}
|
|
232
|
+
const requested = [...requestedByKey.values()];
|
|
233
|
+
const response = requested.length > 0
|
|
234
|
+
? await input.client.workerReadGameSourceFiles(input.taskId, {
|
|
235
|
+
workerKey: input.workerKey,
|
|
236
|
+
leaseToken: input.leaseToken,
|
|
237
|
+
files: requested,
|
|
238
|
+
})
|
|
239
|
+
: { files: [] };
|
|
240
|
+
const urlByKey = new Map(response.files.map((entry) => [entry.key, entry.downloadUrl]));
|
|
241
|
+
await (0, game_source_git_1.materializeGameSourceLock)({
|
|
242
|
+
rootDir: input.projectDir,
|
|
243
|
+
blobCacheDir: blobCacheRoot(input.workerHomeDir),
|
|
244
|
+
lock,
|
|
245
|
+
download: async (key) => {
|
|
246
|
+
const entry = Object.values(lock.files).find((candidate) => candidate.key === key);
|
|
247
|
+
const url = urlByKey.get(key);
|
|
248
|
+
if (!entry || !url)
|
|
249
|
+
throw new Error("game_source_material_url_missing");
|
|
250
|
+
return await downloadBuffer(url, entry.bytes, entry.sha256);
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
async function writeManagedGameSourceIgnore(projectDir) {
|
|
255
|
+
const ignorePath = node_path_1.default.join(projectDir, ".gitignore");
|
|
256
|
+
let existing = "";
|
|
257
|
+
try {
|
|
258
|
+
existing = await (0, promises_1.readFile)(ignorePath, "utf8");
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
if (error.code !== "ENOENT")
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
await (0, promises_1.writeFile)(ignorePath, (0, game_source_git_1.updateManagedGitignore)(existing));
|
|
265
|
+
}
|
|
266
|
+
async function setupGameSourceWorkspace(input) {
|
|
267
|
+
const setupStartedAt = Date.now();
|
|
268
|
+
const source = input.assignment.gameSource;
|
|
269
|
+
if (!source)
|
|
270
|
+
throw new Error("game_source_assignment_missing");
|
|
271
|
+
const taskBranch = `task/${input.assignment.task.id}`;
|
|
272
|
+
const projectDir = node_path_1.default.join(input.workspaceDir, "project");
|
|
273
|
+
const resumed = (0, node_fs_1.existsSync)(node_path_1.default.join(projectDir, ".git"));
|
|
274
|
+
const repositoryCache = resumed
|
|
275
|
+
? "retained_workspace"
|
|
276
|
+
: source.baseRepository
|
|
277
|
+
? (0, node_fs_1.existsSync)(node_path_1.default.join(repoCacheRoot(input.workerHomeDir), String(source.baseRepository.appId), `${source.baseRepository.repoGeneration}.git`))
|
|
278
|
+
? "exact_hit"
|
|
279
|
+
: "miss"
|
|
280
|
+
: "new_repository";
|
|
281
|
+
emitGameSourceWorkerEvent("playdrop.game_source.setup_started", {
|
|
282
|
+
taskId: input.assignment.task.id,
|
|
283
|
+
appId: source.baseRepository?.appId ?? null,
|
|
284
|
+
repoGeneration: source.baseRepository?.repoGeneration ?? null,
|
|
285
|
+
repositoryCache,
|
|
286
|
+
});
|
|
287
|
+
const selectedBaseCommit = source.selectedBaseVersionId === null
|
|
288
|
+
? null
|
|
289
|
+
: source.authoritativeVersions.find((version) => version.versionId === source.selectedBaseVersionId)?.commitSha ?? null;
|
|
290
|
+
const taskBaseSha = selectedBaseCommit ?? source.baseRepository?.selectedCommitSha ?? null;
|
|
291
|
+
const pendingMaterials = new Map();
|
|
292
|
+
let bareRepoPath;
|
|
293
|
+
if (source.baseRepository) {
|
|
294
|
+
const sourceBareRepoPath = await prepareExistingBareCache({
|
|
295
|
+
assignment: source,
|
|
296
|
+
workerHomeDir: input.workerHomeDir,
|
|
297
|
+
workspaceDir: input.workspaceDir,
|
|
298
|
+
});
|
|
299
|
+
bareRepoPath = source.mode === "REMIX"
|
|
300
|
+
? await prepareRemixBareRepository({
|
|
301
|
+
sourceBareRepoPath,
|
|
302
|
+
destination: node_path_1.default.join(input.workspaceDir, ".playdrop", "remix-game.git"),
|
|
303
|
+
})
|
|
304
|
+
: sourceBareRepoPath;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
bareRepoPath = node_path_1.default.join(input.workspaceDir, ".playdrop", "new-game.git");
|
|
308
|
+
if (!(0, node_fs_1.existsSync)(bareRepoPath)) {
|
|
309
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(bareRepoPath), { recursive: true });
|
|
310
|
+
await git.run(["init", "--bare", bareRepoPath]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (!resumed) {
|
|
314
|
+
await addTaskWorktree({
|
|
315
|
+
bareRepoPath,
|
|
316
|
+
projectDir,
|
|
317
|
+
taskBranch,
|
|
318
|
+
startSha: taskBaseSha,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
else if (!await retainedWorktreeIsUsable({ bareRepoPath, projectDir, taskBranch })) {
|
|
322
|
+
await reattachRetainedWorktree({
|
|
323
|
+
bareRepoPath,
|
|
324
|
+
projectDir,
|
|
325
|
+
taskBranch,
|
|
326
|
+
startSha: taskBaseSha,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
if (taskBaseSha && !resumed) {
|
|
330
|
+
await materializeCurrentLock({ ...input, projectDir, taskId: input.assignment.task.id });
|
|
331
|
+
}
|
|
332
|
+
if (source.listingSync && !resumed) {
|
|
333
|
+
const listingFiles = new Map();
|
|
334
|
+
for (const file of source.listingSync.files) {
|
|
335
|
+
listingFiles.set(file.path, await downloadBuffer(file.downloadUrl, file.bytes, file.sha256));
|
|
336
|
+
}
|
|
337
|
+
await (0, game_source_git_1.syncAuthoritativeListing)({
|
|
338
|
+
repoPath: projectDir,
|
|
339
|
+
listing: {
|
|
340
|
+
version: source.listingSync.version,
|
|
341
|
+
displayName: source.listingSync.displayName,
|
|
342
|
+
subtitle: source.listingSync.subtitle,
|
|
343
|
+
description: source.listingSync.description,
|
|
344
|
+
iconPath: source.listingSync.iconPath,
|
|
345
|
+
heroPortraitPath: source.listingSync.heroPortraitPath,
|
|
346
|
+
heroLandscapePath: source.listingSync.heroLandscapePath,
|
|
347
|
+
socialLandscapePath: source.listingSync.socialLandscapePath,
|
|
348
|
+
screenshotsPortrait: source.listingSync.screenshotsPortrait,
|
|
349
|
+
screenshotsLandscape: source.listingSync.screenshotsLandscape,
|
|
350
|
+
videosPortrait: source.listingSync.videosPortrait,
|
|
351
|
+
videosLandscape: source.listingSync.videosLandscape,
|
|
352
|
+
files: listingFiles,
|
|
353
|
+
updatedAt: new Date(source.listingSync.updatedAt),
|
|
354
|
+
},
|
|
355
|
+
putImmutableFile: async (key, content, contentSha256) => {
|
|
356
|
+
const cachePath = blobCachePath(input.workerHomeDir, key);
|
|
357
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(cachePath), { recursive: true });
|
|
358
|
+
if (!(0, node_fs_1.existsSync)(cachePath))
|
|
359
|
+
await (0, promises_1.writeFile)(cachePath, content, { flag: "wx" });
|
|
360
|
+
pendingMaterials.set(key, {
|
|
361
|
+
path: key,
|
|
362
|
+
sha256: contentSha256,
|
|
363
|
+
bytes: content.length,
|
|
364
|
+
key,
|
|
365
|
+
content,
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (source.listingSync && !resumed) {
|
|
371
|
+
const healedLock = (0, game_source_git_1.parseGameSourceLock)(await (0, promises_1.readFile)(node_path_1.default.join(projectDir, ".playdrop", "files.lock")));
|
|
372
|
+
await (0, game_source_git_1.materializeGameSourceLock)({
|
|
373
|
+
rootDir: projectDir,
|
|
374
|
+
blobCacheDir: blobCacheRoot(input.workerHomeDir),
|
|
375
|
+
lock: healedLock,
|
|
376
|
+
download: async () => {
|
|
377
|
+
throw new Error("game_source_self_heal_blob_cache_missing");
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
await writeManagedGameSourceIgnore(projectDir);
|
|
382
|
+
const transcriptDir = node_path_1.default.join(projectDir, "transcripts");
|
|
383
|
+
for (const transcript of source.transcripts) {
|
|
384
|
+
await (0, promises_1.mkdir)(transcriptDir, { recursive: true });
|
|
385
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(transcriptDir, `task-${transcript.taskId}-attempt-${transcript.attempt}.jsonl`), await downloadBuffer(transcript.downloadUrl, transcript.bytes, transcript.sha256));
|
|
386
|
+
}
|
|
387
|
+
const retainedMarkerDir = node_path_1.default.join(input.workspaceDir, ".playdrop");
|
|
388
|
+
await (0, promises_1.mkdir)(retainedMarkerDir, { recursive: true });
|
|
389
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(retainedMarkerDir, "game-source-retained.json"), `${JSON.stringify({ taskId: input.assignment.task.id, attemptedAt: new Date().toISOString() })}\n`);
|
|
390
|
+
emitGameSourceWorkerEvent("playdrop.game_source.setup_completed", {
|
|
391
|
+
taskId: input.assignment.task.id,
|
|
392
|
+
appId: source.baseRepository?.appId ?? null,
|
|
393
|
+
repoGeneration: source.baseRepository?.repoGeneration ?? null,
|
|
394
|
+
repositoryCache,
|
|
395
|
+
durationMs: Date.now() - setupStartedAt,
|
|
396
|
+
selfHealVersionCount: 0,
|
|
397
|
+
transcriptCount: source.transcripts.length,
|
|
398
|
+
});
|
|
399
|
+
return {
|
|
400
|
+
assignment: source,
|
|
401
|
+
workspaceDir: input.workspaceDir,
|
|
402
|
+
projectDir,
|
|
403
|
+
bareRepoPath,
|
|
404
|
+
taskBranch,
|
|
405
|
+
baseHeadSha: taskBaseSha,
|
|
406
|
+
canonicalHeadSha: source.mode === "REMIX" ? null : source.baseRepository?.expectedHeadSha ?? null,
|
|
407
|
+
versions: source.mode === "REMIX" ? [] : source.authoritativeVersions,
|
|
408
|
+
healedVersionCommits: [],
|
|
409
|
+
pendingMaterials,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
async function walkFiles(root, current = root) {
|
|
413
|
+
const files = [];
|
|
414
|
+
for (const entry of await (0, promises_1.readdir)(current, { withFileTypes: true })) {
|
|
415
|
+
if (entry.name === ".git")
|
|
416
|
+
continue;
|
|
417
|
+
const absolute = node_path_1.default.join(current, entry.name);
|
|
418
|
+
const relative = normalizeRelativePath(root, absolute);
|
|
419
|
+
if (entry.isDirectory()) {
|
|
420
|
+
if (["node_modules", "dist", "build", "coverage", ".next", ".playdrop-task-events"].includes(entry.name))
|
|
421
|
+
continue;
|
|
422
|
+
if (relative === ".playdrop" || relative.startsWith(".playdrop/"))
|
|
423
|
+
continue;
|
|
424
|
+
files.push(...await walkFiles(root, absolute));
|
|
425
|
+
}
|
|
426
|
+
else if (entry.isFile()) {
|
|
427
|
+
files.push(absolute);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return files;
|
|
431
|
+
}
|
|
432
|
+
async function gitCommit(repoPath, message) {
|
|
433
|
+
await git.run([
|
|
434
|
+
"-c", "user.name=Playdrop Game Source",
|
|
435
|
+
"-c", "user.email=game-source@playdrop.invalid",
|
|
436
|
+
"commit", "--allow-empty", "-m", message,
|
|
437
|
+
], repoPath);
|
|
438
|
+
return (await git.run(["rev-parse", "HEAD"], repoPath)).toString("utf8").trim();
|
|
439
|
+
}
|
|
440
|
+
async function commitSanitizedGameSourceTree(input) {
|
|
441
|
+
const taskHead = await git.run(["rev-parse", "--verify", "HEAD"], input.repoPath)
|
|
442
|
+
.then((output) => output.toString("utf8").trim())
|
|
443
|
+
.catch(() => null);
|
|
444
|
+
if (input.baseHeadSha) {
|
|
445
|
+
if (!taskHead)
|
|
446
|
+
throw new Error("game_source_task_head_missing");
|
|
447
|
+
await git.run(["merge-base", "--is-ancestor", input.baseHeadSha, taskHead], input.repoPath);
|
|
448
|
+
}
|
|
449
|
+
const treeSha = (await git.run(["write-tree"], input.repoPath)).toString("utf8").trim();
|
|
450
|
+
const commitSha = (await git.run([
|
|
451
|
+
"-c", "user.name=Playdrop Game Source",
|
|
452
|
+
"-c", "user.email=game-source@playdrop.invalid",
|
|
453
|
+
"commit-tree", treeSha,
|
|
454
|
+
...(input.baseHeadSha ? ["-p", input.baseHeadSha] : []),
|
|
455
|
+
"-m", input.message,
|
|
456
|
+
], input.repoPath)).toString("utf8").trim();
|
|
457
|
+
await git.run(["update-ref", "HEAD", commitSha, taskHead ?? "0".repeat(40)], input.repoPath);
|
|
458
|
+
return commitSha;
|
|
459
|
+
}
|
|
460
|
+
async function stageGameSourceCommit(input) {
|
|
461
|
+
const gitFiles = new Map();
|
|
462
|
+
const materials = new Map();
|
|
463
|
+
const transcripts = [];
|
|
464
|
+
const excluded = [];
|
|
465
|
+
for (const absolute of await walkFiles(input.projectDir)) {
|
|
466
|
+
const relative = normalizeRelativePath(input.projectDir, absolute);
|
|
467
|
+
const content = await (0, promises_1.readFile)(absolute);
|
|
468
|
+
const classification = (0, game_source_git_1.classifyGameSourceFile)(relative, content);
|
|
469
|
+
if (classification === "git")
|
|
470
|
+
gitFiles.set(relative, content);
|
|
471
|
+
else if (classification === "material")
|
|
472
|
+
materials.set(relative, content);
|
|
473
|
+
else if (classification === "transcript")
|
|
474
|
+
transcripts.push(relative);
|
|
475
|
+
else
|
|
476
|
+
excluded.push(relative);
|
|
477
|
+
}
|
|
478
|
+
const lock = (0, game_source_git_1.createGameSourceLock)(materials);
|
|
479
|
+
await (0, promises_1.mkdir)(node_path_1.default.join(input.projectDir, ".playdrop"), { recursive: true });
|
|
480
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(input.projectDir, ".playdrop", "files.lock"), (0, game_source_git_1.serializeGameSourceLock)(lock));
|
|
481
|
+
await writeManagedGameSourceIgnore(input.projectDir);
|
|
482
|
+
if (input.taskId !== undefined && input.summary !== undefined) {
|
|
483
|
+
await (0, promises_1.mkdir)(node_path_1.default.join(input.projectDir, "tasks"), { recursive: true });
|
|
484
|
+
await (0, promises_1.writeFile)(node_path_1.default.join(input.projectDir, "tasks", `${input.taskId}.md`), `${input.summary.trim()}\n`);
|
|
485
|
+
}
|
|
486
|
+
const hasHead = await git.run(["rev-parse", "--verify", "HEAD"], input.projectDir)
|
|
487
|
+
.then(() => true)
|
|
488
|
+
.catch(() => false);
|
|
489
|
+
if (hasHead)
|
|
490
|
+
await git.run(["add", "-u", "--", "."], input.projectDir);
|
|
491
|
+
for (const relative of [...materials.keys(), ...transcripts, ...excluded]) {
|
|
492
|
+
await git.run(["rm", "--cached", "--ignore-unmatch", "--", relative], input.projectDir);
|
|
493
|
+
}
|
|
494
|
+
for (const relative of [
|
|
495
|
+
...gitFiles.keys(),
|
|
496
|
+
".playdrop/files.lock",
|
|
497
|
+
".gitignore",
|
|
498
|
+
...(input.taskId === undefined ? [] : [`tasks/${input.taskId}.md`]),
|
|
499
|
+
]) {
|
|
500
|
+
await git.run(["add", "--force", "--", relative], input.projectDir);
|
|
501
|
+
}
|
|
502
|
+
return { lock, materials };
|
|
503
|
+
}
|
|
504
|
+
async function checkpointFailedGameSourceWorkspace(input) {
|
|
505
|
+
const branch = (await git.run(["symbolic-ref", "--short", "HEAD"], input.workspace.projectDir))
|
|
506
|
+
.toString("utf8")
|
|
507
|
+
.trim();
|
|
508
|
+
if (branch !== input.workspace.taskBranch)
|
|
509
|
+
throw new Error("game_source_task_branch_changed");
|
|
510
|
+
await stageGameSourceCommit({ projectDir: input.workspace.projectDir });
|
|
511
|
+
return await gitCommit(input.workspace.projectDir, `Task ${input.taskId}: failed workspace checkpoint`);
|
|
512
|
+
}
|
|
513
|
+
async function reconcileGameSourceWorkspace(input) {
|
|
514
|
+
const { projectDir } = input.workspace;
|
|
515
|
+
if (input.workspace.assignment.baseRepository && input.workspace.assignment.mode !== "REMIX") {
|
|
516
|
+
try {
|
|
517
|
+
await (0, game_source_git_1.validateCanonicalRefTargets)(projectDir, expectedRefs(input.workspace.assignment), git);
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
await git.run([
|
|
521
|
+
"--git-dir",
|
|
522
|
+
input.workspace.bareRepoPath,
|
|
523
|
+
"worktree",
|
|
524
|
+
"remove",
|
|
525
|
+
"--force",
|
|
526
|
+
projectDir,
|
|
527
|
+
]).catch(() => Buffer.alloc(0));
|
|
528
|
+
const quarantine = `${input.workspace.bareRepoPath}.quarantine-${Date.now()}-${(0, node_crypto_1.randomUUID)()}`;
|
|
529
|
+
await (0, promises_1.rename)(input.workspace.bareRepoPath, quarantine).catch(() => undefined);
|
|
530
|
+
throw new Error("game_source_ref_target_tampered");
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const { lock, materials } = await stageGameSourceCommit({
|
|
534
|
+
projectDir,
|
|
535
|
+
taskId: input.taskId,
|
|
536
|
+
summary: input.summary,
|
|
537
|
+
});
|
|
538
|
+
const commitSha = await commitSanitizedGameSourceTree({
|
|
539
|
+
repoPath: projectDir,
|
|
540
|
+
baseHeadSha: input.workspace.baseHeadSha,
|
|
541
|
+
message: `Task ${input.taskId}: ${input.summary.trim()}`,
|
|
542
|
+
});
|
|
543
|
+
await (0, game_source_git_1.scanOutgoingObjects)({
|
|
544
|
+
repoPath: projectDir,
|
|
545
|
+
proposedRefs: [...new Set([commitSha, ...input.workspace.versions.map((version) => version.commitSha)])],
|
|
546
|
+
previousTargets: input.workspace.baseHeadSha
|
|
547
|
+
? [
|
|
548
|
+
input.workspace.baseHeadSha,
|
|
549
|
+
...input.workspace.assignment.authoritativeVersions.map((version) => version.commitSha),
|
|
550
|
+
]
|
|
551
|
+
: [],
|
|
552
|
+
}, git);
|
|
553
|
+
const currentMaterials = Object.entries(lock.files).map(([filePath, entry]) => ({
|
|
554
|
+
path: filePath,
|
|
555
|
+
sha256: entry.sha256,
|
|
556
|
+
bytes: entry.bytes,
|
|
557
|
+
key: entry.key,
|
|
558
|
+
content: materials.get(filePath),
|
|
559
|
+
}));
|
|
560
|
+
const materialByUploadKey = new Map(input.workspace.pendingMaterials);
|
|
561
|
+
for (const material of currentMaterials)
|
|
562
|
+
materialByUploadKey.set(material.key, material);
|
|
563
|
+
const materialList = [...materialByUploadKey.values()];
|
|
564
|
+
return { workspace: input.workspace, commitSha, materials: materialList };
|
|
565
|
+
}
|
|
566
|
+
async function finalizeGameSourceRepository(input) {
|
|
567
|
+
const { workspace, commitSha } = input.reconciled;
|
|
568
|
+
const tagRef = (0, game_source_git_1.versionTagRef)(input.version);
|
|
569
|
+
const existingVersion = workspace.versions.find((version) => version.versionId === input.appVersionId);
|
|
570
|
+
const existingTagTarget = await git.run(["rev-parse", "--verify", tagRef], workspace.projectDir)
|
|
571
|
+
.then((output) => output.toString("utf8").trim())
|
|
572
|
+
.catch(() => null);
|
|
573
|
+
if (existingTagTarget !== commitSha) {
|
|
574
|
+
if (existingTagTarget && !existingVersion) {
|
|
575
|
+
throw new Error(`game_source_version_tag_conflict:${tagRef}`);
|
|
576
|
+
}
|
|
577
|
+
await git.run([
|
|
578
|
+
"update-ref",
|
|
579
|
+
tagRef,
|
|
580
|
+
commitSha,
|
|
581
|
+
existingTagTarget ?? "0".repeat(40),
|
|
582
|
+
], workspace.projectDir);
|
|
583
|
+
}
|
|
584
|
+
const versions = [
|
|
585
|
+
...workspace.versions.filter((version) => version.versionId !== input.appVersionId),
|
|
586
|
+
{ versionId: input.appVersionId, ...input.version, commitSha },
|
|
587
|
+
];
|
|
588
|
+
const canonical = versions.map((version) => ({
|
|
589
|
+
version: { major: version.major, minor: version.minor, patch: version.patch },
|
|
590
|
+
commitSha: version.commitSha,
|
|
591
|
+
}));
|
|
592
|
+
const bundlePath = node_path_1.default.join(workspace.workspaceDir, ".playdrop", `outgoing-${(0, node_crypto_1.randomUUID)()}.bundle`);
|
|
593
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(bundlePath), { recursive: true });
|
|
594
|
+
const previousMain = workspace.canonicalHeadSha;
|
|
595
|
+
const zeroSha = "0".repeat(40);
|
|
596
|
+
await git.run(["update-ref", "refs/heads/main", commitSha, previousMain ?? zeroSha], workspace.projectDir);
|
|
597
|
+
let bundle;
|
|
598
|
+
try {
|
|
599
|
+
await (0, game_source_git_1.createCanonicalBundle)({
|
|
600
|
+
repoPath: workspace.projectDir,
|
|
601
|
+
outputPath: bundlePath,
|
|
602
|
+
expected: { headSha: commitSha, versions: canonical },
|
|
603
|
+
}, git);
|
|
604
|
+
bundle = await (0, promises_1.readFile)(bundlePath);
|
|
605
|
+
}
|
|
606
|
+
finally {
|
|
607
|
+
if (previousMain) {
|
|
608
|
+
await git.run(["update-ref", "refs/heads/main", previousMain, commitSha], workspace.projectDir);
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
await git.run(["update-ref", "-d", "refs/heads/main", commitSha], workspace.projectDir);
|
|
612
|
+
}
|
|
613
|
+
await (0, promises_1.rm)(bundlePath, { force: true });
|
|
614
|
+
}
|
|
615
|
+
return { ...input.reconciled, bundle, bundleSha256: (0, game_source_git_1.sha256)(bundle), versions };
|
|
616
|
+
}
|
|
617
|
+
async function uploadFinalizedGameSource(input) {
|
|
618
|
+
const blobs = input.source.materials.map(({ sha256: contentSha, bytes, key }) => ({ sha256: contentSha, bytes, key }));
|
|
619
|
+
const targetBaseGeneration = input.source.workspace.assignment.targetRepository.repoGeneration;
|
|
620
|
+
const prepared = await input.client.workerPrepareGameSource(input.taskId, {
|
|
621
|
+
workerKey: input.workerKey,
|
|
622
|
+
leaseToken: input.leaseToken,
|
|
623
|
+
appId: input.appId,
|
|
624
|
+
appUploadSessionId: input.appUploadSessionId,
|
|
625
|
+
baseGeneration: targetBaseGeneration,
|
|
626
|
+
bundle: {
|
|
627
|
+
sha256: input.source.bundleSha256,
|
|
628
|
+
bytes: input.source.bundle.length,
|
|
629
|
+
headSha: input.source.commitSha,
|
|
630
|
+
commitSha: input.source.commitSha,
|
|
631
|
+
healedVersionCommits: input.source.workspace.healedVersionCommits,
|
|
632
|
+
},
|
|
633
|
+
blobs,
|
|
634
|
+
});
|
|
635
|
+
const materialByKey = new Map(input.source.materials.map((entry) => [entry.key, entry.content]));
|
|
636
|
+
for (const blob of prepared.blobs) {
|
|
637
|
+
if (!blob.upload)
|
|
638
|
+
continue;
|
|
639
|
+
const content = materialByKey.get(blob.key);
|
|
640
|
+
if (!content)
|
|
641
|
+
throw new Error("game_source_material_missing");
|
|
642
|
+
await uploadBuffer(blob.upload, content);
|
|
643
|
+
}
|
|
644
|
+
if (prepared.bundle.currentUpload)
|
|
645
|
+
await uploadBuffer(prepared.bundle.currentUpload, input.source.bundle);
|
|
646
|
+
if (prepared.bundle.previousUpload)
|
|
647
|
+
await uploadBuffer(prepared.bundle.previousUpload, input.source.bundle);
|
|
648
|
+
return {
|
|
649
|
+
attempt: input.attempt,
|
|
650
|
+
baseGeneration: targetBaseGeneration,
|
|
651
|
+
bundleSha256: input.source.bundleSha256,
|
|
652
|
+
bundleBytes: input.source.bundle.length,
|
|
653
|
+
bundleStorageKey: prepared.bundle.currentKey,
|
|
654
|
+
headSha: input.source.commitSha,
|
|
655
|
+
commitSha: input.source.commitSha,
|
|
656
|
+
healedVersionCommits: input.source.workspace.healedVersionCommits.filter(() => true),
|
|
657
|
+
blobs,
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
async function directorySize(root) {
|
|
661
|
+
let total = 0;
|
|
662
|
+
for (const entry of await (0, promises_1.readdir)(root, { withFileTypes: true }).catch(() => [])) {
|
|
663
|
+
const absolute = node_path_1.default.join(root, entry.name);
|
|
664
|
+
if (entry.isDirectory())
|
|
665
|
+
total += await directorySize(absolute);
|
|
666
|
+
else if (entry.isFile())
|
|
667
|
+
total += (await (0, promises_1.stat)(absolute)).size;
|
|
668
|
+
}
|
|
669
|
+
return total;
|
|
670
|
+
}
|
|
671
|
+
async function repoCacheEntryHasActiveWorktree(appDirectory) {
|
|
672
|
+
for (const child of await (0, promises_1.readdir)(appDirectory, { withFileTypes: true }).catch(() => [])) {
|
|
673
|
+
if (!child.isDirectory() || !child.name.endsWith(".git"))
|
|
674
|
+
continue;
|
|
675
|
+
const worktrees = await (0, promises_1.readdir)(node_path_1.default.join(appDirectory, child.name, "worktrees")).catch(() => []);
|
|
676
|
+
if (worktrees.length > 0)
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
return false;
|
|
680
|
+
}
|
|
681
|
+
async function enforceCacheLimit(root, limit) {
|
|
682
|
+
const entries = await (0, promises_1.readdir)(root, { withFileTypes: true }).catch(() => []);
|
|
683
|
+
const candidates = await Promise.all(entries.map(async (entry) => {
|
|
684
|
+
const absolute = node_path_1.default.join(root, entry.name);
|
|
685
|
+
const info = await (0, promises_1.stat)(absolute);
|
|
686
|
+
const active = root.endsWith(`${node_path_1.default.sep}repos`) && entry.isDirectory()
|
|
687
|
+
? await repoCacheEntryHasActiveWorktree(absolute)
|
|
688
|
+
: false;
|
|
689
|
+
return { absolute, modified: info.mtimeMs, bytes: entry.isDirectory() ? await directorySize(absolute) : info.size, active };
|
|
690
|
+
}));
|
|
691
|
+
let total = candidates.reduce((sum, entry) => sum + entry.bytes, 0);
|
|
692
|
+
for (const entry of candidates.sort((left, right) => left.modified - right.modified)) {
|
|
693
|
+
if (total <= limit)
|
|
694
|
+
break;
|
|
695
|
+
if (entry.active)
|
|
696
|
+
continue;
|
|
697
|
+
await (0, promises_1.rm)(entry.absolute, { recursive: true, force: true });
|
|
698
|
+
total -= entry.bytes;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
async function maintainGameSourceCaches(workerHomeDir) {
|
|
702
|
+
await Promise.all([
|
|
703
|
+
enforceCacheLimit(repoCacheRoot(workerHomeDir), REPO_CACHE_LIMIT_BYTES),
|
|
704
|
+
enforceCacheLimit(blobCacheRoot(workerHomeDir), BLOB_CACHE_LIMIT_BYTES),
|
|
705
|
+
]);
|
|
706
|
+
const taskRoot = node_path_1.default.join(workerHomeDir, "tasks");
|
|
707
|
+
const cutoff = Date.now() - FAILED_WORKSPACE_RETENTION_MS;
|
|
708
|
+
for (const entry of await (0, promises_1.readdir)(taskRoot, { withFileTypes: true }).catch(() => [])) {
|
|
709
|
+
if (!entry.isDirectory())
|
|
710
|
+
continue;
|
|
711
|
+
const marker = node_path_1.default.join(taskRoot, entry.name, ".playdrop", "game-source-retained.json");
|
|
712
|
+
const info = await (0, promises_1.stat)(marker).catch(() => null);
|
|
713
|
+
if (info && info.mtimeMs < cutoff)
|
|
714
|
+
await (0, promises_1.rm)(node_path_1.default.join(taskRoot, entry.name), { recursive: true, force: true });
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
async function cleanupCompletedGameSourceWorkspace(input) {
|
|
718
|
+
await git.run(["update-ref", "refs/heads/main", input.headSha], input.workspace.projectDir);
|
|
719
|
+
const expectedTags = new Set(input.versions.map((version) => (0, game_source_git_1.versionTagRef)(semanticVersion(version))));
|
|
720
|
+
for (const version of input.versions) {
|
|
721
|
+
await git.run(["update-ref", (0, game_source_git_1.versionTagRef)(semanticVersion(version)), version.commitSha], input.workspace.projectDir);
|
|
722
|
+
}
|
|
723
|
+
const tagOutput = await git.run(["for-each-ref", "--format=%(refname)", "refs/tags"], input.workspace.projectDir);
|
|
724
|
+
for (const ref of tagOutput.toString("utf8").trim().split("\n").filter(Boolean)) {
|
|
725
|
+
if (!expectedTags.has(ref))
|
|
726
|
+
await git.run(["update-ref", "-d", ref], input.workspace.projectDir);
|
|
727
|
+
}
|
|
728
|
+
await git.run(["--git-dir", input.workspace.bareRepoPath, "worktree", "remove", "--force", input.workspace.projectDir]);
|
|
729
|
+
await git.run(["--git-dir", input.workspace.bareRepoPath, "branch", "-D", input.workspace.taskBranch]).catch(() => Buffer.alloc(0));
|
|
730
|
+
const destination = node_path_1.default.join(repoCacheRoot(input.workerHomeDir), String(input.appId), `${input.repoGeneration}.git`);
|
|
731
|
+
if (node_path_1.default.resolve(destination) !== node_path_1.default.resolve(input.workspace.bareRepoPath)) {
|
|
732
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(destination), { recursive: true });
|
|
733
|
+
await (0, promises_1.rm)(destination, { recursive: true, force: true });
|
|
734
|
+
await (0, promises_1.rename)(input.workspace.bareRepoPath, destination);
|
|
735
|
+
}
|
|
736
|
+
await (0, promises_1.rm)(input.workspace.workspaceDir, { recursive: true, force: true });
|
|
737
|
+
}
|
|
738
|
+
function readGameSourceWorkerInventory(workerHomeDir) {
|
|
739
|
+
const cachedRepositories = [];
|
|
740
|
+
const repoRoot = repoCacheRoot(workerHomeDir);
|
|
741
|
+
if ((0, node_fs_1.existsSync)(repoRoot)) {
|
|
742
|
+
for (const appEntry of (0, node_fs_1.readdirSync)(repoRoot, { withFileTypes: true })) {
|
|
743
|
+
const appId = Number(appEntry.name);
|
|
744
|
+
if (!appEntry.isDirectory() || !Number.isSafeInteger(appId) || appId <= 0)
|
|
745
|
+
continue;
|
|
746
|
+
for (const generationEntry of (0, node_fs_1.readdirSync)(node_path_1.default.join(repoRoot, appEntry.name), { withFileTypes: true })) {
|
|
747
|
+
const match = /^([1-9][0-9]*)\.git$/.exec(generationEntry.name);
|
|
748
|
+
if (generationEntry.isDirectory() && match?.[1])
|
|
749
|
+
cachedRepositories.push({ appId, repoGeneration: match[1] });
|
|
750
|
+
if (cachedRepositories.length >= INVENTORY_LIMIT)
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
if (cachedRepositories.length >= INVENTORY_LIMIT)
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
const retainedTaskIds = [];
|
|
758
|
+
const taskRoot = node_path_1.default.join(workerHomeDir, "tasks");
|
|
759
|
+
if ((0, node_fs_1.existsSync)(taskRoot)) {
|
|
760
|
+
for (const entry of (0, node_fs_1.readdirSync)(taskRoot, { withFileTypes: true })) {
|
|
761
|
+
if (!entry.isDirectory())
|
|
762
|
+
continue;
|
|
763
|
+
const marker = node_path_1.default.join(taskRoot, entry.name, ".playdrop", "game-source-retained.json");
|
|
764
|
+
if (!(0, node_fs_1.existsSync)(marker))
|
|
765
|
+
continue;
|
|
766
|
+
try {
|
|
767
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(marker, "utf8"));
|
|
768
|
+
const taskId = Number(parsed.taskId);
|
|
769
|
+
if (Number.isSafeInteger(taskId) && taskId > 0)
|
|
770
|
+
retainedTaskIds.push(taskId);
|
|
771
|
+
}
|
|
772
|
+
catch {
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
if (retainedTaskIds.length >= INVENTORY_LIMIT)
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return { cachedRepositories, retainedTaskIds };
|
|
780
|
+
}
|