@crowdedkingdoms/crowdyjs 17.12.0-dev.1 → 17.14.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 (70) hide show
  1. package/MIGRATION.md +127 -0
  2. package/README.md +99 -4
  3. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  4. package/dist/crowdy-dsh/bridge.js +2 -0
  5. package/dist/crowdy-studio/controller.d.ts +64 -8
  6. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  7. package/dist/crowdy-studio/controller.js +345 -46
  8. package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
  9. package/dist/crowdy-studio/dom-shell.js +16 -9
  10. package/dist/crowdy-studio/embed/hud-layer.d.ts +2 -1
  11. package/dist/crowdy-studio/embed/hud-layer.d.ts.map +1 -1
  12. package/dist/crowdy-studio/embed/panel.d.ts +9 -6
  13. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  14. package/dist/crowdy-studio/embed/panel.js +4 -2
  15. package/dist/crowdy-studio/index.d.ts +2 -2
  16. package/dist/crowdy-studio/index.d.ts.map +1 -1
  17. package/dist/crowdy-studio/models.d.ts +1 -1
  18. package/dist/crowdy-studio/starter-projects.d.ts +22 -0
  19. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  20. package/dist/crowdy-studio/starter-projects.js +129 -5
  21. package/dist/domains/exec.d.ts +222 -20
  22. package/dist/domains/exec.d.ts.map +1 -1
  23. package/dist/domains/exec.js +215 -21
  24. package/dist/domains/marketplace.d.ts +15 -3
  25. package/dist/domains/marketplace.d.ts.map +1 -1
  26. package/dist/domains/marketplace.js +17 -3
  27. package/dist/errors.d.ts +3 -1
  28. package/dist/errors.d.ts.map +1 -1
  29. package/dist/generated/graphql.d.ts +422 -0
  30. package/dist/generated/graphql.d.ts.map +1 -1
  31. package/dist/generated/graphql.js +23 -11
  32. package/dist/grid-mods/exec-client-halves.d.ts +140 -0
  33. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -0
  34. package/dist/grid-mods/exec-client-halves.js +341 -0
  35. package/dist/grid-mods/grid-host-calls.d.ts +3 -1
  36. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  37. package/dist/grid-mods/grid-host-calls.js +3 -1
  38. package/dist/grid-mods/index.d.ts +1 -0
  39. package/dist/grid-mods/index.d.ts.map +1 -1
  40. package/dist/grid-mods/index.js +1 -0
  41. package/dist/grid-mods/mod-runtime.d.ts +10 -2
  42. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  43. package/dist/grid-mods/mod-runtime.js +2 -0
  44. package/dist/grid-scope.d.ts +1 -0
  45. package/dist/grid-scope.d.ts.map +1 -1
  46. package/dist/grid-scope.js +1 -0
  47. package/dist/index.d.ts +4 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +4 -3
  50. package/dist/kit/npcs.d.ts.map +1 -1
  51. package/dist/kit/social.d.ts.map +1 -1
  52. package/dist/live-coding/rust-analysis.js +13 -1
  53. package/dist/player-runtime/glue-runtime.d.ts +19 -6
  54. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  55. package/dist/player-runtime/glue-runtime.js +40 -16
  56. package/dist/player-runtime/player-code-broker.d.ts +29 -0
  57. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  58. package/dist/player-runtime/player-code-broker.js +41 -8
  59. package/dist/player-runtime/player-glue-worker.d.ts +2 -1
  60. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  61. package/dist/player-runtime/player-glue-worker.js +3 -1
  62. package/dist/stores/actors.d.ts +12 -2
  63. package/dist/stores/actors.d.ts.map +1 -1
  64. package/dist/stores/actors.js +43 -18
  65. package/dist/stores/chunks.d.ts +12 -0
  66. package/dist/stores/chunks.d.ts.map +1 -1
  67. package/dist/stores/chunks.js +112 -39
  68. package/dist/stores/durable.d.ts.map +1 -1
  69. package/dist/stores/durable.js +2 -1
  70. package/package.json +1 -1
