@kradle/challenges-sdk 0.12.0 → 0.13.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 (85) hide show
  1. package/CHANGELOG.md +67 -1
  2. package/LLM_README.md +285 -192
  3. package/MIGRATION-0.13.md +109 -0
  4. package/README.md +97 -88
  5. package/dist/engine.d.ts +8 -0
  6. package/dist/engine.d.ts.map +1 -0
  7. package/dist/engine.js +17 -0
  8. package/dist/engine.js.map +1 -0
  9. package/dist/index.d.ts +19 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +42 -16
  12. package/dist/index.js.map +1 -1
  13. package/dist/runtime/builder.d.ts +32 -0
  14. package/dist/runtime/builder.d.ts.map +1 -0
  15. package/dist/runtime/builder.js +357 -0
  16. package/dist/runtime/builder.js.map +1 -0
  17. package/dist/runtime/errors.d.ts +61 -0
  18. package/dist/runtime/errors.d.ts.map +1 -0
  19. package/dist/runtime/errors.js +71 -0
  20. package/dist/runtime/errors.js.map +1 -0
  21. package/dist/runtime/reducer.d.ts +205 -0
  22. package/dist/runtime/reducer.d.ts.map +1 -0
  23. package/dist/runtime/reducer.js +2025 -0
  24. package/dist/runtime/reducer.js.map +1 -0
  25. package/dist/runtime/rules.d.ts +29 -0
  26. package/dist/runtime/rules.d.ts.map +1 -0
  27. package/dist/runtime/rules.js +23 -0
  28. package/dist/runtime/rules.js.map +1 -0
  29. package/dist/runtime/sandbox.d.ts +2 -1
  30. package/dist/runtime/sandbox.d.ts.map +1 -1
  31. package/dist/runtime/sandbox.js +7 -4
  32. package/dist/runtime/sandbox.js.map +1 -1
  33. package/dist/runtime/time.d.ts +33 -0
  34. package/dist/runtime/time.d.ts.map +1 -0
  35. package/dist/runtime/time.js +53 -0
  36. package/dist/runtime/time.js.map +1 -0
  37. package/dist/runtime/types.d.ts +963 -0
  38. package/dist/runtime/types.d.ts.map +1 -0
  39. package/dist/runtime/types.js +25 -0
  40. package/dist/runtime/types.js.map +1 -0
  41. package/dist/runtime/wire.d.ts +858 -0
  42. package/dist/runtime/wire.d.ts.map +1 -0
  43. package/dist/runtime/wire.js +28 -0
  44. package/dist/runtime/wire.js.map +1 -0
  45. package/dist/runtime/world.d.ts +58 -3
  46. package/dist/runtime/world.d.ts.map +1 -1
  47. package/dist/runtime/world.js +12 -0
  48. package/dist/runtime/world.js.map +1 -1
  49. package/dist/structures.d.ts +119 -0
  50. package/dist/structures.d.ts.map +1 -0
  51. package/dist/structures.js +279 -0
  52. package/dist/structures.js.map +1 -0
  53. package/dist/test/harness.d.ts +133 -29
  54. package/dist/test/harness.d.ts.map +1 -1
  55. package/dist/test/harness.js +191 -66
  56. package/dist/test/harness.js.map +1 -1
  57. package/dist/test/helpers.d.ts +3 -2
  58. package/dist/test/helpers.d.ts.map +1 -1
  59. package/dist/test/helpers.js +2 -2
  60. package/dist/test/helpers.js.map +1 -1
  61. package/package.json +30 -7
  62. package/dist/runtime/examples/capture-the-flag.d.ts +0 -33
  63. package/dist/runtime/examples/capture-the-flag.d.ts.map +0 -1
  64. package/dist/runtime/examples/capture-the-flag.js +0 -79
  65. package/dist/runtime/examples/capture-the-flag.js.map +0 -1
  66. package/dist/runtime/examples/climb.d.ts +0 -34
  67. package/dist/runtime/examples/climb.d.ts.map +0 -1
  68. package/dist/runtime/examples/climb.js +0 -54
  69. package/dist/runtime/examples/climb.js.map +0 -1
  70. package/dist/runtime/examples/four-bridges.d.ts +0 -107
  71. package/dist/runtime/examples/four-bridges.d.ts.map +0 -1
  72. package/dist/runtime/examples/four-bridges.js +0 -294
  73. package/dist/runtime/examples/four-bridges.js.map +0 -1
  74. package/dist/runtime/examples/herding.d.ts +0 -59
  75. package/dist/runtime/examples/herding.d.ts.map +0 -1
  76. package/dist/runtime/examples/herding.js +0 -181
  77. package/dist/runtime/examples/herding.js.map +0 -1
  78. package/dist/runtime/examples/skywars.d.ts +0 -116
  79. package/dist/runtime/examples/skywars.d.ts.map +0 -1
  80. package/dist/runtime/examples/skywars.js +0 -253
  81. package/dist/runtime/examples/skywars.js.map +0 -1
  82. package/dist/runtime/sdk.d.ts +0 -1038
  83. package/dist/runtime/sdk.d.ts.map +0 -1
  84. package/dist/runtime/sdk.js +0 -1271
  85. package/dist/runtime/sdk.js.map +0 -1
