castle-web-cli 0.4.239 → 0.4.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/dist/agent.js +5 -1
  2. package/dist/api.d.ts +20 -0
  3. package/dist/api.js +57 -0
  4. package/dist/bundle.d.ts +38 -1
  5. package/dist/bundle.js +309 -13
  6. package/dist/castle-host/host.js +163 -11
  7. package/dist/castleJson.d.ts +10 -0
  8. package/dist/castleJson.js +46 -2
  9. package/dist/check.js +5 -2
  10. package/dist/devSessionServer.js +4 -1
  11. package/dist/devSessionStorage.d.ts +1 -0
  12. package/dist/devSessionStorage.js +32 -7
  13. package/dist/importOrder.d.ts +2 -0
  14. package/dist/importOrder.js +29 -0
  15. package/dist/index.js +6 -3
  16. package/dist/init.js +24 -2
  17. package/dist/platformDoc.js +2 -1
  18. package/dist/playPagePolicy.js +5 -1
  19. package/dist/resetLeaderboards.d.ts +8 -1
  20. package/dist/resetLeaderboards.js +43 -8
  21. package/dist/save-deck.d.ts +32 -2
  22. package/dist/save-deck.js +240 -39
  23. package/kits/base/CLAUDE.md +1 -1
  24. package/kits/base/castle.json +1 -1
  25. package/kits/base/sdk/README.md +174 -6
  26. package/kits/base/sdk/analytics.d.ts +8 -0
  27. package/kits/base/sdk/analytics.js +92 -0
  28. package/kits/base/sdk/castle.d.ts +5 -1
  29. package/kits/base/sdk/castle.js +2 -0
  30. package/kits/base/sdk/commands.d.ts +48 -0
  31. package/kits/base/sdk/commands.js +1 -0
  32. package/kits/base/sdk/debugConsole.d.ts +17 -0
  33. package/kits/base/sdk/debugConsole.js +154 -0
  34. package/kits/base/sdk/experiments.js +24 -1
  35. package/kits/base/sdk/hostRetry.d.ts +7 -0
  36. package/kits/base/sdk/hostRetry.js +57 -0
  37. package/kits/base/sdk/hub.d.ts +20 -2
  38. package/kits/base/sdk/hub.js +99 -13
  39. package/kits/base/sdk/multiplayer.d.ts +2 -0
  40. package/kits/base/sdk/multiplayer.js +168 -26
  41. package/kits/base/sdk/reconnectBudget.d.ts +6 -0
  42. package/kits/base/sdk/reconnectBudget.js +41 -1
  43. package/kits/base/sdk/runtime.js +36 -19
  44. package/kits/base/sdk/server/hub.d.ts +19 -0
  45. package/kits/base/sdk/server/hub.js +12 -0
  46. package/kits/base/sdk/server/platformHandle.d.ts +1 -0
  47. package/kits/base/sdk/server/wrapper.d.ts +1 -1
  48. package/kits/base/sdk/server/wrapper.js +26 -1
  49. package/kits/base/sdk/transport.d.ts +2 -1
  50. package/kits/base/sdk/transport.js +35 -0
  51. package/kits/hub-game/CLAUDE.md +66 -19
  52. package/kits/hub-game/code/client/act.js +9 -6
  53. package/kits/hub-game/code/client/actCore.js +26 -6
  54. package/kits/hub-game/code/client/actGateLog.js +36 -0
  55. package/kits/hub-game/code/client/actionOverflow.js +29 -8
  56. package/kits/hub-game/code/client/actionRailSurface.js +186 -0
  57. package/kits/hub-game/code/client/actionRailTree.js +173 -0
  58. package/kits/hub-game/code/client/askSurface.js +85 -0
  59. package/kits/hub-game/code/client/askTree.js +51 -0
  60. package/kits/hub-game/code/client/attention.js +31 -6
  61. package/kits/hub-game/code/client/ballot.js +42 -5
  62. package/kits/hub-game/code/client/ballotSurface.js +115 -0
  63. package/kits/hub-game/code/client/ballotTree.js +180 -0
  64. package/kits/hub-game/code/client/catchingUp.js +19 -0
  65. package/kits/hub-game/code/client/celebrate.js +66 -0
  66. package/kits/hub-game/code/client/chrome.js +473 -53
  67. package/kits/hub-game/code/client/companion.js +93 -23
  68. package/kits/hub-game/code/client/companionDress.js +1 -1
  69. package/kits/hub-game/code/client/cornerSurface.js +106 -0
  70. package/kits/hub-game/code/client/cornerTree.js +83 -0
  71. package/kits/hub-game/code/client/decor.js +20 -11
  72. package/kits/hub-game/code/client/deviceStorage.js +121 -0
  73. package/kits/hub-game/code/client/disguise.js +23 -0
  74. package/kits/hub-game/code/client/disguiseDraw.js +87 -0
  75. package/kits/hub-game/code/client/dockSurface.js +206 -0
  76. package/kits/hub-game/code/client/dockTree.js +232 -0
  77. package/kits/hub-game/code/client/earned.js +29 -0
  78. package/kits/hub-game/code/client/emoteSurface.js +188 -0
  79. package/kits/hub-game/code/client/emoteTree.js +264 -0
  80. package/kits/hub-game/code/client/farAvatars.js +4 -3
  81. package/kits/hub-game/code/client/fpsTelemetry.js +3 -1
  82. package/kits/hub-game/code/client/grab.js +121 -50
  83. package/kits/hub-game/code/client/holdShow.js +19 -0
  84. package/kits/hub-game/code/client/hookLayer.js +96 -12
  85. package/kits/hub-game/code/client/hubControls.js +7 -1
  86. package/kits/hub-game/code/client/hudSurface.js +11 -3
  87. package/kits/hub-game/code/client/hudTree.js +7 -4
  88. package/kits/hub-game/code/client/idle.js +21 -3
  89. package/kits/hub-game/code/client/invites.js +24 -3
  90. package/kits/hub-game/code/client/keys.js +15 -0
  91. package/kits/hub-game/code/client/labelsNear.js +8 -1
  92. package/kits/hub-game/code/client/layoutCache.js +57 -8
  93. package/kits/hub-game/code/client/loadingCover.js +53 -4
  94. package/kits/hub-game/code/client/menuIcons.js +15 -0
  95. package/kits/hub-game/code/client/menuSurface.js +102 -0
  96. package/kits/hub-game/code/client/menuTree.js +135 -0
  97. package/kits/hub-game/code/client/modelLook.js +41 -0
  98. package/kits/hub-game/code/client/pickerSurface.js +152 -0
  99. package/kits/hub-game/code/client/pickerTree.js +163 -0
  100. package/kits/hub-game/code/client/pushVisit.js +4 -2
  101. package/kits/hub-game/code/client/quality.js +188 -29
  102. package/kits/hub-game/code/client/qualityEntry.js +10 -1
  103. package/kits/hub-game/code/client/quickChatSurface.js +222 -0
  104. package/kits/hub-game/code/client/quickChatTree.js +201 -0
  105. package/kits/hub-game/code/client/rehello.js +75 -0
  106. package/kits/hub-game/code/client/renderVisibility.js +17 -0
  107. package/kits/hub-game/code/client/replay.js +118 -0
  108. package/kits/hub-game/code/client/role.js +3 -0
  109. package/kits/hub-game/code/client/safeLayout.js +441 -56
  110. package/kits/hub-game/code/client/safeStyle.js +13 -10
  111. package/kits/hub-game/code/client/say.js +2 -0
  112. package/kits/hub-game/code/client/soundSurface.js +77 -0
  113. package/kits/hub-game/code/client/soundTree.js +74 -0
  114. package/kits/hub-game/code/client/soundscape.js +12 -9
  115. package/kits/hub-game/code/client/soundscapeCues.js +1 -1
  116. package/kits/hub-game/code/client/state.js +67 -1
  117. package/kits/hub-game/code/client/stuckSurface.js +76 -0
  118. package/kits/hub-game/code/client/stuckTree.js +67 -0
  119. package/kits/hub-game/code/client/talk.js +42 -12
  120. package/kits/hub-game/code/client/talkTree.js +4 -2
  121. package/kits/hub-game/code/client/textAskSurface.js +147 -0
  122. package/kits/hub-game/code/client/textAskTree.js +67 -0
  123. package/kits/hub-game/code/client/tiers.js +252 -27
  124. package/kits/hub-game/code/client/together.js +4 -1
  125. package/kits/hub-game/code/client/uiDom.js +86 -8
  126. package/kits/hub-game/code/client/uiTree.js +33 -4
  127. package/kits/hub-game/code/client/vehicle.js +72 -51
  128. package/kits/hub-game/code/client/weakestTier.js +75 -31
  129. package/kits/hub-game/code/client/wear.js +159 -5
  130. package/kits/hub-game/code/client/worldLabels.js +205 -25
  131. package/kits/hub-game/code/companionSpec.js +4 -2
  132. package/kits/hub-game/code/server/act.js +3 -0
  133. package/kits/hub-game/code/server/actGate.js +83 -0
  134. package/kits/hub-game/code/server/actions.js +71 -15
  135. package/kits/hub-game/code/server/actors.js +20 -5
  136. package/kits/hub-game/code/server/analytics.js +35 -3
  137. package/kits/hub-game/code/server/ask.js +39 -3
  138. package/kits/hub-game/code/server/ballot.js +167 -4
  139. package/kits/hub-game/code/server/celebrate.js +64 -0
  140. package/kits/hub-game/code/server/companion.js +17 -2
  141. package/kits/hub-game/code/server/decor.js +11 -2
  142. package/kits/hub-game/code/server/disguise.js +63 -0
  143. package/kits/hub-game/code/server/earned.js +6 -2
  144. package/kits/hub-game/code/server/friendBests.js +13 -4
  145. package/kits/hub-game/code/server/friendsAmong.js +67 -8
  146. package/kits/hub-game/code/server/grab.js +12 -2
  147. package/kits/hub-game/code/server/heldOffers.js +142 -0
  148. package/kits/hub-game/code/server/holdShow.js +98 -0
  149. package/kits/hub-game/code/server/hub.js +851 -45
  150. package/kits/hub-game/code/server/idle.js +110 -9
  151. package/kits/hub-game/code/server/index.js +9 -0
  152. package/kits/hub-game/code/server/labels.js +13 -3
  153. package/kits/hub-game/code/server/manifest.js +94 -6
  154. package/kits/hub-game/code/server/menu.js +26 -3
  155. package/kits/hub-game/code/server/npcs.js +55 -9
  156. package/kits/hub-game/code/server/observe.js +67 -6
  157. package/kits/hub-game/code/server/players.js +8 -1
  158. package/kits/hub-game/code/server/replay.js +135 -0
  159. package/kits/hub-game/code/server/storageLimit.js +4 -1
  160. package/kits/hub-game/code/server/townDay.js +74 -0
  161. package/kits/hub-game/code/server/vehicle.js +3 -0
  162. package/kits/hub-game/code/server/vis.js +26 -4
  163. package/kits/hub-game/code/server/wallet.js +677 -0
  164. package/kits/hub-game/code/server/wear.js +13 -3
  165. package/kits/hub-game/code/server/writerLease.js +191 -0
  166. package/kits/hub-game/code/shared/act.js +1 -1
  167. package/kits/hub-game/code/shared/expression.js +6 -0
  168. package/kits/hub-game/code/shared/replay.js +37 -0
  169. package/kits/hub-game/code/systems/hub.js +427 -54
  170. package/kits/hub-game/docs/analytics.md +16 -2
  171. package/kits/hub-game/docs/contract.md +942 -99
  172. package/kits/hub-game/docs/home-pieces.md +5 -6
  173. package/kits/hub-game/docs/observed-progress.md +49 -1
  174. package/kits/hub-game/docs/vehicle-preset.md +23 -0
  175. package/kits/hub-game/index.html +1 -0
  176. package/kits/hub-game/models/hats/baker-cap.pxmodel +3 -3
  177. package/kits/hub-game/models/hats/bat-clip.pxmodel +3 -3
  178. package/kits/hub-game/models/hats/beekeeper.pxmodel +3 -3
  179. package/kits/hub-game/models/hats/cap.pxmodel +3 -3
  180. package/kits/hub-game/models/hats/captain.pxmodel +3 -3
  181. package/kits/hub-game/models/hats/chef-toque.pxmodel +3 -3
  182. package/kits/hub-game/models/hats/crooked-top.pxmodel +3 -3
  183. package/kits/hub-game/models/hats/delivery-cap.pxmodel +3 -3
  184. package/kits/hub-game/models/hats/fire-helmet.pxmodel +3 -3
  185. package/kits/hub-game/models/hats/flower-crown.pxmodel +3 -3
  186. package/kits/hub-game/models/hats/foam-crown.pxmodel +3 -3
  187. package/kits/hub-game/models/hats/hard-hat.pxmodel +3 -3
  188. package/kits/hub-game/models/hats/lantern.pxmodel +3 -3
  189. package/kits/hub-game/models/hats/laurel.pxmodel +3 -3
  190. package/kits/hub-game/models/hats/lighthouse.pxmodel +3 -3
  191. package/kits/hub-game/models/hats/nurse-cap.pxmodel +3 -3
  192. package/kits/hub-game/models/hats/police-cap.pxmodel +3 -3
  193. package/kits/hub-game/models/hats/sailor.pxmodel +3 -3
  194. package/kits/hub-game/models/hats/souwester.pxmodel +3 -3
  195. package/kits/hub-game/models/hats/straw.pxmodel +3 -3
  196. package/kits/hub-game/models/hats/sunflower.pxmodel +3 -3
  197. package/kits/hub-game/models/hats/sweatband.pxmodel +3 -3
  198. package/kits/hub-game/models/hats/teacher-beret.pxmodel +3 -3
  199. package/kits/hub-game/models/hats/witch.pxmodel +3 -3
  200. package/kits/hub-game/models/hold-show/daisy.pxmodel +231 -0
  201. package/kits/hub-game/models/hold-show/moonflower.pxmodel +171 -0
  202. package/kits/hub-game/models/hold-show/rose.pxmodel +191 -0
  203. package/kits/hub-game/models/hold-show/square/daisy.pxmodel +233 -0
  204. package/kits/hub-game/models/hold-show/square/moonflower.pxmodel +173 -0
  205. package/kits/hub-game/models/hold-show/square/rose.pxmodel +193 -0
  206. package/kits/hub-game/models/hold-show/square/sunflower.pxmodel +313 -0
  207. package/kits/hub-game/models/hold-show/square/tulip.pxmodel +133 -0
  208. package/kits/hub-game/models/hold-show/sunflower.pxmodel +311 -0
  209. package/kits/hub-game/models/hold-show/tulip.pxmodel +131 -0
  210. package/kits/hub-game/package-lock.json +3 -3
  211. package/kits/hub-game/package.json +4 -3
  212. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +1 -0
  213. package/kits/hub-game/scripts/fixtures/hud-surface.json +12 -12
  214. package/kits/hub-game/scripts/fixtures/talk-surface.json +8 -8
  215. package/kits/hub-game/scripts/gen-hats.mjs +1 -1
  216. package/kits/hub-game/scripts/gen-hold-show.mjs +27 -0
  217. package/kits/hub-game/scripts/pack.mjs +89 -23
  218. package/kits/hub-game/scripts/test-act-client.mjs +5 -0
  219. package/kits/hub-game/scripts/test-act-core.mjs +32 -0
  220. package/kits/hub-game/scripts/test-act-gate.mjs +186 -0
  221. package/kits/hub-game/scripts/test-action-rail-crowded-dom.mjs +7 -1
  222. package/kits/hub-game/scripts/test-action-rail-default-dom.mjs +102 -0
  223. package/kits/hub-game/scripts/test-action-rail-never-silent-dom.mjs +50 -0
  224. package/kits/hub-game/scripts/test-action-rail-surface.mjs +368 -0
  225. package/kits/hub-game/scripts/test-action-rail-town-jobs-dom.mjs +118 -0
  226. package/kits/hub-game/scripts/test-actions-client.mjs +5 -3
  227. package/kits/hub-game/scripts/test-actions.mjs +24 -0
  228. package/kits/hub-game/scripts/test-actors.mjs +19 -0
  229. package/kits/hub-game/scripts/test-again-corner-dom.mjs +59 -0
  230. package/kits/hub-game/scripts/test-analytics.mjs +79 -0
  231. package/kits/hub-game/scripts/test-arrival-pose-server.mjs +25 -8
  232. package/kits/hub-game/scripts/test-ask-client.mjs +9 -0
  233. package/kits/hub-game/scripts/test-ask-surface.mjs +188 -0
  234. package/kits/hub-game/scripts/test-attention.mjs +43 -1
  235. package/kits/hub-game/scripts/test-ballot-sheet-dom.mjs +71 -0
  236. package/kits/hub-game/scripts/test-ballot-surface.mjs +276 -0
  237. package/kits/hub-game/scripts/test-ballot.mjs +420 -3
  238. package/kits/hub-game/scripts/test-ban-join.mjs +1 -1
  239. package/kits/hub-game/scripts/test-celebrate-client.mjs +62 -0
  240. package/kits/hub-game/scripts/test-celebrate.mjs +116 -0
  241. package/kits/hub-game/scripts/test-chat.mjs +73 -0
  242. package/kits/hub-game/scripts/test-companion-client.mjs +203 -21
  243. package/kits/hub-game/scripts/test-companion.mjs +110 -3
  244. package/kits/hub-game/scripts/test-control-layout-dom.mjs +57 -10
  245. package/kits/hub-game/scripts/test-corner-surface.mjs +268 -0
  246. package/kits/hub-game/scripts/test-decor-client.mjs +59 -3
  247. package/kits/hub-game/scripts/test-decor.mjs +27 -0
  248. package/kits/hub-game/scripts/test-device-class.mjs +4 -1
  249. package/kits/hub-game/scripts/test-disguise-client.mjs +281 -0
  250. package/kits/hub-game/scripts/test-disguise.mjs +176 -0
  251. package/kits/hub-game/scripts/test-dock-surface.mjs +404 -0
  252. package/kits/hub-game/scripts/test-door-stay-client.mjs +602 -0
  253. package/kits/hub-game/scripts/test-door-stay.mjs +613 -0
  254. package/kits/hub-game/scripts/test-earned-client.mjs +119 -0
  255. package/kits/hub-game/scripts/test-emote-surface.mjs +616 -0
  256. package/kits/hub-game/scripts/test-fps-telemetry.mjs +39 -4
  257. package/kits/hub-game/scripts/test-friend-bests.mjs +38 -12
  258. package/kits/hub-game/scripts/test-ghost-click-dom.mjs +75 -0
  259. package/kits/hub-game/scripts/test-grab-client.mjs +29 -2
  260. package/kits/hub-game/scripts/test-grab-orbit.mjs +260 -11
  261. package/kits/hub-game/scripts/test-grab.mjs +10 -1
  262. package/kits/hub-game/scripts/test-hats.mjs +28 -0
  263. package/kits/hub-game/scripts/test-held-offers.mjs +394 -0
  264. package/kits/hub-game/scripts/test-high-only.mjs +3 -3
  265. package/kits/hub-game/scripts/test-hold-show-client.mjs +175 -0
  266. package/kits/hub-game/scripts/test-hold-show.mjs +355 -0
  267. package/kits/hub-game/scripts/test-hub-controls.mjs +3 -1
  268. package/kits/hub-game/scripts/test-hub-idle.mjs +348 -0
  269. package/kits/hub-game/scripts/test-hub-leaving.mjs +21 -0
  270. package/kits/hub-game/scripts/test-hub-ops.mjs +119 -0
  271. package/kits/hub-game/scripts/test-hub-trip.mjs +240 -4
  272. package/kits/hub-game/scripts/test-hud-clear.mjs +83 -0
  273. package/kits/hub-game/scripts/test-hud-rate.mjs +2 -1
  274. package/kits/hub-game/scripts/test-idle.mjs +160 -0
  275. package/kits/hub-game/scripts/test-invites-client.mjs +53 -0
  276. package/kits/hub-game/scripts/test-labels.mjs +11 -0
  277. package/kits/hub-game/scripts/test-landscape-layout.mjs +20 -0
  278. package/kits/hub-game/scripts/test-loading-cover.mjs +67 -1
  279. package/kits/hub-game/scripts/test-manifest.mjs +27 -0
  280. package/kits/hub-game/scripts/test-menu-client.mjs +54 -5
  281. package/kits/hub-game/scripts/test-menu-surface.mjs +236 -0
  282. package/kits/hub-game/scripts/test-npcs.mjs +128 -0
  283. package/kits/hub-game/scripts/test-observed.mjs +171 -3
  284. package/kits/hub-game/scripts/test-pack.mjs +166 -0
  285. package/kits/hub-game/scripts/test-picker-surface.mjs +321 -0
  286. package/kits/hub-game/scripts/test-placeat-server.mjs +395 -0
  287. package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
  288. package/kits/hub-game/scripts/test-pointer-clear-dom.mjs +82 -0
  289. package/kits/hub-game/scripts/test-progress-reset.mjs +184 -6
  290. package/kits/hub-game/scripts/test-push-visit.mjs +9 -0
  291. package/kits/hub-game/scripts/test-quality.mjs +312 -9
  292. package/kits/hub-game/scripts/test-quick-chat-surface.mjs +511 -0
  293. package/kits/hub-game/scripts/test-rehello.mjs +237 -0
  294. package/kits/hub-game/scripts/test-rejoin-yaw.mjs +138 -0
  295. package/kits/hub-game/scripts/test-relations-among.mjs +13 -7
  296. package/kits/hub-game/scripts/test-relations-refresh.mjs +90 -2
  297. package/kits/hub-game/scripts/test-replay-client.mjs +110 -0
  298. package/kits/hub-game/scripts/test-replay.mjs +178 -0
  299. package/kits/hub-game/scripts/test-resume-held.mjs +13 -0
  300. package/kits/hub-game/scripts/test-resume-pose-server.mjs +43 -5
  301. package/kits/hub-game/scripts/test-role-client.mjs +2 -1
  302. package/kits/hub-game/scripts/test-safe-act.mjs +233 -0
  303. package/kits/hub-game/scripts/test-safe-caption.mjs +364 -0
  304. package/kits/hub-game/scripts/test-safe-layout.mjs +79 -0
  305. package/kits/hub-game/scripts/test-safe-prompt.mjs +163 -0
  306. package/kits/hub-game/scripts/test-sound-surface.mjs +256 -0
  307. package/kits/hub-game/scripts/test-soundscape.mjs +85 -2
  308. package/kits/hub-game/scripts/test-stuck-surface.mjs +174 -0
  309. package/kits/hub-game/scripts/test-stuck.mjs +31 -0
  310. package/kits/hub-game/scripts/test-talk-surface.mjs +23 -6
  311. package/kits/hub-game/scripts/test-talk-walk-dom.mjs +123 -0
  312. package/kits/hub-game/scripts/test-text-ask-surface.mjs +273 -0
  313. package/kits/hub-game/scripts/test-tiers.mjs +453 -3
  314. package/kits/hub-game/scripts/test-toast-no-row-dom.mjs +71 -0
  315. package/kits/hub-game/scripts/test-together.mjs +11 -0
  316. package/kits/hub-game/scripts/test-town-day.mjs +90 -0
  317. package/kits/hub-game/scripts/test-try-on.mjs +39 -0
  318. package/kits/hub-game/scripts/test-ui-dom-dom.mjs +49 -2
  319. package/kits/hub-game/scripts/test-ui-tree.mjs +28 -0
  320. package/kits/hub-game/scripts/test-vehicle-client.mjs +68 -1
  321. package/kits/hub-game/scripts/test-vis.mjs +145 -0
  322. package/kits/hub-game/scripts/test-wallet.mjs +650 -0
  323. package/kits/hub-game/scripts/test-weakest-tier.mjs +135 -1
  324. package/kits/hub-game/scripts/test-world-labels.mjs +340 -0
  325. package/kits/hub-game/scripts/test-writer-lease-server.mjs +234 -0
  326. package/kits/hub-game/scripts/test-writer-lease.mjs +281 -0
  327. package/kits/hub-game/scripts/writer-storage-fixture.mjs +37 -0
  328. package/kits/hub-game/tools/hubScene/export.mjs +6 -5
  329. package/kits/hub-game/tools/hubScene/hubdata.mjs +10 -0
  330. package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +36 -2
  331. package/kits/hub-game/tools/hubScene/validate-manifest.mjs +10 -2
  332. package/kits/multiplayer-3d/castle.json +5 -5
  333. package/kits/multiplayer-3d/code/client/resumeGate.js +49 -2
  334. package/kits/multiplayer-3d/code/server/ownership.js +25 -6
  335. package/kits/multiplayer-3d/code/server/world.js +19 -4
  336. package/kits/multiplayer-3d/code/systems/multiplayer.js +67 -11
  337. package/kits/multiplayer-3d/package-lock.json +1 -1
  338. package/kits/multiplayer-3d/package.json +2 -1
  339. package/kits/multiplayer-3d/scripts/test-ground-half.mjs +56 -0
  340. package/kits/multiplayer-3d/scripts/test-join-watchdog.mjs +54 -3
  341. package/kits/multiplayer-3d/scripts/test-owned-moves.mjs +190 -0
  342. package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +191 -5
  343. package/kits/multiplayer-3d/scripts/test-resync-reconnect.mjs +68 -0
  344. package/kits/physics-2d/castle.json +2 -2
  345. package/kits/physics-2d/engine/scene.js +10 -2
  346. package/kits/physics-3d/CLAUDE.md +14 -0
  347. package/kits/physics-3d/behaviors/Player.jsx +39 -3
  348. package/kits/physics-3d/castle.json +3 -3
  349. package/kits/physics-3d/docs/engine-model-cache.md +109 -0
  350. package/kits/physics-3d/docs/engine-player.md +76 -0
  351. package/kits/physics-3d/docs/engine-skip-work.md +16 -0
  352. package/kits/physics-3d/docs/pxmodel-format.md +5 -1
  353. package/kits/physics-3d/engine3d/gait.js +16 -8
  354. package/kits/physics-3d/engine3d/groundsize.js +23 -0
  355. package/kits/physics-3d/engine3d/kithooks.js +50 -0
  356. package/kits/physics-3d/engine3d/look.js +110 -17
  357. package/kits/physics-3d/engine3d/lookbake.js +19 -1
  358. package/kits/physics-3d/engine3d/materialpresets.js +3 -2
  359. package/kits/physics-3d/engine3d/modelcache.js +280 -0
  360. package/kits/physics-3d/engine3d/modelcachedigest.js +37 -0
  361. package/kits/physics-3d/engine3d/modelcachegate.js +69 -0
  362. package/kits/physics-3d/engine3d/modelrefs.js +13 -0
  363. package/kits/physics-3d/engine3d/optimize.js +20 -9
  364. package/kits/physics-3d/engine3d/playerRun.js +26 -1
  365. package/kits/physics-3d/engine3d/pxmodel.js +7 -3
  366. package/kits/physics-3d/engine3d/templatecache.js +722 -0
  367. package/kits/physics-3d/engine3d/world3d.js +211 -17
  368. package/kits/physics-3d/package-lock.json +1 -1
  369. package/kits/physics-3d/package.json +2 -1
  370. package/kits/physics-3d/play/behaviors/Player.js +43 -3
  371. package/kits/physics-3d/scripts/render.mjs +56 -8
  372. package/kits/physics-3d/scripts/template-cache-fixtures.mjs +37 -0
  373. package/kits/physics-3d/scripts/template-cache-v1-bytes.json +49 -0
  374. package/kits/physics-3d/scripts/test-gait.mjs +53 -9
  375. package/kits/physics-3d/scripts/test-ground-half.mjs +120 -0
  376. package/kits/physics-3d/scripts/test-model-cache.mjs +600 -0
  377. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1 -0
  378. package/kits/physics-3d/scripts/test-sleeping-models.mjs +384 -0
  379. package/kits/physics-3d/scripts/test-template-cache-minified.mjs +106 -0
  380. package/kits/physics-3d/scripts/test-template-cache.mjs +519 -0
  381. package/kits/physics-3d/scripts/test-wall-slide.mjs +272 -0
  382. package/kits/physics-3d/systems/physics3d.js +51 -2
  383. package/kits/real-time/castle.json +2 -2
  384. package/kits/real-time/code/client/connection.js +3 -0
  385. package/package.json +2 -2
  386. package/vendor/three/examples/jsm/libs/fflate.module.js +2672 -0