@@ -0,0 +1,140 @@
1
+ import type { ExecAPI, ExecClientCapabilitySummary, ExecGridClientMod } from '../domains/exec.js';
2
+ import { type PlayerCodeBrokerOptions, type PlayerCodeGridBounds, type PlayerCodeHostCall, type PlayerCodePresentation } from '../player-runtime/player-code-broker.js';
3
+ /** The grid a player stands in: its id and chunk box. */
4
+ export type ExecClientHalvesGrid = PlayerCodeGridBounds & {
5
+ gridId: string;
6
+ };
7
+ /**
8
+ * One question for the player. `author`: trust every CLIENT half of `authorId` on the grid, at
9
+ * the hash of their union (`exec.trustAuthor`). `mod`: consent to one CLIENT half at its hash
10
+ * (`exec.consentClientMod`).
11
+ */
12
+ export interface ExecClientHalfPrompt {
13
+ kind: 'author' | 'mod';
14
+ gridId: string;
15
+ authorId: string;
16
+ /** What a yes consents to: the author's `authorCapabilityHash`, or the mod's `capabilityHash`. */
17
+ capabilityHash: string;
18
+ /** The summary to show: the author's union, or the one CLIENT half's. */
19
+ capabilitySummaryJson: string;
20
+ capabilitySummary: ExecClientCapabilitySummary | null;
21
+ /** The CLIENT halves a yes covers now. */
22
+ mods: readonly ExecGridClientMod[];
23
+ }
24
+ /**
25
+ * Why a CLIENT half stopped: no longer listed (`removed`), a new digest, capability hash or tick
26
+ * interval (`changed`), listed without the player's consent or trust (`unconsented`), refused by
27
+ * `filter` (`filtered`), the runner left the grid (`left-grid`) or was stopped (`stopped`), or
28
+ * the broker's circuit breaker tripped (`circuit-open`).
29
+ */
30
+ export type ExecClientHalfStopReason = 'removed' | 'changed' | 'unconsented' | 'filtered' | 'left-grid' | 'stopped' | 'circuit-open';
31
+ /** A consent, fetch or start that failed, and when that CLIENT half is tried again. */
32
+ export interface ExecClientHalfError {
33
+ mod: ExecGridClientMod;
34
+ stage: 'consent' | 'fetch' | 'start';
35
+ /**
36
+ * `not-found`: not served to the player now (every refusal of the artifact, and a trust while
37
+ * not standing in the grid); `rate-limited`: 12 fetches a minute per player and mod;
38
+ * `conflict`: the hash moved on; `refused`: the served module was, for bytes that differ from
39
+ * its digest, an unknown CLIENT ABI or a capability summary that does not parse; `failed`:
40
+ * anything else.
41
+ */
42
+ reason: 'not-found' | 'rate-limited' | 'conflict' | 'refused' | 'failed';
43
+ error: unknown;
44
+ /** When the runner fetches or starts it again (epoch ms); absent for a consent. */
45
+ retryAt?: number;
46
+ }
47
+ /** The part of `PlayerCodeBroker` the runner drives. */
48
+ export interface ExecClientHalfBroker {
49
+ start(artifact: ArrayBuffer): Promise<void>;
50
+ stop(): void;
51
+ }
52
+ export interface ExecClientHalvesOptions {
53
+ exec: Pick<ExecAPI, 'gridClientMods' | 'consentClientMod' | 'trustAuthor' | 'modClientArtifactBytes'>;
54
+ appId: string;
55
+ /** The platform glue worker (`@crowdedkingdoms/crowdyjs/player-glue-worker`), same origin. */
56
+ workerUrl: string | URL;
57
+ /**
58
+ * Answers the host calls a CLIENT half makes that the broker does not answer itself, for
59
+ * example with `createGridHostCalls` over the grid's scope.
60
+ */
61
+ onHostCall: (call: PlayerCodeHostCall, mod: ExecGridClientMod) => Promise<unknown>;
62
+ onPresentation?: (presentation: PlayerCodePresentation, mod: ExecGridClientMod) => void;
63
+ /**
64
+ * Asks the player about CLIENT halves they neither consented to nor trust the author of; true
65
+ * consents. Without it, only what the player already agreed to runs. A declined question is
66
+ * not asked again on this grid until its hash changes.
67
+ */
68
+ confirm?: (prompt: ExecClientHalfPrompt) => boolean | Promise<boolean>;
69
+ /** `author` (the default): one question per author; `mod`: one per CLIENT half. */
70
+ ask?: 'author' | 'mod';
71
+ /** Leaves out the CLIENT halves it returns false for, e.g. the one Crowdy Studio previews. */
72
+ filter?: (mod: ExecGridClientMod) => boolean;
73
+ onStarted?: (mod: ExecGridClientMod) => void;
74
+ onStopped?: (mod: ExecGridClientMod, reason: ExecClientHalfStopReason) => void;
75
+ onError?: (error: ExecClientHalfError) => void;
76
+ /** How long a CLIENT half waits after `NOT_FOUND` before it is fetched again. Default 15 s. */
77
+ notFoundRetryMs?: number;
78
+ /** How long after `RATE_LIMITED`. Default 60 s, the limit's window. */
79
+ rateLimitedRetryMs?: number;
80
+ /** How long after any other failure, refused bytes included. Default 60 s. */
81
+ failedRetryMs?: number;
82
+ /** Modules kept by digest, across grids. Default 16. */
83
+ cacheSize?: number;
84
+ now?: () => number;
85
+ brokerFactory?: (options: PlayerCodeBrokerOptions) => ExecClientHalfBroker;
86
+ }
87
+ /**
88
+ * Runs the CLIENT halves of ck-exec mods that the grid a player stands in serves, the way a game
89
+ * should: tell it the grid ({@link enterGrid}) and call {@link refresh} on a cadence (every 10 s
90
+ * or so). Each refresh lists the grid's CLIENT halves (`exec.gridClientMods`), stops the workers
91
+ * whose mod is gone or whose `modId`, `digest`, `capabilityHash` or tick interval changed, asks
92
+ * the player once per author (or per CLIENT half) about the rest, fetches each consented one
93
+ * (`exec.modClientArtifactBytes`, which refuses bytes that differ from their digest) and runs it
94
+ * in a `PlayerCodeBroker` with `engine: 'ck-exec'`, its fuel budget and tick interval, bounded
95
+ * to the host calls of the capability summary the player consented to.
96
+ *
97
+ * Modules are cached by digest, since a digest never changes its bytes and the artifact query
98
+ * allows 12 fetches a minute per player and mod. A cached module starts without a fetch, so the
99
+ * serve checks that query makes (`run_client_code`, standing in the grid) are those of the fetch
100
+ * that filled the cache; consent and trust are the listing's, on every refresh.
101
+ *
102
+ * `NOT_FOUND` (not served to this player now) and `RATE_LIMITED` hold that CLIENT half back for
103
+ * a while instead of fetching on every refresh. The legacy grid-attached client mods
104
+ * (`marketplace.gridClientMods`) are not this runner's.
105
+ */
106
+ export declare class ExecClientHalves {
107
+ private readonly options;
108
+ private grid;
109
+ private generation;
110
+ private readonly workers;
111
+ private readonly cache;
112
+ private readonly retryAt;
113
+ private readonly declined;
114
+ private readonly approved;
115
+ private inFlight;
116
+ constructor(options: ExecClientHalvesOptions);
117
+ /** The grid the player stands in, or null. Any change stops every CLIENT half of the old one. */
118
+ enterGrid(grid: ExecClientHalvesGrid | null): void;
119
+ /** The CLIENT halves running now. */
120
+ get running(): readonly ExecGridClientMod[];
121
+ /**
122
+ * One reconcile of the current grid; a call while one runs for the same grid joins it. Rejects
123
+ * when the grid's CLIENT halves cannot be listed, and what runs keeps running.
124
+ */
125
+ refresh(): Promise<void>;
126
+ /** Stops every CLIENT half and leaves the grid; the module cache stays. */
127
+ stop(): void;
128
+ private reconcile;
129
+ private stopStale;
130
+ /** Asks about what the player has not agreed to; true when a consent or trust went through. */
131
+ private askAbout;
132
+ private start;
133
+ private fail;
134
+ private remember;
135
+ private wanted;
136
+ private stopWorker;
137
+ private stopAll;
138
+ private now;
139
+ }
140
+ //# sourceMappingURL=exec-client-halves.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-client-halves.d.ts","sourceRoot":"","sources":["../../src/grid-mods/exec-client-halves.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,yCAAyC,CAAC;AAEjD,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,kGAAkG;IAClG,cAAc,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACtD,0CAA0C;IAC1C,IAAI,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACpC;AAED;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAChC,SAAS,GACT,SAAS,GACT,aAAa,GACb,UAAU,GACV,WAA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AAS;IAiBjB,+FAA+F;YACjF,QAAQ;YA8ER,KAAK;IAkFnB,OAAO,CAAC,IAAI;IAaZ,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,GAAG;CAGZ"}
@@ -0,0 +1,341 @@
1
+ import { CrowdyGraphQLError, CrowdyProtocolError } from '../errors.js';
2
+ import { PlayerCodeBroker, } from '../player-runtime/player-code-broker.js';
3
+ const identity = (m) => `${m.modId}\u0000${m.digest}\u0000${m.capabilityHash}\u0000${m.tickIntervalMs}`;
4
+ function refusal(error) {
5
+ if (error instanceof CrowdyProtocolError)
6
+ return 'refused';
7
+ if (error instanceof CrowdyGraphQLError) {
8
+ if (error.code === 'NOT_FOUND')
9
+ return 'not-found';
10
+ if (error.code === 'RATE_LIMITED')
11
+ return 'rate-limited';
12
+ if (error.code === 'CONFLICT')
13
+ return 'conflict';
14
+ }
15
+ return 'failed';
16
+ }
17
+ /**
18
+ * Runs the CLIENT halves of ck-exec mods that the grid a player stands in serves, the way a game
19
+ * should: tell it the grid ({@link enterGrid}) and call {@link refresh} on a cadence (every 10 s
20
+ * or so). Each refresh lists the grid's CLIENT halves (`exec.gridClientMods`), stops the workers
21
+ * whose mod is gone or whose `modId`, `digest`, `capabilityHash` or tick interval changed, asks
22
+ * the player once per author (or per CLIENT half) about the rest, fetches each consented one
23
+ * (`exec.modClientArtifactBytes`, which refuses bytes that differ from their digest) and runs it
24
+ * in a `PlayerCodeBroker` with `engine: 'ck-exec'`, its fuel budget and tick interval, bounded
25
+ * to the host calls of the capability summary the player consented to.
26
+ *
27
+ * Modules are cached by digest, since a digest never changes its bytes and the artifact query
28
+ * allows 12 fetches a minute per player and mod. A cached module starts without a fetch, so the
29
+ * serve checks that query makes (`run_client_code`, standing in the grid) are those of the fetch
30
+ * that filled the cache; consent and trust are the listing's, on every refresh.
31
+ *
32
+ * `NOT_FOUND` (not served to this player now) and `RATE_LIMITED` hold that CLIENT half back for
33
+ * a while instead of fetching on every refresh. The legacy grid-attached client mods
34
+ * (`marketplace.gridClientMods`) are not this runner's.
35
+ */
36
+ export class ExecClientHalves {
37
+ constructor(options) {
38
+ this.options = options;
39
+ this.grid = null;
40
+ this.generation = 0;
41
+ this.workers = new Map();
42
+ this.cache = new Map();
43
+ this.retryAt = new Map();
44
+ this.declined = new Set();
45
+ this.approved = new Set();
46
+ this.inFlight = null;
47
+ }
48
+ /** The grid the player stands in, or null. Any change stops every CLIENT half of the old one. */
49
+ enterGrid(grid) {
50
+ if (sameGrid(this.grid, grid))
51
+ return;
52
+ this.stopAll('left-grid');
53
+ this.grid = grid ? { ...grid } : null;
54
+ this.generation++;
55
+ this.declined.clear();
56
+ this.approved.clear();
57
+ }
58
+ /** The CLIENT halves running now. */
59
+ get running() {
60
+ return [...this.workers.values()].filter((w) => w.started).map((w) => w.mod);
61
+ }
62
+ /**
63
+ * One reconcile of the current grid; a call while one runs for the same grid joins it. Rejects
64
+ * when the grid's CLIENT halves cannot be listed, and what runs keeps running.
65
+ */
66
+ refresh() {
67
+ if (this.inFlight?.generation === this.generation)
68
+ return this.inFlight.done;
69
+ const generation = this.generation;
70
+ const done = this.reconcile(generation).finally(() => {
71
+ if (this.inFlight?.done === done)
72
+ this.inFlight = null;
73
+ });
74
+ this.inFlight = { generation, done };
75
+ return done;
76
+ }
77
+ /** Stops every CLIENT half and leaves the grid; the module cache stays. */
78
+ stop() {
79
+ this.stopAll('stopped');
80
+ this.grid = null;
81
+ this.generation++;
82
+ this.declined.clear();
83
+ this.approved.clear();
84
+ }
85
+ async reconcile(generation) {
86
+ const grid = this.grid;
87
+ if (!grid)
88
+ return;
89
+ const { exec, appId } = this.options;
90
+ const current = () => generation === this.generation;
91
+ let listed = await exec.gridClientMods(appId, grid.gridId);
92
+ if (!current())
93
+ return;
94
+ this.stopStale(listed);
95
+ if (await this.askAbout(listed, grid, current)) {
96
+ if (!current())
97
+ return;
98
+ listed = await exec.gridClientMods(appId, grid.gridId);
99
+ if (!current())
100
+ return;
101
+ this.stopStale(listed);
102
+ }
103
+ for (const mod of listed) {
104
+ if (!current())
105
+ return;
106
+ if (!this.wanted(mod) || !(mod.callerConsented || mod.callerTrustsAuthor))
107
+ continue;
108
+ if (this.workers.has(mod.modId))
109
+ continue;
110
+ if ((this.retryAt.get(identity(mod)) ?? 0) > this.now())
111
+ continue;
112
+ await this.start(mod, grid, current);
113
+ }
114
+ }
115
+ stopStale(listed) {
116
+ const byId = new Map(listed.map((m) => [m.modId, m]));
117
+ for (const [modId, worker] of [...this.workers]) {
118
+ const next = byId.get(modId);
119
+ const reason = !next
120
+ ? 'removed'
121
+ : identity(next) !== identity(worker.mod)
122
+ ? 'changed'
123
+ : !this.wanted(next)
124
+ ? 'filtered'
125
+ : !(next.callerConsented || next.callerTrustsAuthor)
126
+ ? 'unconsented'
127
+ : null;
128
+ if (reason)
129
+ this.stopWorker(modId, reason);
130
+ }
131
+ }
132
+ /** Asks about what the player has not agreed to; true when a consent or trust went through. */
133
+ async askAbout(listed, grid, current) {
134
+ const pending = listed.filter((m) => this.wanted(m) && !m.callerConsented && !m.callerTrustsAuthor);
135
+ if (pending.length === 0)
136
+ return false;
137
+ const prompts = [];
138
+ if ((this.options.ask ?? 'author') === 'author') {
139
+ for (const authorId of new Set(pending.map((m) => m.authorId))) {
140
+ const theirs = listed.filter((m) => m.authorId === authorId);
141
+ const [first] = theirs;
142
+ prompts.push({
143
+ key: `author\u0000${authorId}\u0000${first.authorCapabilityHash}`,
144
+ prompt: {
145
+ kind: 'author',
146
+ gridId: grid.gridId,
147
+ authorId,
148
+ capabilityHash: first.authorCapabilityHash,
149
+ capabilitySummaryJson: first.authorCapabilitySummaryJson,
150
+ capabilitySummary: first.authorCapabilitySummary,
151
+ mods: theirs,
152
+ },
153
+ });
154
+ }
155
+ }
156
+ else {
157
+ for (const mod of pending) {
158
+ prompts.push({
159
+ key: `mod\u0000${mod.modId}\u0000${mod.capabilityHash}`,
160
+ prompt: {
161
+ kind: 'mod',
162
+ gridId: grid.gridId,
163
+ authorId: mod.authorId,
164
+ capabilityHash: mod.capabilityHash,
165
+ capabilitySummaryJson: mod.capabilitySummaryJson,
166
+ capabilitySummary: mod.capabilitySummary,
167
+ mods: [mod],
168
+ },
169
+ });
170
+ }
171
+ }
172
+ let agreed = false;
173
+ for (const { key, prompt } of prompts) {
174
+ if (!current())
175
+ return agreed;
176
+ if (this.declined.has(key))
177
+ continue;
178
+ if (!this.approved.has(key)) {
179
+ if (!this.options.confirm)
180
+ continue;
181
+ const yes = await this.options.confirm(prompt);
182
+ if (!current())
183
+ return agreed;
184
+ if (!yes) {
185
+ this.declined.add(key);
186
+ continue;
187
+ }
188
+ // Kept until it goes through: a trust refused while the player's presence is not yet
189
+ // registered is retried on the next refresh without asking again.
190
+ this.approved.add(key);
191
+ }
192
+ try {
193
+ const { exec, appId } = this.options;
194
+ if (prompt.kind === 'author') {
195
+ await exec.trustAuthor(appId, grid.gridId, prompt.authorId, prompt.capabilityHash);
196
+ }
197
+ else {
198
+ await exec.consentClientMod(appId, prompt.mods[0].modId, prompt.capabilityHash);
199
+ }
200
+ this.approved.delete(key);
201
+ agreed = true;
202
+ }
203
+ catch (error) {
204
+ const reason = refusal(error);
205
+ // The hash moved on: the next listing brings the new one, and a new question.
206
+ if (reason === 'conflict')
207
+ this.approved.delete(key);
208
+ this.options.onError?.({ mod: prompt.mods[0], stage: 'consent', reason, error });
209
+ }
210
+ }
211
+ return agreed;
212
+ }
213
+ async start(mod, grid, current) {
214
+ // What the player consented to, and what the served artifact itself lists, bound the
215
+ // module's host calls in the broker.
216
+ const consented = mod.capabilitySummary?.hostFunctions;
217
+ if (!Array.isArray(consented)) {
218
+ this.fail(mod, 'start', new CrowdyProtocolError({
219
+ message: `CLIENT half of mod ${mod.modId}: its capability summary does not parse`,
220
+ }));
221
+ return;
222
+ }
223
+ let module = this.cache.get(mod.digest);
224
+ if (module) {
225
+ this.cache.delete(mod.digest);
226
+ this.cache.set(mod.digest, module);
227
+ }
228
+ else {
229
+ try {
230
+ const a = await this.options.exec.modClientArtifactBytes(this.options.appId, mod.modId);
231
+ module = {
232
+ bytes: a.bytes,
233
+ fuelPerDispatch: a.fuelPerDispatch,
234
+ hostFunctions: a.capabilitySummary.hostFunctions,
235
+ };
236
+ this.remember(a.digest, module);
237
+ if (!current())
238
+ return;
239
+ // Changed between the listing and the fetch: the next listing starts the new one.
240
+ if (a.digest !== mod.digest ||
241
+ a.capabilityHash !== mod.capabilityHash ||
242
+ a.tickIntervalMs !== mod.tickIntervalMs) {
243
+ return;
244
+ }
245
+ }
246
+ catch (error) {
247
+ if (!current())
248
+ return;
249
+ this.fail(mod, 'fetch', error);
250
+ return;
251
+ }
252
+ }
253
+ const served = module.hostFunctions;
254
+ const broker = (this.options.brokerFactory ?? ((o) => new PlayerCodeBroker(o)))({
255
+ engine: 'ck-exec',
256
+ workerUrl: this.options.workerUrl,
257
+ grid: { low: grid.low, high: grid.high, gridId: grid.gridId },
258
+ moduleName: mod.name,
259
+ artifactHash: mod.digest,
260
+ fuelPerDispatch: module.fuelPerDispatch,
261
+ tickIntervalMs: mod.tickIntervalMs,
262
+ consentedHostCalls: consented.filter((fn) => served.includes(fn)),
263
+ onHostCall: (call) => this.options.onHostCall(call, mod),
264
+ onPresentation: (presentation) => this.options.onPresentation?.(presentation, mod),
265
+ onCircuitOpen: () => {
266
+ if (this.workers.get(mod.modId)?.broker !== broker)
267
+ return;
268
+ this.retryAt.set(identity(mod), this.now() + (this.options.failedRetryMs ?? 60000));
269
+ this.stopWorker(mod.modId, 'circuit-open');
270
+ },
271
+ });
272
+ const worker = { mod, broker, started: false };
273
+ this.workers.set(mod.modId, worker);
274
+ try {
275
+ await broker.start(module.bytes);
276
+ }
277
+ catch (error) {
278
+ if (this.workers.get(mod.modId) !== worker)
279
+ return;
280
+ this.workers.delete(mod.modId);
281
+ broker.stop();
282
+ if (current())
283
+ this.fail(mod, 'start', error);
284
+ return;
285
+ }
286
+ if (this.workers.get(mod.modId) !== worker)
287
+ return;
288
+ worker.started = true;
289
+ this.options.onStarted?.(mod);
290
+ }
291
+ fail(mod, stage, error) {
292
+ const reason = refusal(error);
293
+ const wait = reason === 'not-found'
294
+ ? (this.options.notFoundRetryMs ?? 15000)
295
+ : reason === 'rate-limited'
296
+ ? (this.options.rateLimitedRetryMs ?? 60000)
297
+ : (this.options.failedRetryMs ?? 60000);
298
+ const retryAt = this.now() + wait;
299
+ this.retryAt.set(identity(mod), retryAt);
300
+ this.options.onError?.({ mod, stage, reason, error, retryAt });
301
+ }
302
+ remember(digest, module) {
303
+ this.cache.set(digest, module);
304
+ const limit = Math.max(1, this.options.cacheSize ?? 16);
305
+ for (const oldest of this.cache.keys()) {
306
+ if (this.cache.size <= limit)
307
+ break;
308
+ this.cache.delete(oldest);
309
+ }
310
+ }
311
+ wanted(mod) {
312
+ return this.options.filter ? this.options.filter(mod) : true;
313
+ }
314
+ stopWorker(modId, reason) {
315
+ const worker = this.workers.get(modId);
316
+ if (!worker)
317
+ return;
318
+ this.workers.delete(modId);
319
+ worker.broker.stop();
320
+ if (worker.started)
321
+ this.options.onStopped?.(worker.mod, reason);
322
+ }
323
+ stopAll(reason) {
324
+ for (const modId of [...this.workers.keys()])
325
+ this.stopWorker(modId, reason);
326
+ }
327
+ now() {
328
+ return (this.options.now ?? Date.now)();
329
+ }
330
+ }
331
+ function sameGrid(a, b) {
332
+ if (!a || !b)
333
+ return a === b;
334
+ return (a.gridId === b.gridId &&
335
+ a.low.x === b.low.x &&
336
+ a.low.y === b.low.y &&
337
+ a.low.z === b.low.z &&
338
+ a.high.x === b.high.x &&
339
+ a.high.y === b.high.y &&
340
+ a.high.z === b.high.z);
341
+ }
@@ -64,7 +64,9 @@ export declare class GridHostCallRefused extends Error {
64
64
  * through ordinary CrowdyJS confined to one grid (DN-10 §4). Hand the result
65
65
  * to `PlayerCodeBroker({ onHostCall })`; the broker has already applied the
66
66
  * allowlist, rate caps and chunk clamps, and answers `grid_info`, `emit_event`,
67
- * `hud_set` and `overlay_draw` itself.
67
+ * `hud_set` and `overlay_draw` itself. A ck-exec CLIENT half (`engine:
68
+ * 'ck-exec'`) reaches only the crowdy-client-sdk calls: the model and sessions
69
+ * cases below serve legacy CLIENT modules until 18.0.
68
70
  */
69
71
  export declare function createGridHostCalls(options: GridHostCallsOptions): (call: PlayerCodeHostCall) => Promise<unknown>;
70
72
  //# sourceMappingURL=grid-host-calls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grid-host-calls.d.ts","sourceRoot":"","sources":["../../src/grid-mods/grid-host-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;QAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACtF,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,CAAC,KAAK,EAAE;QACf,KAAK,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,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F,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,sEAAsE;AACtE,qBAAa,mBAAoB,SAAQ,KAAK;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,MAAM,SAA+B;CAIvE;AAID;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,OAAO,CAAC,CA+KhD"}
@@ -12,7 +12,9 @@ const SPATIAL_KINDS = new Set(['actor', 'client_event', 'server_event', 'text'])
12
12
  * through ordinary CrowdyJS confined to one grid (DN-10 §4). Hand the result
13
13
  * to `PlayerCodeBroker({ onHostCall })`; the broker has already applied the
14
14
  * allowlist, rate caps and chunk clamps, and answers `grid_info`, `emit_event`,
15
- * `hud_set` and `overlay_draw` itself.
15
+ * `hud_set` and `overlay_draw` itself. A ck-exec CLIENT half (`engine:
16
+ * 'ck-exec'`) reaches only the crowdy-client-sdk calls: the model and sessions
17
+ * cases below serve legacy CLIENT modules until 18.0.
16
18
  */
17
19
  export function createGridHostCalls(options) {
18
20
  const { scope, client, local } = options;
@@ -1,3 +1,4 @@
1
1
  export { createGridHostCalls, GridHostCallRefused, type GridHostCallsOptions, type GridHostLocal, } from './grid-host-calls.js';
2
2
  export { startGridMod, type GridModSpec, type WasmGridModSpec, type ProgramGridModSpec, type RunningGridMod, type StartGridModOptions, } from './mod-runtime.js';
3
+ export { ExecClientHalves, type ExecClientHalvesGrid, type ExecClientHalvesOptions, type ExecClientHalfBroker, type ExecClientHalfError, type ExecClientHalfPrompt, type ExecClientHalfStopReason, } from './exec-client-halves.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grid-mods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grid-mods/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,yBAAyB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { createGridHostCalls, GridHostCallRefused, } from './grid-host-calls.js';
2
2
  export { startGridMod, } from './mod-runtime.js';
3
+ export { ExecClientHalves, } from './exec-client-halves.js';
@@ -1,8 +1,12 @@
1
- import { type PlayerCodePresentation } from '../player-runtime/player-code-broker.js';
1
+ import { type PlayerCodeEngine, type PlayerCodePresentation } from '../player-runtime/player-code-broker.js';
2
2
  import type { GridProgramPort } from '../grid-program/protocol.js';
3
3
  import type { GridScope } from '../grid-scope.js';
4
4
  import { type GridHostCallsOptions, type GridHostLocal } from './grid-host-calls.js';
5
- /** A Rust CLIENT mod: platform-built WASM run in the tokenless glue worker. */
5
+ /**
6
+ * A Rust CLIENT mod: platform-built WASM run in the tokenless glue worker. A ck-exec mod's
7
+ * CLIENT half is `engine: 'ck-exec'` with the `digest`, `fuelPerDispatch`, `tickIntervalMs` and
8
+ * summary host calls of `exec.modClientArtifactBytes` (`ExecClientHalves` runs a whole grid's).
9
+ */
6
10
  export interface WasmGridModSpec {
7
11
  kind: 'wasm';
8
12
  moduleName: string;
@@ -10,6 +14,10 @@ export interface WasmGridModSpec {
10
14
  artifactHash?: string;
11
15
  fuelPerDispatch?: bigint;
12
16
  tickIntervalMs?: number;
17
+ /** Default `'player-compute'`, a legacy CLIENT module. */
18
+ engine?: PlayerCodeEngine;
19
+ /** A CLIENT half's `capabilitySummary.hostFunctions`; required with `engine: 'ck-exec'`. */
20
+ consentedHostCalls?: readonly string[];
13
21
  /** The platform glue worker URL (`@crowdedkingdoms/crowdyjs/player-glue-worker`). */
14
22
  workerUrl: string | URL;
15
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mod-runtime.d.ts","sourceRoot":"","sources":["../../src/grid-mods/mod-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAE9B,+EAA+E;AAC/E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;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AK,IAAI,CAAC;IAChE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,cAAc,CAAC,CA6CzB"}
@@ -15,6 +15,8 @@ export async function startGridMod(options) {
15
15
  const box = scope.bounds;
16
16
  if (spec.kind === 'wasm') {
17
17
  const broker = new PlayerCodeBroker({
18
+ engine: spec.engine,
19
+ consentedHostCalls: spec.consentedHostCalls,
18
20
  workerUrl: spec.workerUrl,
19
21
  grid: { low: box.low, high: box.high, gridId: scope.gridId },
20
22
  moduleName: spec.moduleName,
@@ -260,6 +260,7 @@ export declare class GridScope {
260
260
  fuelUsed: string;
261
261
  durationUs: number;
262
262
  }>;
263
+ /** @deprecated Superseded by `client.exec.gridClientMods(appId, gridId)`; removed in 18.0. */
263
264
  clientMods: () => Promise<{
264
265
  __typename?: "GridClientMod";
265
266
  attachmentId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"grid-scope.d.ts","sourceRoot":"","sources":["../src/grid-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C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EACpD,OAAO,GAAG,QAAQ,CACnB;;;;;;;;;;;;;qBAQM,IAAI,CACT,uCAAuC,CAAC,OAAO,CAAC,EAChD,OAAO,GAAG,QAAQ,CACnB;;;;;;;;;;;;;8BAOmB,MAAM;MAM5B;IAEF,2DAA2D;IAC3D,QAAQ,CAAC,OAAO;wBAEL,IAAI,CAAC,oCAAoC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;6BAO3D,MAAM,cAAc,MAAM,WAAW,OAAO;;;;;;;QAQjE,8FAA8F;;;;;;;;;;;;;;;;;;;;;MAM9F;IAEF;;;;OAIG;IACH,QAAQ,CAAC,IAAI;6BACU,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;6BAIvD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;sBAI9D,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;6BAI/C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;MAI5E;CACH"}
@@ -101,6 +101,7 @@ export class GridScope {
101
101
  exportName,
102
102
  ...(params !== undefined ? { paramsJson: JSON.stringify(params) } : {}),
103
103
  }),
104
+ /** @deprecated Superseded by `client.exec.gridClientMods(appId, gridId)`; removed in 18.0. */
104
105
  clientMods: () => this.clients.marketplace.gridClientMods({
105
106
  appId: this.appId,
106
107
  gridId: this.gridId,