briyah 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +309 -4
- package/data/common/prompts/character_creator/defaults_config.json +1 -1
- package/dist-sdk/server/src/app.service.d.ts +8 -1
- package/dist-sdk/server/src/app.service.js +26 -0
- package/dist-sdk/server/src/room/room.d.ts +3 -2
- package/dist-sdk/server/src/room/room.js +8 -5
- package/dist-sdk/server/src/sdk/index.d.ts +2 -2
- package/dist-sdk/server/src/story/story.service.js +2 -2
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Agent.html +20 -20
- package/docs/classes/Briyah.html +14 -14
- package/docs/classes/BriyahConfigService.html +5 -5
- package/docs/classes/NativeToolRegistry.html +6 -6
- package/docs/classes/Room.html +46 -37
- package/docs/classes/RoomMessage.html +11 -11
- package/docs/enums/MessageAction.html +3 -3
- package/docs/functions/availableToolPacks.html +2 -2
- package/docs/functions/dnd5eTools.html +2 -2
- package/docs/functions/enabledToolPacks.html +2 -2
- package/docs/functions/registerToolPacks.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +125 -4
- package/docs/interfaces/AgentCreationOptions.html +26 -0
- package/docs/interfaces/AgentInfo.html +3 -3
- package/docs/interfaces/AgentMessagesResponse.html +2 -2
- package/docs/interfaces/AppService.html +210 -178
- package/docs/interfaces/Artifact.html +4 -4
- package/docs/interfaces/ArtifactMetadata.html +3 -3
- package/docs/interfaces/ArtifactWriteOptions.html +5 -5
- package/docs/interfaces/AttachDocumentResponse.html +2 -2
- package/docs/interfaces/BriyahConfigOptions.html +9 -9
- package/docs/interfaces/ChapterInfo.html +2 -2
- package/docs/interfaces/Character.html +2 -2
- package/docs/interfaces/CreateAgentResponse.html +2 -2
- package/docs/interfaces/CreateRoomResponse.html +2 -2
- package/docs/interfaces/CreateStoryResponse.html +2 -2
- package/docs/interfaces/FileList.html +2 -2
- package/docs/interfaces/FileMetadata.html +3 -3
- package/docs/interfaces/IConfigService.html +3 -3
- package/docs/interfaces/LoggingOptions.html +6 -6
- package/docs/interfaces/Message.html +2 -2
- package/docs/interfaces/ModelInfo.html +2 -2
- package/docs/interfaces/NativeToolDefinition.html +8 -8
- package/docs/interfaces/PreparedPromptResponse.html +2 -2
- package/docs/interfaces/ProcessTextResponse.html +2 -2
- package/docs/interfaces/PromptFile.html +2 -2
- package/docs/interfaces/PromptFileContent.html +2 -2
- package/docs/interfaces/PromptFilesResponse.html +2 -2
- package/docs/interfaces/PromptFolder.html +2 -2
- package/docs/interfaces/PromptFolderDefaults.html +24 -0
- package/docs/interfaces/PromptFolderDefaultsResponse.html +5 -0
- package/docs/interfaces/PromptFoldersResponse.html +2 -2
- package/docs/interfaces/RoomDetails.html +4 -4
- package/docs/interfaces/RoomInfo.html +2 -2
- package/docs/interfaces/RoomMessageUpdate.html +2 -2
- package/docs/interfaces/RoomMessagesResponse.html +2 -2
- package/docs/interfaces/SendMessageResult.html +2 -2
- package/docs/interfaces/StoryErrorEvent.html +3 -3
- package/docs/interfaces/StoryIdea.html +2 -2
- package/docs/interfaces/StoryInfo.html +3 -3
- package/docs/interfaces/StoryIntroduceCharacterEvent.html +3 -3
- package/docs/interfaces/StoryProgressChapterEvent.html +3 -3
- package/docs/interfaces/StoryState.html +5 -5
- package/docs/interfaces/StoryStateEvent.html +3 -3
- package/docs/interfaces/ToolArtifact.html +4 -4
- package/docs/interfaces/ToolCaller.html +5 -5
- package/docs/interfaces/ToolDefinition.html +2 -2
- package/docs/interfaces/ToolHelpers.html +4 -4
- package/docs/interfaces/ToolParameter.html +2 -2
- package/docs/interfaces/ToolRoomAccess.html +9 -9
- package/docs/interfaces/ToolSummary.html +2 -2
- package/docs/interfaces/ToolsResponse.html +2 -2
- package/docs/interfaces/Transaction.html +2 -2
- package/docs/interfaces/TransactionHistoryResponse.html +2 -2
- package/docs/modules.html +1 -1
- package/docs/types/PromptScope.html +1 -1
- package/docs/types/RoomTurnMode.html +8 -0
- package/docs/types/ToolContext.html +2 -2
- package/docs/types/ToolRunResult.html +1 -1
- package/package.json +3 -2
- package/src/tools/packs/dnd5e/README.md +627 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "briyah",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Briyah multi-agent AI SDK",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist-sdk/server/src/sdk/index.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"data/common/config",
|
|
13
13
|
"data/common/prompts",
|
|
14
14
|
"data/common/story_ideas",
|
|
15
|
-
"README.md"
|
|
15
|
+
"README.md",
|
|
16
|
+
"src/tools/packs/dnd5e/README.md"
|
|
16
17
|
],
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
# The 5e tool pack
|
|
2
|
+
|
|
3
|
+
A set of native tools that let a Briyah room run a fifth-edition tabletop game. There is
|
|
4
|
+
no D&D feature in Briyah: a game is an ordinary room, assembled from agents, prompt
|
|
5
|
+
folders, tool grants and a room leader. This pack only supplies the dice and the
|
|
6
|
+
arithmetic.
|
|
7
|
+
|
|
8
|
+
The four prompt folders that go with it ship separately, in `server/data/common/prompts/`:
|
|
9
|
+
`dungeon_master`, `dnd_player`, `character_creator` and `campaign_designer`.
|
|
10
|
+
Set the room's turn mode to **directed** and its leader to the Dungeon Master, so exactly
|
|
11
|
+
one agent answers each message and the DM controls the order of play.
|
|
12
|
+
|
|
13
|
+
Each folder carries a `defaults_config.json`, so selecting it in the create-agent dialog fills
|
|
14
|
+
in that role's name, nickname, description, tool grants and cache TTL. The grant table below is
|
|
15
|
+
what those files declare. `prompt-folders.spec.ts` reads them as the grant list, checking both that
|
|
16
|
+
every name is a tool the pack registers and that the specialist's prompt mentions it — a typo would
|
|
17
|
+
otherwise show up mid-session as an agent that cannot roll.
|
|
18
|
+
|
|
19
|
+
| Agent | Prompt folder | Tools it is granted |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| Dungeon Master | `dungeon_master` | all seventeen |
|
|
22
|
+
| Player | `dnd_player` | none — see [Why players get no tools](#why-players-get-no-tools) |
|
|
23
|
+
| Character creator | `character_creator` | `create_sheet`, `read_sheet`, `patch_sheet`, `level_up`, `roll_dice`, `rules_lookup`, `spell` |
|
|
24
|
+
| Campaign designer | `campaign_designer` | `stat_block`, `magic_item`, `rules_lookup` |
|
|
25
|
+
|
|
26
|
+
## What the pack knows, and what still needs a document
|
|
27
|
+
|
|
28
|
+
875 SRD entries are built in and reachable through a tool, which is paid for once in a tool
|
|
29
|
+
result rather than on every cached call:
|
|
30
|
+
|
|
31
|
+
| Tool | Covers |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `stat_block` | 317 creatures |
|
|
34
|
+
| `magic_item` | 239 magic items |
|
|
35
|
+
| `spell` | 319 spells, and each class's list |
|
|
36
|
+
| `rules_lookup` | Conditions, rules, tables, 37 weapons, armour, 9 races, the SRD feat, the SRD background, carrying capacity |
|
|
37
|
+
|
|
38
|
+
**The one real gap is class features by level.** The pack knows a class's hit die, saving
|
|
39
|
+
throws, skill list, casting progression, subclass level and ASI levels — but not what Rage or
|
|
40
|
+
Sneak Attack or Channel Divinity do. That, deeper combat procedure, and anything your table
|
|
41
|
+
plays with from outside the SRD are what a rule document is still for.
|
|
42
|
+
|
|
43
|
+
The pack ships fifteen documents distilled from the SRD for exactly those gaps, in
|
|
44
|
+
`server/data/common/artifacts/dnd5e/` beside a `manifest.json`. **They need no upload**: they appear
|
|
45
|
+
on the Artifacts page as read-only artifacts whenever the pack is enabled, and the create-agent
|
|
46
|
+
dialog pre-ticks the right one as soon as a prompt folder is selected.
|
|
47
|
+
|
|
48
|
+
| Document | For |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `dungeon_master-procedure.md` | The Dungeon Master — round structure, action economy, rulings, travel, traps |
|
|
51
|
+
| `character_creator-basics.md` | The character creator — what the tools answer, and languages |
|
|
52
|
+
| `class-<name>.md` ×12 | Whoever needs that class: the creator building one, the agent playing one |
|
|
53
|
+
| `campaign_designer-setting.md` | The campaign designer — the planes and the SRD pantheons |
|
|
54
|
+
|
|
55
|
+
All twelve class documents are pre-ticked on the **character creator**, and nowhere else. It is
|
|
56
|
+
handed players one at a time and cannot know in advance what any of them will pick, so the twelve
|
|
57
|
+
travel together or the build is guessed: a played campaign whose creator carried none of them
|
|
58
|
+
produced a fighter with neither Second Wind nor the fighting style he had chosen, and two casters
|
|
59
|
+
with spell slots and no spells. That is ~11.4k tokens in the creator's cached prefix — on Haiku, for
|
|
60
|
+
an agent used a few dozen times per campaign, against every sheet in the campaign being wrong.
|
|
61
|
+
|
|
62
|
+
A **player's** class document is still ticked nowhere, because nobody knows the party when the
|
|
63
|
+
agents are created. Tick the one class each player is actually playing.
|
|
64
|
+
|
|
65
|
+
Attach any document to **exactly one** agent. `attachedArtifacts` is per-agent and each provider
|
|
66
|
+
injects it as a `Document:` message into only that agent's requests, so the DM carries neither the
|
|
67
|
+
creation chapters nor whatever the designer is reading. That is the reason these are separate agents
|
|
68
|
+
rather than modes of the DM — and the reason class features are twelve files rather than one: a
|
|
69
|
+
wizard player carries the wizard, not eleven classes it will never be.
|
|
70
|
+
|
|
71
|
+
`docs/dnd5e-rule-documents/README.md` records what was left out of the distillation and why.
|
|
72
|
+
|
|
73
|
+
## Where creature statistics come from
|
|
74
|
+
|
|
75
|
+
The DM must never invent a creature's numbers — a made-up monster corrupts every roll in the
|
|
76
|
+
fight — so `stat_block` gives it three routes, in order:
|
|
77
|
+
|
|
78
|
+
1. **The shipped table** (`data/monsters.generated.ts`): all 317 SRD creatures, from the
|
|
79
|
+
commoner to the tarrasque. One cheap call, no waiting.
|
|
80
|
+
2. **The room's `Bestiary`**: creatures particular to this campaign, written with
|
|
81
|
+
`stat_block`'s `define` parameter by either the designer or the DM. A bestiary entry
|
|
82
|
+
**overrides** a shipped creature of the same name, so a game can say "our goblins carry
|
|
83
|
+
crossbows".
|
|
84
|
+
3. **Ask the designer**, only for a creature that should be theirs to design.
|
|
85
|
+
|
|
86
|
+
This is the reason the designer exists for *world-building* rather than for monster lookup. An
|
|
87
|
+
earlier version of this pack routed every stat block through the designer, which made the
|
|
88
|
+
common case — the DM needs numbers for an ordinary goblin — cost a whisper, a republish, a
|
|
89
|
+
reply, and a cache rebuild, in the middle of a fight. `stat_block` makes it one call.
|
|
90
|
+
|
|
91
|
+
Values are transcribed from SRD 5.1; anything you disagree with can be overridden in the
|
|
92
|
+
`Bestiary` without touching the code.
|
|
93
|
+
|
|
94
|
+
### Regenerating the shipped table
|
|
95
|
+
|
|
96
|
+
`data/monsters.ts` owns the shapes; `data/monsters.generated.ts` is written by
|
|
97
|
+
`server/scripts/import-srd-monsters.js` from a checkout of
|
|
98
|
+
[OldManUmby/DND.SRD.Wiki](https://github.com/OldManUmby/DND.SRD.Wiki), which is SRD 5.1 plus
|
|
99
|
+
the Nov 2018 errata under the same licence.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
node scripts/import-srd-monsters.js ../docs/dnd.srd.5.1-0.5.2 --verbose
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Nothing in the build runs it, so the pack does not depend on the source repository being
|
|
106
|
+
present. The parse is strict: a creature that does not match the expected shape is reported
|
|
107
|
+
and skipped rather than written half-formed, since a wrong number in a stat block is worse
|
|
108
|
+
than a missing creature. Re-run it by hand and read the diff.
|
|
109
|
+
|
|
110
|
+
### Why a large table is not a problem
|
|
111
|
+
|
|
112
|
+
Lookup is a keyed map hit, so an exact name costs the same at 2,000 creatures as at 24
|
|
113
|
+
(measured: ~0.01 ms either way), and keys are re-normalized rather than trusted, so a row
|
|
114
|
+
written straight from a source document — `"Ogre Zombie (Variant)"` — still resolves. Two
|
|
115
|
+
things do scale, and both are handled:
|
|
116
|
+
|
|
117
|
+
- **Ambiguity.** A partial name that matches several creatures returns the candidates and asks
|
|
118
|
+
which was meant, rather than silently picking the first. With a large table `"giant"` matches
|
|
119
|
+
a dozen creatures, and a wrong monster in a real fight is worse than a failed lookup. An exact
|
|
120
|
+
name still wins outright, so `"bandit"` resolves cleanly even though `"bandit captain"` exists.
|
|
121
|
+
- **Result size.** `list` is capped at 60 names per source and reports totals plus a `truncated`
|
|
122
|
+
flag, and takes a `filter`. A failed lookup returns at most eight near matches and a count,
|
|
123
|
+
never the whole table. This matters because `truncateResult` replaces an over-16 KB result with
|
|
124
|
+
a mangled *string* rather than clipping it, which would destroy the JSON precisely on the error
|
|
125
|
+
path. Measured at 2,000 creatures: `list` 1.2 KB, a miss 0.4 KB.
|
|
126
|
+
|
|
127
|
+
`monster.tool.spec.ts` guards the table itself — no two keys normalizing to the same name, every
|
|
128
|
+
key agreeing with its creature's name, every entry passing the same validation a hand-written
|
|
129
|
+
definition does, every damage and hit-dice expression actually rollable, every prose section
|
|
130
|
+
having both a name and a body, every saving throw numeric, every entry rendering, and the
|
|
131
|
+
largest creature's `stat_block` result staying inside the 16 KB cap. Those are the checks that
|
|
132
|
+
catch a bad row at CI time rather than mid-fight. Tests about *listing*, ambiguity and near
|
|
133
|
+
matches run against a fixture table instead, so they test the behaviour rather than the data.
|
|
134
|
+
|
|
135
|
+
The one thing that stays linear is a *miss*, which runs the fuzzy tiers over every name: about
|
|
136
|
+
4 ms at 2,000 creatures. That is not worth optimizing — it only happens when a lookup fails, and
|
|
137
|
+
4 ms is invisible next to a model round-trip.
|
|
138
|
+
|
|
139
|
+
**What it does not do:** a stat block is a template, not an instance. `count` returns an
|
|
140
|
+
individually rolled hit point total per creature in a group, but nothing stores them — the DM
|
|
141
|
+
tracks monster hit points in its `situation` line, and `apply_hp` remains for characters with
|
|
142
|
+
sheets. Making monsters first-class would mean instantiating them as ownerless sheets, which is
|
|
143
|
+
a larger change than this.
|
|
144
|
+
|
|
145
|
+
## Weapons and magic items
|
|
146
|
+
|
|
147
|
+
Two more tables, both there for the same reason as the bestiary: to stop a number being
|
|
148
|
+
invented.
|
|
149
|
+
|
|
150
|
+
**Weapons** (`data/weapons.ts`, 37 of them) turn an equipment list into attack lines.
|
|
151
|
+
`create_sheet` derives `attacks` from the weapons a character carries unless the caller passed
|
|
152
|
+
its own, and `inventory` keeps them in step as gear changes. The engine picks the ability
|
|
153
|
+
correctly — Strength for a melee weapon, the better of Strength and Dexterity for a finesse
|
|
154
|
+
one, Dexterity for a ranged one, and the *melee* ability for a thrown melee weapon — adds
|
|
155
|
+
proficiency only when one of the character's classes actually grants that weapon (a wizard has
|
|
156
|
+
five, not a category), and uses the two-handed die for a versatile weapon. There is no weapon
|
|
157
|
+
tool: `rules_lookup` answers `topic: "glaive"` and `topic: "chain mail"`, and the pack already
|
|
158
|
+
has as many tools as a five-call turn can chain.
|
|
159
|
+
|
|
160
|
+
`syncWeaponAttacks` only ever touches an entry whose name is **exactly** a table weapon.
|
|
161
|
+
"Longsword +1", "Claws" and anything hand-written are left alone — a fuzzy match would mistake
|
|
162
|
+
the first for a plain longsword and quietly strip its bonus.
|
|
163
|
+
|
|
164
|
+
**Magic items** (`data/magic-items.generated.ts`, 239 of them) work like creatures: the
|
|
165
|
+
`magic_item` tool looks one up or defines a campaign item into a `Magic Items` artifact that
|
|
166
|
+
overrides the book. An item *is* its text, so the prose is the payload and only the fields a
|
|
167
|
+
tool computes from are structured — type, rarity, attunement, charges, and the twenty bonuses
|
|
168
|
+
written plainly enough to trust. Anything conditional stays in the text on purpose: the
|
|
169
|
+
arrow-catching shield's +2 applies only against ranged attacks, and a bonus wrongly structured
|
|
170
|
+
is one that silently applies twice.
|
|
171
|
+
|
|
172
|
+
**Attunement** is tracked as `att` on the inventory entry, so it travels with the item and the
|
|
173
|
+
three-item limit is a count rather than a second list to keep in step. Exceeding it is a
|
|
174
|
+
refusal naming what is already attuned. An item needing attunement contributes nothing until it
|
|
175
|
+
has it — which is the whole point of tracking it, since a ring of protection in a pocket should
|
|
176
|
+
not be adding to armour class.
|
|
177
|
+
|
|
178
|
+
### Regenerating the item table
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
node scripts/import-srd-items.js ../docs/dnd.srd.5.1-0.5.2 --verbose
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Two items exceed the 6 KB text cap and are truncated with a pointer to the rule document — the
|
|
185
|
+
wand of wonder and the deck of many things, both of which are random tables the DM should read
|
|
186
|
+
from the source anyway.
|
|
187
|
+
|
|
188
|
+
## Races
|
|
189
|
+
|
|
190
|
+
`data/races.ts` is **hand-written**, unlike the creature and item tables. Nine races and four
|
|
191
|
+
subraces is small enough to check by eye, and the thing that mattered was splitting what is
|
|
192
|
+
mechanical — ability increases, speed, size, darkvision, proficiencies, resistances — from prose
|
|
193
|
+
the player just reads. A generator would have to guess that split.
|
|
194
|
+
|
|
195
|
+
`create_sheet` applies it, which means **the `abilities` in a spec are the scores *before* the
|
|
196
|
+
race**. That is the one thing to get right on the calling side, and the creator's prompt says it
|
|
197
|
+
three times, because adding the bonus by hand as well is the obvious mistake and the sheet cannot
|
|
198
|
+
tell the difference afterwards. The result's `race` field lists exactly what was applied so it can
|
|
199
|
+
be checked, and `applyRacialBonuses: false` exists for rebuilding a sheet whose numbers were
|
|
200
|
+
already finished.
|
|
201
|
+
|
|
202
|
+
Applied **once**, at creation. The increases land in `abil`, which then holds the character's
|
|
203
|
+
real scores — there is no separate base — so `recomputeDerived` reads the race for hit points and
|
|
204
|
+
speed but never touches ability scores. That is what makes levelling up safe.
|
|
205
|
+
|
|
206
|
+
Three racial rules are genuinely derived rather than stored, so they stay right as a character
|
|
207
|
+
changes:
|
|
208
|
+
|
|
209
|
+
- the **hill dwarf's** extra hit point per level, read on every recompute;
|
|
210
|
+
- the **dwarf's** immunity to the heavy-armour speed penalty, read by `effectiveSpeed`;
|
|
211
|
+
- **weapon proficiency**, so a dwarf wizard really is proficient with a warhammer.
|
|
212
|
+
|
|
213
|
+
SRD 5.1 carries **one** subrace per race where full 5e has several. An unrecognised *subrace*
|
|
214
|
+
resolves to its base race and says so — a mountain dwarf is a real thing, just not here. An
|
|
215
|
+
unrecognised *race* resolves to nothing and is reported, because guessing would silently change
|
|
216
|
+
ability scores.
|
|
217
|
+
|
|
218
|
+
## Spells
|
|
219
|
+
|
|
220
|
+
319 of them, generated by `scripts/import-srd-spells.js`, with a `spell` tool that looks one up
|
|
221
|
+
or lists what a class can cast at a level.
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
node scripts/import-srd-spells.js ../docs/dnd.srd.5.1-0.5.2 --verbose
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
The importer reads **two** files. A spell's own page carries no class information at all; which
|
|
228
|
+
classes may cast it lives in `Spells/## Spell Lists.md`, and without it there is no way to tell a
|
|
229
|
+
player that a wizard cannot take *cure wounds*. A spell that ends up on nobody's list is reported,
|
|
230
|
+
because that means the lists failed to parse rather than that the spell is unusual — the guard in
|
|
231
|
+
`spell.tool.spec.ts` asserts all 319 are on at least one.
|
|
232
|
+
|
|
233
|
+
`concentration` is derived from the duration rather than trusted, and asserted both ways: exactly
|
|
234
|
+
the spells whose duration begins "Concentration" carry the flag. `At Higher Levels` is split into
|
|
235
|
+
its own field, since deciding whether to upcast is the one thing a caller looks for separately.
|
|
236
|
+
|
|
237
|
+
**There is no `define`, unlike `stat_block` and `magic_item`.** Those two need a structured home
|
|
238
|
+
because tools compute from them — a creature's attack bonus, an item's contribution to armour
|
|
239
|
+
class. Nothing computes from a spell: its effect is prose the DM adjudicates, so a homebrew spell
|
|
240
|
+
needs a description in the `Campaign` document and a name on the sheet, both of which already
|
|
241
|
+
work. A fourth campaign artifact holding fields no tool reads would be shape for its own sake.
|
|
242
|
+
|
|
243
|
+
**A spell off the character's class list is reported, never refused**, by both `create_sheet` and
|
|
244
|
+
`level_up`. A subclass, a racial trait or a magic item can all grant one — a High Elf knows a
|
|
245
|
+
wizard cantrip whatever its class — so refusing would be wrong more often than right. Naming it
|
|
246
|
+
lets a real mistake get noticed.
|
|
247
|
+
|
|
248
|
+
## Carrying capacity and encumbrance
|
|
249
|
+
|
|
250
|
+
Two regimes, and keeping them apart is the whole job.
|
|
251
|
+
|
|
252
|
+
The **base rule** is always in force and almost never binding — capacity is Strength × 15, which
|
|
253
|
+
the SRD itself calls "high enough that most characters don't usually have to worry about it". The
|
|
254
|
+
only thing it changes is dropping speed to 5 feet while dragging something past capacity. So the
|
|
255
|
+
sheet does not print a carrying line at all in that case: it would be noise in the owner's prompt
|
|
256
|
+
every turn.
|
|
257
|
+
|
|
258
|
+
The **variant is opt-in**, set with `encumbrance: true` on the sheet, and turning it on has a
|
|
259
|
+
consequence the rules state outright: *"when you use this variant, ignore the Strength column of
|
|
260
|
+
the Armor table."* So `effectiveSpeed` stops applying the heavy-armour penalty and starts applying
|
|
261
|
+
a weight one. Doing both would charge a Strength 12 fighter twice for the same plate mail, and
|
|
262
|
+
there is a test that pins exactly that.
|
|
263
|
+
|
|
264
|
+
Above Strength × 5 costs 10 feet; above Strength × 10 costs 20 feet **and** disadvantage on every
|
|
265
|
+
ability check, attack roll and saving throw that uses Strength, Dexterity or Constitution. That
|
|
266
|
+
last part reaches all three kinds of roll, so `conditionEffects` consults the skill-to-ability map
|
|
267
|
+
rather than guessing which checks are physical.
|
|
268
|
+
|
|
269
|
+
It is a table-wide rule living on a per-character sheet, because the pack has no room-level
|
|
270
|
+
configuration. Set it for everyone or for nobody.
|
|
271
|
+
|
|
272
|
+
### Weights, and what has none
|
|
273
|
+
|
|
274
|
+
`scripts/import-srd-gear.js` reads the three places the SRD prints a pound figure — the gear,
|
|
275
|
+
armour and weapon tables — into one name-to-pounds map.
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
node scripts/import-srd-gear.js ../docs/dnd.srd.5.1-0.5.2 --verbose
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Three lookups, each earning its place: an exact name; the same words with a comma swapped, since
|
|
282
|
+
the SRD files things for sorting rather than reading (`Clothes, common` is what a person writes as
|
|
283
|
+
"common clothes", exactly as `Crossbow, light` is a light crossbow); then a bundle, because
|
|
284
|
+
`Arrows (20) — 1 lb.` means one arrow weighs a twentieth of a pound and `arrows x40` should come
|
|
285
|
+
to two.
|
|
286
|
+
|
|
287
|
+
**A dash in the table is zero; absent from the table is unknown**, and the difference is
|
|
288
|
+
load-bearing. The SRD prints no weight for vestments, a holy symbol or a campaign's own trinket,
|
|
289
|
+
so `carriedWeight` *names* what it could not weigh and every report says how many items that was.
|
|
290
|
+
A total is a floor, never the whole truth, and saying so is better than quietly treating a
|
|
291
|
+
breastplate-sized unknown as weightless.
|
|
292
|
+
|
|
293
|
+
Coin counts at fifty pieces to the pound.
|
|
294
|
+
|
|
295
|
+
## Backgrounds
|
|
296
|
+
|
|
297
|
+
SRD 5.1 carries **one**: Acolyte. Same licence situation as the feats, and the same shape of
|
|
298
|
+
answer — except that here the SRD hands over the extensibility itself. Its *Customizing a
|
|
299
|
+
Background* rule says in as many words that you may replace the feature, choose any two skills,
|
|
300
|
+
and choose any two tool proficiencies or languages. A table inventing "Sailor" is playing by the
|
|
301
|
+
book, not houseruling.
|
|
302
|
+
|
|
303
|
+
So `create_sheet` applies a background it knows — two skills, the equipment package, the coin, and
|
|
304
|
+
a feature that shows on the sheet — and **accepts one it does not**, granting nothing and saying
|
|
305
|
+
so, with the two skills and the gear coming from the spec as they always did. `rules_lookup`
|
|
306
|
+
answers a background name, and `"backgrounds"` returns the customization rule itself.
|
|
307
|
+
|
|
308
|
+
Two details that are rules rather than conveniences:
|
|
309
|
+
|
|
310
|
+
- **A skill collision is a choice, not a silent skip.** "If a character would gain the same
|
|
311
|
+
proficiency from two different sources, he or she can choose a different proficiency of the same
|
|
312
|
+
kind instead" — so a cleric who already took Religion is *told* the background owes them another
|
|
313
|
+
skill rather than having one picked for them.
|
|
314
|
+
- **`backgroundEquipment: false`** skips the package and the coin, which is the SRD's own option
|
|
315
|
+
for a character who spends coin on gear instead. The skills and the feature still apply.
|
|
316
|
+
|
|
317
|
+
The suggested traits, ideals, bonds and flaws are in the table because they are the answer to a
|
|
318
|
+
player who says "I don't know what they're like" — the creator can read one out instead of
|
|
319
|
+
inventing a personality on their behalf. Tool proficiencies are **reported, never stored**: the
|
|
320
|
+
pack does not model tools, and a field implying it tracked them would be a lie.
|
|
321
|
+
|
|
322
|
+
## Feats
|
|
323
|
+
|
|
324
|
+
SRD 5.1 carries **one** feat: Grappler. That is the licence, not an omission — the rest of 5e's
|
|
325
|
+
feats are outside CC-BY-4.0 and must not be added to `data/`. So the work here was the mechanism
|
|
326
|
+
rather than the table, and the mechanism was the part that was broken: `level_up` took a `feat`
|
|
327
|
+
name, echoed it into a details line, and **threw it away**. A character who took a feat had taken
|
|
328
|
+
nothing.
|
|
329
|
+
|
|
330
|
+
Now `feats` is a field on the sheet, and `level_up`:
|
|
331
|
+
|
|
332
|
+
- **refuses an ability score improvement and a feat at the same level.** The rule is "you can
|
|
333
|
+
forgo taking that feature to take a feat instead" — one or the other. Both were previously
|
|
334
|
+
applied happily.
|
|
335
|
+
- **refuses a duplicate**, since a feat can be taken only once.
|
|
336
|
+
- **refuses an unmet prerequisite**, naming the shortfall: Grappler needs Strength 13.
|
|
337
|
+
- **accepts a feat from outside the SRD** by name, records it, and says its effect needs
|
|
338
|
+
`patch_sheet`. Refusing would make the pack unusable at any table that plays with more than
|
|
339
|
+
one feat; applying an invented effect would be worse.
|
|
340
|
+
|
|
341
|
+
Everything is vetted before anything is written, so a refusal leaves the character exactly as
|
|
342
|
+
they were rather than half-levelled.
|
|
343
|
+
|
|
344
|
+
A feat's `grants` can carry ability increases, skills, weapon proficiencies, resistances, speed
|
|
345
|
+
and limited-use pools — none of which the one SRD feat needs, since Grappler's benefit is a rule
|
|
346
|
+
about advantage rather than a number. The structure is there for the feats a campaign adds, and
|
|
347
|
+
`feats.spec.ts` exercises it by adding one to the table temporarily.
|
|
348
|
+
|
|
349
|
+
## How a session starts
|
|
350
|
+
|
|
351
|
+
1. The DM whispers the **campaign designer** to interview the human player and publish
|
|
352
|
+
`Campaign`. The designer asks about tone, setting, what the player wants to spend time
|
|
353
|
+
doing, lethality and anything to avoid — one question per message — then writes the world.
|
|
354
|
+
2. The DM whispers the **character creator** one player's name at a time; the creator
|
|
355
|
+
interviews that player and whispers back as each sheet lands.
|
|
356
|
+
3. Play begins.
|
|
357
|
+
|
|
358
|
+
Every handover is a whisper, so uninvited players are neither prompted nor told anything —
|
|
359
|
+
`canHear` restricts a whisper to its targets, which
|
|
360
|
+
`server/src/room/directed-handoff.spec.ts` pins down. All of it still appears in the room log,
|
|
361
|
+
so the person running the game watches the whole setup even though no agent but the two
|
|
362
|
+
involved can see it.
|
|
363
|
+
|
|
364
|
+
### When the party goes off the map
|
|
365
|
+
|
|
366
|
+
The DM whispers the designer what actually happened — where the party went, what they ignored,
|
|
367
|
+
and what stat blocks are missing — and the designer republishes `Campaign` around the game
|
|
368
|
+
being played. Both prompts forbid herding the party back: no collapsed bridges, no insistent
|
|
369
|
+
messengers. Abandoned factions keep pursuing their aims offstage, and what they achieve
|
|
370
|
+
unopposed becomes a consequence the party meets later.
|
|
371
|
+
|
|
372
|
+
The campaign document is written as a **situation rather than a plot** for this reason —
|
|
373
|
+
factions with motives and clocks, places with something present, people with a want and a
|
|
374
|
+
secret, and an explicit list of what was left blank. There is no scene sequence to derail.
|
|
375
|
+
|
|
376
|
+
Keep the creator in the room afterwards: in directed mode it is never prompted unless
|
|
377
|
+
addressed, so it costs nothing at rest, and the DM calls it back for every level-up. Give it a
|
|
378
|
+
low `maxHistoryMessages` (20) — its history still accumulates public messages through
|
|
379
|
+
`hear()` even while it stays silent.
|
|
380
|
+
|
|
381
|
+
### Levelling up
|
|
382
|
+
|
|
383
|
+
Split the same way creation is, and for the same reason: the choices a level offers come out of
|
|
384
|
+
the character-creation rules, which the creator carries and the DM does not.
|
|
385
|
+
|
|
386
|
+
1. The DM calls `award_xp`. It **applies nothing** — it reports `levelUpsAvailable`, each entry
|
|
387
|
+
naming the character, the level reached, and exactly what must be chosen.
|
|
388
|
+
2. The DM whispers the creator with one character and that `choices` list copied verbatim. The
|
|
389
|
+
list is already correct for that class at that level, and the classes differ: a fighter
|
|
390
|
+
improves at levels a ranger does not, a cleric picks its subclass at 1 and a wizard at 2.
|
|
391
|
+
3. The creator interviews the player — one question at a time for the human, everything at once
|
|
392
|
+
for an AI — and applies it with `level_up`, then reports back.
|
|
393
|
+
|
|
394
|
+
Two rules keep this from being expensive or destructive. The creator must never call
|
|
395
|
+
`create_sheet` on a character who already has one, because rebuilding discards their notes,
|
|
396
|
+
inventory and current hit points; and it must never rewrite the owning agent's description,
|
|
397
|
+
which was written once at creation without a level precisely so it never needs writing again.
|
|
398
|
+
The DM chooses the moment, and it is not mid-combat.
|
|
399
|
+
|
|
400
|
+
`prompt-folders.spec.ts` guards the parts of this that live in prose — including that every tool
|
|
401
|
+
a specialist is granted is actually named in its prompt, which is how `level_up` came to be
|
|
402
|
+
granted to the creator and mentioned nowhere.
|
|
403
|
+
|
|
404
|
+
## Turning it on
|
|
405
|
+
|
|
406
|
+
```
|
|
407
|
+
BRIYAH_TOOL_PACKS=dnd5e
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Nothing is registered without that. Once it is set, all seventeen tools become grantable to any
|
|
411
|
+
agent on the Agents page — on the create dialog as well as the edit form — and an agent only sees the
|
|
412
|
+
ones it has been granted.
|
|
413
|
+
|
|
414
|
+
An SDK host can register them directly instead:
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
import { dnd5eTools } from 'briyah';
|
|
418
|
+
briyah.registerTools(dnd5eTools());
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## The tools
|
|
422
|
+
|
|
423
|
+
| Tool | What it does |
|
|
424
|
+
|---|---|
|
|
425
|
+
| `roll_dice` | Rolls dice expressions in a labelled, semicolon-separated batch |
|
|
426
|
+
| `roll_initiative` | Rolls a whole encounter's initiative in one call and writes the order to an artifact |
|
|
427
|
+
| `check` | Any d20 test, with modifiers read off the character's sheet; rolls damage for attacks |
|
|
428
|
+
| `apply_hp` | Damage, healing, temporary hit points, the dying sequence, death saves |
|
|
429
|
+
| `rest` | Short and long rests, including spending hit dice |
|
|
430
|
+
| `spend` | Spell slots, hit dice, feature uses, item charges |
|
|
431
|
+
| `conditions` | Conditions and exhaustion, returning the mechanical effects they impose |
|
|
432
|
+
| `inventory` | Items, currency, transfers between characters, equipping armour |
|
|
433
|
+
| `award_xp` | Awards experience and reports available level-ups without applying them |
|
|
434
|
+
| `level_up` | Applies a level and recalculates everything downstream |
|
|
435
|
+
| `create_sheet` | Builds a character sheet, computing everything the rules determine |
|
|
436
|
+
| `read_sheet` | Reads a sheet or a one-line party summary, optionally narrowed to a section |
|
|
437
|
+
| `patch_sheet` | Sets fields directly, validated — the escape hatch when no other tool fits |
|
|
438
|
+
| `stat_block` | Looks up a creature, or defines one for this campaign |
|
|
439
|
+
| `magic_item` | Looks up a magic item, or defines one for this campaign |
|
|
440
|
+
| `spell` | Looks up a spell, or lists what a class can cast |
|
|
441
|
+
| `rules_lookup` | SRD excerpts for conditions, rules, tables and equipment |
|
|
442
|
+
|
|
443
|
+
**Labels on `roll_dice` use `=`, not `:`.** Expressions are semicolon-separated and each may
|
|
444
|
+
carry a name, which is what makes a multi-roll result readable:
|
|
445
|
+
|
|
446
|
+
```
|
|
447
|
+
attack=1d20+4; damage=2d6+2 correct
|
|
448
|
+
attack: 1d20+4; damage: 2d6+2 parsed as part of the expression, and fails
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Worth stating because a colon is the natural guess — it is how the rest of a tool call is
|
|
452
|
+
written — and because a monster's turn is the common case for a labelled batch: one call
|
|
453
|
+
carrying the to-hit and the damage together, rather than two. `roll_dice` takes up to 20
|
|
454
|
+
expressions and accepts `adv`/`dis`, `kh`/`kl`, `dh`/`dl`, `r1`, `min2`, `crit` and `xN`.
|
|
455
|
+
|
|
456
|
+
Suggested grants:
|
|
457
|
+
|
|
458
|
+
| Agent | Prompt folder | Tools |
|
|
459
|
+
|---|---|---|
|
|
460
|
+
| Dungeon Master | `dungeon_master` | all seventeen |
|
|
461
|
+
| AI player | `dnd_player` | **none** — see below |
|
|
462
|
+
| Human player | `dnd_player` | none |
|
|
463
|
+
| Character creator | `character_creator` | `create_sheet`, `read_sheet`, `patch_sheet`, `level_up`, `roll_dice`, `rules_lookup`, `spell` |
|
|
464
|
+
| Campaign designer | `campaign_designer` | `stat_block`, `magic_item`, `rules_lookup` |
|
|
465
|
+
|
|
466
|
+
The designer writes the `Campaign` document with the `publish` action rather than a tool. Its two
|
|
467
|
+
lookups exist so it can check what the book already has and define only what the campaign
|
|
468
|
+
genuinely invented — a creature into the `Bestiary`, an item into `Magic Items`. Both land where
|
|
469
|
+
the DM's own lookups find them, so the campaign document stays short and neither definition
|
|
470
|
+
touches anybody's cached prompt.
|
|
471
|
+
|
|
472
|
+
The character creator holds `level_up` because **it runs level-ups too, not just creation**.
|
|
473
|
+
The choices a level offers come out of the character-creation rules it carries and the Dungeon
|
|
474
|
+
Master does not, and a level-up is the same job as building a sheet: a private interview with
|
|
475
|
+
one player. The DM awards the experience with `award_xp`, which reports what must be chosen
|
|
476
|
+
and applies nothing, then hands that list to the creator.
|
|
477
|
+
|
|
478
|
+
### Why players get no tools
|
|
479
|
+
|
|
480
|
+
Not an oversight, and not only a trust decision — players have nothing to call a tool *for*.
|
|
481
|
+
A character's sheet is an artifact they are a viewer of, so it is already rendered into
|
|
482
|
+
their perceive prompt every turn, as is the shared `Party Status`. `read_sheet` exists for
|
|
483
|
+
the **Dungeon Master**, which is deliberately *not* a viewer of the sheets (see below); it
|
|
484
|
+
is a cache-avoidance mechanism, not a data-access one.
|
|
485
|
+
|
|
486
|
+
That leaves rolling and state changes, and both belong to the DM:
|
|
487
|
+
|
|
488
|
+
- **Rolling.** `runAgentTurn` lets an agent chain up to five private `EXECUTE`s and only its
|
|
489
|
+
final audible message reaches the room. `MessageAction.TOOL` notices are visible to no
|
|
490
|
+
agent at all (`canHear` returns false for them) and are filtered out of the room log
|
|
491
|
+
unless `showThoughts` is on. So a player with dice could roll five times and report the
|
|
492
|
+
best, and no other agent — including the DM — could tell. One roller means one source of
|
|
493
|
+
truth.
|
|
494
|
+
- **State.** `spend` accepts a negative amount to *restore* a resource, so a player holding
|
|
495
|
+
it could quietly refill their own spell slots.
|
|
496
|
+
|
|
497
|
+
A human-controlled agent additionally never takes an AI turn at all — `Room.perceive`
|
|
498
|
+
returns early for it — so its `toolNames` would be inert regardless. The DM prompt is
|
|
499
|
+
explicit that it rolls for every player and must never wait for one to roll.
|
|
500
|
+
|
|
501
|
+
`dnd_player/perceive.json` omits `execute` from its action enum, so with
|
|
502
|
+
`additionalProperties: false` a player cannot emit a tool call even if one were granted.
|
|
503
|
+
|
|
504
|
+
`award_xp` deliberately does not apply the level it reports. The hit point increase, ability
|
|
505
|
+
score improvements and new spells are the player's choices; the tool lists what must be
|
|
506
|
+
decided and waits for `level_up`.
|
|
507
|
+
|
|
508
|
+
## The artifacts it maintains
|
|
509
|
+
|
|
510
|
+
| Artifact | Viewers | Contents |
|
|
511
|
+
|---|---|---|
|
|
512
|
+
| `Sheet: <Character>` | that character's agent | The full sheet |
|
|
513
|
+
| `Party Status` | every agent | One line per character: level, hit points, armour class, conditions |
|
|
514
|
+
| `Encounter` | every agent | The current initiative order |
|
|
515
|
+
| `Campaign` | the Dungeon Master (and its author) | The world: factions, places, people, hooks |
|
|
516
|
+
| `Bestiary` | its author only | Creature statistics particular to this campaign |
|
|
517
|
+
|
|
518
|
+
`Bestiary` is scoped to whoever wrote it because everything reads it through `stat_block`, so
|
|
519
|
+
nobody needs it in a cached prompt — the same reasoning as the character sheets. You can still
|
|
520
|
+
read and hand-edit it in the Artifacts tab.
|
|
521
|
+
|
|
522
|
+
`Campaign` is the one changing artifact the DM *is* a viewer of, and that is a deliberate
|
|
523
|
+
exception: the DM consults it constantly, so reading it through a tool every turn would cost
|
|
524
|
+
far more than carrying it. The price is that a redesign invalidates the DM's cached prefix,
|
|
525
|
+
including its attached play rules. Redesigns happen a handful of times a campaign, so that is
|
|
526
|
+
the right side of the trade — but it is why the designer is told to publish a revision only
|
|
527
|
+
when the game has actually moved, not to tinker.
|
|
528
|
+
|
|
529
|
+
### Where a character's public identity lives
|
|
530
|
+
|
|
531
|
+
Agents are created before their characters exist, so their descriptions start as
|
|
532
|
+
placeholders. `create_sheet` therefore rewrites the owning agent's description **once**, to
|
|
533
|
+
`Thorin Ironfoot — Mountain Dwarf Fighter`, using the new `ToolRoomAccess.setDescription`.
|
|
534
|
+
|
|
535
|
+
It deliberately carries no level, hit points or conditions. A description is rendered into
|
|
536
|
+
the roster of every *other* agent's cached prompt prefix, so each write invalidates the whole
|
|
537
|
+
room's cache; character creation is the one moment when that is cheap, because play has not
|
|
538
|
+
started. Everything that changes goes in `Party Status`, which is re-rendered from the sheets
|
|
539
|
+
and costs nothing to update.
|
|
540
|
+
|
|
541
|
+
So the split is: **description** = who you are, written once; **`Party Status`** = what state
|
|
542
|
+
you are in, rewritten freely.
|
|
543
|
+
|
|
544
|
+
### Why the Dungeon Master cannot see the sheets
|
|
545
|
+
|
|
546
|
+
A viewer has an artifact rendered into its **cached** prompt prefix, ahead of its attached
|
|
547
|
+
documents. So if the Dungeon Master could view five sheets, every hit point change would
|
|
548
|
+
invalidate its cache — including the rule documents attached to it, which are usually the
|
|
549
|
+
largest thing in the room. A DM carrying 15k tokens of rules would re-pay for them on every
|
|
550
|
+
hit.
|
|
551
|
+
|
|
552
|
+
So sheets are scoped to their owner and attributed to their owner, and the Dungeon Master
|
|
553
|
+
reads them through `read_sheet` instead. A tool result lands in history rather than in the
|
|
554
|
+
cached prefix, which the conversation was going to invalidate anyway.
|
|
555
|
+
|
|
556
|
+
The human user is unaffected by this scoping: the room's artifact list ignores `viewers`,
|
|
557
|
+
so every sheet is readable and editable in the client's Artifacts tab.
|
|
558
|
+
|
|
559
|
+
## The sheet format
|
|
560
|
+
|
|
561
|
+
One Markdown artifact per character, in three regions:
|
|
562
|
+
|
|
563
|
+
1. A **rendered summary**, regenerated from state on every write. Never authoritative, so a
|
|
564
|
+
human editing it loses nothing.
|
|
565
|
+
2. A **free-prose region** between `<!-- briyah:notes -->` markers, preserved byte-for-byte
|
|
566
|
+
across writes. Backstory and table notes live here; no tool overwrites it.
|
|
567
|
+
3. A fenced **` ```briyah-state `** block holding the canonical JSON. Located by its info
|
|
568
|
+
string, and tagged that way both to be unambiguous to find and to tell the model not to
|
|
569
|
+
hand-edit it.
|
|
570
|
+
|
|
571
|
+
If the state block is missing or unparseable, every writing tool **refuses to write** and
|
|
572
|
+
returns recovery instructions rather than overwriting whatever data survives. `Sheet
|
|
573
|
+
Backups` is where the last good copy lives, since room artifacts have no version history.
|
|
574
|
+
|
|
575
|
+
## Two failure channels
|
|
576
|
+
|
|
577
|
+
Used consistently, because they mean different things to a model:
|
|
578
|
+
|
|
579
|
+
- **Operational failures** — a bad argument, an unknown character, a corrupt sheet, no
|
|
580
|
+
room — are thrown, and surface as `{ ok: false, error }`. These read as "the tool broke".
|
|
581
|
+
- **Rules refusals** — no spell slots left, already dead — are *returned successfully*
|
|
582
|
+
with `applied: false`, the `rule` that was violated, and an `options` list of what is
|
|
583
|
+
legal instead. These read as a ruling. The `options` field is what stops a model
|
|
584
|
+
retrying the same rejected call.
|
|
585
|
+
|
|
586
|
+
## Design constraints worth knowing before extending it
|
|
587
|
+
|
|
588
|
+
- **Parameters cannot express nested shapes.** `ToolParameter` has only a type word and a
|
|
589
|
+
prose description. Complex input is therefore a single `string` parameter carrying JSON
|
|
590
|
+
or a delimited mini-syntax, with two or three verbatim examples in the description —
|
|
591
|
+
models reproduce a shown example far more reliably than they invent a shape.
|
|
592
|
+
- **Nothing validates argument types.** A parameter declared `number` arrives as `"3"`
|
|
593
|
+
routinely; one declared `string` and documented as JSON arrives as a real object about as
|
|
594
|
+
often as a string. Everything goes through `engine/coerce.ts` first.
|
|
595
|
+
- **An agent may chain at most five tool calls per turn.** Tools are coarse-grained and
|
|
596
|
+
batch-capable for this reason: a combat round has to fit.
|
|
597
|
+
- **Results are truncated at 16 KB**, and truncation replaces the whole result with a
|
|
598
|
+
mangled string rather than clipping it, destroying the JSON. Every tool stays inside the
|
|
599
|
+
limit by construction — batches cap at 12 entries, `roll_dice` at 20 expressions.
|
|
600
|
+
- **Read-modify-write must not yield.** `ToolRoomAccess` is synchronous on purpose;
|
|
601
|
+
concurrent tool calls are real, since commissioned agents run their turns under
|
|
602
|
+
`Promise.allSettled`. Use `room.update()` and do not `await` inside the callback.
|
|
603
|
+
|
|
604
|
+
## Layout
|
|
605
|
+
|
|
606
|
+
```
|
|
607
|
+
engine/ pure logic, no room access
|
|
608
|
+
coerce.ts argument coercion
|
|
609
|
+
dice.ts expression parser and roller
|
|
610
|
+
rules.ts derived statistics from sheet state
|
|
611
|
+
sheet.ts the character sheet artifact: parse and render
|
|
612
|
+
character.ts construction and the rules-aware mutations
|
|
613
|
+
bestiary.ts the Bestiary artifact: parse, render, resolve creature lookups
|
|
614
|
+
data/ SRD 5.1 tables and monsters, and the licence
|
|
615
|
+
tools/ one file per group of tools; thin wrappers over the engine
|
|
616
|
+
prompt-folders.spec.ts structural guards on the four prompt folders and their defaults
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
`rules.ts` imports only *types* from `sheet.ts`, never values, so `sheet.ts` can render
|
|
620
|
+
using it without a runtime cycle.
|
|
621
|
+
|
|
622
|
+
## Licensing
|
|
623
|
+
|
|
624
|
+
Rules data is derived from SRD 5.1, published by Wizards of the Coast under CC-BY-4.0. See
|
|
625
|
+
`data/LICENSE-SRD.md` for the attribution and what may be added. Only SRD content belongs
|
|
626
|
+
in `data/`; anything beyond it belongs in a rule document the user uploads and attaches to
|
|
627
|
+
their Dungeon Master agent.
|