castle-web-cli 0.4.228 → 0.4.230

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 (236) hide show
  1. package/dist/agent-prompts.d.ts +11 -3
  2. package/dist/agent-prompts.js +153 -53
  3. package/dist/agent.d.ts +2 -0
  4. package/dist/agent.js +43 -33
  5. package/dist/api.d.ts +47 -2
  6. package/dist/api.js +85 -16
  7. package/dist/castle-host/host.d.ts +91 -0
  8. package/dist/castle-host/host.js +779 -3
  9. package/dist/castleJson.d.ts +59 -0
  10. package/dist/castleJson.js +267 -3
  11. package/dist/check.js +27 -1
  12. package/dist/cloudGit.d.ts +20 -1
  13. package/dist/cloudGit.js +267 -10
  14. package/dist/contentPack.d.ts +49 -0
  15. package/dist/contentPack.js +273 -0
  16. package/dist/devExperiments.d.ts +21 -0
  17. package/dist/devExperiments.js +139 -0
  18. package/dist/devHub.d.ts +55 -0
  19. package/dist/devHub.js +187 -0
  20. package/dist/devSessionChild.js +3 -1
  21. package/dist/devSessionServer.d.ts +14 -1
  22. package/dist/devSessionServer.js +229 -44
  23. package/dist/experimentAssignment.d.ts +15 -0
  24. package/dist/experimentAssignment.js +41 -0
  25. package/dist/importCheckHook.d.ts +40 -0
  26. package/dist/importCheckHook.js +171 -0
  27. package/dist/importRegression.d.ts +15 -0
  28. package/dist/importRegression.js +100 -0
  29. package/dist/importTrust.d.ts +2 -0
  30. package/dist/importTrust.js +27 -0
  31. package/dist/importUpdateHook.d.ts +18 -0
  32. package/dist/importUpdateHook.js +31 -8
  33. package/dist/importUpdateHookRunner.js +19 -7
  34. package/dist/imports.d.ts +16 -0
  35. package/dist/imports.js +145 -33
  36. package/dist/index.js +8 -1
  37. package/dist/init.d.ts +3 -0
  38. package/dist/init.js +125 -8
  39. package/dist/install.js +4 -1
  40. package/dist/localPaths.js +4 -0
  41. package/dist/login.js +2 -2
  42. package/dist/platformDoc.js +3 -8
  43. package/dist/playPagePolicy.js +3 -1
  44. package/dist/remix.js +5 -0
  45. package/dist/routerTaskReport.d.ts +28 -0
  46. package/dist/routerTaskReport.js +56 -0
  47. package/dist/save-deck.d.ts +18 -0
  48. package/dist/save-deck.js +145 -6
  49. package/dist/serve.d.ts +8 -0
  50. package/dist/serve.js +94 -13
  51. package/dist/serverBundle.d.ts +1 -1
  52. package/dist/serverBundle.js +5 -1
  53. package/dist/sourceLineage.d.ts +42 -0
  54. package/dist/sourceLineage.js +380 -0
  55. package/dist/webSourceSync.d.ts +11 -0
  56. package/dist/webSourceSync.js +26 -9
  57. package/kits/base/CLAUDE.md +2 -3
  58. package/kits/base/castle.json +1 -1
  59. package/kits/base/sdk/README.md +301 -52
  60. package/kits/base/sdk/agent.js +4 -4
  61. package/kits/base/sdk/avatar.d.ts +12 -0
  62. package/kits/base/sdk/avatar.js +23 -0
  63. package/kits/base/sdk/castle.d.ts +6 -1
  64. package/kits/base/sdk/castle.js +3 -0
  65. package/kits/base/sdk/commands.d.ts +208 -0
  66. package/kits/base/sdk/commands.js +16 -0
  67. package/kits/base/sdk/context.d.ts +6 -0
  68. package/kits/base/sdk/experiments.d.ts +15 -0
  69. package/kits/base/sdk/experiments.js +83 -0
  70. package/kits/base/sdk/hub.d.ts +85 -0
  71. package/kits/base/sdk/hub.js +107 -0
  72. package/kits/base/sdk/multiplayer.d.ts +86 -6
  73. package/kits/base/sdk/multiplayer.js +157 -4
  74. package/kits/base/sdk/server/hub.d.ts +169 -0
  75. package/kits/base/sdk/server/hub.js +125 -0
  76. package/kits/base/sdk/server/platformHandle.d.ts +49 -2
  77. package/kits/base/sdk/server/storage.d.ts +55 -2
  78. package/kits/base/sdk/server/wrapper.d.ts +85 -6
  79. package/kits/base/sdk/server/wrapper.js +393 -30
  80. package/kits/base/sdk/transport.d.ts +2 -1
  81. package/kits/base/sdk/transport.js +13 -1
  82. package/kits/hub-game/.prettierrc +5 -0
  83. package/kits/hub-game/CLAUDE.md +146 -0
  84. package/kits/hub-game/blueprints/avatar-0.scene +28 -0
  85. package/kits/hub-game/blueprints/avatar-1.scene +28 -0
  86. package/kits/hub-game/blueprints/avatar-2.scene +28 -0
  87. package/kits/hub-game/blueprints/avatar-3.scene +28 -0
  88. package/kits/hub-game/blueprints/bean/avatar-0.scene +28 -0
  89. package/kits/hub-game/blueprints/bean/avatar-1.scene +28 -0
  90. package/kits/hub-game/blueprints/bean/avatar-2.scene +28 -0
  91. package/kits/hub-game/blueprints/bean/avatar-3.scene +28 -0
  92. package/kits/hub-game/blueprints/blocky/avatar-0.scene +28 -0
  93. package/kits/hub-game/blueprints/blocky/avatar-1.scene +28 -0
  94. package/kits/hub-game/blueprints/blocky/avatar-2.scene +28 -0
  95. package/kits/hub-game/blueprints/blocky/avatar-3.scene +28 -0
  96. package/kits/hub-game/blueprints/pixel/avatar-0.scene +28 -0
  97. package/kits/hub-game/blueprints/pixel/avatar-1.scene +28 -0
  98. package/kits/hub-game/blueprints/pixel/avatar-2.scene +28 -0
  99. package/kits/hub-game/blueprints/pixel/avatar-3.scene +28 -0
  100. package/kits/hub-game/castle.json +96 -0
  101. package/kits/hub-game/code/client/attention.js +133 -0
  102. package/kits/hub-game/code/client/avatar.js +288 -0
  103. package/kits/hub-game/code/client/cabinets.js +90 -0
  104. package/kits/hub-game/code/client/chat.js +135 -0
  105. package/kits/hub-game/code/client/chrome.js +1001 -0
  106. package/kits/hub-game/code/client/doorFrame.js +15 -0
  107. package/kits/hub-game/code/client/firstJoin.js +14 -0
  108. package/kits/hub-game/code/client/grab.js +241 -0
  109. package/kits/hub-game/code/client/hookLayer.js +230 -0
  110. package/kits/hub-game/code/client/idle.js +326 -0
  111. package/kits/hub-game/code/client/keys.js +48 -0
  112. package/kits/hub-game/code/client/pack.js +232 -0
  113. package/kits/hub-game/code/client/packFormat.js +397 -0
  114. package/kits/hub-game/code/client/say.js +127 -0
  115. package/kits/hub-game/code/client/sha256.js +80 -0
  116. package/kits/hub-game/code/client/sound.js +147 -0
  117. package/kits/hub-game/code/client/state.js +131 -0
  118. package/kits/hub-game/code/client/talk.js +259 -0
  119. package/kits/hub-game/code/client/together.js +365 -0
  120. package/kits/hub-game/code/client/wear.js +149 -0
  121. package/kits/hub-game/code/server/actors.js +627 -0
  122. package/kits/hub-game/code/server/blocks.js +103 -0
  123. package/kits/hub-game/code/server/cabinets.js +309 -0
  124. package/kits/hub-game/code/server/game.js +137 -0
  125. package/kits/hub-game/code/server/grab.js +247 -0
  126. package/kits/hub-game/code/server/history.js +96 -0
  127. package/kits/hub-game/code/server/hub.js +1904 -0
  128. package/kits/hub-game/code/server/idle.js +412 -0
  129. package/kits/hub-game/code/server/index.js +64 -0
  130. package/kits/hub-game/code/server/labels.js +59 -0
  131. package/kits/hub-game/code/server/manifest.js +527 -0
  132. package/kits/hub-game/code/server/npcs.js +745 -0
  133. package/kits/hub-game/code/server/party.js +381 -0
  134. package/kits/hub-game/code/server/place.js +43 -0
  135. package/kits/hub-game/code/server/say.js +83 -0
  136. package/kits/hub-game/code/server/wear.js +142 -0
  137. package/kits/hub-game/code/systems/hub.js +2230 -0
  138. package/kits/hub-game/docs/content-pack.md +151 -0
  139. package/kits/hub-game/docs/contract.md +1139 -0
  140. package/kits/hub-game/docs/style.md +137 -0
  141. package/kits/hub-game/drawings/blocky/castle-eye.sprite +58 -0
  142. package/kits/hub-game/drawings/blocky/dash.sprite +59 -0
  143. package/kits/hub-game/drawings/blocky/pom.sprite +59 -0
  144. package/kits/hub-game/drawings/blocky/tabby.sprite +59 -0
  145. package/kits/hub-game/drawings/pixel/castle-arm.sprite +13 -0
  146. package/kits/hub-game/drawings/pixel/castle-body.sprite +23 -0
  147. package/kits/hub-game/drawings/pixel/castle-leg.sprite +12 -0
  148. package/kits/hub-game/drawings/pixel/kai-arm.sprite +14 -0
  149. package/kits/hub-game/drawings/pixel/kai-head.sprite +24 -0
  150. package/kits/hub-game/drawings/pixel/kai-leg.sprite +15 -0
  151. package/kits/hub-game/drawings/pixel/kai-torso.sprite +18 -0
  152. package/kits/hub-game/drawings/pixel/mimi-arm.sprite +13 -0
  153. package/kits/hub-game/drawings/pixel/mimi-head.sprite +23 -0
  154. package/kits/hub-game/drawings/pixel/mimi-leg.sprite +15 -0
  155. package/kits/hub-game/drawings/pixel/mimi-torso.sprite +18 -0
  156. package/kits/hub-game/drawings/pixel/nox-arm.sprite +13 -0
  157. package/kits/hub-game/drawings/pixel/nox-head.sprite +21 -0
  158. package/kits/hub-game/drawings/pixel/nox-leg.sprite +14 -0
  159. package/kits/hub-game/drawings/pixel/nox-torso.sprite +18 -0
  160. package/kits/hub-game/eslint.config.js +20 -0
  161. package/kits/hub-game/fonts.generated.js +9 -0
  162. package/kits/hub-game/index.html +22 -0
  163. package/kits/hub-game/main.jsx +6 -0
  164. package/kits/hub-game/models/avatar-0.pxmodel +21 -0
  165. package/kits/hub-game/models/avatar-1.pxmodel +24 -0
  166. package/kits/hub-game/models/avatar-2.pxmodel +27 -0
  167. package/kits/hub-game/models/avatar-3.pxmodel +22 -0
  168. package/kits/hub-game/models/bean/avatar-0.pxmodel +19 -0
  169. package/kits/hub-game/models/bean/avatar-1.pxmodel +24 -0
  170. package/kits/hub-game/models/bean/avatar-2.pxmodel +22 -0
  171. package/kits/hub-game/models/bean/avatar-3.pxmodel +24 -0
  172. package/kits/hub-game/models/blocky/avatar-0.pxmodel +21 -0
  173. package/kits/hub-game/models/blocky/avatar-1.pxmodel +30 -0
  174. package/kits/hub-game/models/blocky/avatar-2.pxmodel +28 -0
  175. package/kits/hub-game/models/blocky/avatar-3.pxmodel +27 -0
  176. package/kits/hub-game/models/pixel/avatar-0.pxmodel +24 -0
  177. package/kits/hub-game/models/pixel/avatar-1.pxmodel +16 -0
  178. package/kits/hub-game/models/pixel/avatar-2.pxmodel +19 -0
  179. package/kits/hub-game/models/pixel/avatar-3.pxmodel +23 -0
  180. package/kits/hub-game/package-lock.json +365 -0
  181. package/kits/hub-game/package.json +32 -0
  182. package/kits/hub-game/scenes/main.scene +318 -0
  183. package/kits/hub-game/scripts/check.mjs +339 -0
  184. package/kits/hub-game/scripts/fixtures/sdk-stub.mjs +3 -0
  185. package/kits/hub-game/scripts/gen-avatars-bean.mjs +748 -0
  186. package/kits/hub-game/scripts/gen-avatars-blocky.mjs +607 -0
  187. package/kits/hub-game/scripts/gen-avatars-pixel.mjs +771 -0
  188. package/kits/hub-game/scripts/gen-avatars.mjs +621 -0
  189. package/kits/hub-game/scripts/pack.mjs +192 -0
  190. package/kits/hub-game/scripts/test-actors.mjs +666 -0
  191. package/kits/hub-game/scripts/test-attention.mjs +103 -0
  192. package/kits/hub-game/scripts/test-avatar.mjs +472 -0
  193. package/kits/hub-game/scripts/test-ban-join.mjs +194 -0
  194. package/kits/hub-game/scripts/test-blocks.mjs +351 -0
  195. package/kits/hub-game/scripts/test-chat.mjs +98 -0
  196. package/kits/hub-game/scripts/test-classic.mjs +590 -0
  197. package/kits/hub-game/scripts/test-door-jump.mjs +131 -0
  198. package/kits/hub-game/scripts/test-door.mjs +56 -0
  199. package/kits/hub-game/scripts/test-grab.mjs +331 -0
  200. package/kits/hub-game/scripts/test-hub-ops.mjs +835 -0
  201. package/kits/hub-game/scripts/test-hub-trip.mjs +1310 -0
  202. package/kits/hub-game/scripts/test-idle.mjs +518 -0
  203. package/kits/hub-game/scripts/test-interest.mjs +413 -0
  204. package/kits/hub-game/scripts/test-keys.mjs +50 -0
  205. package/kits/hub-game/scripts/test-manifest.mjs +224 -0
  206. package/kits/hub-game/scripts/test-no-forms.mjs +16 -0
  207. package/kits/hub-game/scripts/test-npcs.mjs +714 -0
  208. package/kits/hub-game/scripts/test-pack.mjs +424 -0
  209. package/kits/hub-game/scripts/test-party.mjs +286 -0
  210. package/kits/hub-game/scripts/test-say.mjs +149 -0
  211. package/kits/hub-game/scripts/test-together.mjs +183 -0
  212. package/kits/hub-game/theme.style +3 -0
  213. package/kits/multiplayer-3d/castle.json +5 -5
  214. package/kits/multiplayer-3d/code/client/avatars.js +101 -1
  215. package/kits/multiplayer-3d/code/server/players.js +4 -1
  216. package/kits/multiplayer-3d/code/server/sceneBodies.js +27 -6
  217. package/kits/multiplayer-3d/code/server/world.js +20 -7
  218. package/kits/multiplayer-3d/code/systems/multiplayer.js +222 -11
  219. package/kits/physics-2d/castle.json +2 -2
  220. package/kits/physics-2d/engine/art.js +13 -0
  221. package/kits/physics-2d/engine/assets.js +4 -2
  222. package/kits/physics-2d/engine/scene.js +25 -5
  223. package/kits/physics-3d/CLAUDE.md +6 -1
  224. package/kits/physics-3d/castle.json +3 -3
  225. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +32 -4
  226. package/kits/physics-3d/engine3d/artobjects.js +2 -2
  227. package/kits/physics-3d/engine3d/materials.js +29 -1
  228. package/kits/physics-3d/engine3d/world3d.js +65 -1
  229. package/kits/physics-3d/systems/physics3d.js +5 -2
  230. package/kits/real-time/castle.json +2 -2
  231. package/kits/real-time/code/client/connection.js +77 -7
  232. package/kits/real-time/code/client/gameHooks.js +63 -3
  233. package/kits/real-time/code/client/messages.js +7 -0
  234. package/kits/real-time/code/server/gameHooks.js +24 -0
  235. package/kits/real-time/code/server/session.js +390 -22
  236. package/package.json +2 -2
