@crowdedkingdoms/crowdyjs 8.0.1 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ npm install @crowdedkingdoms/crowdyjs
12
12
 
13
13
  CrowdyJS v4 targets browsers by default and uses native `fetch`, `WebSocket`, `crypto`, `btoa`, and `atob`. Node tools can still use the SDK, but must provide browser-compatible globals when opening realtime connections.
14
14
 
15
- > **Server compatibility:** v5.2+ targets environments on release **v0.1.19 or later** (`cks-game-api >= v0.10.3`, `cks-management-api >= v0.1.70`). The destructive mutations send an `idempotencyKey` argument that older servers don't define. v6.1's `client.gameApps.deleteGrid` additionally requires release **v0.1.33+** (`cks-game-api >= v0.12.3`).
15
+ > **Server compatibility:** v5.2+ targets environments on release **v0.1.19 or later** (`cks-game-api >= v0.10.3`, `cks-management-api >= v0.1.70`). The destructive mutations send an `idempotencyKey` argument that older servers don't define. v6.1's `client.gameApps.deleteGrid` additionally requires release **v0.1.33+** (`cks-game-api >= v0.12.3`). The game-model **permission effects** fields (`permissionEffects` on `gameModel.upsertFunction`/`seed`, `permissionEffectsAppliedJson` on events) require a `cks-game-api` build with the `2026-07-17-model-permission-effects` migration; older servers reject queries/mutations that include them (omit the fields and everything else keeps working).
16
16
 
17
17
  ## Standalone builds and schema refresh
18
18
 
@@ -106,6 +106,7 @@ If `managementUrl` is omitted, the SDK falls back to `httpUrl` for backwards-com
106
106
  | `client.udp` | UDP proxy subscriptions + spatial mutations (`sendActorUpdate`, `sendVoxelUpdate`, `sendAudioPacket`, `sendTextPacket`, `sendClientEvent`). |
107
107
  | `client.realtime` | Connection status, manual `connect()` / `disconnect()`, `onStatus()` listener. |
108
108
  | `client.world(appId)` | Higher-level helpers for browser games (`actor.join`, `actor.sendState`, `actor.sendText`). |
109
+ | `client.kit(appId)` | Game Kit: ready-made mappings of game concepts onto the game model — `kit.inventory`, `kit.objects` (lockable doors/chests with custom permissions), `kit.npcs`, plus blueprint builders + `kit.deploy(...)` for the admin "load the rules" step. |
109
110
 
110
111
  **Studio-admin surface** (privileged; drive with a server-side / studio token, grouped under `client.admin`):
111
112
 
