@crowdedkingdoms/crowdyjs 17.13.0-dev.1 → 18.0.0-dev.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 (284) hide show
  1. package/MIGRATION.md +163 -1
  2. package/README.md +142 -146
  3. package/dist/crowdy-client.d.ts +12 -31
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +15 -37
  6. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  7. package/dist/crowdy-dsh/bridge.js +3 -6
  8. package/dist/crowdy-studio/controller.d.ts +59 -57
  9. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  10. package/dist/crowdy-studio/controller.js +268 -206
  11. package/dist/crowdy-studio/diagnostics.d.ts +3 -12
  12. package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
  13. package/dist/crowdy-studio/dom-shell.d.ts +2 -4
  14. package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
  15. package/dist/crowdy-studio/dom-shell.js +16 -47
  16. package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -1
  17. package/dist/crowdy-studio/embed/panel.d.ts +3 -12
  18. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  19. package/dist/crowdy-studio/embed/panel.js +3 -6
  20. package/dist/crowdy-studio/index.d.ts +1 -3
  21. package/dist/crowdy-studio/index.d.ts.map +1 -1
  22. package/dist/crowdy-studio/index.js +0 -2
  23. package/dist/crowdy-studio/models.d.ts +3 -4
  24. package/dist/crowdy-studio/models.d.ts.map +1 -1
  25. package/dist/crowdy-studio/starter-projects.d.ts +8 -4
  26. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  27. package/dist/crowdy-studio/starter-projects.js +83 -100
  28. package/dist/domains/appAccess.d.ts +14 -1
  29. package/dist/domains/appAccess.d.ts.map +1 -1
  30. package/dist/domains/appAccess.js +37 -1
  31. package/dist/domains/exec.d.ts +162 -15
  32. package/dist/domains/exec.d.ts.map +1 -1
  33. package/dist/domains/exec.js +180 -18
  34. package/dist/domains/host.d.ts +3 -3
  35. package/dist/domains/host.js +3 -3
  36. package/dist/domains/marketplace.d.ts +9 -58
  37. package/dist/domains/marketplace.d.ts.map +1 -1
  38. package/dist/domains/marketplace.js +9 -106
  39. package/dist/domains/playerWallet.d.ts +6 -12
  40. package/dist/domains/playerWallet.d.ts.map +1 -1
  41. package/dist/domains/playerWallet.js +6 -21
  42. package/dist/errors.d.ts +7 -13
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +6 -10
  45. package/dist/generated/graphql.d.ts +1384 -7977
  46. package/dist/generated/graphql.d.ts.map +1 -1
  47. package/dist/generated/graphql.js +22 -321
  48. package/dist/grid-mods/exec-client-halves.d.ts +156 -0
  49. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -0
  50. package/dist/grid-mods/exec-client-halves.js +356 -0
  51. package/dist/grid-mods/grid-host-calls.d.ts +29 -15
  52. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  53. package/dist/grid-mods/grid-host-calls.js +40 -44
  54. package/dist/grid-mods/index.d.ts +1 -0
  55. package/dist/grid-mods/index.d.ts.map +1 -1
  56. package/dist/grid-mods/index.js +1 -0
  57. package/dist/grid-mods/mod-runtime.d.ts +21 -6
  58. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  59. package/dist/grid-mods/mod-runtime.js +6 -2
  60. package/dist/grid-scope.d.ts +0 -188
  61. package/dist/grid-scope.d.ts.map +1 -1
  62. package/dist/grid-scope.js +0 -69
  63. package/dist/index.d.ts +12 -18
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +11 -16
  66. package/dist/kit/actions.d.ts +5 -9
  67. package/dist/kit/actions.d.ts.map +1 -1
  68. package/dist/kit/actions.js +5 -9
  69. package/dist/kit/index.d.ts +2 -33
  70. package/dist/kit/index.d.ts.map +1 -1
  71. package/dist/kit/index.js +1 -32
  72. package/dist/kit/kit.d.ts +8 -208
  73. package/dist/kit/kit.d.ts.map +1 -1
  74. package/dist/kit/kit.js +5 -163
  75. package/dist/kit/social.d.ts +1 -3
  76. package/dist/kit/social.d.ts.map +1 -1
  77. package/dist/kit/social.js +1 -3
  78. package/dist/kit/wire.d.ts +16 -5
  79. package/dist/kit/wire.d.ts.map +1 -1
  80. package/dist/kit/wire.js +19 -5
  81. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  82. package/dist/live-coding/assets/manifest.json +1 -1
  83. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  84. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  85. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  86. package/dist/live-coding/rust-analysis.js +31 -23
  87. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  88. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  89. package/dist/player-runtime/client-host-calls.js +28 -0
  90. package/dist/player-runtime/glue-runtime.d.ts +27 -10
  91. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  92. package/dist/player-runtime/glue-runtime.js +40 -45
  93. package/dist/player-runtime/glue-sab.d.ts +2 -2
  94. package/dist/player-runtime/glue-sab.js +2 -2
  95. package/dist/player-runtime/player-code-broker.d.ts +80 -24
  96. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  97. package/dist/player-runtime/player-code-broker.js +169 -41
  98. package/dist/player-runtime/player-glue-worker.d.ts +8 -8
  99. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  100. package/dist/player-runtime/player-glue-worker.js +26 -9
  101. package/dist/stores/actors.d.ts +12 -2
  102. package/dist/stores/actors.d.ts.map +1 -1
  103. package/dist/stores/actors.js +43 -18
  104. package/dist/stores/chunks.d.ts +12 -0
  105. package/dist/stores/chunks.d.ts.map +1 -1
  106. package/dist/stores/chunks.js +112 -39
  107. package/dist/stores/durable.d.ts.map +1 -1
  108. package/dist/stores/durable.js +2 -1
  109. package/dist/stores/inbox.d.ts +1 -1
  110. package/dist/stores/inbox.d.ts.map +1 -1
  111. package/dist/stores/index.d.ts +0 -11
  112. package/dist/stores/index.d.ts.map +1 -1
  113. package/dist/stores/index.js +0 -4
  114. package/dist/stores/session.d.ts +0 -2
  115. package/dist/stores/session.d.ts.map +1 -1
  116. package/package.json +1 -1
  117. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  118. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  119. package/dist/crowdy-studio/model-lint-log.js +0 -93
  120. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  121. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  122. package/dist/crowdy-studio/model-lint.js +0 -45
  123. package/dist/domains/compute.d.ts +0 -208
  124. package/dist/domains/compute.d.ts.map +0 -1
  125. package/dist/domains/compute.js +0 -274
  126. package/dist/domains/controlPlane.d.ts +0 -38
  127. package/dist/domains/controlPlane.d.ts.map +0 -1
  128. package/dist/domains/controlPlane.js +0 -43
  129. package/dist/domains/gameModel.d.ts +0 -1174
  130. package/dist/domains/gameModel.d.ts.map +0 -1
  131. package/dist/domains/gameModel.js +0 -1333
  132. package/dist/domains/playerCompute.d.ts +0 -91
  133. package/dist/domains/playerCompute.d.ts.map +0 -1
  134. package/dist/domains/playerCompute.js +0 -136
  135. package/dist/domains/playerModel.d.ts +0 -20
  136. package/dist/domains/playerModel.d.ts.map +0 -1
  137. package/dist/domains/playerModel.js +0 -54
  138. package/dist/kit/abilities.d.ts +0 -66
  139. package/dist/kit/abilities.d.ts.map +0 -1
  140. package/dist/kit/abilities.js +0 -71
  141. package/dist/kit/blueprints/combat.d.ts +0 -81
  142. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  143. package/dist/kit/blueprints/combat.js +0 -357
  144. package/dist/kit/blueprints/core.d.ts +0 -222
  145. package/dist/kit/blueprints/core.d.ts.map +0 -1
  146. package/dist/kit/blueprints/core.js +0 -185
  147. package/dist/kit/blueprints/decks.d.ts +0 -50
  148. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  149. package/dist/kit/blueprints/decks.js +0 -163
  150. package/dist/kit/blueprints/economy.d.ts +0 -88
  151. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  152. package/dist/kit/blueprints/economy.js +0 -533
  153. package/dist/kit/blueprints/guild.d.ts +0 -51
  154. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  155. package/dist/kit/blueprints/guild.js +0 -50
  156. package/dist/kit/blueprints/index.d.ts +0 -23
  157. package/dist/kit/blueprints/index.d.ts.map +0 -1
  158. package/dist/kit/blueprints/index.js +0 -22
  159. package/dist/kit/blueprints/inventory.d.ts +0 -84
  160. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  161. package/dist/kit/blueprints/inventory.js +0 -257
  162. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  163. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  164. package/dist/kit/blueprints/leaderboards.js +0 -126
  165. package/dist/kit/blueprints/liveops.d.ts +0 -42
  166. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  167. package/dist/kit/blueprints/liveops.js +0 -170
  168. package/dist/kit/blueprints/locks.d.ts +0 -82
  169. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  170. package/dist/kit/blueprints/locks.js +0 -155
  171. package/dist/kit/blueprints/loot.d.ts +0 -90
  172. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  173. package/dist/kit/blueprints/loot.js +0 -229
  174. package/dist/kit/blueprints/matches.d.ts +0 -84
  175. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  176. package/dist/kit/blueprints/matches.js +0 -349
  177. package/dist/kit/blueprints/moderation.d.ts +0 -32
  178. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  179. package/dist/kit/blueprints/moderation.js +0 -140
  180. package/dist/kit/blueprints/npcs.d.ts +0 -78
  181. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  182. package/dist/kit/blueprints/npcs.js +0 -125
  183. package/dist/kit/blueprints/plots.d.ts +0 -63
  184. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  185. package/dist/kit/blueprints/plots.js +0 -151
  186. package/dist/kit/blueprints/progression.d.ts +0 -68
  187. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  188. package/dist/kit/blueprints/progression.js +0 -324
  189. package/dist/kit/blueprints/quests.d.ts +0 -72
  190. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  191. package/dist/kit/blueprints/quests.js +0 -285
  192. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  193. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  194. package/dist/kit/blueprints/worldsim.js +0 -468
  195. package/dist/kit/combat.d.ts +0 -141
  196. package/dist/kit/combat.d.ts.map +0 -1
  197. package/dist/kit/combat.js +0 -196
  198. package/dist/kit/decks.d.ts +0 -157
  199. package/dist/kit/decks.d.ts.map +0 -1
  200. package/dist/kit/decks.js +0 -186
  201. package/dist/kit/director.d.ts +0 -88
  202. package/dist/kit/director.d.ts.map +0 -1
  203. package/dist/kit/director.js +0 -86
  204. package/dist/kit/economy.d.ts +0 -289
  205. package/dist/kit/economy.d.ts.map +0 -1
  206. package/dist/kit/economy.js +0 -427
  207. package/dist/kit/engine.d.ts +0 -48
  208. package/dist/kit/engine.d.ts.map +0 -1
  209. package/dist/kit/engine.js +0 -113
  210. package/dist/kit/features.d.ts +0 -60
  211. package/dist/kit/features.d.ts.map +0 -1
  212. package/dist/kit/features.js +0 -65
  213. package/dist/kit/instances.d.ts +0 -52
  214. package/dist/kit/instances.d.ts.map +0 -1
  215. package/dist/kit/instances.js +0 -60
  216. package/dist/kit/inventory.d.ts +0 -129
  217. package/dist/kit/inventory.d.ts.map +0 -1
  218. package/dist/kit/inventory.js +0 -200
  219. package/dist/kit/leaderboards.d.ts +0 -86
  220. package/dist/kit/leaderboards.d.ts.map +0 -1
  221. package/dist/kit/leaderboards.js +0 -133
  222. package/dist/kit/liveops.d.ts +0 -112
  223. package/dist/kit/liveops.d.ts.map +0 -1
  224. package/dist/kit/liveops.js +0 -183
  225. package/dist/kit/loot.d.ts +0 -128
  226. package/dist/kit/loot.d.ts.map +0 -1
  227. package/dist/kit/loot.js +0 -160
  228. package/dist/kit/matches.d.ts +0 -301
  229. package/dist/kit/matches.d.ts.map +0 -1
  230. package/dist/kit/matches.js +0 -458
  231. package/dist/kit/matchmaking.d.ts +0 -57
  232. package/dist/kit/matchmaking.d.ts.map +0 -1
  233. package/dist/kit/matchmaking.js +0 -59
  234. package/dist/kit/minigames.d.ts +0 -30
  235. package/dist/kit/minigames.d.ts.map +0 -1
  236. package/dist/kit/minigames.js +0 -38
  237. package/dist/kit/mobs.d.ts +0 -90
  238. package/dist/kit/mobs.d.ts.map +0 -1
  239. package/dist/kit/mobs.js +0 -98
  240. package/dist/kit/moderation.d.ts +0 -73
  241. package/dist/kit/moderation.d.ts.map +0 -1
  242. package/dist/kit/moderation.js +0 -103
  243. package/dist/kit/movement.d.ts +0 -78
  244. package/dist/kit/movement.d.ts.map +0 -1
  245. package/dist/kit/movement.js +0 -103
  246. package/dist/kit/notifications.d.ts +0 -45
  247. package/dist/kit/notifications.d.ts.map +0 -1
  248. package/dist/kit/notifications.js +0 -67
  249. package/dist/kit/npcs.d.ts +0 -226
  250. package/dist/kit/npcs.d.ts.map +0 -1
  251. package/dist/kit/npcs.js +0 -141
  252. package/dist/kit/objects.d.ts +0 -116
  253. package/dist/kit/objects.d.ts.map +0 -1
  254. package/dist/kit/objects.js +0 -119
  255. package/dist/kit/pets.d.ts +0 -85
  256. package/dist/kit/pets.d.ts.map +0 -1
  257. package/dist/kit/pets.js +0 -96
  258. package/dist/kit/plots.d.ts +0 -85
  259. package/dist/kit/plots.d.ts.map +0 -1
  260. package/dist/kit/plots.js +0 -113
  261. package/dist/kit/progression.d.ts +0 -181
  262. package/dist/kit/progression.d.ts.map +0 -1
  263. package/dist/kit/progression.js +0 -265
  264. package/dist/kit/quests.d.ts +0 -171
  265. package/dist/kit/quests.d.ts.map +0 -1
  266. package/dist/kit/quests.js +0 -237
  267. package/dist/kit/racing.d.ts +0 -85
  268. package/dist/kit/racing.d.ts.map +0 -1
  269. package/dist/kit/racing.js +0 -99
  270. package/dist/kit/shared.d.ts +0 -73
  271. package/dist/kit/shared.d.ts.map +0 -1
  272. package/dist/kit/shared.js +0 -101
  273. package/dist/kit/telemetry.d.ts +0 -66
  274. package/dist/kit/telemetry.d.ts.map +0 -1
  275. package/dist/kit/telemetry.js +0 -133
  276. package/dist/kit/territory.d.ts +0 -97
  277. package/dist/kit/territory.d.ts.map +0 -1
  278. package/dist/kit/territory.js +0 -114
  279. package/dist/kit/worldsim.d.ts +0 -263
  280. package/dist/kit/worldsim.d.ts.map +0 -1
  281. package/dist/kit/worldsim.js +0 -268
  282. package/dist/stores/model.d.ts +0 -81
  283. package/dist/stores/model.d.ts.map +0 -1
  284. package/dist/stores/model.js +0 -163