@@ -0,0 +1,272 @@
1
+ // Real Player + Physics3DSystem + the kit's real, vendored Rapier WASM.
2
+ // Run from any directory: node kits/physics-3d/scripts/test-wall-slide.mjs.
3
+ import assert from 'node:assert/strict';
4
+ import { register } from 'node:module';
5
+
6
+ register('data:text/javascript,' + encodeURIComponent(`
7
+ import { existsSync, readFileSync } from 'node:fs';
8
+ import { fileURLToPath } from 'node:url';
9
+ export async function resolve(specifier, context, next) {
10
+ const parent = context.parentURL ?? '';
11
+ if (specifier.startsWith('@imports/castle.physics-2d/')) {
12
+ specifier = parent.replace(/\\/kits\\/.*/, '/kits/physics-2d/') + specifier.slice(27);
13
+ }
14
+ if ((specifier.startsWith('.') || specifier.startsWith('file:')) && parent.includes('/kits/') && !/\\.(m?js|jsx|json)$/.test(specifier)) {
15
+ const base = new URL(specifier, parent).href;
16
+ for (const ext of ['.js', '.jsx']) if (existsSync(fileURLToPath(base + ext))) return next(base + ext, context);
17
+ }
18
+ return next(specifier, context);
19
+ }
20
+ export async function load(url, context, next) {
21
+ if (url.endsWith('/behaviors/Player.jsx')) {
22
+ return { format: 'module', source: readFileSync(fileURLToPath(url), 'utf8') + '\\nexport { applyMove };', shortCircuit: true };
23
+ }
24
+ return next(url, context);
25
+ }
26
+ `));
27
+ const { Player, applyMove } = await import('../behaviors/Player.jsx');
28
+ const { Physics3DSystem } = await import('../systems/physics3d.js');
29
+ const { Player: PlayPlayer } = await import('../play/behaviors/Player.js');
30
+ const DT = 1 / 60;
31
+ const RADIUS = 0.35;
32
+ const props = { ...Player.defaultProps };
33
+ const transform = (x, y, z) => ({ x, y, z, rotationX: 0, rotationY: 0, rotationZ: 0, scaleX: 1, scaleY: 1, scaleZ: 1 });
34
+ const wall = (id, x, z, width, depth, type = 'fixed', solid = true) => ({
35
+ id, runtime: {}, components: {
36
+ Transform: transform(x, 2, z), Shape: { kind: 'box', width, height: 4, depth },
37
+ Body: { type, gravityScale: 0, friction: 0.6, restitution: 0 }, ...(solid ? { Solid: {} } : {}),
38
+ },
39
+ });
40
+
41
+ async function makeWorld({ enabled, walls = [], angle = 15, orbit = false, x = -RADIUS - 0.002, z = 0, PlayerClass = Player } = {}) {
42
+ const actor = { id: 'player', runtime: {}, components: {
43
+ Transform: transform(x, 1, z), Shape: { kind: 'capsule', radius: RADIUS, height: 1.4 },
44
+ Body: { type: 'dynamic', lockRotations: true, friction: 0, restitution: 0, gravityScale: 2 }, Solid: {}, Player: { ...props },
45
+ } };
46
+ const system = new Physics3DSystem();
47
+ const scene = {
48
+ time: 0, keys: new Set(), persistent: { camAngle: (90 + angle) * Math.PI / 180 },
49
+ data: { engine: { player: { ...(enabled === undefined ? {} : { slideOnWalls: enabled }) } } },
50
+ actors: [actor, ...walls], maxFps: 0, three: null,
51
+ cameraControl: orbit ? 'orbit' : undefined,
52
+ getActors: () => scene.actors, getActor: (id) => scene.actors.find((a) => a.id === id),
53
+ actorsWith: () => [], forEachBehavior: () => {},
54
+ };
55
+ system.attach(scene);
56
+ const calls = [];
57
+ const api = scene.physics3d;
58
+ scene.physics3d = Object.fromEntries(Object.entries(api).map(([name, fn]) => [name, (...args) => {
59
+ const result = fn(...args);
60
+ calls.push(JSON.stringify([name, args.map((a) => a?.components ? a.id : a), result]));
61
+ return result;
62
+ }]));
63
+ const frame = (walking = false, jump = false) => {
64
+ scene.time += DT;
65
+ scene.keys = new Set([...(walking ? ['KeyW'] : []), ...(jump ? ['Space'] : [])]);
66
+ new PlayerClass(props).update(actor, scene, DT);
67
+ system.afterBehaviors(scene, DT);
68
+ return { ...system.bodies.get(actor.id).body.translation() };
69
+ };
70
+ for (let i = 0; i < 200 && !api.ready(); i += 1) {
71
+ await new Promise((resolve) => setTimeout(resolve, 5));
72
+ system.afterBehaviors(scene, DT);
73
+ }
74
+ assert.ok(api.ready(), 'real Rapier initialized');
75
+ for (let i = 0; i < 180; i += 1) frame();
76
+ calls.length = 0;
77
+ return { actor, scene, system, calls, frame, close: () => system.dispose(scene) };
78
+ }
79
+
80
+ async function walk(options, jump = false) {
81
+ const w = await makeWorld(options);
82
+ try {
83
+ const start = { ...w.actor.components.Transform };
84
+ const samples = [];
85
+ for (let i = 0; i < 240; i += 1) samples.push(w.frame(true, jump && i === 0));
86
+ const end = samples.at(-1);
87
+ const tail = samples.slice(-60);
88
+ return {
89
+ dx: end.x - start.x, dz: end.z - start.z,
90
+ maxX: Math.max(...samples.map((p) => p.x)), maxZ: Math.max(...samples.map((p) => p.z)),
91
+ jitter: Math.max(...tail.map((p) => p.x)) - Math.min(...tail.map((p) => p.x)) +
92
+ Math.max(...tail.map((p) => p.z)) - Math.min(...tail.map((p) => p.z)),
93
+ samples, calls: [...w.calls],
94
+ };
95
+ } finally { w.close(); }
96
+ }
97
+
98
+ // The pre-key primitive, retained to check exact calls and arithmetic without
99
+ // relying on the new implementation as its own reference.
100
+ function originalMove(phys, actor, move, speed, grounded, dt) {
101
+ const mass = phys.mass(actor);
102
+ const vel = phys.getVelocity(actor);
103
+ if (move) {
104
+ const factor = Math.min(1, dt * 14) * (grounded ? 1 : 0.3);
105
+ phys.applyImpulse(actor, {
106
+ x: (move.x * speed - vel.x) * mass * factor, y: 0,
107
+ z: (move.z * speed - vel.z) * mass * factor,
108
+ });
109
+ } else if (grounded) {
110
+ const factor = Math.min(1, dt * 12);
111
+ phys.applyImpulse(actor, { x: -vel.x * mass * factor, y: 0, z: -vel.z * mass * factor });
112
+ }
113
+ }
114
+ for (const enabled of [undefined, false, 1, 'true']) {
115
+ for (const grounded of [true, false]) for (const move of [null, { x: 0, z: 0 }, { x: 0.3, z: -0.8 }]) {
116
+ for (const dt of [0, 1 / 144, DT, 1 / 30, 0.1]) {
117
+ const record = (fn) => {
118
+ const calls = [];
119
+ const phys = {
120
+ mass: (a) => { calls.push(['mass', a]); return 2.75; },
121
+ getVelocity: (a) => { calls.push(['getVelocity', a]); return { x: 1.234, y: -0.12, z: -0.567 }; },
122
+ applyImpulse: (a, v) => calls.push(['applyImpulse', a, v]),
123
+ castWalkWall: () => assert.fail('no casts without literal true'),
124
+ };
125
+ fn(phys, 'player', move, 6, grounded, dt, { data: { engine: { player: { slideOnWalls: enabled } } } });
126
+ return calls;
127
+ };
128
+ assert.deepEqual(record(applyMove), record(originalMove), 'disabled key: original calls, order and impulse bits');
129
+ }
130
+ }
131
+ }
132
+ console.log('disabled key: original applyMove calls and impulses match exactly (120 cases)');
133
+
134
+ // Airborne steering bypasses the wall probe even with the key enabled.
135
+ for (const [grounded, y] of [[false, -2], [false, 8], [true, 8]]) {
136
+ const a = [];
137
+ const b = [];
138
+ const fake = (calls) => ({
139
+ mass: () => 2, getVelocity: () => ({ x: 1, y, z: -1 }),
140
+ applyImpulse: (_, impulse) => calls.push(impulse),
141
+ castWalkWall: () => assert.fail('jumping/airborne players do not probe walls'),
142
+ });
143
+ const move = { x: 0.4, z: 0.8 };
144
+ applyMove(fake(a), 'player', move, 6, grounded, DT, { data: { engine: { player: { slideOnWalls: true } } } });
145
+ originalMove(fake(b), 'player', move, 6, grounded, DT);
146
+ assert.deepEqual(a, b, 'airborne steering unchanged');
147
+ }
148
+
149
+ const longWall = () => [wall('wall', 0.5, 0, 1, 100)];
150
+ const free = await walk({ enabled: true });
151
+ const baseline = await walk({ walls: longWall() });
152
+ console.log(`baseline: ${baseline.dz.toFixed(4)} m along wall in 4 s; free tangent ${free.dz.toFixed(4)} m`);
153
+ assert.ok(baseline.dz >= -0.01 && baseline.dz < 0.4, 'without the key, the real wall reproduces the stall');
154
+ const off = await walk({ enabled: false, walls: longWall() });
155
+ assert.deepEqual(off.samples, baseline.samples, 'false preserves every physics position');
156
+ assert.deepEqual(off.calls, baseline.calls, 'false preserves every API call and argument');
157
+ assert.ok(!baseline.calls.some((call) => call.includes('castWalkWall')), 'absent key makes no extra casts');
158
+
159
+ for (const orbit of [false, true]) {
160
+ const slide = await walk({ enabled: true, walls: longWall(), orbit });
161
+ assert.ok(slide.dz > free.dz * 0.9, 'slide covers most of the free tangent distance');
162
+ assert.ok(slide.maxX <= -RADIUS + 0.005, 'capsule never penetrates the wall (5 mm solver tolerance)');
163
+ console.log(`${orbit ? 'orbit' : 'tank'} slide: ${slide.dz.toFixed(4)} m; closest capsule edge ${(slide.maxX + RADIUS).toFixed(5)} m`);
164
+ }
165
+ const corner = await walk({ enabled: true, angle: 45, z: -RADIUS - 0.002, walls: [
166
+ wall('x-wall', 0.5, 0, 1, 100), wall('z-wall', 0, 0.5, 100, 1),
167
+ ] });
168
+ assert.ok(corner.maxX <= -RADIUS + 0.005 && corner.maxZ <= -RADIUS + 0.005, 'corner does not penetrate either wall');
169
+ assert.ok(corner.jitter < 0.001, 'corner stops with less than 1 mm movement in its final second');
170
+ console.log(`corner: final-second movement ${corner.jitter.toFixed(6)} m`);
171
+ const mirrorSlide = await walk({ enabled: true, walls: longWall(), PlayerClass: PlayPlayer });
172
+ const sourceSlide = await walk({ enabled: true, walls: longWall() });
173
+ assert.deepEqual(mirrorSlide.samples, sourceSlide.samples, 'generated play mirror has identical wall slide');
174
+ assert.deepEqual(mirrorSlide.calls, sourceSlide.calls, 'generated play mirror makes identical physics calls');
175
+ const openOff = await walk({ enabled: false });
176
+ assert.deepEqual(free.samples, openOff.samples, 'open-ground walking is exactly unchanged');
177
+ console.log(`open ground: ${Math.hypot(free.dx, free.dz).toFixed(4)} m, identical with key off/on`);
178
+ const approach = await walk({ enabled: true, angle: 45, x: -2, z: -2, walls: [
179
+ wall('x-wall', 0.5, 0, 1, 100), wall('z-wall', 0, 0.5, 100, 1),
180
+ ] });
181
+ assert.ok(approach.jitter < 0.001, 'entering a corner at speed also comes to rest without jitter');
182
+ assert.ok(approach.samples.at(-1).x <= -RADIUS + 0.005 && approach.samples.at(-1).z <= -RADIUS + 0.005,
183
+ 'corner approach finishes outside both walls');
184
+
185
+ // More grazing headings must also be seen by the radius sweep, even where
186
+ // a short centre ray would miss the wall entirely.
187
+ for (const angle of [10, 20, 75, 80]) {
188
+ const open = await walk({ enabled: true, angle });
189
+ const slide = await walk({ enabled: true, angle, walls: longWall() });
190
+ assert.ok(slide.dz > open.dz * 0.9, `heading ${angle}: retains tangent speed`);
191
+ assert.ok(slide.maxX <= -RADIUS + 0.005, `heading ${angle}: does not penetrate`);
192
+ }
193
+ // The helper passes through non-fixed bodies and sensors, even with a fixed
194
+ // player (its own collider must still be excluded explicitly).
195
+ for (const [type, solid] of [['dynamic', true], ['kinematic', true], ['fixed', false]]) {
196
+ const w = await makeWorld({ enabled: true, walls: [wall('ignored', 0.5, 0, 1, 100, type, solid)] });
197
+ try {
198
+ assert.equal(w.scene.physics3d.castWalkWall(w.actor, { x: 1, y: 0, z: 0 }, 0.12), null, `${type}/${solid}: ignored`);
199
+ w.actor.components.Body.type = 'fixed';
200
+ w.system.afterBehaviors(w.scene, DT);
201
+ assert.equal(w.scene.physics3d.castWalkWall(w.actor, { x: 1, y: 0, z: 0 }, 0.12), null, 'player is excluded even when fixed');
202
+ } finally { w.close(); }
203
+ }
204
+ // Hover, slopes and jump trajectories stay exactly as before. A broad ramp
205
+ // tilts up 12 degrees; the player starts on it and walks uphill.
206
+ const ramp = () => {
207
+ const a = wall('ramp', 0, 0, 100, 100);
208
+ Object.assign(a.components.Transform, { y: -2, rotationZ: 12 });
209
+ return [a];
210
+ };
211
+ for (const jump of [false, true]) {
212
+ const a = await walk({ enabled: false, walls: ramp() }, jump);
213
+ const b = await walk({ enabled: true, walls: ramp() }, jump);
214
+ assert.deepEqual(b.samples, a.samples, `ramp, jump=${jump}: unchanged positions`);
215
+ }
216
+ const jumpingOff = await walk({ enabled: false }, true);
217
+ const jumpingOn = await walk({ enabled: true }, true);
218
+ assert.deepEqual(jumpingOn.samples, jumpingOff.samples, 'jump and landing unchanged on open ground');
219
+ assert.ok(Math.max(...jumpingOn.samples.map((p) => p.y)) > 1.5, 'jump case really leaves the ground');
220
+ console.log('grazing headings, fixed-solid filtering, self exclusion, ramp, hover and jump checks passed');
221
+ // A straight wall split into boxes must not become a closed corner at a
222
+ // convex box edge. Cross both seams of the three-box wall within four seconds.
223
+ const joinedWalls = (count, offset = 0) => {
224
+ const ends = count === 2 ? [-50, 0.25, 50] : [-50, 0.25, 1, 50];
225
+ return Array.from({ length: count }, (_, i) => wall(`part-${i}`, 0.5 + (i % 2 ? offset : 0),
226
+ (ends[i] + ends[i + 1]) / 2, 1, ends[i + 1] - ends[i]));
227
+ };
228
+ const seamFree = await walk({ enabled: true, angle: 5 });
229
+ const seamOne = await walk({ enabled: true, angle: 5, walls: longWall() });
230
+ const seams = [];
231
+ for (const count of [2, 3]) for (const offset of [0, 0.003, -0.003]) {
232
+ const result = await walk({ enabled: true, angle: 5, walls: joinedWalls(count, offset) });
233
+ console.log(`${count}-box seam, offset ${offset}: ${result.dz.toFixed(4)} m; one box ${seamOne.dz.toFixed(4)} m`);
234
+ seams.push({ count, offset, result });
235
+ }
236
+ // Verify the primitive's choice directly: the second box's convex edge is
237
+ // a continuation of the x-facing wall, not an opposing z-facing end wall.
238
+ const seamProbe = await makeWorld({ enabled: true, walls: joinedWalls(2), z: 0.15 });
239
+ try {
240
+ const first = seamProbe.system.bodies.get('part-0').collider.handle;
241
+ const hit = seamProbe.scene.physics3d.castWalkWall(seamProbe.actor, { x: 0, y: 0, z: 1 }, 0.12, first);
242
+ assert.ok(hit && hit.actorId === 'part-1', 'probe really reaches the adjoining box edge');
243
+ assert.ok(hit.normal.x < -0.999 && Math.abs(hit.normal.z) < 1e-6, 'edge resolves to the continuing wall face');
244
+ } finally { seamProbe.close(); }
245
+ const barrier = (height) => {
246
+ const a = wall('barrier', 0.5, 0, 1, 100);
247
+ a.components.Shape.height = height;
248
+ a.components.Transform.y = height / 2;
249
+ return [a];
250
+ };
251
+ const lowOff = await walk({ enabled: false, walls: barrier(0.5) });
252
+ const lowOn = await walk({ enabled: true, walls: barrier(0.5) });
253
+ console.log(`0.5 m barrier: off ${lowOff.dz.toFixed(4)} m, on ${lowOn.dz.toFixed(4)} m; free ${free.dz.toFixed(4)} m`);
254
+ for (const height of [0.02, 0.08, 0.15]) {
255
+ const curbOff = await walk({ enabled: false, walls: barrier(height) });
256
+ const curbOn = await walk({ enabled: true, walls: barrier(height) });
257
+ assert.ok(curbOn.dx > 20, `${height} m curb is crossed`);
258
+ assert.deepEqual(curbOn.samples, curbOff.samples, `${height} m curb: hover/step trajectory unchanged`);
259
+ console.log(`${height} m curb: ${curbOn.dx.toFixed(4)} m across it, identical with key off/on`);
260
+ }
261
+ for (const { count, offset, result } of seams) {
262
+ assert.ok(result.dz > seamFree.dz * 0.9, `${count}-box seam ${offset}: retains free tangent speed`);
263
+ assert.ok(result.maxX <= -RADIUS + Math.max(0, offset) + 0.005, 'no wall penetration across seams');
264
+ }
265
+ assert.ok(lowOff.dz < 0.4, 'low barrier reproduces the original stall');
266
+ assert.ok(lowOn.dz > free.dz * 0.9, 'low barrier retains free tangent speed');
267
+ assert.ok(lowOn.maxX <= -RADIUS + 0.005, 'capsule never penetrates low barrier');
268
+ const mirrorSeam = await walk({ enabled: true, angle: 5, walls: joinedWalls(3, -0.003), PlayerClass: PlayPlayer });
269
+ assert.deepEqual(mirrorSeam.samples, seams.at(-1).result.samples, 'play mirror crosses offset seams identically');
270
+ const mirrorBarrier = await walk({ enabled: true, walls: barrier(0.5), PlayerClass: PlayPlayer });
271
+ assert.deepEqual(mirrorBarrier.samples, lowOn.samples, 'play mirror slides along low barriers identically');
272
+ console.log('wall-slide: all checks passed (real Rapier; friction combine rule unchanged)');
@@ -18,6 +18,7 @@ import { giveBackViewRange } from '../engine3d/viewrange.js';
18
18
  import { leaveSky } from '../engine3d/skylife.js';
