@kradle/challenges-sdk 0.17.0 → 0.19.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/CHANGELOG.md +30 -1
- package/LLM_README.md +24 -1
- package/README.md +23 -0
- package/dist/engine.d.ts +4 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +2 -2
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/chat.d.ts +7 -0
- package/dist/runtime/chat.d.ts.map +1 -0
- package/dist/runtime/chat.js +73 -0
- package/dist/runtime/chat.js.map +1 -0
- package/dist/runtime/reducer.d.ts.map +1 -1
- package/dist/runtime/reducer.js +35 -3
- package/dist/runtime/reducer.js.map +1 -1
- package/dist/runtime/types.d.ts +22 -3
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/wire.d.ts +50 -2
- package/dist/runtime/wire.d.ts.map +1 -1
- package/dist/runtime/wire.js +1 -0
- package/dist/runtime/wire.js.map +1 -1
- package/dist/test/harness.d.ts +9 -0
- package/dist/test/harness.d.ts.map +1 -1
- package/dist/test/harness.js +18 -0
- package/dist/test/harness.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,33 @@ also hand-edit this file or the [Unreleased] section at any time.
|
|
|
17
17
|
|
|
18
18
|
## [Unreleased]
|
|
19
19
|
|
|
20
|
+
## [0.19.0] - 2026-10-01
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- `g.say(message)` and `g.tell(to, message)` take static rich text: a string, or a `ChatText` component with `text`, optional `extra` children, a named or six-digit hexadecimal `color`, and boolean `bold`, `italic`, `underlined` and `strikethrough` fields. An array joins components in order. Whitespace stays unchanged. Another field, an invalid color, a cycle, or nesting deeper than 64 levels fails the run (`bad_component`). A night in a werewolves game reads `g.say([{ text: "Night falls. ", color: "gray" }, { text: "Close your eyes.", bold: true }])`.
|
|
25
|
+
- Dynamic text stays in `g.tellraw(to, component)`, which keeps the broader Minecraft component API and its plain-text conversion for agents.
|
|
26
|
+
- New exported types: `ChatText` and `ChatColor`, from `@kradle/challenges-sdk` and from `@kradle/challenges-sdk/engine`.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- With a server that supports structured announcements, a human sees the formatted line without a Kradle prefix, an agent reads the same words as a system message, and a targeted message reaches its recipient alone — spectators get no copy. A label you write yourself, such as `[PRIVATE]`, stays part of your text. An older server uses the plain text and the chat route it used before, so no challenge code needs a change.
|
|
31
|
+
- `on.effectFailed` preserves the original effect kind with structured announcements. On an older engine a `tellraw` to an agent becomes an announcement, so its failure still names the kind `announce`.
|
|
32
|
+
- `README.md` and `LLM_README.md` describe static rich text in `say` and `tell`, with the `README.md` paragraph beside the author example.
|
|
33
|
+
|
|
34
|
+
## [0.18.0] - 2026-09-30
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- The chat gate: `g.mute(to, { message? })`, `g.unmute`, `g.deafen(to, { message? })`, `g.undeafen`. A muted player's public chat line reaches nobody else and their whispers are refused; a deafened player hears no chat line from anyone. System messages pass both gates and `on.chat` still fires for every line. Each call sends the player a notice: the default, your own text, or none for `""` or `null`. `to` is one player, several, or `"all"`. A werewolves night is `g.mute(villagers); g.deafen(villagers)`.
|
|
39
|
+
- The gate is not readable from the context: keep it in your state when the rules need it. A player who is not in the world does not take the change, so call it again for a late joiner (`on.joined`). In a test, `game.gate()` reports who is muted and who is deafened.
|
|
40
|
+
- `g.tellraw(to, component)`: a formatted chat line as `/tellraw` takes it (`"text"`, `{ text, color, bold, extra }`, or an array). A human sees the formatting; an agent reads the plain text as a system message, so an `on.effectFailed` for a `tellraw` to an agent names the kind `announce`.
|
|
41
|
+
- New exported types: `GateOptions` and `TextComponent` from `@kradle/challenges-sdk`, `GateEffect` and `TextComponent` from `@kradle/challenges-sdk/engine`, and `GateReport` (what `game.gate()` returns) from `@kradle/challenges-sdk/test`.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- `LLM_README.md` has a "The chat gate" section and names `g.tellraw`; the hide-and-seek example in `README.md` mutes a hider the seekers caught.
|
|
46
|
+
|
|
20
47
|
## [0.17.0] - 2026-09-25
|
|
21
48
|
|
|
22
49
|
### Added
|
|
@@ -267,7 +294,9 @@ also hand-edit this file or the [Unreleased] section at any time.
|
|
|
267
294
|
- Voting primitives (`votedFor`, `promptVote`, `allVotesIn`, `assignDefaultVotes`) for challenges that use discuss-then-vote-then-act phases as an alternative to pad-based voting.
|
|
268
295
|
- Build-time validation of vote IDs and options against `KRADLE_CHALLENGE_VOTING_OPTIONS` (when set), matching the existing `getLocation`/`setEndState` pattern. `promptVote` also validates each announced option against the declared `votingOptions`.
|
|
269
296
|
|
|
270
|
-
[Unreleased]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.
|
|
297
|
+
[Unreleased]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.19.0...HEAD
|
|
298
|
+
[0.19.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.18.0...v0.19.0
|
|
299
|
+
[0.18.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.17.0...v0.18.0
|
|
271
300
|
[0.17.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.16.0...v0.17.0
|
|
272
301
|
[0.16.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.15.0...v0.16.0
|
|
273
302
|
[0.15.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.14.1...v0.15.0
|
package/LLM_README.md
CHANGED
|
@@ -183,7 +183,30 @@ The steps register behavior and return the same challenge object. Use one chain
|
|
|
183
183
|
|
|
184
184
|
**Votes.** `g.votes(id)` (voter to option), `g.vote(player, id)`, `g.voteOpen(id)`, `g.tally(id)` (`{ counts, leaders, abstaining }`); `g.openVote(id)` (a new round; throws `vote_open` on an open round), `g.closeVote(id)`, `g.resetVote(id)`. A round is closed until opened. An eliminated player's vote is refused unless `allowEliminated`; the `player` vote (`skills.voteForPlayer`) excludes the voter unless `allowSelf`.
|
|
185
185
|
|
|
186
|
-
**Messages and metrics.** `g.say(message)`, `g.tell(to, message)`, `g.title(to, { title, subtitle?, fadeIn?, stay?, fadeOut? })`, `g.log(message, { player?, data? })`, `g.setMetric(name, value, { player? })` (the last value per name reaches the run result), `g.achievement(player, id)` (an id is lowercase letters, digits, `_` and `-`; recorded once per player, listed on `game_over` and readable as `p.achievements`).
|
|
186
|
+
**Messages and metrics.** `g.say(message)`, `g.tell(to, message)`, `g.tellraw(to, component)` (a JSON text component as `/tellraw` takes it: `"text"`, `{ text, color, bold, extra }` or an array; a human sees the formatting, an agent reads the plain text as a system message), `g.title(to, { title, subtitle?, fadeIn?, stay?, fadeOut? })`, `g.log(message, { player?, data? })`, `g.setMetric(name, value, { player? })` (the last value per name reaches the run result), `g.achievement(player, id)` (an id is lowercase letters, digits, `_` and `-`; recorded once per player, listed on `game_over` and readable as `p.achievements`).
|
|
187
|
+
|
|
188
|
+
`g.say(message)` and `g.tell(to, message)` accept a string or static `ChatText`.
|
|
189
|
+
A component has `text`, optional `extra` children, a named or hexadecimal `color`,
|
|
190
|
+
and boolean `bold`, `italic`, `underlined`, or `strikethrough` fields. Arrays join
|
|
191
|
+
components in order. Whitespace stays unchanged. Other fields, invalid colors,
|
|
192
|
+
cycles, and nesting deeper than 64 levels produce `bad_component`.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
// no-compile
|
|
196
|
+
g.say([{ text: "Night falls. ", color: "gray" }, { text: "Close your eyes.", bold: true }]);
|
|
197
|
+
g.tell(player, { text: "[PRIVATE] Your role is CUPID.", color: "light_purple" });
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
With a server that supports structured announcements, humans see the formatted
|
|
201
|
+
text without a Kradle prefix. Agents get the same words through the internal
|
|
202
|
+
message route. A targeted message reaches only its recipient; spectators do not
|
|
203
|
+
get a copy. Existing labels such as `[PRIVATE]` remain part of the author's text.
|
|
204
|
+
Older servers use the plain-text message and the existing prefixed chat route.
|
|
205
|
+
`g.tellraw(to, component)` retains its broader Minecraft component API and its
|
|
206
|
+
existing plain-text conversion for agents. Dynamic text belongs in `tellraw`,
|
|
207
|
+
not in `say` or `tell`.
|
|
208
|
+
|
|
209
|
+
**The chat gate.** `g.mute(to, { message? })`: the players' public chat lines reach nobody else, and their whispers are refused. `g.deafen(to, { message? })`: the players hear no chat line from anyone. `g.unmute(to, { message? })` and `g.undeafen(to, { message? })` undo them. System messages (`g.say`, `g.tell`, `g.tellraw`, titles) pass both gates, and `on.chat` still fires for every line. Each call sends the player a notice: the engine's default when `message` is absent, your own text, or none for `""` or `null`. `to` is one player, several, or `"all"` (every participant; the engine refuses the change for a player who is not in the world, so a late joiner needs the call again). The gate is not readable from the context: keep it in your state when the rules need it. With structured announcements, `on.effectFailed` preserves the original effect kind. On a legacy engine, a `tellraw` to an agent becomes an announcement, so its failure names the kind `announce`. A werewolves night is `g.mute(villagers); g.deafen(villagers)`: the wolves talk in public and only the wolves hear it.
|
|
187
210
|
|
|
188
211
|
**Scores and roster.** `g.setScore(player, n)`, `g.addScore(player, delta)` (refused when `outcome.scores` exists), `g.eliminate(player)`, `g.random.int(lo, hi)`, `g.random.pick(items)`, `g.random.shuffle(items)`, `g.random.weighted(items)`.
|
|
189
212
|
|
package/README.md
CHANGED
|
@@ -80,6 +80,8 @@ const challenge = defineChallenge(config, {
|
|
|
80
80
|
g.say(`${attacker.name} found ${player.name}!`);
|
|
81
81
|
},
|
|
82
82
|
zoneEntered: (g, { player, zone }) => zone === "base" && g.tell(player, "You are safe here."),
|
|
83
|
+
// A hider who got caught watches in silence: no chat line of theirs reaches the others.
|
|
84
|
+
died: (g, { player }) => player.role === "hider" && g.mute(player, { message: "The seekers got you. Watch quietly." }),
|
|
83
85
|
})
|
|
84
86
|
.outcome({
|
|
85
87
|
scores: (_g, p) => (p.role === "seeker" ? p.state.tags : 0),
|
|
@@ -91,6 +93,27 @@ const challenge = defineChallenge(config, {
|
|
|
91
93
|
export default challenge;
|
|
92
94
|
```
|
|
93
95
|
|
|
96
|
+
`g.say(message)` and `g.tell(to, message)` accept a string or static `ChatText`.
|
|
97
|
+
A component has `text`, optional `extra` children, a named or hexadecimal `color`,
|
|
98
|
+
and boolean `bold`, `italic`, `underlined`, or `strikethrough` fields. Arrays join
|
|
99
|
+
components in order. Whitespace stays unchanged. Other fields, invalid colors,
|
|
100
|
+
cycles, and nesting deeper than 64 levels produce `bad_component`.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
// no-compile
|
|
104
|
+
g.say([{ text: "Night falls. ", color: "gray" }, { text: "Close your eyes.", bold: true }]);
|
|
105
|
+
g.tell(player, { text: "[PRIVATE] Your role is CUPID.", color: "light_purple" });
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
With a server that supports structured announcements, humans see the formatted
|
|
109
|
+
text without a Kradle prefix. Agents get the same words through the internal
|
|
110
|
+
message route. A targeted message reaches only its recipient; spectators do not
|
|
111
|
+
get a copy. Existing labels such as `[PRIVATE]` remain part of the author's text.
|
|
112
|
+
Older servers use the plain-text message and the existing prefixed chat route.
|
|
113
|
+
`g.tellraw(to, component)` retains its broader Minecraft component API and its
|
|
114
|
+
existing plain-text conversion for agents. Dynamic text belongs in `tellraw`,
|
|
115
|
+
not in `say` or `tell`.
|
|
116
|
+
|
|
94
117
|
Kradle pays each participant its final `score` as points, so `outcome.scores`
|
|
95
118
|
(or `g.setScore` / `g.addScore`) is what a game is worth. `g.achievement(player, id)`
|
|
96
119
|
records an achievement once per player (`p.achievements`); Kradle records
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { AnyChallenge } from "./runtime/builder.js";
|
|
2
|
-
export { ChallengeError, type ErrorCategory
|
|
3
|
-
export { MAX_BATCH_EFFECTS, MAX_FILL_VOLUME, type State,
|
|
2
|
+
export { ChallengeError, categoryOf, type ErrorCategory } from "./runtime/errors.js";
|
|
3
|
+
export { assertJson, MAX_BATCH_EFFECTS, MAX_FILL_VOLUME, parseBlockState, type State, splitBatches, } from "./runtime/reducer.js";
|
|
4
4
|
export { type Duration, type Ticks, toTicks } from "./runtime/time.js";
|
|
5
|
-
export type { Action, BlockId, Box, Capability, ContainerItem, Effect, EffectId, EndReason, EngineChallenge, EntityTypeId, Event, GameMode, ItemId, ItemMeta, ItemStack, Json, ManifestVote, Participant, PlayerSample, RuntimeManifest, SdkEndState, SlotChange, Status, TitleTimes, Vec3, } from "./runtime/wire.js";
|
|
5
|
+
export type { Action, BlockId, Box, Capability, ChatColor, ChatText, ContainerItem, Effect, EffectId, EndReason, EngineChallenge, EntityTypeId, Event, GameMode, GateEffect, ItemId, ItemMeta, ItemStack, Json, ManifestVote, Participant, PlayerSample, RuntimeManifest, SdkEndState, SlotChange, Status, TextComponent, TitleTimes, Vec3, } from "./runtime/wire.js";
|
|
6
6
|
export { ALL_CAPABILITIES, MINECRAFT_TARGET } from "./runtime/wire.js";
|
|
7
|
-
export type { ChunkMessage, Entity, EntityMove, Equipment, EquipmentChange, EquipmentSlot, Equipped, WorldState } from "./runtime/world.js";
|
|
7
|
+
export type { ChunkMessage, Entity, EntityMove, Equipment, EquipmentChange, EquipmentSlot, Equipped, WorldState, } from "./runtime/world.js";
|
|
8
8
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EACN,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,KAAK,KAAK,EACV,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,MAAM,EACN,OAAO,EACP,GAAG,EACH,UAAU,EACV,SAAS,EACT,QAAQ,EACR,aAAa,EACb,MAAM,EACN,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,IAAI,GACJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,YAAY,EACZ,MAAM,EACN,UAAU,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,UAAU,GACV,MAAM,oBAAoB,CAAC"}
|
package/dist/engine.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MINECRAFT_TARGET = exports.ALL_CAPABILITIES = exports.toTicks = exports.splitBatches = exports.parseBlockState = exports.
|
|
3
|
+
exports.MINECRAFT_TARGET = exports.ALL_CAPABILITIES = exports.toTicks = exports.splitBatches = exports.parseBlockState = exports.MAX_FILL_VOLUME = exports.MAX_BATCH_EFFECTS = exports.assertJson = exports.categoryOf = exports.ChallengeError = void 0;
|
|
4
4
|
var errors_js_1 = require("./runtime/errors.js");
|
|
5
5
|
Object.defineProperty(exports, "ChallengeError", { enumerable: true, get: function () { return errors_js_1.ChallengeError; } });
|
|
6
6
|
Object.defineProperty(exports, "categoryOf", { enumerable: true, get: function () { return errors_js_1.categoryOf; } });
|
|
7
7
|
var reducer_js_1 = require("./runtime/reducer.js");
|
|
8
|
+
Object.defineProperty(exports, "assertJson", { enumerable: true, get: function () { return reducer_js_1.assertJson; } });
|
|
8
9
|
Object.defineProperty(exports, "MAX_BATCH_EFFECTS", { enumerable: true, get: function () { return reducer_js_1.MAX_BATCH_EFFECTS; } });
|
|
9
10
|
Object.defineProperty(exports, "MAX_FILL_VOLUME", { enumerable: true, get: function () { return reducer_js_1.MAX_FILL_VOLUME; } });
|
|
10
|
-
Object.defineProperty(exports, "assertJson", { enumerable: true, get: function () { return reducer_js_1.assertJson; } });
|
|
11
11
|
Object.defineProperty(exports, "parseBlockState", { enumerable: true, get: function () { return reducer_js_1.parseBlockState; } });
|
|
12
12
|
Object.defineProperty(exports, "splitBatches", { enumerable: true, get: function () { return reducer_js_1.splitBatches; } });
|
|
13
13
|
var time_js_1 = require("./runtime/time.js");
|
package/dist/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":";;;AAGA,iDAAqF;AAA5E,2GAAA,cAAc,OAAA;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":";;;AAGA,iDAAqF;AAA5E,2GAAA,cAAc,OAAA;AAAE,uGAAA,UAAU,OAAA;AACnC,mDAO8B;AAN7B,wGAAA,UAAU,OAAA;AACV,+GAAA,iBAAiB,OAAA;AACjB,6GAAA,eAAe,OAAA;AACf,6GAAA,eAAe,OAAA;AAEf,0GAAA,YAAY,OAAA;AAEb,6CAAuE;AAAnC,kGAAA,OAAO,OAAA;AAgC3C,6CAAuE;AAA9D,2GAAA,gBAAgB,OAAA;AAAE,2GAAA,gBAAgB,OAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export { ChallengeError, type ErrorCategory } from "./runtime/errors.js";
|
|
|
3
3
|
export { MAX_BATCH_EFFECTS, MAX_FILL_VOLUME, MAX_TRANSITIONS_PER_EVENT } from "./runtime/reducer.js";
|
|
4
4
|
export { winBy } from "./runtime/rules.js";
|
|
5
5
|
export { addDuration, asMinutes, asSeconds, type Duration, minutes, seconds, subtractDuration, TICKS_PER_SECOND, type Ticks, ticks, toTicks, } from "./runtime/time.js";
|
|
6
|
-
export type { BlockMatch, BlockPos, BlockSpec, BlockState, ChallengeApi, ChallengeConfig, Ctx, CtxOf, Decl, DeepReadonly, EndStateOf, GameRuleId, Handlers, Init, ItemMatch, ItemRequest, LocationOf, NotifyCtx, NotifyCtxOf, ObservedPlayer, OptionFor, Outcome, ParamSpec, ParamsOf, PhaseSpec, PhaseStep, Player, PlayerIn, PlayerOf, Random, ReadCtx, ReadCtxOf, ReadPlayer, ReadPlayerOf, Result, RoleOf, Roster, SetupCtx, SetupCtxOf, StateDecl, TitleOptions, To, VoteIdOf, VoteRule, World, } from "./runtime/types.js";
|
|
6
|
+
export type { BlockMatch, BlockPos, BlockSpec, BlockState, ChallengeApi, ChallengeConfig, Ctx, CtxOf, Decl, DeepReadonly, EndStateOf, GameRuleId, GateOptions, Handlers, Init, ItemMatch, ItemRequest, LocationOf, NotifyCtx, NotifyCtxOf, ObservedPlayer, OptionFor, Outcome, ParamSpec, ParamsOf, PhaseSpec, PhaseStep, Player, PlayerIn, PlayerOf, Random, ReadCtx, ReadCtxOf, ReadPlayer, ReadPlayerOf, Result, RoleOf, Roster, SetupCtx, SetupCtxOf, StateDecl, TitleOptions, To, VoteIdOf, VoteRule, World, } from "./runtime/types.js";
|
|
7
7
|
export { PLAYER_VOTE, WORLD_DEFAULTS } from "./runtime/types.js";
|
|
8
|
+
export type { BlockId, Box, ChatColor, ChatText, EffectId, EndReason, EntityTypeId, GameMode, ItemId, ItemMeta, ItemStack, Json, SdkEndState, Status, TextComponent, Vec3, } from "./runtime/wire.js";
|
|
8
9
|
export { MINECRAFT_TARGET } from "./runtime/wire.js";
|
|
9
|
-
export type { BlockId, Box, EffectId, EndReason, EntityTypeId, GameMode, ItemId, ItemMeta, ItemStack, Json, SdkEndState, Status, Vec3, } from "./runtime/wire.js";
|
|
10
10
|
export { blockIdOf, bounds, type Entity, type EntityFilter, type Equipment, inBox } from "./runtime/world.js";
|
|
11
11
|
import type { BlockPos } from "./runtime/types.js";
|
|
12
12
|
import type { Vec3 } from "./runtime/wire.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,KAAK,QAAQ,EACb,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,EACL,OAAO,GACP,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,GAAG,EACH,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,YAAY,EACZ,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,EAAE,EACF,QAAQ,EACR,QAAQ,EACR,KAAK,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,KAAK,QAAQ,EACb,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,EACL,OAAO,GACP,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,GAAG,EACH,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,E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
42
42
|
const above = (at) => ({ x: Math.floor(at.x), y: Math.floor(at.y) + 1, z: Math.floor(at.z) });
|
|
43
43
|
exports.above = above;
|
|
44
44
|
/** `at` moved by `d` on each axis. */
|
|
45
|
-
const offset = (at, d) => ({
|
|
45
|
+
const offset = (at, d) => ({
|
|
46
|
+
x: at.x + (d.x ?? 0),
|
|
47
|
+
y: at.y + (d.y ?? 0),
|
|
48
|
+
z: at.z + (d.z ?? 0),
|
|
49
|
+
});
|
|
46
50
|
exports.offset = offset;
|
|
47
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,8CAA8C;AAC9C,mDAA0F;AAA9C,6GAAA,eAAe,OAAA;AAC3D,iDAAyE;AAAhE,2GAAA,cAAc,OAAA;AACvB,mDAAqG;AAA5F,+GAAA,iBAAiB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,uHAAA,yBAAyB,OAAA;AACtE,+CAA2C;AAAlC,iGAAA,KAAK,OAAA;AACd,6CAY2B;AAX1B,sGAAA,WAAW,OAAA;AACX,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AAET,kGAAA,OAAO,OAAA;AACP,kGAAA,OAAO,OAAA;AACP,2GAAA,gBAAgB,OAAA;AAChB,2GAAA,gBAAgB,OAAA;AAEhB,gGAAA,KAAK,OAAA;AACL,kGAAA,OAAO,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,8CAA8C;AAC9C,mDAA0F;AAA9C,6GAAA,eAAe,OAAA;AAC3D,iDAAyE;AAAhE,2GAAA,cAAc,OAAA;AACvB,mDAAqG;AAA5F,+GAAA,iBAAiB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,uHAAA,yBAAyB,OA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,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAAxG,QAAA,KAAK,SAAmG;AACrH,sCAAsC;AAC/B,MAAM,MAAM,GAAG,CAAC,EAAQ,EAAE,CAAgB,EAAQ,EAAE,CAAC,CAAC;IAC5D,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC,CAAC;AAJU,QAAA,MAAM,UAIhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/runtime/chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAsB1C,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,CAAA;CAAE,CAwClF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chatText = chatText;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
const colors = new Set([
|
|
6
|
+
"black",
|
|
7
|
+
"dark_blue",
|
|
8
|
+
"dark_green",
|
|
9
|
+
"dark_aqua",
|
|
10
|
+
"dark_red",
|
|
11
|
+
"dark_purple",
|
|
12
|
+
"gold",
|
|
13
|
+
"gray",
|
|
14
|
+
"dark_gray",
|
|
15
|
+
"blue",
|
|
16
|
+
"green",
|
|
17
|
+
"aqua",
|
|
18
|
+
"red",
|
|
19
|
+
"light_purple",
|
|
20
|
+
"yellow",
|
|
21
|
+
"white",
|
|
22
|
+
]);
|
|
23
|
+
const styles = new Set(["bold", "italic", "underlined", "strikethrough"]);
|
|
24
|
+
/** Validate, copy, and flatten static text before it enters an effect. */
|
|
25
|
+
function chatText(value) {
|
|
26
|
+
const ancestors = new Set();
|
|
27
|
+
let message = "";
|
|
28
|
+
function copy(v, depth) {
|
|
29
|
+
const bad = () => (0, errors_js_1.apiError)("bad_component", "say/tell: expected static chat text");
|
|
30
|
+
if (typeof v === "string") {
|
|
31
|
+
message += v;
|
|
32
|
+
return v;
|
|
33
|
+
}
|
|
34
|
+
if (!v || typeof v !== "object" || ancestors.has(v) || depth > 64)
|
|
35
|
+
throw bad();
|
|
36
|
+
ancestors.add(v);
|
|
37
|
+
try {
|
|
38
|
+
if (Array.isArray(v))
|
|
39
|
+
return v.length === 0 ? "" : Array.from(v, (child) => copy(child, depth + 1));
|
|
40
|
+
const obj = v;
|
|
41
|
+
if (typeof obj.text !== "string")
|
|
42
|
+
throw bad();
|
|
43
|
+
const result = { text: obj.text };
|
|
44
|
+
for (const key of Object.keys(obj)) {
|
|
45
|
+
if (key === "text" || key === "extra")
|
|
46
|
+
continue;
|
|
47
|
+
if (obj[key] === undefined && (styles.has(key) || key === "color"))
|
|
48
|
+
continue;
|
|
49
|
+
if (styles.has(key) && typeof obj[key] === "boolean")
|
|
50
|
+
result[key] = obj[key];
|
|
51
|
+
else if (key === "color" &&
|
|
52
|
+
typeof obj[key] === "string" &&
|
|
53
|
+
(colors.has(obj[key]) || /^#[0-9a-fA-F]{6}$/.test(obj[key])))
|
|
54
|
+
result[key] = obj[key];
|
|
55
|
+
else
|
|
56
|
+
throw bad();
|
|
57
|
+
}
|
|
58
|
+
message += obj.text;
|
|
59
|
+
if (obj.extra !== undefined) {
|
|
60
|
+
if (!Array.isArray(obj.extra))
|
|
61
|
+
throw bad();
|
|
62
|
+
result.extra = obj.extra.map((child) => copy(child, depth + 1));
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
ancestors.delete(v);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const component = copy(value, 0);
|
|
71
|
+
return typeof value === "string" ? { message } : { message, component };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/runtime/chat.ts"],"names":[],"mappings":";;AAwBA,4BAwCC;AAhED,2CAAuC;AAGvC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACtB,OAAO;IACP,WAAW;IACX,YAAY;IACZ,WAAW;IACX,UAAU;IACV,aAAa;IACb,MAAM;IACN,MAAM;IACN,WAAW;IACX,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,cAAc;IACd,QAAQ;IACR,OAAO;CACP,CAAC,CAAC;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,SAAgB,QAAQ,CAAC,KAAc;IACtC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,SAAS,IAAI,CAAC,CAAU,EAAE,KAAa;QACtC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAQ,EAAC,eAAe,EAAE,qCAAqC,CAAC,CAAC;QACnF,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,CAAC;YACb,OAAO,CAAC,CAAC;QACV,CAAC;QACD,IAAI,C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GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;oBAE5D,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;;oBACnB,MAAM,GAAG,EAAE,CAAC;YAClB,CAAC;YACD,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC;YACpB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,MAAM,GAAG,EAAE,CAAC;gBAC3C,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,MAAkB,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACV,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/runtime/reducer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/runtime/reducer.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAW,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAEX,SAAS,EACT,UAAU,EACV,eAAe,EAGf,QAAQ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AAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,4EAA4E;IAC5E,MAAM,EAAE;QACP,wCAAwC;QACxC,OAAO,EAAE,MAAM,CAAC;QAChB,kDAAkD;QAClD,YAAY,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI,CAAC;CACT;AAmBD,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAgC7D;AAeD,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAS1D;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAKxD;AAsDD,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAmB1D;AAqKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG;IAC/C,IAAI,EAAE,MAAM,KAAK,CAAC;IAClB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC5E,CAmnDA"}
|
package/dist/runtime/reducer.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.parseBlockState = parseBlockState;
|
|
|
22
22
|
exports.blockSpecString = blockSpecString;
|
|
23
23
|
exports.splitBatches = splitBatches;
|
|
24
24
|
exports.createReducer = createReducer;
|
|
25
|
+
const chat_js_1 = require("./chat.js");
|
|
25
26
|
const errors_js_1 = require("./errors.js");
|
|
26
27
|
const time_js_1 = require("./time.js");
|
|
27
28
|
const types_js_1 = require("./types.js");
|
|
@@ -464,6 +465,17 @@ function createReducer(def) {
|
|
|
464
465
|
const write = (op) => guard(op, ["setup", "full"]);
|
|
465
466
|
const notify = (op) => guard(op, ["notify", "setup", "full"]);
|
|
466
467
|
const flow = (op) => guard(op, ["full"]);
|
|
468
|
+
const gate = (kind, to, options) => {
|
|
469
|
+
write(kind);
|
|
470
|
+
const message = options?.message;
|
|
471
|
+
// "all" is every participant: a gate change names a player, never the room.
|
|
472
|
+
const names = to === "all" ? Object.keys(s.players) : targets(to);
|
|
473
|
+
for (const name of names) {
|
|
474
|
+
if (name === undefined)
|
|
475
|
+
continue;
|
|
476
|
+
push(message === undefined ? { kind, player: name } : { kind, player: name, message });
|
|
477
|
+
}
|
|
478
|
+
};
|
|
467
479
|
const push = (raw) => {
|
|
468
480
|
// A plain copy: an author's argument may be a view (`p.pos`, `g.params.box`).
|
|
469
481
|
const effect = compact(snapshot(raw));
|
|
@@ -619,12 +631,20 @@ function createReducer(def) {
|
|
|
619
631
|
// ---- notifications
|
|
620
632
|
say(message) {
|
|
621
633
|
notify("say");
|
|
622
|
-
push({ kind: "announce", message });
|
|
634
|
+
push({ kind: "announce", ...(0, chat_js_1.chatText)(message) });
|
|
623
635
|
},
|
|
624
636
|
tell(to, message) {
|
|
625
637
|
notify("tell");
|
|
638
|
+
const text = (0, chat_js_1.chatText)(message);
|
|
639
|
+
for (const name of targets(to))
|
|
640
|
+
push({ kind: "announce", ...text, to: name });
|
|
641
|
+
},
|
|
642
|
+
tellraw(to, component) {
|
|
643
|
+
notify("tellraw");
|
|
644
|
+
if (component === undefined || component === null)
|
|
645
|
+
throw (0, errors_js_1.apiError)("bad_component", "tellraw: no component");
|
|
626
646
|
for (const name of targets(to))
|
|
627
|
-
push({ kind: "
|
|
647
|
+
push({ kind: "tellraw", component, to: name });
|
|
628
648
|
},
|
|
629
649
|
title(to, options) {
|
|
630
650
|
notify("title");
|
|
@@ -685,6 +705,10 @@ function createReducer(def) {
|
|
|
685
705
|
const target = s.players[p.name] ?? p;
|
|
686
706
|
target.score += delta;
|
|
687
707
|
},
|
|
708
|
+
mute: (to, options) => gate("mute", to, options),
|
|
709
|
+
unmute: (to, options) => gate("unmute", to, options),
|
|
710
|
+
deafen: (to, options) => gate("deafen", to, options),
|
|
711
|
+
undeafen: (to, options) => gate("undeafen", to, options),
|
|
688
712
|
eliminate(p) {
|
|
689
713
|
write("eliminate");
|
|
690
714
|
const target = s.players[p.name] ?? p;
|
|
@@ -702,7 +726,15 @@ function createReducer(def) {
|
|
|
702
726
|
write("give");
|
|
703
727
|
const id = typeof item === "string" ? item : item.id;
|
|
704
728
|
const n = count ?? (typeof item === "string" ? 1 : (item.count ?? 1));
|
|
705
|
-
const meta = typeof item === "string"
|
|
729
|
+
const meta = typeof item === "string"
|
|
730
|
+
? {}
|
|
731
|
+
: {
|
|
732
|
+
name: item.name,
|
|
733
|
+
lore: item.lore,
|
|
734
|
+
enchantments: item.enchantments,
|
|
735
|
+
damage: item.damage,
|
|
736
|
+
components: item.components,
|
|
737
|
+
};
|
|
706
738
|
push(compact({ kind: "give", player: p.name, item: id, count: n, ...meta }));
|
|
707
739
|
},
|
|
708
740
|
clear(p, item, count) {
|