@@ -1,45 +0,0 @@
1
- import { print } from 'graphql';
2
- import { CrowdyModelLintDocument } from '../generated/graphql.js';
3
- /**
4
- * The lint query, printed from the generated document rather than written here.
5
- *
6
- * IT USED TO BE A TEMPLATE LITERAL, and that made it the one query in this SDK that
7
- * `check:schema` could not validate: codegen only sees operation documents, so the query
8
- * asking "is this app's model coherent" was itself unchecked against the schema it targets.
9
- * `gameModelLint` was not even present in the committed SDL. Printing from
10
- * `CrowdyModelLintDocument` means the string and the validated document cannot disagree.
11
- */
12
- export const MODEL_LINT_QUERY = print(CrowdyModelLintDocument);
13
- function severityOf(finding) {
14
- return finding.severity === 'error' ? 'error' : 'warning';
15
- }
16
- /**
17
- * A stable, readable label for the thing the finding is about.
18
- *
19
- * Prefixed with the kind because subjects collide across kinds — an automation and a
20
- * function may both be called `on_join`, and a Problems list that showed both as `on_join`
21
- * would be actively misleading about which one is broken.
22
- */
23
- export function modelLintSubjectPath(finding) {
24
- return `${finding.subjectKind}/${finding.subject}`;
25
- }
26
- export function modelLintDiagnostics(result, target = 'SERVER') {
27
- if (!result?.findings?.length)
28
- return [];
29
- return result.findings.map((finding) => ({
30
- target,
31
- path: modelLintSubjectPath(finding),
32
- line: 1,
33
- column: 1,
34
- severity: severityOf(finding),
35
- // The remedy is joined into the message rather than dropped: an editor's Problems
36
- // list shows one line per entry and has nowhere else to put it, and a finding a
37
- // developer cannot act on from where they are reading it is the failure this whole
38
- // feature exists to fix.
39
- message: finding.remedy
40
- ? `${finding.message} — ${finding.remedy}`
41
- : finding.message,
42
- code: finding.code,
43
- source: 'model-lint',
44
- }));
45
- }
@@ -1,208 +0,0 @@
1
- import type { GraphQLClient } from '../client.js';
2
- import { type ComputeUpsertModuleMutation, type ComputeUpsertModuleMutationVariables, type ComputeDeployVersionMutation, type ComputeSetModuleEnabledMutation, type ComputeSetModuleEnabledMutationVariables, type ComputeResetBreakerMutation, type ComputeResetBreakerMutationVariables, type ComputeDeleteModuleMutation, type ComputeDeleteModuleMutationVariables, type ComputeUpsertTriggerMutation, type ComputeUpsertTriggerMutationVariables, type ComputeDeleteTriggerMutation, type ComputeDeleteTriggerMutationVariables, type ComputeSetPolicyMutation, type ComputeSetPolicyMutationVariables, type ComputeInvokeMutation, type ComputeInvokeMutationVariables, type ComputeModulesQuery, type ComputeModulesQueryVariables, type ComputeModuleQuery, type ComputeModuleQueryVariables, type ComputeModuleVersionsQuery, type ComputeModuleVersionsQueryVariables, type ComputeModuleTriggersQuery, type ComputeModuleTriggersQueryVariables, type ComputeModulePolicyQuery, type ComputeModulePolicyQueryVariables, type ComputeModuleRunsQuery, type ComputeModuleRunsQueryVariables, type ComputeModuleStatsQuery, type ComputeModuleStatsQueryVariables, type ComputeModuleLogsQuery, type ComputeModuleLogsQueryVariables, type ComputeDeployTemplateMutation, type ComputeDeployTemplateMutationVariables, type ComputeTemplatesQuery, type ComputeTemplatesQueryVariables, type ComputeAppDiagnosticsQuery, type ComputeAppDiagnosticsQueryVariables } from '../generated/graphql.js';
3
- /** The crowdy-compute-sdk version the platform toolchain currently pins. */
4
- export declare const COMPUTE_SDK_VERSION = "0.1.3";
5
- /** The guest ABI version the platform currently supports. */
6
- export declare const COMPUTE_ABI_VERSION = 0;
7
- /** Options for {@link ComputeAPI.deployVersion}. */
8
- export interface DeployVersionOptions {
9
- appId: ComputeSetModuleEnabledMutationVariables['appId'];
10
- moduleName: string;
11
- /**
12
- * Relative path -> file contents. Must include `Cargo.toml` and
13
- * `src/lib.rs`; only `.rs` files under `src/` plus `Cargo.toml` are
14
- * accepted by the server (crate allowlist, size caps, no build-time code).
15
- */
16
- sourceFiles: Record<string, string>;
17
- /** crowdy-compute-sdk version pin. Defaults to {@link COMPUTE_SDK_VERSION}. */
18
- sdkVersion?: string;
19
- /** Guest ABI version pin. Defaults to {@link COMPUTE_ABI_VERSION}. */
20
- abiVersion?: number;
21
- }
22
- /** Options for {@link ComputeAPI.waitForCompile}. */
23
- export interface WaitForCompileOptions {
24
- /** Total budget in ms before giving up (default 120_000). */
25
- timeoutMs?: number;
26
- /** Poll interval in ms (default 2_000). */
27
- intervalMs?: number;
28
- }
29
- /**
30
- * Typed client for **Compute Modules** — server-side Rust/WebAssembly logic
31
- * on the Game API (`client.compute`). Studios upload Rust source; the
32
- * platform compiles it to WASM and runs it sandboxed on the game servers with
33
- * fuel metering, triggers (tick / event / invoke), an app-scoped host data
34
- * API, and replication egress. Modules are **server-only**: this client
35
- * manages, invokes, and observes them — nothing executes client-side.
36
- *
37
- * Authoring mutations require the org **`manage_compute`** permission;
38
- * monitoring queries require **`view_compute_diagnostics`**. `invoke` is
39
- * gated per-export by the invoke trigger's policy.
40
- *
41
- * Docs: https://docs.crowdedkingdoms.com/game-api/compute-modules
42
- */
43
- export declare class ComputeAPI {
44
- private gql;
45
- constructor(gql: GraphQLClient);
46
- /**
47
- * Create or update a module's metadata (upsert key `(appId, name)`). New
48
- * modules start disabled; enable after a successful compile.
49
- *
50
- * **Nothing runs for an app with no player in it.** A module ticks only while
51
- * its app has at least one player connected, anywhere in the fleet, and stops
52
- * when the last one leaves. `alwaysOn` is retired (2026-09-01) and passing
53
- * `true` is refused — a world that must advance while empty should compute the
54
- * elapsed time on its first tick after a player returns, which is cheaper than
55
- * ticking an empty world and gives the same result.
56
- *
57
- * Requires the org **`manage_compute`** permission.
58
- *
59
- * @throws {CrowdyGraphQLError} `FORBIDDEN` without the permission.
60
- * @throws {CrowdyGraphQLError} `BAD_REQUEST` if `alwaysOn: true` is passed.
61
- */
62
- upsertModule(input: ComputeUpsertModuleMutationVariables['input']): Promise<ComputeUpsertModuleMutation['computeUpsertModule']>;
63
- /**
64
- * Upload an immutable source version and make it the deployed version. The
65
- * source is validated server-side (Cargo.toml + `src/*.rs` only, dependency
66
- * allowlist, size caps, no build-time code) and parked as
67
- * `compileStatus: "pending"` until a game server compiles it — poll with
68
- * {@link moduleVersions} or {@link waitForCompile}.
69
- *
70
- * Requires the org **`manage_compute`** permission.
71
- *
72
- * @param opts - App, module, `sourceFiles` map (stringified for you), and
73
- * optional SDK/ABI pins (defaulted to the current platform pins).
74
- */
75
- deployVersion(opts: DeployVersionOptions): Promise<ComputeDeployVersionMutation['computeDeployVersion']>;
76
- /**
77
- * Enable or disable a module. Enabling requires a successfully compiled
78
- * deployed version and resets the failure circuit; disabling stops all
79
- * scheduling. Requires the org **`manage_compute`** permission.
80
- *
81
- * This does **not** restart a module that was stopped for exceeding a
82
- * resource limit (`breakerLatchedAt`). Deploy a fixed version, or call
83
- * {@link resetBreaker}.
84
- */
85
- setModuleEnabled(variables: ComputeSetModuleEnabledMutationVariables): Promise<ComputeSetModuleEnabledMutation['computeSetModuleEnabled']>;
86
- /**
87
- * Restart a module that was stopped for exceeding a resource limit, without
88
- * deploying a new version.
89
- *
90
- * A module stopped this way reports `breakerLatchedAt` and a
91
- * `breakerReason` saying what it exceeded. Deploying a fix clears it
92
- * automatically and is the normal path; use this when the limit itself was
93
- * wrong, or the load is being accepted deliberately. The reason is recorded
94
- * with the module's history. Requires the org **`manage_compute`**
95
- * permission.
96
- */
97
- resetBreaker(variables: ComputeResetBreakerMutationVariables): Promise<ComputeResetBreakerMutation['computeResetBreaker']>;
98
- /**
99
- * Delete a module and (via cascade) its versions, triggers, and lease. Run
100
- * history is retained for auditing. **Destructive.** Requires the org
101
- * **`manage_compute`** permission.
102
- *
103
- * @returns `true` if a module was deleted.
104
- */
105
- deleteModule(variables: ComputeDeleteModuleMutationVariables): Promise<ComputeDeleteModuleMutation['computeDeleteModule']>;
106
- /**
107
- * Bind a trigger to a module: a tick loop (`triggerType: "tick"` +
108
- * `tickHz`, clamped by the app policy), an event subscription
109
- * (`triggerType: "event"` + `onEvent`: `function_invoked` |
110
- * `property_changed` | `container_created` | `compute_event`), or a
111
- * client-callable export (`triggerType: "invoke"` + `exportName` +
112
- * optional `invokePolicyJson` authority tree; null policy = compute admins
113
- * only). Requires the org **`manage_compute`** permission.
114
- */
115
- upsertTrigger(input: ComputeUpsertTriggerMutationVariables['input']): Promise<ComputeUpsertTriggerMutation['computeUpsertTrigger']>;
116
- /**
117
- * Delete a trigger by id. Requires the org **`manage_compute`** permission.
118
- *
119
- * @returns `true` if a trigger was deleted.
120
- */
121
- deleteTrigger(variables: ComputeDeleteTriggerMutationVariables): Promise<ComputeDeleteTriggerMutation['computeDeleteTrigger']>;
122
- /**
123
- * Set the app's compute policy (guardrails: kill switch, module count,
124
- * tick-rate / fuel / memory / runtime / host-op / egress ceilings, circuit
125
- * tuning). Omitted fields keep their current values; values above the
126
- * platform ceilings are rejected. Requires the org **`manage_compute`**
127
- * permission.
128
- */
129
- setPolicy(input: ComputeSetPolicyMutationVariables['input']): Promise<ComputeSetPolicyMutation['computeSetPolicy']>;
130
- /**
131
- * Invoke a module's client-callable export (an `invoke` trigger) as a
132
- * **synchronous RPC**: the module runs server-side and its result comes
133
- * back directly — unlike the spatial send surface, a failure (policy
134
- * denial, fuel exhaustion, trap) is a thrown error, not a silent drop.
135
- *
136
- * Authorization: the export's invoke policy, or `manage_compute` holders
137
- * only when no policy is set.
138
- *
139
- * @returns The invoke result; `resultJson` is set when the module's bytes
140
- * parse as JSON (`resultBase64` always carries the raw bytes).
141
- * @throws {CrowdyGraphQLError} `FORBIDDEN` on policy denial; `BAD_REQUEST`
142
- * when the module is disabled or the call fails inside the sandbox.
143
- */
144
- invoke(variables: ComputeInvokeMutationVariables): Promise<ComputeInvokeMutation['computeInvoke']>;
145
- /** List the app's modules. Requires **`view_compute_diagnostics`**. */
146
- modules(variables: ComputeModulesQueryVariables): Promise<ComputeModulesQuery['computeModules']>;
147
- /** Read one module by name. Requires **`view_compute_diagnostics`**. */
148
- module(variables: ComputeModuleQueryVariables): Promise<ComputeModuleQuery['computeModule']>;
149
- /**
150
- * List a module's source versions, newest first, including compile
151
- * status/log. Requires **`view_compute_diagnostics`**.
152
- */
153
- moduleVersions(variables: ComputeModuleVersionsQueryVariables): Promise<ComputeModuleVersionsQuery['computeModuleVersions']>;
154
- /**
155
- * The platform's engine-template registry: ready-made engines deployable
156
- * by name with {@link deployTemplate}.
157
- */
158
- templates(variables: ComputeTemplatesQueryVariables): Promise<ComputeTemplatesQuery['computeTemplates']>;
159
- /**
160
- * Deploy a named engine template from the platform registry — one call
161
- * instead of the upsert/deploy/trigger/enable sequence. Compilation runs
162
- * asynchronously; follow with {@link waitForCompile}.
163
- */
164
- deployTemplate(variables: ComputeDeployTemplateMutationVariables): Promise<ComputeDeployTemplateMutation['computeDeployTemplate']>;
165
- /**
166
- * Poll {@link moduleVersions} until the newest version's compile settles
167
- * (`succeeded` or `failed`). Resolves with the settled version; **rejects**
168
- * on compile failure (message includes the compile log) or timeout.
169
- *
170
- * Requires **`view_compute_diagnostics`**.
171
- */
172
- waitForCompile(appId: ComputeModuleVersionsQueryVariables['appId'], moduleName: string, opts?: WaitForCompileOptions): Promise<ComputeModuleVersionsQuery['computeModuleVersions'][number]>;
173
- /**
174
- * List trigger bindings, optionally filtered to one module. Requires
175
- * **`view_compute_diagnostics`**.
176
- */
177
- moduleTriggers(variables: ComputeModuleTriggersQueryVariables): Promise<ComputeModuleTriggersQuery['computeModuleTriggers']>;
178
- /**
179
- * Read the app's compute policy (platform defaults when unset). Requires
180
- * **`view_compute_diagnostics`**.
181
- */
182
- modulePolicy(variables: ComputeModulePolicyQueryVariables): Promise<ComputeModulePolicyQuery['computeModulePolicy']>;
183
- /**
184
- * List runs, newest first (module loads/`init`, every failure, and circuit
185
- * probes; healthy high-frequency ticks are aggregated into per-minute
186
- * usage instead of one row per tick). Requires
187
- * **`view_compute_diagnostics`**.
188
- */
189
- moduleRuns(variables: ComputeModuleRunsQueryVariables): Promise<ComputeModuleRunsQuery['computeModuleRuns']>;
190
- /**
191
- * Aggregate activity over a recent window (default 60 minutes): run and
192
- * failure counts, fuel, egress, per-module breakdown. Requires
193
- * **`view_compute_diagnostics`**.
194
- */
195
- moduleStats(variables: ComputeModuleStatsQueryVariables): Promise<ComputeModuleStatsQuery['computeModuleStats']>;
196
- /**
197
- * Diagnostic log lines (guest `log()` output + failure lines), newest
198
- * first. Requires **`view_compute_diagnostics`**.
199
- */
200
- moduleLogs(variables: ComputeModuleLogsQueryVariables): Promise<ComputeModuleLogsQuery['computeModuleLogs']>;
201
- /**
202
- * Snapshot of the app's compute footprint: module/version/trigger counts,
203
- * 24h run activity, most-active modules. Requires
204
- * **`view_compute_diagnostics`**.
205
- */
206
- appDiagnostics(variables: ComputeAppDiagnosticsQueryVariables): Promise<ComputeAppDiagnosticsQuery['computeAppDiagnostics']>;
207
- }
208
- //# sourceMappingURL=compute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../src/domains/compute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EAEzC,KAAK,4BAA4B,EAEjC,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAE7C,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EAEzC,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EAEzC,KAAK,4BAA4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AO,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,CAAC;CAIhE"}
@@ -1,274 +0,0 @@
1
- import { ComputeUpsertModuleDocument, ComputeDeployVersionDocument, ComputeSetModuleEnabledDocument, ComputeResetBreakerDocument, ComputeDeleteModuleDocument, ComputeUpsertTriggerDocument, ComputeDeleteTriggerDocument, ComputeSetPolicyDocument, ComputeInvokeDocument, ComputeModulesDocument, ComputeModuleDocument, ComputeModuleVersionsDocument, ComputeModuleTriggersDocument, ComputeModulePolicyDocument, ComputeModuleRunsDocument, ComputeModuleStatsDocument, ComputeModuleLogsDocument, ComputeAppDiagnosticsDocument, ComputeDeployTemplateDocument, ComputeTemplatesDocument, } from '../generated/graphql.js';
2
- /** The crowdy-compute-sdk version the platform toolchain currently pins. */
3
- export const COMPUTE_SDK_VERSION = '0.1.3';
4
- /** The guest ABI version the platform currently supports. */
5
- export const COMPUTE_ABI_VERSION = 0;
6
- /**
7
- * Typed client for **Compute Modules** — server-side Rust/WebAssembly logic
8
- * on the Game API (`client.compute`). Studios upload Rust source; the
9
- * platform compiles it to WASM and runs it sandboxed on the game servers with
10
- * fuel metering, triggers (tick / event / invoke), an app-scoped host data
11
- * API, and replication egress. Modules are **server-only**: this client
12
- * manages, invokes, and observes them — nothing executes client-side.
13
- *
14
- * Authoring mutations require the org **`manage_compute`** permission;
15
- * monitoring queries require **`view_compute_diagnostics`**. `invoke` is
16
- * gated per-export by the invoke trigger's policy.
17
- *
18
- * Docs: https://docs.crowdedkingdoms.com/game-api/compute-modules
19
- */
20
- export class ComputeAPI {
21
- constructor(gql) {
22
- this.gql = gql;
23
- }
24
- // -- Authoring (manage_compute) ---------------------------------------------
25
- /**
26
- * Create or update a module's metadata (upsert key `(appId, name)`). New
27
- * modules start disabled; enable after a successful compile.
28
- *
29
- * **Nothing runs for an app with no player in it.** A module ticks only while
30
- * its app has at least one player connected, anywhere in the fleet, and stops
31
- * when the last one leaves. `alwaysOn` is retired (2026-09-01) and passing
32
- * `true` is refused — a world that must advance while empty should compute the
33
- * elapsed time on its first tick after a player returns, which is cheaper than
34
- * ticking an empty world and gives the same result.
35
- *
36
- * Requires the org **`manage_compute`** permission.
37
- *
38
- * @throws {CrowdyGraphQLError} `FORBIDDEN` without the permission.
39
- * @throws {CrowdyGraphQLError} `BAD_REQUEST` if `alwaysOn: true` is passed.
40
- */
41
- async upsertModule(input) {
42
- const data = await this.gql.request(ComputeUpsertModuleDocument, { input });
43
- return data.computeUpsertModule;
44
- }
45
- /**
46
- * Upload an immutable source version and make it the deployed version. The
47
- * source is validated server-side (Cargo.toml + `src/*.rs` only, dependency
48
- * allowlist, size caps, no build-time code) and parked as
49
- * `compileStatus: "pending"` until a game server compiles it — poll with
50
- * {@link moduleVersions} or {@link waitForCompile}.
51
- *
52
- * Requires the org **`manage_compute`** permission.
53
- *
54
- * @param opts - App, module, `sourceFiles` map (stringified for you), and
55
- * optional SDK/ABI pins (defaulted to the current platform pins).
56
- */
57
- async deployVersion(opts) {
58
- const data = await this.gql.request(ComputeDeployVersionDocument, {
59
- input: {
60
- appId: opts.appId,
61
- moduleName: opts.moduleName,
62
- sourceFilesJson: JSON.stringify(opts.sourceFiles),
63
- sdkVersion: opts.sdkVersion ?? COMPUTE_SDK_VERSION,
64
- abiVersion: opts.abiVersion ?? COMPUTE_ABI_VERSION,
65
- },
66
- });
67
- return data.computeDeployVersion;
68
- }
69
- /**
70
- * Enable or disable a module. Enabling requires a successfully compiled
71
- * deployed version and resets the failure circuit; disabling stops all
72
- * scheduling. Requires the org **`manage_compute`** permission.
73
- *
74
- * This does **not** restart a module that was stopped for exceeding a
75
- * resource limit (`breakerLatchedAt`). Deploy a fixed version, or call
76
- * {@link resetBreaker}.
77
- */
78
- async setModuleEnabled(variables) {
79
- const data = await this.gql.request(ComputeSetModuleEnabledDocument, variables);
80
- return data.computeSetModuleEnabled;
81
- }
82
- /**
83
- * Restart a module that was stopped for exceeding a resource limit, without
84
- * deploying a new version.
85
- *
86
- * A module stopped this way reports `breakerLatchedAt` and a
87
- * `breakerReason` saying what it exceeded. Deploying a fix clears it
88
- * automatically and is the normal path; use this when the limit itself was
89
- * wrong, or the load is being accepted deliberately. The reason is recorded
90
- * with the module's history. Requires the org **`manage_compute`**
91
- * permission.
92
- */
93
- async resetBreaker(variables) {
94
- const data = await this.gql.request(ComputeResetBreakerDocument, variables);
95
- return data.computeResetBreaker;
96
- }
97
- /**
98
- * Delete a module and (via cascade) its versions, triggers, and lease. Run
99
- * history is retained for auditing. **Destructive.** Requires the org
100
- * **`manage_compute`** permission.
101
- *
102
- * @returns `true` if a module was deleted.
103
- */
104
- async deleteModule(variables) {
105
- const data = await this.gql.request(ComputeDeleteModuleDocument, variables);
106
- return data.computeDeleteModule;
107
- }
108
- /**
109
- * Bind a trigger to a module: a tick loop (`triggerType: "tick"` +
110
- * `tickHz`, clamped by the app policy), an event subscription
111
- * (`triggerType: "event"` + `onEvent`: `function_invoked` |
112
- * `property_changed` | `container_created` | `compute_event`), or a
113
- * client-callable export (`triggerType: "invoke"` + `exportName` +
114
- * optional `invokePolicyJson` authority tree; null policy = compute admins
115
- * only). Requires the org **`manage_compute`** permission.
116
- */
117
- async upsertTrigger(input) {
118
- const data = await this.gql.request(ComputeUpsertTriggerDocument, { input });
119
- return data.computeUpsertTrigger;
120
- }
121
- /**
122
- * Delete a trigger by id. Requires the org **`manage_compute`** permission.
123
- *
124
- * @returns `true` if a trigger was deleted.
125
- */
126
- async deleteTrigger(variables) {
127
- const data = await this.gql.request(ComputeDeleteTriggerDocument, variables);
128
- return data.computeDeleteTrigger;
129
- }
130
- /**
131
- * Set the app's compute policy (guardrails: kill switch, module count,
132
- * tick-rate / fuel / memory / runtime / host-op / egress ceilings, circuit
133
- * tuning). Omitted fields keep their current values; values above the
134
- * platform ceilings are rejected. Requires the org **`manage_compute`**
135
- * permission.
136
- */
137
- async setPolicy(input) {
138
- const data = await this.gql.request(ComputeSetPolicyDocument, { input });
139
- return data.computeSetPolicy;
140
- }
141
- // -- Invoke ------------------------------------------------------------------
142
- /**
143
- * Invoke a module's client-callable export (an `invoke` trigger) as a
144
- * **synchronous RPC**: the module runs server-side and its result comes
145
- * back directly — unlike the spatial send surface, a failure (policy
146
- * denial, fuel exhaustion, trap) is a thrown error, not a silent drop.
147
- *
148
- * Authorization: the export's invoke policy, or `manage_compute` holders
149
- * only when no policy is set.
150
- *
151
- * @returns The invoke result; `resultJson` is set when the module's bytes
152
- * parse as JSON (`resultBase64` always carries the raw bytes).
153
- * @throws {CrowdyGraphQLError} `FORBIDDEN` on policy denial; `BAD_REQUEST`
154
- * when the module is disabled or the call fails inside the sandbox.
155
- */
156
- async invoke(variables) {
157
- const data = await this.gql.request(ComputeInvokeDocument, variables);
158
- return data.computeInvoke;
159
- }
160
- // -- Monitoring (view_compute_diagnostics) ------------------------------------
161
- /** List the app's modules. Requires **`view_compute_diagnostics`**. */
162
- async modules(variables) {
163
- const data = await this.gql.request(ComputeModulesDocument, variables);
164
- return data.computeModules;
165
- }
166
- /** Read one module by name. Requires **`view_compute_diagnostics`**. */
167
- async module(variables) {
168
- const data = await this.gql.request(ComputeModuleDocument, variables);
169
- return data.computeModule;
170
- }
171
- /**
172
- * List a module's source versions, newest first, including compile
173
- * status/log. Requires **`view_compute_diagnostics`**.
174
- */
175
- async moduleVersions(variables) {
176
- const data = await this.gql.request(ComputeModuleVersionsDocument, variables);
177
- return data.computeModuleVersions;
178
- }
179
- /**
180
- * The platform's engine-template registry: ready-made engines deployable
181
- * by name with {@link deployTemplate}.
182
- */
183
- async templates(variables) {
184
- const data = await this.gql.request(ComputeTemplatesDocument, variables);
185
- return data.computeTemplates;
186
- }
187
- /**
188
- * Deploy a named engine template from the platform registry — one call
189
- * instead of the upsert/deploy/trigger/enable sequence. Compilation runs
190
- * asynchronously; follow with {@link waitForCompile}.
191
- */
192
- async deployTemplate(variables) {
193
- const data = await this.gql.request(ComputeDeployTemplateDocument, variables);
194
- return data.computeDeployTemplate;
195
- }
196
- /**
197
- * Poll {@link moduleVersions} until the newest version's compile settles
198
- * (`succeeded` or `failed`). Resolves with the settled version; **rejects**
199
- * on compile failure (message includes the compile log) or timeout.
200
- *
201
- * Requires **`view_compute_diagnostics`**.
202
- */
203
- async waitForCompile(appId, moduleName, opts = {}) {
204
- const timeoutMs = opts.timeoutMs ?? 120000;
205
- const intervalMs = opts.intervalMs ?? 2000;
206
- const deadline = Date.now() + timeoutMs;
207
- for (;;) {
208
- const versions = await this.moduleVersions({ appId, moduleName, limit: 1 });
209
- const latest = versions[0];
210
- if (latest?.compileStatus === 'succeeded')
211
- return latest;
212
- if (latest?.compileStatus === 'failed') {
213
- throw new Error(`compute module '${moduleName}' compile failed:\n${latest.compileLog ?? '(no log)'}`);
214
- }
215
- if (Date.now() + intervalMs > deadline) {
216
- throw new Error(`compute module '${moduleName}' compile did not settle within ${timeoutMs}ms` +
217
- ` (status: ${latest?.compileStatus ?? 'no version found'})`);
218
- }
219
- await new Promise((r) => setTimeout(r, intervalMs));
220
- }
221
- }
222
- /**
223
- * List trigger bindings, optionally filtered to one module. Requires
224
- * **`view_compute_diagnostics`**.
225
- */
226
- async moduleTriggers(variables) {
227
- const data = await this.gql.request(ComputeModuleTriggersDocument, variables);
228
- return data.computeModuleTriggers;
229
- }
230
- /**
231
- * Read the app's compute policy (platform defaults when unset). Requires
232
- * **`view_compute_diagnostics`**.
233
- */
234
- async modulePolicy(variables) {
235
- const data = await this.gql.request(ComputeModulePolicyDocument, variables);
236
- return data.computeModulePolicy;
237
- }
238
- /**
239
- * List runs, newest first (module loads/`init`, every failure, and circuit
240
- * probes; healthy high-frequency ticks are aggregated into per-minute
241
- * usage instead of one row per tick). Requires
242
- * **`view_compute_diagnostics`**.
243
- */
244
- async moduleRuns(variables) {
245
- const data = await this.gql.request(ComputeModuleRunsDocument, variables);
246
- return data.computeModuleRuns;
247
- }
248
- /**
249
- * Aggregate activity over a recent window (default 60 minutes): run and
250
- * failure counts, fuel, egress, per-module breakdown. Requires
251
- * **`view_compute_diagnostics`**.
252
- */
253
- async moduleStats(variables) {
254
- const data = await this.gql.request(ComputeModuleStatsDocument, variables);
255
- return data.computeModuleStats;
256
- }
257
- /**
258
- * Diagnostic log lines (guest `log()` output + failure lines), newest
259
- * first. Requires **`view_compute_diagnostics`**.
260
- */
261
- async moduleLogs(variables) {
262
- const data = await this.gql.request(ComputeModuleLogsDocument, variables);
263
- return data.computeModuleLogs;
264
- }
265
- /**
266
- * Snapshot of the app's compute footprint: module/version/trigger counts,
267
- * 24h run activity, most-active modules. Requires
268
- * **`view_compute_diagnostics`**.
269
- */
270
- async appDiagnostics(variables) {
271
- const data = await this.gql.request(ComputeAppDiagnosticsDocument, variables);
272
- return data.computeAppDiagnostics;
273
- }
274
- }
@@ -1,38 +0,0 @@
1
- import type { GraphQLClient } from '../client.js';
2
- import { type CpComputePlatformCeilingsQuery, type CpSetComputePlatformCeilingsMutation, type CpSetComputePlatformCeilingsInput } from '../generated/graphql.js';
3
- /**
4
- * Operator (platform-policy) surface — exposed as `client.operator`.
5
- *
6
- * As of the v13 unified API this surface is reduced to the platform-wide
7
- * compute ceilings: dedicated customer environments were retired, and the
8
- * infrastructure control plane (environments, change orders, secrets, release
9
- * management, audit) moved to the separate infra-control-plane service with
10
- * its own auth and operator console. EVERY operation here still requires
11
- * `users.is_operator` (super-admins implicitly have it).
12
- *
13
- * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session, `FORBIDDEN`
14
- * when the caller is not an operator.
15
- */
16
- export declare class ControlPlaneAPI {
17
- private readonly api;
18
- constructor(api: GraphQLClient);
19
- /**
20
- * The platform-wide compute ceilings (max modules, tick rates, fuel,
21
- * memory, run time, db-op and egress budgets).
22
- *
23
- * @returns The stored ceilings row.
24
- */
25
- computePlatformCeilings(): Promise<CpComputePlatformCeilingsQuery['cpComputePlatformCeilings']>;
26
- /**
27
- * Patch the platform compute ceilings. Patch semantics per knob: omit =
28
- * unchanged, explicit `null` = clear the override (fall back to the
29
- * game-api bootstrap default), positive value = set. Takes effect on the
30
- * next `computeSetPolicy` call (no restart), within a 30s cache bound.
31
- * Writes a `compute.platform_ceilings_set` audit entry.
32
- *
33
- * @param input - The per-knob patch.
34
- * @returns The stored ceilings after the patch.
35
- */
36
- setComputePlatformCeilings(input: CpSetComputePlatformCeilingsInput): Promise<CpSetComputePlatformCeilingsMutation['cpSetComputePlatformCeilings']>;
37
- }
38
- //# sourceMappingURL=controlPlane.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"controlPlane.d.ts","sourceRoot":"","sources":["../../src/domains/controlPlane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAGL,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EACzC,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAE/C;;;;;OAKG;IACG,uBAAuB,IAAI,OAAO,CACtC,8BAA8B,CAAC,2BAA2B,CAAC,CAC5D;IAOD;;;;;;;;;OASG;IACG,0BAA0B,CAC9B,KAAK,EAAE,iCAAiC,GACvC,OAAO,CACR,oCAAoC,CAAC,8BAA8B,CAAC,CACrE;CAOF"}
@@ -1,43 +0,0 @@
1
- import { CpComputePlatformCeilingsDocument, CpSetComputePlatformCeilingsDocument, } from '../generated/graphql.js';
2
- /**
3
- * Operator (platform-policy) surface — exposed as `client.operator`.
4
- *
5
- * As of the v13 unified API this surface is reduced to the platform-wide
6
- * compute ceilings: dedicated customer environments were retired, and the
7
- * infrastructure control plane (environments, change orders, secrets, release
8
- * management, audit) moved to the separate infra-control-plane service with
9
- * its own auth and operator console. EVERY operation here still requires
10
- * `users.is_operator` (super-admins implicitly have it).
11
- *
12
- * @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session, `FORBIDDEN`
13
- * when the caller is not an operator.
14
- */
15
- export class ControlPlaneAPI {
16
- constructor(api) {
17
- this.api = api;
18
- }
19
- /**
20
- * The platform-wide compute ceilings (max modules, tick rates, fuel,
21
- * memory, run time, db-op and egress budgets).
22
- *
23
- * @returns The stored ceilings row.
24
- */
25
- async computePlatformCeilings() {
26
- const data = await this.api.request(CpComputePlatformCeilingsDocument);
27
- return data.cpComputePlatformCeilings;
28
- }
29
- /**
30
- * Patch the platform compute ceilings. Patch semantics per knob: omit =
31
- * unchanged, explicit `null` = clear the override (fall back to the
32
- * game-api bootstrap default), positive value = set. Takes effect on the
33
- * next `computeSetPolicy` call (no restart), within a 30s cache bound.
34
- * Writes a `compute.platform_ceilings_set` audit entry.
35
- *
36
- * @param input - The per-knob patch.
37
- * @returns The stored ceilings after the patch.
38
- */
39
- async setComputePlatformCeilings(input) {
40
- const data = await this.api.request(CpSetComputePlatformCeilingsDocument, { input });
41
- return data.cpSetComputePlatformCeilings;
42
- }
43
- }