19
19
  import { dropShadowFade } from '../engine3d/shadowfade.js';
20
20
  import { FrozenPhysics } from '../engine3d/frozenphysics.js';
21
+ import { colliderHalf } from '../engine3d/groundsize.js';
21
22
  import { prepareModelConsumers } from '../engine3d/modelready.js';
22
23
 
23
24
  const FIXED_STEP = 1 / 60;
@@ -225,11 +226,13 @@ export class Physics3DSystem {
225
226
  // A scene whose top level says `"ground": { "none": true }` has no ground:
226
227
  // what is not stood on something falls (a pit, lava, the sky).
227
228
  if (scene?.data?.ground?.none === true) return;
228
- // The ground everything stands on, matching the visual ground plane.
229
+ // The ground everything stands on: 100 m each way from the origin, or
230
+ // the scene's `ground.half` (engine3d/groundsize.js).
231
+ const half = colliderHalf(scene?.data?.ground);
229
232
  const groundBody = this.world.createRigidBody(
230
233
  RAPIER.RigidBodyDesc.fixed().setTranslation(0, -0.5, 0)
231
234
  );
232
- this.world.createCollider(RAPIER.ColliderDesc.cuboid(100, 0.5, 100), groundBody);
235
+ this.world.createCollider(RAPIER.ColliderDesc.cuboid(half, 0.5, half), groundBody);
233
236
  }