package/dist/api.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as config from './config.js';
2
+ import { createHash, randomBytes } from 'node:crypto';
2
3
  // CASTLE_API_URL reroutes API traffic to a local forwarding proxy inside Castle cloud
3
4
  // sandboxes (which also set CASTLE_TOKEN to a sandbox-scoped credential). Unset anywhere
4
5
  // else, so normal installs always talk to the real API.
@@ -76,16 +77,21 @@ function pickData(data, key) {
76
77
  return (data.data?.[key] ?? null);
77
78
  }
78
79
  export async function startCLILogin() {
79
- const data = await graphql(`mutation { startCLILogin { pollToken url } }`);
80
+ const verifier = randomBytes(32).toString('base64url');
81
+ const challenge = createHash('sha256').update(verifier, 'ascii').digest('base64url');
82
+ const data = await graphql(`mutation($challenge: String!) {
83
+ startCLILogin(challenge: $challenge) { pollToken url }
84
+ }`, { challenge });
80
85
  handleAPIError(data);
81
- return pickData(data, 'startCLILogin');
86
+ const login = pickData(data, 'startCLILogin');
87
+ return { pollToken: login.pollToken, url: login.url, verifier };
82
88
  }
83
- export async function pollForCLILogin(pollToken) {
84
- const data = await graphql(`query($pollToken: String!) {
85
- pollForCLILogin(pollToken: $pollToken) {
89
+ export async function pollForCLILogin(pollToken, verifier) {
90
+ const data = await graphql(`query($pollToken: String!, $verifier: String!) {
91
+ pollForCLILogin(pollToken: $pollToken, verifier: $verifier) {
86
92
  userId username token isAnonymous
87
93
  }
88
- }`, { pollToken });
94
+ }`, { pollToken, verifier });
89
95
  handleAPIError(data);
90
96
  return pickData(data, 'pollForCLILogin');
91
97
  }