@@ -268,6 +269,45 @@ await actor.sendToActor(
268
269
 
269
270
  The world helpers are thin wrappers over `client.udp.*` with the appId pre-bound — convenient for browser games. Advanced callers can always use `client.udp.*` with the generated GraphQL input types directly.
270
271
 
272
+ ## Game Kit
273
+
274
+ `client.kit(appId)` maps traditional game concepts onto the abstract game
275
+ model + automations API. Studios **deploy blueprints** (the admin "load the
276
+ state/rules" step, requires `manage_apps`); game clients then use the typed
277
+ runtime helpers. Everything composes `client.gameModel` — no new server
278
+ surface.
279
+
280
+ ```ts
281
+ // Studio setup (admin context):
282
+ import { inventoryBlueprint, lockBlueprint, npcBlueprint } from '@crowdedkingdoms/crowdyjs';
283
+
284
+ await admin.kit(appId).deploy([
285
+ inventoryBlueprint(),
286
+ lockBlueprint({ objectTypeName: 'Door', authority: { kind: 'key' } }),
287
+ npcBlueprint({
288
+ behaviors: [{
289
+ name: 'npc-wander',
290
+ role: 'wanderer',
291
+ trigger: { intervalMs: 60000 },
292
+ mutations: [
293
+ { target: 'self', property: 'x', expression: 'self.x + rand_int(-2, 2)' },
294
+ { target: 'self', property: 'z', expression: 'self.z + rand_int(-2, 2)' },
295
+ ],
296
+ }],
297
+ }),
298
+ ]);
299
+
300
+ // Game client (player token):
301
+ const kit = game.kit(appId);
302
+ const bag = await kit.inventory.ensure(me.userId);
303
+ const result = await kit.objects.open(doorId, { keyId });
304
+ if (!result.success) console.warn('locked:', result.errorMessage);
305
+ ```
306
+
307
+ See the docs guides [Modeling game concepts](https://docs.crowdedkingdoms.com/game-api/modeling-game-concepts)
308
+ (the underlying model) and [Game Kit](https://docs.crowdedkingdoms.com/crowdyjs/game-kit)
309
+ (the SDK surface).
310
+
271
311
  ## Errors
272
312
 
273
313
  Transport and protocol failures throw structured error classes:
@@ -27,6 +27,7 @@ import { SubscriptionManager } from './subscriptions.js';
27
27
  import type { CrowdyLogger } from './logger.js';
28
28
  import type { TokenStore } from './session.js';
29
29
  import { WorldClient } from './world.js';
30
+ import { GameKitClient, type GameKitOptions } from './kit/index.js';
30
31
  import { AuthAPI } from './domains/auth.js';
31
32
  import { UsersAPI } from './domains/users.js';
32
33
  import { AppsAPI } from './domains/apps.js';
@@ -196,6 +197,20 @@ export declare class CrowdyClient {
196
197
  * @param appId - The app to scope realtime traffic to (BigInt as a decimal string).
197
198
  */
198
199
  world(appId: string): WorldClient;
200
+ /**
201
+ * App-scoped **Game Kit** facade over `client.gameModel`: high-level
202
+ * building blocks that map traditional game concepts onto Game Models +
203
+ * Automations — `kit.inventory` (bags/item stacks), `kit.objects` (lockable
204
+ * doors/chests with custom permissions), `kit.npcs` (server-driven NPCs),
205
+ * and the studio-side `kit.deploy(blueprints)` that loads the matching
206
+ * rules/state into the app (requires `manage_apps`). See
207
+ * {@link GameKitClient} and the "CrowdyJS → Game Kit" docs guide.
208
+ *
209
+ * @param appId - The app to scope model calls to (BigInt as a decimal string).
210
+ * @param options - Optional per-helper config when your blueprints use
211
+ * non-default type names/prefixes.
212
+ */
213
+ kit(appId: string, options?: GameKitOptions): GameKitClient;
199
214
  /** Closes the WebSocket and clears the in-memory auth token. */
200
215
  close(): void;
201
216
  }
@@ -1 +1 @@
1
- {"version":3,"file":"crowdy-client.d.ts","sourceRoot":"","sources":["../src/crowdy-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,E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,GAAE,kBAAuB,GAC9B,YAAY,CAEd"}
@@ -25,6 +25,7 @@ import { GraphQLClient } from './client.js';
25
25
  import { LbCookieStore } from './lb-cookie-store.js';
26
26
  import { SubscriptionManager } from './subscriptions.js';
27
27
  import { WorldClient } from './world.js';
28
+ import { GameKitClient } from './kit/index.js';
28
29
  import { AuthAPI } from './domains/auth.js';
29
30
  import { UsersAPI } from './domains/users.js';
30
31
  import { AppsAPI } from './domains/apps.js';
@@ -140,6 +141,22 @@ export class CrowdyClient {
140
141
  world(appId) {
141
142
  return new WorldClient(appId, this.udp);
142
143
  }
144
+ /**
145
+ * App-scoped **Game Kit** facade over `client.gameModel`: high-level
146
+ * building blocks that map traditional game concepts onto Game Models +
147
+ * Automations — `kit.inventory` (bags/item stacks), `kit.objects` (lockable
148
+ * doors/chests with custom permissions), `kit.npcs` (server-driven NPCs),
149
+ * and the studio-side `kit.deploy(blueprints)` that loads the matching
150
+ * rules/state into the app (requires `manage_apps`). See
151
+ * {@link GameKitClient} and the "CrowdyJS → Game Kit" docs guide.
152
+ *
153
+ * @param appId - The app to scope model calls to (BigInt as a decimal string).
154
+ * @param options - Optional per-helper config when your blueprints use
155
+ * non-default type names/prefixes.
156
+ */
157
+ kit(appId, options) {
158
+ return new GameKitClient(appId, this.gameModel, options);
159
+ }
143
160
  /** Closes the WebSocket and clears the in-memory auth token. */
144
161
  close() {
145
162
  this.realtime.close();
@@ -2039,6 +2039,19 @@ export type FunctionParamInput = {
2039
2039
  /** int | float | string | bool | array | object | container_ref */
2040
2040
  valueType: Scalars['String']['input'];
2041
2041
  };
2042
+ /** A declarative grid-permission effect the function applies TRANSACTIONALLY with its property mutations: grant or revoke runtime grid permissions (the same ACL Buddy enforces on movement/voxel writes) driven by game logic. Expressions are compiled server-side and evaluated in the invocation context (params plus the injected $caller_user_id / $self_owner_id / $session_id / $current_turn_user_id). If an effect fails, the whole invocation rolls back. Applied effects are recorded on the invocation event. */
2043
+ export type FunctionPermissionEffectInput = {
2044
+ /** 'grant' (upsert direct grants, optionally expiring) or 'revoke' (delete direct grants for the listed keys). */
2045
+ action: Scalars['String']['input'];
2046
+ /** Expression resolving the grid id (int) the permissions apply to, e.g. "self.grid_id". The grid must belong to the app. */
2047
+ gridIdExpression: Scalars['String']['input'];
2048
+ /** Runtime permission keys to grant/revoke (validated against the runtime_permissions catalog, e.g. 'access', 'teleport', 'update_voxel_data', 'use_voice_chat'). */
2049
+ permissionKeys: Array<Scalars['String']['input']>;
2050
+ /** Grant only: optional expression resolving a TTL in seconds (int > 0) after which the grant expires (rentals/leases), e.g. '86400'. Omit for a non-expiring grant. */
2051
+ ttlSecondsExpression?: InputMaybe<Scalars['String']['input']>;
2052
+ /** Expression resolving the target user id (int), e.g. "$caller_user_id" or "self.owner_user_id". */
2053
+ userExpression: Scalars['String']['input'];
2054
+ };
2042
2055
  /** Startup contract for browser game clients. Fetch this after login to initialize protocol/version checks and UDP proxy state in one round trip. */
2043
2056
  export type GameClientBootstrap = {
2044
2057
  __typename?: 'GameClientBootstrap';
@@ -2454,6 +2467,8 @@ export type GmEvent = {
2454
2467
  mutationsAppliedJson: Scalars['String']['output'];
2455
2468
  /** JSON object of params. */
2456
2469
  paramsJson: Scalars['String']['output'];
2470
+ /** JSON array of grid-permission effects this invocation applied (audit trail for model-driven grants/revokes): [{ action, permission_keys, user_id, grid_id, expires_at }]. */
2471
+ permissionEffectsAppliedJson: Scalars['String']['output'];
2457
2472
  /** JSON-encoded return value. */
2458
2473
  returnValueJson: Maybe<Scalars['String']['output']>;
2459
2474
  /** The self container id the function ran against. */
@@ -2496,6 +2511,8 @@ export type GmFunction = {
2496
2511
  notifications: Array<GmFunctionNotification>;
2497
2512
  /** Typed parameters the function accepts. */
2498
2513
  parameters: Array<GmFunctionParam>;
2514
+ /** Declarative grid-permission effects (grant/revoke runtime grid ACL rows) applied atomically with the function's mutations. */
2515
+ permissionEffects: Array<GmFunctionPermissionEffect>;
2499
2516
  /** Optional expression whose value becomes the invoke result. */
2500
2517
  returnExpression: Maybe<Scalars['String']['output']>;
2501
2518
  /** Optional declared return value type. */
@@ -2539,6 +2556,20 @@ export type GmFunctionParam = {
2539
2556
  /** Value type: int | float | string | bool | array | object | container_ref. */
2540
2557
  valueType: Scalars['String']['output'];
2541
2558
  };
2559
+ /** A declarative grid-permission effect applied transactionally with the function's mutations: grant or revoke runtime grid permissions (the ACL Buddy enforces) driven by game logic. */
2560
+ export type GmFunctionPermissionEffect = {
2561
+ __typename?: 'GmFunctionPermissionEffect';
2562
+ /** 'grant' or 'revoke'. */
2563
+ action: Scalars['String']['output'];
2564
+ /** The expression (source) resolving the grid id. */
2565
+ gridIdExpression: Scalars['String']['output'];
2566
+ /** Runtime permission keys granted/revoked. */
2567
+ permissionKeys: Array<Scalars['String']['output']>;
2568
+ /** Grant only: optional expression resolving a TTL in seconds. */
2569
+ ttlSecondsExpression: Maybe<Scalars['String']['output']>;
2570
+ /** The expression (source) resolving the target user id. */
2571
+ userExpression: Scalars['String']['output'];
2572
+ };
2542
2573
  /** The outcome of a gameModelInvoke call (return value, applied writes, and any error). */
2543
2574
  export type GmInvokeResult = {
2544
2575
  __typename?: 'GmInvokeResult';
@@ -5287,6 +5318,8 @@ export type SeedFunctionInput = {
5287
5318
  notifications?: InputMaybe<Array<FunctionNotificationInput>>;
5288
5319
  /** Typed parameters the function accepts. */
5289
5320
  parameters?: InputMaybe<Array<FunctionParamInput>>;
5321
+ /** Declarative grid-permission effects (grant/revoke runtime grid ACL rows) applied atomically with the function's mutations. Max 4 per function. */
5322
+ permissionEffects?: InputMaybe<Array<FunctionPermissionEffectInput>>;
5290
5323
  /** Optional expression whose value becomes the invoke result. */
5291
5324
  returnExpression?: InputMaybe<Scalars['String']['input']>;
5292
5325
  /** Optional declared return value type. */
@@ -6062,6 +6095,8 @@ export type UpsertFunctionInput = {
6062
6095
  notifications?: InputMaybe<Array<FunctionNotificationInput>>;
6063
6096
  /** Typed parameters the function accepts. */
6064
6097
  parameters?: InputMaybe<Array<FunctionParamInput>>;
6098
+ /** Declarative grid-permission effects (grant/revoke runtime grid ACL rows) applied atomically with the function's mutations. Max 4 per function. */
6099
+ permissionEffects?: InputMaybe<Array<FunctionPermissionEffectInput>>;
6065
6100
  /** Optional expression whose value becomes the invoke result. */
6066
6101
  returnExpression?: InputMaybe<Scalars['String']['input']>;
6067
6102
  /** Optional declared return value type. */
@@ -9647,6 +9682,7 @@ export type GameModelEventsQuery = {
9647
9682
  automationId: string | null;
9648
9683
  paramsJson: string;
9649
9684
  mutationsAppliedJson: string;
9685
+ permissionEffectsAppliedJson: string;
9650
9686
  returnValueJson: string | null;
9651
9687
  success: boolean;
9652
9688
  errorMessage: string | null;
@@ -9681,6 +9717,7 @@ export type GameModelEventsConnectionQuery = {
9681
9717
  automationId: string | null;
9682
9718
  paramsJson: string;
9683
9719
  mutationsAppliedJson: string;
9720
+ permissionEffectsAppliedJson: string;
9684
9721
  returnValueJson: string | null;
9685
9722
  success: boolean;
9686
9723
  errorMessage: string | null;
@@ -9734,6 +9771,14 @@ export type GmFunctionFieldsFragment = {
9734
9771
  expression: string;
9735
9772
  }>;
9736
9773
  }>;
9774
+ permissionEffects: Array<{
9775
+ __typename?: 'GmFunctionPermissionEffect';
9776
+ action: string;
9777
+ permissionKeys: Array<string>;
9778
+ userExpression: string;
9779
+ gridIdExpression: string;
9780
+ ttlSecondsExpression: string | null;
9781
+ }>;
9737
9782
  };
9738
9783
  export type GmPropertyDefFieldsFragment = {
9739
9784
  __typename?: 'GmPropertyDef';
@@ -9855,6 +9900,14 @@ export type GameModelUpsertFunctionMutation = {
9855
9900
  expression: string;
9856
9901
  }>;
9857
9902
  }>;
9903
+ permissionEffects: Array<{
9904
+ __typename?: 'GmFunctionPermissionEffect';
9905
+ action: string;
9906
+ permissionKeys: Array<string>;
9907
+ userExpression: string;
9908
+ gridIdExpression: string;
9909
+ ttlSecondsExpression: string | null;
9910
+ }>;
9858
9911
  };
9859
9912
  };
9860
9913
  export type GameModelDeleteFunctionMutationVariables = Exact<{
@@ -9959,6 +10012,14 @@ export type GameModelTypeSchemaQuery = {
9959
10012
  expression: string;
9960
10013
  }>;
9961
10014
  }>;
10015
+ permissionEffects: Array<{
10016
+ __typename?: 'GmFunctionPermissionEffect';
10017
+ action: string;
10018
+ permissionKeys: Array<string>;
10019
+ userExpression: string;
10020
+ gridIdExpression: string;
10021
+ ttlSecondsExpression: string | null;
10022
+ }>;
9962
10023
  }>;
9963
10024
  };
9964
10025
  };
@@ -10040,6 +10101,14 @@ export type GameModelFunctionQuery = {
10040
10101
  expression: string;
10041
10102
  }>;
10042
10103
  }>;
10104
+ permissionEffects: Array<{
10105
+ __typename?: 'GmFunctionPermissionEffect';
10106
+ action: string;
10107
+ permissionKeys: Array<string>;
10108
+ userExpression: string;
10109
+ gridIdExpression: string;
10110
+ ttlSecondsExpression: string | null;
10111
+ }>;
10043
10112
  };
10044
10113
  };
10045
10114
  export type GameModelFunctionsQueryVariables = Exact<{
@@ -10086,6 +10155,14 @@ export type GameModelFunctionsQuery = {
10086
10155
  expression: string;
10087
10156
  }>;
10088
10157
  }>;
10158
+ permissionEffects: Array<{
10159
+ __typename?: 'GmFunctionPermissionEffect';
10160
+ action: string;
10161
+ permissionKeys: Array<string>;
10162
+ userExpression: string;
10163
+ gridIdExpression: string;
10164
+ ttlSecondsExpression: string | null;
10165
+ }>;
10089
10166
  }>;
10090
10167
  };
10091
10168
  export type GameModelFeaturesQueryVariables = Exact<{