234
237
 
235
238
  reconcileBodies(scene) {
@@ -789,6 +792,33 @@ function fixedSolids() {
789
792
  return flags.EXCLUDE_DYNAMIC | flags.EXCLUDE_KINEMATIC | flags.EXCLUDE_SENSORS;
790
793
  }
791
794
 
795
+ // A sweep can return a convex edge's support normal instead of either
796
+ // face. Sample both sides of the contact and use the face closest to that
797
+ // support normal: the next box's end is not a second wall at a straight seam.
798
+ function walkFaceNormal(hit) {
799
+ const n = hit.normal1;
800
+ // A lower-cap/top-edge contact with an upward normal can be stepped over;
801
+ // keep it instead of substituting a vertical side face below that edge.
802
+ if (Math.abs(n.y) > 0.2) return n;
803
+ const p = hit.witness1;
804
+ let best = n;
805
+ let alignment = -1;
806
+ for (const side of [-0.001, 0.001]) {
807
+ const from = {
808
+ x: p.x + n.x * 0.02 - n.z * side,
809
+ y: p.y + n.y * 0.02,
810
+ z: p.z + n.z * 0.02 + n.x * side,
811
+ };
812
+ const face = hit.collider.castRayAndGetNormal(new RAPIER.Ray(from, { x: -n.x, y: -n.y, z: -n.z }), 0.04, true);
813
+ const score = face ? face.normal.x * n.x + face.normal.y * n.y + face.normal.z * n.z : -1;
814
+ if (face && face.timeOfImpact > 0 && score > alignment) {
815
+ best = face.normal;
816
+ alignment = score;
817
+ }
818
+ }
819
+ return best;
820
+ }
821
+
792
822
  // The author-facing API behaviors reach through `scene.physics3d`. Motion goes
793
823
  // through the body (never by writing a dynamic actor's Transform); rays
794
824
  // exclude sensors so ground checks don't land on pickups.
@@ -887,6 +917,25 @@ function makeApi(system, runtime) {
887
917
  const n = met.normal;
888
918
  return { distance: met.timeOfImpact, actorId: system.byCollider.get(met.collider.handle) ?? null, normal: { x: n.x, y: n.y, z: n.z } };
889
919
  },
920
+ // Player walk probe: sweep its actual collider horizontally a short
921
+ // distance, including the capsule's lower part against low barriers.
922
+ // Only fixed solids; exclude the player and optionally the first wall
923
+ // so a second probe can find the other face of a corner. The 1 cm skin
924
+ // removes the into-wall target before contact creates sustained friction.
925
+ castWalkWall: (actor, dir, maxToi, excludeCollider) => {
926
+ const body = bodyOf(actor);
927
+ const collider = system.bodies.get(idOf(actor))?.collider;
928
+ if (!system.world || !body || !collider) return null;
929
+ const hit = system.world.castShape(
930
+ collider.translation(), collider.rotation(), dir, collider.shape, 0.01, maxToi, false,
931
+ fixedSolids(), undefined, undefined, body,
932
+ excludeCollider === undefined ? undefined : (collider) => collider.handle !== excludeCollider
933
+ );
934
+ if (!hit) return null;
935
+ const n = walkFaceNormal(hit);
936
+ return { distance: hit.time_of_impact, actorId: system.byCollider.get(hit.collider.handle) ?? null,
937
+ colliderHandle: hit.collider.handle, normal: { x: n.x, y: n.y, z: n.z } };
938
+ },
890
939
  // `castBallFixed`: a ball of `radius` swept from `origin` along the unit
891
940
  // `dir`, no farther than `maxToi`; the first fixed solid it touches, as
892
941
  // `{ distance, actorId, normal }` (how far the ball's middle got, and the
@@ -3,11 +3,11 @@
3
3
  "imports": {
4
4
  "castle.base": {
5
5
  "deckId": "yRcmH4_aYllE",
6
- "version": "2026-10-23T12:08:44.010Z"
6
+ "version": "2026-11-15T00:40:25.157Z"
7
7
  }
8
8
  },
9
9
  "autoUpdateWhenImported": true,
10
10
  "deckId": "xFVr-afOLuUQ",
11
11
  "cardId": "w6G45sy3_P_m",
12
- "publishedVersion": "2026-10-23T12:14:35.623Z"
12
+ "publishedVersion": "2026-11-15T00:41:55.124Z"
13
13
  }