@@ -197,6 +203,11 @@ export async function webDeckSourceVersions(deckIds) {
197
203
  export async function deckRows(deckIds) {
198
204
  return aliasedDeckQuery(deckIds, (id) => `deck(deckId: "${id}") { ${DECK_ROW_FIELDS} }`);
199
205
  }
206
+ // Ghost reads the uploaded scene, compares it with the saved one and stores it before it
207
+ // answers, which scales with the bundle: a 20-40 MB scene has taken 10-40 s. Under the
208
+ // default 10 s the save was reported failed after Ghost had published it, and the source
209
+ // that belongs with it was never uploaded. Matches save-deck's large upload timeout.
210
+ const PUBLISH_API_TIMEOUT_MS = 300_000;
200
211
  export async function updateCardAndDeckV2(deck, card, characterBundle) {
201
212
  // Old Ghost versions do not know the characterBundle argument. Keep the exact
202
213
  // pre-feature mutation for ordinary decks; only a deck that explicitly owns the
@@ -214,7 +225,7 @@ export async function updateCardAndDeckV2(deck, card, characterBundle) {
214
225
  deck { deckId }
215
226
  card { cardId }
216
227
  }
217
- }`, publishesCharacters ? { deck, card, characterBundle } : { deck, card });
228
+ }`, publishesCharacters ? { deck, card, characterBundle } : { deck, card }, { timeoutMs: PUBLISH_API_TIMEOUT_MS });
218
229
  handleAPIError(data);