@@ -0,0 +1,858 @@
1
+ import type { ChunkMessage, EntityMove, EquipmentChange } from "./world.js";
2
+ /** A position in the world: block coordinates when integer; a player's position has decimals. */
3
+ export type Vec3 = {
4
+ /** East. */
5
+ x: number;
6
+ /** Up. */
7
+ y: number;
8
+ /** South. */
9
+ z: number;
10
+ };
11
+ /** Block coordinates, both corners inclusive. A player is in a box when the block at their feet is inside. */
12
+ export type Box = {
13
+ /** One corner. */
14
+ from: Vec3;
15
+ /** The opposite corner. Either corner may hold the smaller coordinates. */
16
+ to: Vec3;
17
+ };
18
+ /** A JSON value: what the state, the log data and the custom events carry. */
19
+ export type Json = null | boolean | number | string | Json[]
20
+ /** An object of JSON values. */
21
+ | {
22
+ [key: string]: Json;
23
+ };
24
+ /** A block id (`minecraft:oak_fence`) or a block state string (`minecraft:oak_fence[north=true]`). */
25
+ export type BlockId = `minecraft:${string}`;
26
+ /** An item id: `minecraft:diamond`. */
27
+ export type ItemId = `minecraft:${string}`;
28
+ /** An entity type id: `minecraft:pig`. */
29
+ export type EntityTypeId = `minecraft:${string}`;
30
+ /** A status effect id: `minecraft:speed`. */
31
+ export type EffectId = `minecraft:${string}`;
32
+ /** A game mode, as `/gamemode` names it. */
33
+ export type GameMode = "survival" | "creative" | "adventure" | "spectator";
34
+ /** One entry of the run's roster, as `run_started` lists them. */
35
+ export type Participant = {
36
+ /** The player's name, unique in the run. */
37
+ name: string;
38
+ /** The role id the run assigned. */
39
+ role: string;
40
+ /** `true` for a human; absent or `false` for an agent. */
41
+ human?: boolean;
42
+ };
43
+ /**
44
+ * A tagged entity the world carries (armor stands, markers): where a challenge finds its spawns and chest spots.
45
+ * `tags` are the entity's scoreboard tags.
46
+ */
47
+ export type Marker = {
48
+ /** The entity type, e.g. `minecraft:armor_stand`. */
49
+ type: EntityTypeId;
50
+ /** The entity's position. */
51
+ at: Vec3;
52
+ /** The custom name, when one is set. */
53
+ name?: string | undefined;
54
+ /** The scoreboard tags. */
55
+ tags: string[];
56
+ };
57
+ /** The item metadata the engine samples and a request can set. */
58
+ export interface ItemMeta {
59
+ /** The custom display name, when one is set. */
60
+ name?: string | undefined;
61
+ /** The lore lines, when set. */
62
+ lore?: string[] | undefined;
63
+ /** Enchantment id to level, e.g. `{ "minecraft:sharpness": 1 }`. */
64
+ enchantments?: Record<string, number> | undefined;
65
+ /** Damage taken by a tool or armor piece. */
66
+ damage?: number | undefined;
67
+ }
68
+ /** An observed stack: what a slot holds. */
69
+ export interface ItemStack extends ItemMeta {
70
+ /** The item id. */
71
+ id: ItemId;
72
+ /** How many, 1 to the stack size. */
73
+ count: number;
74
+ }
75
+ /** A slot on the wire: no `item` means the slot is empty now. Slots 0-35 main (0-8 hotbar), 36-39 armor, 40 offhand. */
76
+ export type SlotChange = {
77
+ /** The slot index. */
78
+ slot: number;
79
+ /** The item now in the slot; absent when the slot is empty now. */
80
+ item?: ItemId | undefined;
81
+ /** How many; absent with `item`. */
82
+ count?: number | undefined;
83
+ } & ItemMeta;
84
+ /** An item to put in a container slot. `nbt` is the SNBT the SDK built from the request's metadata and raw `snbt`. */
85
+ export type ContainerItem = {
86
+ /** The slot index; the next free one when absent. */
87
+ slot?: number | undefined;
88
+ /** The item id. */
89
+ item: ItemId;
90
+ /** How many. */
91
+ count: number;
92
+ /** The item data (SNBT), when the request had metadata. */
93
+ nbt?: string | undefined;
94
+ } & ItemMeta;
95
+ /** Title timing in server ticks, as `/title times`. */
96
+ export type TitleTimes = {
97
+ /** Fade-in ticks. */
98
+ fadeIn: number;
99
+ /** Ticks on the screen. */
100
+ stay: number;
101
+ /** Fade-out ticks. */
102
+ fadeOut: number;
103
+ };
104
+ /** What an engine can supply. The arena reports them in `run_started`; the SDK checks the challenge's needs against them. */
105
+ export type Capability = "move" | "damage" | "death" | "pickup" | "inventory" | "blocks" | "zones" | "entities" | "custom" | "batch" | "query" | "walk" | "mirror" | "chat" | "lifecycle" | "requests" | "containers";
106
+ /** Every capability. The harness reports them all in `run_started`. */
107
+ export declare const ALL_CAPABILITIES: Capability[];
108
+ /** One player's changed fields since the previous tick. One sample per server tick. */
109
+ export type PlayerSample = {
110
+ /** The player's name. */
111
+ name: string;
112
+ /** `true` for a participant of the run; `false` for the watcher, a spectator or a human in the lobby. */
113
+ participant: boolean;
114
+ /** The server's entity id and the player's uuid, on the first sample. */
115
+ id?: number | undefined;
116
+ /** The player's uuid, on the first sample. */
117
+ uuid?: string | undefined;
118
+ /** The position, when it changed. */
119
+ pos?: Vec3 | undefined;
120
+ /** Degrees, Minecraft convention; sent with `pos`. */
121
+ yaw?: number | undefined;
122
+ /** Degrees; sent with `pos`. */
123
+ pitch?: number | undefined;
124
+ /** Degrees; sent with `pos`. */
125
+ headYaw?: number | undefined;
126
+ /** Half-hearts, when it changed. */
127
+ health?: number | undefined;
128
+ /** The food level, 0..20, when it changed. */
129
+ food?: number | undefined;
130
+ /** The game mode, when it changed. */
131
+ gamemode?: GameMode | undefined;
132
+ /** The item in the main hand, `null` for an empty hand; when it changed. */
133
+ held?: ItemId | null | undefined;
134
+ /** The equipment slots that changed. */
135
+ equipment?: EquipmentChange[] | undefined;
136
+ /** Whether the player is invisible, when it changed. */
137
+ invisible?: boolean | undefined;
138
+ };
139
+ /** An engine fact the arena feeds to `reduce`: the plugin's messages plus the arena's own. */
140
+ export type Event =
141
+ /** The run starts: the seed, the roster, the resolved params, the engine's capabilities, the declared locations and the markers the engine read. */
142
+ {
143
+ type: "run_started";
144
+ /** The run's random seed. */
145
+ seed: number;
146
+ /** The roster. */
147
+ participants: Participant[];
148
+ /** The resolved per-run parameters: the declaration's defaults under the job's overrides. */
149
+ params: Record<string, Json>;
150
+ /** What this engine supplies. */
151
+ capabilities: Capability[];
152
+ /** The declared locations' coordinates, by name. */
153
+ locations?: Record<string, Vec3> | undefined;
154
+ /** The marker entities the engine read, when the manifest asked for them. */
155
+ markers?: Marker[] | undefined;
156
+ }
157
+ /** One server tick: the players whose sample changed, the entities that moved, the time when it changed. */
158
+ | {
159
+ type: "tick";
160
+ /** The server's tick counter. */
161
+ serverTick: number;
162
+ /** Every online player whose sample changed since the previous tick; the first tick after configure has them all. */
163
+ players?: PlayerSample[] | undefined;
164
+ /** Entities that moved since the previous tick. */
165
+ entities?: EntityMove[] | undefined;
166
+ /** The world time of day, when it changed. */
167
+ time?: number | undefined;
168
+ }
169
+ /** A player entered the run's world (the operational roster: participant or not). */
170
+ | {
171
+ type: "player_joined";
172
+ /** The player's name. */
173
+ name: string;
174
+ /** `true` for a participant of the run. */
175
+ participant?: boolean | undefined;
176
+ /** The player's uuid. */
177
+ uuid?: string | undefined;
178
+ /** The server's entity id. */
179
+ id?: number | undefined;
180
+ /** The game mode on arrival. */
181
+ gamemode?: GameMode | undefined;
182
+ }
183
+ /** A player's game mode changed (a human made spectator in the lobby, a reducer effect applied). */
184
+ | {
185
+ type: "gamemode";
186
+ /** The player's name. */
187
+ name: string;
188
+ /** The game mode now. */
189
+ gamemode: GameMode;
190
+ /** The player's uuid. */
191
+ uuid?: string | undefined;
192
+ /** `true` for a participant of the run. */
193
+ participant?: boolean | undefined;
194
+ }
195
+ /** A player left the run's world. */
196
+ | {
197
+ type: "player_left";
198
+ /** The player's name. */
199
+ name: string;
200
+ /** `true` for a participant of the run. */
201
+ participant?: boolean | undefined;
202
+ /** The player's uuid. */
203
+ uuid?: string | undefined;
204
+ /** The server's entity id. */
205
+ id?: number | undefined;
206
+ }
207
+ /** One player's sample outside a tick: the harness sends these; the engine folds moves into ticks. */
208
+ | {
209
+ type: "player_moved";
210
+ /** The player's name. */
211
+ name: string;
212
+ /** The position now. */
213
+ to: Vec3;
214
+ }
215
+ /** A participant took damage; `attacker` when another player caused it. */
216
+ | {
217
+ type: "player_damaged";
218
+ /** The participant. */
219
+ name: string;
220
+ /** The damage, in half-hearts. */
221
+ amount: number;
222
+ /** The damage cause, as the server names it. */
223
+ cause: string;
224
+ /** The player who caused it, when one did. */
225
+ attacker?: string | undefined;
226
+ }
227
+ /** A participant died; `killer` when another player caused it. */
228
+ | {
229
+ type: "player_died";
230
+ /** The participant. */
231
+ name: string;
232
+ /** The death cause, as the server names it. */
233
+ cause: string;
234
+ /** The player who caused it, when one did. */
235
+ killer?: string | undefined;
236
+ }
237
+ /** A participant respawned. */
238
+ | {
239
+ type: "player_respawned";
240
+ /** The participant. */
241
+ name: string;
242
+ }
243
+ /** A participant picked an item up from the ground. */
244
+ | {
245
+ type: "item_picked_up";
246
+ /** The participant. */
247
+ name: string;
248
+ /** The item id. */
249
+ item: ItemId;
250
+ /** How many. */
251
+ count: number;
252
+ /** Where the item was. */
253
+ at: Vec3;
254
+ }
255
+ /** A participant's changed slots. No item = the slot is empty now. */
256
+ | {
257
+ type: "inventory";
258
+ /** The participant. */
259
+ name: string;
260
+ /** The slots that changed. */
261
+ slots: SlotChange[];
262
+ }
263
+ /** A participant broke a block: `block` is the state that was there, `after` what is there now. */
264
+ | {
265
+ type: "block_broken";
266
+ /** The participant. */
267
+ name: string;
268
+ /** The block position. */
269
+ at: Vec3;
270
+ /** The block state that was there. */
271
+ block: BlockId;
272
+ /** The block state there now, when it is not air. */
273
+ after?: BlockId | undefined;
274
+ }
275
+ /**
276
+ * A participant placed a block: `block` is the placed state, `replaced` the one before it.
277
+ * `others` lists the other blocks of a multi-block placement (a door's upper half, a bed's foot).
278
+ */
279
+ | {
280
+ type: "block_placed";
281
+ /** The participant. */
282
+ name: string;
283
+ /** The block position. */
284
+ at: Vec3;
285
+ /** The placed block state. */
286
+ block: BlockId;
287
+ /** The block state it replaced, when that was not air. */
288
+ replaced?: BlockId | undefined;
289
+ /** The other blocks of a multi-block placement. */
290
+ others?: Array<{
291
+ /** The block position. */
292
+ at: Vec3;
293
+ /** The placed block state. */
294
+ block: BlockId;
295
+ /** The block state it replaced, when that was not air. */
296
+ replaced?: BlockId | undefined;
297
+ }> | undefined;
298
+ }
299
+ /** A participant right-clicked a block; `item` is what the hand held. */
300
+ | {
301
+ type: "block_used";
302
+ /** The participant. */
303
+ name: string;
304
+ /** The block position. */
305
+ at: Vec3;
306
+ /** The block state. */
307
+ block: BlockId;
308
+ /** The item in the hand, when one. */
309
+ item?: ItemId | undefined;
310
+ }
311
+ /**
312
+ * A container's contents changed, or its first snapshot (`initial`), or the block is gone (`removed`):
313
+ * the changed slots only, like `inventory`. `by` names the player who moved the items when the engine
314
+ * knows it for certain, else it is absent.
315
+ */
316
+ | {
317
+ type: "container";
318
+ /** The container block. */
319
+ at: Vec3;
320
+ /** The container's block id. */
321
+ block: BlockId;
322
+ /** The slots that changed; every filled slot in the first snapshot. */
323
+ slots: SlotChange[];
324
+ /** The player who moved the items, when the engine is certain. */
325
+ by?: string | undefined;
326
+ /** `true` for the first snapshot of a container. */
327
+ initial?: boolean | undefined;
328
+ /** `true` when the container block is gone; `slots` is empty then. */
329
+ removed?: boolean | undefined;
330
+ }
331
+ /** A non-player entity appeared, with its first sample. */
332
+ | {
333
+ type: "entity_spawned";
334
+ /** The entity id, unique in the run. */
335
+ id: string;
336
+ /** The entity type id. */
337
+ entity: EntityTypeId;
338
+ /** The position. */
339
+ at: Vec3;
340
+ /** The scoreboard tags. */
341
+ tags?: string[] | undefined;
342
+ /** The custom name, when set. */
343
+ name?: string | undefined;
344
+ /** Half-hearts, for a living entity. */
345
+ health?: number | undefined;
346
+ /** The item id, for an item entity. */
347
+ item?: ItemId | undefined;
348
+ /** How many, for an item entity. */
349
+ count?: number | undefined;
350
+ /** The entity's uuid. */
351
+ uuid?: string | undefined;
352
+ /** Degrees, Minecraft convention. */
353
+ yaw?: number | undefined;
354
+ /** Degrees. */
355
+ pitch?: number | undefined;
356
+ /** Degrees. */
357
+ headYaw?: number | undefined;
358
+ /** The equipped items, by slot. */
359
+ equipment?: EquipmentChange[] | undefined;
360
+ /** Whether the entity is invisible. */
361
+ invisible?: boolean | undefined;
362
+ /** A villager's type, profession and level. */
363
+ villager?: {
364
+ /** The villager type (the biome variant). */
365
+ type: string;
366
+ /** The profession id. */
367
+ profession: string;
368
+ /** The trade level, 1 to 5. */
369
+ level: number;
370
+ } | undefined;
371
+ }
372
+ /** An entity's reported fields changed; a move rides the tick instead. */
373
+ | {
374
+ type: "entity_changed";
375
+ /** The entity id. */
376
+ id: string;
377
+ /** The scoreboard tags now. */
378
+ tags?: string[] | undefined;
379
+ /** The custom name now. */
380
+ name?: string | undefined;
381
+ /** Half-hearts now. */
382
+ health?: number | undefined;
383
+ /** The item id now, for an item entity. */
384
+ item?: ItemId | undefined;
385
+ /** How many now, for an item entity. */
386
+ count?: number | undefined;
387
+ /** The equipment slots that changed. */
388
+ equipment?: EquipmentChange[] | undefined;
389
+ /** Whether the entity is invisible now. */
390
+ invisible?: boolean | undefined;
391
+ /** A villager's type, profession and level now. */
392
+ villager?: {
393
+ /** The villager type (the biome variant). */
394
+ type: string;
395
+ /** The profession id. */
396
+ profession: string;
397
+ /** The trade level, 1 to 5. */
398
+ level: number;
399
+ } | undefined;
400
+ }
401
+ /** A player swung an arm. */
402
+ | {
403
+ type: "animation";
404
+ /** The player's name. */
405
+ name: string;
406
+ /** The arm: the main hand, or the off hand. */
407
+ animation: "swing" | "swing_off";
408
+ }
409
+ /** An entity left the world: it died (`killer` when a player did it) or the server removed it. */
410
+ | {
411
+ type: "entity_removed";
412
+ /** The entity id. */
413
+ id: string;
414
+ /** Why: it died, or the server removed it. */
415
+ cause: "died" | "removed";
416
+ /** The player who killed it, when one did. */
417
+ killer?: string | undefined;
418
+ }
419
+ /** A loaded chunk, whole. The engine sends every loaded chunk after configure and each chunk that loads later. */
420
+ | ({
421
+ /** The message type. */
422
+ type: "chunk";
423
+ } & ChunkMessage)
424
+ /** A chunk left the server: its blocks and containers are unknown until it loads again. */
425
+ | {
426
+ type: "chunk_unloaded";
427
+ /** The chunk x (block x >> 4). */
428
+ x: number;
429
+ /** The chunk z (block z >> 4). */
430
+ z: number;
431
+ }
432
+ /** Every block that changed this tick. `cause`: break, place, burn, fade, form, spread, grow, decay, ignite, entity, bucket, flow, piston, explode, effect. `by` when a player did it. */
433
+ | {
434
+ type: "blocks_changed";
435
+ /** The changed blocks, with their positions. */
436
+ changes: Array<Vec3 & {
437
+ /** The block state now. */
438
+ block: BlockId;
439
+ /** The block state before, when known. */
440
+ was?: BlockId | undefined;
441
+ /** What changed it. */
442
+ cause?: string | undefined;
443
+ /** The player who did it, when one did. */
444
+ by?: string | undefined;
445
+ }>;
446
+ }
447
+ /** The engine filled a box (a `fill` effect): one entry instead of one per block. */
448
+ | {
449
+ type: "blocks_filled";
450
+ /** One corner of the box. */
451
+ from: Vec3;
452
+ /** The opposite corner. */
453
+ to: Vec3;
454
+ /** The block state the box holds now. */
455
+ block: BlockId;
456
+ }
457
+ /** A public chat line. */
458
+ | {
459
+ type: "chat";
460
+ /** The player's name. */
461
+ from: string;
462
+ /** The line. */
463
+ text: string;
464
+ /** The player's uuid. */
465
+ uuid?: string | undefined;
466
+ }
467
+ /**
468
+ * The arena forwards every vote. The challenge decides; the arena stores accepted votes only.
469
+ * `round` is the round the arena saw in the last `vote_round` action when it accepted the request;
470
+ * a request without a round, or from an earlier round, is refused.
471
+ */
472
+ | {
473
+ type: "vote_attempt";
474
+ /** The request id; `vote_decision` echoes it. */
475
+ attemptId: string;
476
+ /** The voter. */
477
+ name: string;
478
+ /** The vote. */
479
+ voteId: string;
480
+ /** The chosen option, or the chosen player's name for the `player` vote. */
481
+ option: string;
482
+ /** The round the arena saw when it accepted the request. */
483
+ round?: number | undefined;
484
+ }
485
+ /** The engine ran a batch: `ok` when every effect applied; `failed` lists the ones that did not. */
486
+ | {
487
+ type: "effect_result";
488
+ /** The batch or walk id. */
489
+ id: string;
490
+ /** Whether every effect applied, or the walk arrived. */
491
+ ok: boolean;
492
+ /** The first failure's detail, when not ok. */
493
+ detail?: string | undefined;
494
+ /** The effects that did not apply. */
495
+ failed?: Array<{
496
+ /** The effect's index in the batch. */
497
+ index: number;
498
+ /** Why it failed. */
499
+ detail: string;
500
+ }> | undefined;
501
+ }
502
+ /** One effect the engine refused; `effect` echoes it, `batch` names the batch and the index when it was in one. */
503
+ | {
504
+ type: "effect_failed";
505
+ /** The effect kind. */
506
+ kind: string;
507
+ /** Why. */
508
+ detail: string;
509
+ /** The refused effect. */
510
+ effect?: Effect | undefined;
511
+ /** The batch it was in, when it was in one. */
512
+ batch?: {
513
+ /** The batch's transport id. */
514
+ id: string;
515
+ /** The effect's index in the batch. */
516
+ index: number;
517
+ } | undefined;
518
+ }
519
+ /** A server event the engine forwards by name. */
520
+ | {
521
+ type: "custom";
522
+ /** The event name. */
523
+ name: string;
524
+ /** The participant it is about, when one. */
525
+ player?: string | undefined;
526
+ /** The event's JSON data. */
527
+ data: Json;
528
+ };
529
+ /** A world change the challenge asks for. The arena runs it on the server through the plugin. */
530
+ export type Effect =
531
+ /** Fills a box with one block state. */
532
+ {
533
+ kind: "fill";
534
+ /** One corner of the box. */
535
+ from: Vec3;
536
+ /** The opposite corner. */
537
+ to: Vec3;
538
+ /** The block state to fill with. */
539
+ block: BlockId;
540
+ }
541
+ /** Sets one block; `nbt` is the block entity data (SNBT). */
542
+ | {
543
+ kind: "setblock";
544
+ /** The block position. */
545
+ at: Vec3;
546
+ /** The block state. */
547
+ block: BlockId;
548
+ /** The block entity data (SNBT), when set. */
549
+ nbt?: string | undefined;
550
+ }
551
+ /** Gives items to a player; `nbt` is the item data (SNBT). */
552
+ | {
553
+ kind: "give";
554
+ /** The participant. */
555
+ player: string;
556
+ /** The item id. */
557
+ item: ItemId;
558
+ /** How many. */
559
+ count: number;
560
+ /** The item data (SNBT), when set. */
561
+ nbt?: string | undefined;
562
+ }
563
+ /** Removes items from a player: one item up to `count`, or everything. */
564
+ | {
565
+ kind: "clear";
566
+ /** The participant. */
567
+ player: string;
568
+ /** The item to remove; absent removes everything. */
569
+ item?: ItemId | undefined;
570
+ /** At most this many; absent removes all of the item. */
571
+ count?: number | undefined;
572
+ }
573
+ /** Moves a player. */
574
+ | {
575
+ kind: "teleport";
576
+ /** The participant. */
577
+ player: string;
578
+ /** The destination. */
579
+ to: Vec3;
580
+ }
581
+ /** Applies a status effect for `seconds`. */
582
+ | {
583
+ kind: "effect";
584
+ /** The participant. */
585
+ player: string;
586
+ /** The status effect id. */
587
+ effect: EffectId;
588
+ /** How long, in seconds. */
589
+ seconds: number;
590
+ /** The level minus one: 0 is level I. */
591
+ amplifier: number;
592
+ }
593
+ /** Summons an entity; `nbt` is its data (SNBT). */
594
+ | {
595
+ kind: "summon";
596
+ /** The entity type id. */
597
+ entity: EntityTypeId;
598
+ /** Where. */
599
+ at: Vec3;
600
+ /** The entity data (SNBT), when set. */
601
+ nbt?: string | undefined;
602
+ }
603
+ /** Removes the non-player entities: of the listed types, or all. */
604
+ | {
605
+ kind: "kill_entities";
606
+ /** The entity types to remove; absent removes every non-player entity. */
607
+ entities?: EntityTypeId[] | undefined;
608
+ }
609
+ /** Kills a player. */
610
+ | {
611
+ kind: "kill";
612
+ /** The participant. */
613
+ player: string;
614
+ }
615
+ /** Sets a player's game mode. */
616
+ | {
617
+ kind: "gamemode";
618
+ /** The participant. */
619
+ player: string;
620
+ /** The game mode. */
621
+ mode: GameMode;
622
+ }
623
+ /** Sets a player attribute. */
624
+ | {
625
+ kind: "attribute";
626
+ /** The participant. */
627
+ player: string;
628
+ /** The attribute id, e.g. `minecraft:generic.movement_speed`. */
629
+ attribute: string;
630
+ /** The base value. */
631
+ value: number;
632
+ }
633
+ /** Sets the time of day. */
634
+ | {
635
+ kind: "time";
636
+ /** The time of day, by name. */
637
+ value: "day" | "noon" | "night" | "midnight";
638
+ }
639
+ /** Sets a game rule. */
640
+ | {
641
+ kind: "gamerule";
642
+ /** The game rule name. */
643
+ rule: string;
644
+ /** The value. */
645
+ value: boolean | number;
646
+ }
647
+ /** Shows a title, to one player or to all. */
648
+ | {
649
+ kind: "title";
650
+ /** The participant; absent shows it to all. */
651
+ player?: string | undefined;
652
+ /** The title line. */
653
+ title: string;
654
+ /** The subtitle line, when set. */
655
+ subtitle?: string | undefined;
656
+ /** The fade and stay times, in ticks; the server's defaults when absent. */
657
+ times?: TitleTimes | undefined;
658
+ }
659
+ /** Moves and resizes the world border over `seconds`. */
660
+ | {
661
+ kind: "worldborder";
662
+ /** The new center, when it moves. */
663
+ center?: {
664
+ /** East. */
665
+ x: number;
666
+ /** South. */
667
+ z: number;
668
+ } | undefined;
669
+ /** The new diameter, in blocks, when it changes. */
670
+ size?: number | undefined;
671
+ /** Over how many seconds the size changes; 0 or absent is at once. */
672
+ seconds?: number | undefined;
673
+ }
674
+ /** Replaces the contents of a container block. */
675
+ | {
676
+ kind: "container";
677
+ /** The container block. */
678
+ at: Vec3;
679
+ /** The new contents; every slot not listed is empty. */
680
+ items: ContainerItem[];
681
+ }
682
+ /** Sets the world spawn. */
683
+ | {
684
+ kind: "spawn";
685
+ /** The world spawn. */
686
+ at: Vec3;
687
+ }
688
+ /** Makes a player a spectator. */
689
+ | {
690
+ kind: "eliminate";
691
+ /** The participant. */
692
+ player: string;
693
+ }
694
+ /** A chat line, to one player (`to`) or to all. */
695
+ | {
696
+ kind: "announce";
697
+ /** The text. */
698
+ message: string;
699
+ /** The participant; absent sends it to all. */
700
+ to?: string | undefined;
701
+ }
702
+ /** A raw server command; the arena checks it against its gameplay allowlist. */
703
+ | {
704
+ kind: "command";
705
+ /** The command, without the leading slash. */
706
+ cmd: string;
707
+ };
708
+ /** Why a game ended, as `game_over` reports it. */
709
+ export type EndReason = "rule" | "time" | "phase" | "call" | "error";
710
+ /** What `reduce` returns for the arena: effects, batches, walks, vote answers, log lines, scores, metrics, the game end. */
711
+ export type Action =
712
+ /** One effect, applied on the next tick. */
713
+ {
714
+ type: "effect";
715
+ /** The effect. */
716
+ effect: Effect;
717
+ }
718
+ /** Applied in one server tick. The engine answers with `effect_result {id}`. The setup batches are `setup:<n>`. */
719
+ | {
720
+ type: "batch";
721
+ /** The transport id; `effect_result` echoes it. */
722
+ id: string;
723
+ /** The effects, applied in order in one server tick. */
724
+ effects: Effect[];
725
+ }
726
+ /** The arena walks the bot to `to`; `effect_result {id}` reports; a failed walk teleports unless `fallback` is `none`. */
727
+ | {
728
+ type: "walk";
729
+ /** The request id; `effect_result` echoes it when the walk ends. */
730
+ id: string;
731
+ /** The participant who walks. */
732
+ player: string;
733
+ /** The destination. */
734
+ to: Vec3;
735
+ /** What a failed walk does: a teleport to `to`, or nothing. */
736
+ fallback: "teleport" | "none";
737
+ }
738
+ /** The reducer's answer to a `vote_attempt`; `round` echoes the vote's current round, when the vote exists. */
739
+ | {
740
+ type: "vote_decision";
741
+ /** The `vote_attempt` this answers. */
742
+ attemptId: string;
743
+ /** Whether the vote counts. */
744
+ accepted: boolean;
745
+ /** The reason shown to the voter, when refused. */
746
+ feedback?: string | undefined;
747
+ /** The vote's current round, when the vote exists. */
748
+ round?: number | undefined;
749
+ }
750
+ /** A line in the run log, with JSON data. */
751
+ | {
752
+ type: "log";
753
+ /** The participant the line is about, when one. */
754
+ player?: string | undefined;
755
+ /** The text. */
756
+ message: string;
757
+ /** Structured data for the line. */
758
+ data?: Json | undefined;
759
+ }
760
+ /** A participant's score changed. The arena reports it to the run; the server never sees it. */
761
+ | {
762
+ type: "score";
763
+ /** The participant. */
764
+ player: string;
765
+ /** The new score. */
766
+ score: number;
767
+ }
768
+ /** A metric: the arena keeps the last value per name (global, or per player) and sends them with the run's end. */
769
+ | {
770
+ type: "metric";
771
+ /** The metric name. */
772
+ name: string;
773
+ /** The value; the last one per name is kept. */
774
+ value: number;
775
+ /** The participant the value is for; absent for a global metric. */
776
+ player?: string | undefined;
777
+ }
778
+ /** The state of a vote changed: the arena stamps later requests with `round` while `open`. */
779
+ | {
780
+ type: "vote_round";
781
+ /** The vote. */
782
+ voteId: string;
783
+ /** Whether casts are accepted now. */
784
+ open: boolean;
785
+ /** The round number, from 1; a reset starts a new one. */
786
+ round: number;
787
+ }
788
+ /** The game ended: the winners, the end state, why, and the judge data. */
789
+ | {
790
+ type: "game_over";
791
+ /** The winners' names; empty for no winner. */
792
+ winners: string[];
793
+ /** The end state the challenge declared; empty for none. */
794
+ endState: string;
795
+ /** Why the game ended. */
796
+ reason: EndReason;
797
+ /** The data `judgeContext` returned for the judge, when the challenge has one. */
798
+ judgeContext?: Record<string, Json> | undefined;
799
+ };
800
+ /** A vote as the manifest declares it: the bots pre-validate against `options`; the reducer decides. */
801
+ export interface ManifestVote {
802
+ /** The options of a static vote; absent for the `player` vote (its options are the other participants). */
803
+ options?: string[] | undefined;
804
+ /** `true` (the default): one vote per round. */
805
+ final?: boolean | undefined;
806
+ /** Whether an eliminated player may vote. Default `false`. */
807
+ allowEliminated?: boolean | undefined;
808
+ /** The `player` vote: whether a player may vote for themself. Default `false`. */
809
+ allowSelf?: boolean | undefined;
810
+ }
811
+ /** What the arena and the backend read before the run. Generated from the locked definition. */
812
+ export interface RuntimeManifest {
813
+ /** The protocol version. The arena and the backend refuse another value. */
814
+ runtime: 2;
815
+ /** The challenge's display name, from the configuration. */
816
+ name: string;
817
+ /** The death rule: `single` eliminates on the first death, `respawn` counts deaths. */
818
+ life: "single" | "respawn";
819
+ /** The role ids the rules know: the backend checks them against the challenge's configuration at activation. */
820
+ roles: string[];
821
+ /** The location names the configuration declares, when it declares any. */
822
+ locations?: string[] | undefined;
823
+ /** Tagged entities to read before the game; the engine preloads the chunks of `within`. */
824
+ markers?: {
825
+ /** The scoreboard tags that mark an entity. */
826
+ tags: string[];
827
+ /** The box the engine loads first, so far markers are found too. */
828
+ within?: Box | undefined;
829
+ } | undefined;
830
+ /** The votes, by id. The backend stores them with the artifact; the arena hands them to the bots. */
831
+ votes: Record<string, ManifestVote>;
832
+ /** The per-run parameters the configuration declares, with their defaults. A job may override a value. */
833
+ params: Record<string, {
834
+ /** The value type. */
835
+ type: "number" | "string" | "boolean";
836
+ /** The value when the job sets none. */
837
+ default: number | string | boolean;
838
+ }>;
839
+ }
840
+ /** The run's stage, as the reducer state records it. */
841
+ export type Status = "CONNECTING" | "SETUP" | "PLAYING" | "OVER";
842
+ /** The end states the SDK reports on its own: a failed setup, a thrown rule, facts the engine lacks. */
843
+ export type SdkEndState = "error_setup" | "error_challenge" | "error_unsupported_facts";
844
+ /** The shape every built challenge bundle exports as `default`: what the arena's worker calls. */
845
+ export interface EngineChallenge {
846
+ /** The manifest; read before `init()`. */
847
+ readonly manifest: RuntimeManifest;
848
+ /** A fresh run state. */
849
+ init(): unknown;
850
+ /** One reduction: the next state and the actions for the engine. */
851
+ reduce(state: unknown, event: Event): {
852
+ /** The next state; the input is never changed. */
853
+ state: unknown;
854
+ /** What the engine and the arena apply, in order. */
855
+ actions: Action[];
856
+ };
857
+ }
858
+ //# sourceMappingURL=wire.d.ts.map