@@ -163,6 +163,9 @@ export async function connectSession({
163
163
  // or still open).
164
164
  closeError: () => net.closeCode ?? null,
165
165
 
166
+ // Ask the SDK to recover a silent socket; older SDKs cannot do this.
167
+ reconnect: () => typeof connection.reconnect === 'function' ? connection.reconnect() : false,
168
+
166
169
  // Connection and presence data for a deck status line.
167
170
  status: () => ({
168
171
  state: connection.state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.239",
3
+ "version": "0.4.240",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/castle-xyz/castle-experimental-web.git"
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "rm -rf dist && tsc && chmod +x dist/index.js && vite build && vite build -c vite.cover-bridge.config.ts && cp -R src/castle-host dist/castle-host && chmod -R u+w kits 2>/dev/null; rm -rf kits && cp -R ../kits kits && chmod -R u+w kits && rm -rf kits/*/imports && node ../scripts/vendor-three.mjs",
14
14
  "dev": "tsc --watch",
15
- "check": "node ../scripts/sync-shared.mjs --check && node ../scripts/tests/icon-registry.mjs && node ../scripts/tests/sandbox-graphql-fields.mjs && node ../scripts/tests/kit-package-json.mjs && node ../scripts/tests/kit-catalog.mjs && node ../scripts/tests/import-deck-ref.mjs && node ../scripts/tests/hub-server-config.mjs && node ../scripts/tests/save-failure-reason.mjs && node ../scripts/tests/flow-draft-status.mjs && node ../scripts/tests/router-fences.mjs && node ../scripts/tests/held-tasks.mjs && node ../scripts/tests/held-task-prompts.mjs && node ../scripts/tests/router-stops.mjs && node ../scripts/tests/task-steer.mjs && node ../scripts/tests/task-steer-store.mjs && node ../scripts/tests/task-steer-line.mjs && node ../scripts/tests/router-task-endings.mjs && node ../scripts/tests/router-task-report.mjs && node ../scripts/tests/task-resume.mjs && node ../scripts/tests/task-model-request.mjs && node ../scripts/tests/plan-answered-questions.mjs && node ../scripts/tests/plan-no-standing-nudge.mjs && node ../scripts/tests/sdk-readme-limits.mjs && node ../scripts/tests/task-account.mjs && node ../scripts/tests/effort-support.mjs && node ../scripts/tests/cli-login-pkce.mjs && node ../scripts/tests/publish-timeout.mjs && node ../scripts/tests/bundle-latin1.mjs && eslint . && jscpd && tsc --noEmit && tsc --noEmit -p src/shell/tsconfig.json"
15
+ "check": "node ../scripts/sync-shared.mjs --check && node ../scripts/tests/icon-registry.mjs && node ../scripts/tests/sandbox-graphql-fields.mjs && node ../scripts/tests/kit-package-json.mjs && node ../scripts/tests/kit-catalog.mjs && node ../scripts/tests/import-order.mjs && node ../scripts/tests/import-deck-ref.mjs && node ../scripts/tests/hub-server-config.mjs && node ../scripts/tests/save-failure-reason.mjs && node ../scripts/tests/flow-draft-status.mjs && node ../scripts/tests/router-fences.mjs && node ../scripts/tests/held-tasks.mjs && node ../scripts/tests/held-task-prompts.mjs && node ../scripts/tests/router-stops.mjs && node ../scripts/tests/task-steer.mjs && node ../scripts/tests/task-steer-store.mjs && node ../scripts/tests/task-steer-line.mjs && node ../scripts/tests/router-task-endings.mjs && node ../scripts/tests/router-task-report.mjs && node ../scripts/tests/task-resume.mjs && node ../scripts/tests/task-model-request.mjs && node ../scripts/tests/plan-answered-questions.mjs && node ../scripts/tests/plan-no-standing-nudge.mjs && node ../scripts/tests/sdk-readme-limits.mjs && node ../scripts/tests/task-account.mjs && node ../scripts/tests/effort-support.mjs && node ../scripts/tests/cli-login-pkce.mjs && node ../scripts/tests/publish-timeout.mjs && node ../scripts/tests/bundle-latin1.mjs && eslint . && jscpd && tsc --noEmit && tsc --noEmit -p src/shell/tsconfig.json"
16
16
  },
17
17
  "jscpd": {
18
18
  "path": [