219
230
  const result = data.data?.updateCardAndDeckV2;
220
231
  return { deckId: result.deck.deckId, cardId: result.card.cardId };
@@ -279,18 +290,65 @@ export async function createCauldronServerBundleUploadConfig(deckId) {
279
290
  handleAPIError(data);
280
291
  return pickData(data, 'createCauldronServerBundleUploadConfig');
281
292
  }
282
- export async function saveCauldronServerBundle(deckId, uploadId, serverConfig) {
283
- const data = await graphql(`mutation($deckId: ID!, $uploadId: String, $config: Json) {
284
- saveCauldronServerBundle(deckId: $deckId, uploadId: $uploadId, config: $config) {
285
- deckId
286
- version
287
- sha256
288
- sizeBytes
289
- }
290
- }`, { deckId, uploadId, ...(serverConfig ? { config: serverConfig } : {}) });
293
+ export async function saveCauldronServerBundle(deckId, uploadId, serverConfig, contentPackUploadId) {
294
+ // The pack rides the server bundle's own write, so the two are one release
295
+ // (contentPack.ts). Sent only with a pack: a Ghost that predates the argument
296
+ // refuses a document naming it.
297
+ const data = contentPackUploadId
298
+ ? await graphql(`mutation($deckId: ID!, $uploadId: String, $config: Json, $contentPackUploadId: String) {
299
+ saveCauldronServerBundle(deckId: $deckId, uploadId: $uploadId, config: $config, contentPackUploadId: $contentPackUploadId) {
300
+ deckId
301
+ version
302
+ sha256
303
+ sizeBytes
304
+ contentPackSha256
305
+ }
306
+ }`, { deckId, uploadId, contentPackUploadId, ...(serverConfig ? { config: serverConfig } : {}) })
307
+ : await graphql(`mutation($deckId: ID!, $uploadId: String, $config: Json) {
308
+ saveCauldronServerBundle(deckId: $deckId, uploadId: $uploadId, config: $config) {
309
+ deckId
310
+ version
311
+ sha256
312
+ sizeBytes
313
+ }
314
+ }`, { deckId, uploadId, ...(serverConfig ? { config: serverConfig } : {}) });
291
315
  handleAPIError(data);
292
316
  return pickData(data, 'saveCauldronServerBundle');
293
317
  }
318
+ /**
319
+ * A presigned upload for a content pack, or null when this Ghost does not host
320
+ * packs yet (the field is not in its schema). Anything else is thrown.
321
+ */
322
+ export async function createCauldronContentPackUploadConfig(deckId) {
323
+ const data = await graphql(`mutation($deckId: ID!) {
324
+ createCauldronContentPackUploadConfig(deckId: $deckId) {
325
+ deckId uploadId postUrl postFields
326
+ }
327
+ }`, { deckId });
328
+ const first = data?.errors?.[0];
329
+ if (first && /Cannot query field "createCauldronContentPackUploadConfig"/.test(first.message ?? '')) {
330
+ return null;
331
+ }
332
+ handleAPIError(data);
333
+ return pickData(data, 'createCauldronContentPackUploadConfig');
334
+ }
335
+ /**
336
+ * Sets, or with null clears, the A/B experiments a deck runs (castle.json
337
+ * `experiments`, already validated). Returns false when this Ghost predates
338
+ * experiments (the field is not in its schema) and so stored nothing; anything
339
+ * else is thrown.
340
+ */
341
+ export async function setCauldronDeckExperiments(deckId, experiments, options = {}) {
342
+ const data = await graphql(`mutation($deckId: ID!, $experiments: Json) {
343
+ setCauldronDeckExperiments(deckId: $deckId, experiments: $experiments)
344
+ }`, { deckId, experiments }, options);
345
+ const first = data?.errors?.[0];
346
+ if (first && /Cannot query field "setCauldronDeckExperiments"/.test(first.message ?? '')) {
347
+ return false;
348
+ }
349
+ handleAPIError(data);
350
+ return true;
351
+ }
294
352
  // Metadata for naming an import and distinguishing classic decks. Readable
295
353
  // without auth for the same decks webDeckSource is, including unlisted ones.
296
354
  export async function deckMeta(deckId) {
@@ -310,6 +368,17 @@ export async function webDeckSource(deckId) {
310
368
  handleAPIError(data);
311
369
  return pickData(data, 'webDeckSource');
312
370
  }
371
+ // Every saved version of the deck's source, newest first (Ghost lists at most 50), for its
372
+ // creator or an edit collaborator. A Ghost without the field fails this, as does anyone else.
373
+ export async function savedSourceHistory(deckId, timeoutMs) {
374
+ const data = await graphql(`query($deckId: ID!) {
375
+ webDeckSourceVersions(deckId: $deckId) {
376
+ s3Key archiveUrl savedAt bytes
377
+ }
378
+ }`, { deckId }, timeoutMs === undefined ? {} : { timeoutMs: Math.max(1, timeoutMs) });
379
+ handleAPIError(data);
380
+ return pickData(data, 'webDeckSourceVersions');
381
+ }
313
382
  // Starts every leaderboard on the deck over from empty. Ghost allows it only for
314
383
  // the deck's creator.
315
384
  export async function clearDeckLeaderboards(deckId) {
@@ -20,6 +20,7 @@ export interface HostContext {
20
20
  routeId?: string | null;
21
21
  slot?: string | null;
22
22
  } | null;
23
+ experimentVariants?: Record<string, string> | null;
23
24
  }
24
25
 
25
26
  export interface GraphqlError {
@@ -62,6 +63,7 @@ export interface HostCapabilities {
62
63
  ctx: HostContext,
63
64
  signal?: AbortSignal,
64
65
  ) => Promise<MultiplayerJoinDestinationResult>;
66
+ hub?: HostHub;
65
67
  }
66
68
 
67
69
  export type OracleStream = (url: string, body: string, sink: OracleStreamSink) => () => void;
@@ -134,6 +136,95 @@ export function acquireCauldronMultiplayerDestination(
134
136
  expectedConfigRevision: string,
135
137
  ): Promise<MultiplayerJoinDestinationResult>;
136
138
 
139
+ export type HubHandoffStatus =
140
+ | 'ok'
141
+ | 'cancelled'
142
+ | 'full'
143
+ | 'unavailable'
144
+ | 'not_found'
145
+ | 'forbidden'
146
+ | 'party_required';
147
+
148
+ export type HubHandoffResult =
149
+ | { status: 'ok'; url: string; nonce: string; sessionId: string; bundleHash: string; contentUrl: string | null }
150
+ | {
151
+ status: Exclude<HubHandoffStatus, 'ok'>;
152
+ url: null;
153
+ nonce: null;
154
+ sessionId: null;
155
+ bundleHash: null;
156
+ contentUrl: null;
157
+ };
158
+
159
+ export interface HubDoor {
160
+ doorId: string;
161
+ launcherKind: string;
162
+ placementKind: 'layer' | 'pad' | 'exact';
163
+ placement: unknown;
164
+ padSize: number | null;
165
+ enabled: boolean;
166
+ featured: boolean;
167
+ status: { playersInside: number; friendsInside: number };
168
+ }
169
+
170
+ export type HubDoorsResult =
171
+ | { status: 'ok'; doors: HubDoor[] }
172
+ | { status: 'unavailable'; doors: null };
173
+
174
+ export interface HubFriend {
175
+ userId: string;
176
+ username: string | null;
177
+ here: boolean;
178
+ }
179
+
180
+ export type HubFriendsResult =
181
+ | { status: 'ok'; friends: HubFriend[] }
182
+ | { status: 'unavailable'; friends: null };
183
+
184
+ export interface HubReportResult {
185
+ status: 'ok' | 'unavailable';
186
+ }
187
+
188
+ export interface HubChatMessage {
189
+ id: string;
190
+ fromUserId: string;
191
+ fromUsername: string | null;
192
+ text: string;
193
+ at: string;
194
+ }
195
+
196
+ export type HubChatResult =
197
+ | { status: 'ok'; canChat: boolean; peers: string[]; messages: HubChatMessage[]; cursor: string | null }
198
+ | { status: 'unavailable'; canChat: false; peers: null; messages: null; cursor: null };
199
+
200
+ export interface HubSayResult {
201
+ status: 'sent' | 'none' | 'refused' | 'limited' | 'unavailable';
202
+ id: string | null;
203
+ }
204
+
205
+ export interface HubCommitResult {
206
+ status: 'committed' | 'expired' | 'superseded' | 'cancelled' | 'none' | 'unavailable';
207
+ }
208
+
209
+ export interface HubCancelResult {
210
+ status: 'cancelled' | 'expired' | 'none' | 'unavailable';
211
+ }
212
+
213
+ export interface HostHub {
214
+ go(doorId: string, ctx: HostContext, signal?: AbortSignal): Promise<HubHandoffResult>;
215
+ back(ctx: HostContext, signal?: AbortSignal): Promise<HubHandoffResult>;
216
+ doors(ctx: HostContext): Promise<HubDoorsResult>;
217
+ friends?(ctx: HostContext): Promise<HubFriendsResult>;
218
+ jump?(userId: string, ctx: HostContext, signal?: AbortSignal): Promise<HubHandoffResult>;
219
+ report?(userId: string, reason: string | null, ctx: HostContext): Promise<HubReportResult>;
220
+ chat?(after: string | null, ctx: HostContext): Promise<HubChatResult>;
221
+ say?(text: string, ctx: HostContext): Promise<HubSayResult>;
222
+ reportChat?(messageId: string, ctx: HostContext): Promise<HubReportResult>;
223
+ commit(sessionId: string, ctx: HostContext): Promise<HubCommitResult>;
224
+ cancel(sessionId: string | null, ctx: HostContext): Promise<HubCancelResult>;
225
+ sessionAcquired?(sessionId: string, ctx: HostContext): void;
226
+ }
227
+
137
228
  export interface LeaderboardStreakCredit {
138
229
  deckId: string | null;
139
230
  kind: string;