@playdrop/playdrop-cli 0.16.16 → 0.17.1

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