briyah 1.3.5 → 1.4.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 (239) hide show
  1. package/README.md +849 -684
  2. package/data/common/artifacts/dnd5e/campaign_designer-setting.md +112 -0
  3. package/data/common/artifacts/dnd5e/character_creator-basics.md +40 -0
  4. package/data/common/artifacts/dnd5e/class-barbarian.md +64 -0
  5. package/data/common/artifacts/dnd5e/class-bard.md +63 -0
  6. package/data/common/artifacts/dnd5e/class-cleric.md +60 -0
  7. package/data/common/artifacts/dnd5e/class-druid.md +56 -0
  8. package/data/common/artifacts/dnd5e/class-fighter.md +53 -0
  9. package/data/common/artifacts/dnd5e/class-monk.md +77 -0
  10. package/data/common/artifacts/dnd5e/class-paladin.md +66 -0
  11. package/data/common/artifacts/dnd5e/class-ranger.md +73 -0
  12. package/data/common/artifacts/dnd5e/class-rogue.md +62 -0
  13. package/data/common/artifacts/dnd5e/class-sorcerer.md +67 -0
  14. package/data/common/artifacts/dnd5e/class-warlock.md +83 -0
  15. package/data/common/artifacts/dnd5e/class-wizard.md +51 -0
  16. package/data/common/artifacts/dnd5e/dungeon_master-procedure.md +348 -0
  17. package/data/common/artifacts/dnd5e/manifest.json +95 -0
  18. package/data/common/config/markup +1 -1
  19. package/data/common/config/model_prices.json +1250 -237
  20. package/data/common/prompts/campaign_designer/defaults_config.json +16 -0
  21. package/data/common/prompts/campaign_designer/perceive.json +29 -0
  22. package/data/common/prompts/campaign_designer/perceive.prompt +345 -0
  23. package/data/common/prompts/campaign_designer/system_instruction.prompt +0 -0
  24. package/data/common/prompts/character_creator/defaults_config.json +31 -0
  25. package/data/common/prompts/character_creator/perceive.json +29 -0
  26. package/data/common/prompts/character_creator/perceive.prompt +621 -0
  27. package/data/common/prompts/character_creator/system_instruction.prompt +0 -0
  28. package/data/common/prompts/dnd_player/defaults_config.json +5 -0
  29. package/data/common/prompts/dnd_player/perceive.json +29 -0
  30. package/data/common/prompts/dnd_player/perceive.prompt +312 -0
  31. package/data/common/prompts/dnd_player/system_instruction.prompt +0 -0
  32. package/data/common/prompts/dnd_room_moderator/defaults_config.json +9 -0
  33. package/data/common/prompts/dnd_room_moderator/moderate.json +34 -0
  34. package/data/common/prompts/dnd_room_moderator/moderate.prompt +291 -0
  35. package/data/common/prompts/dnd_room_moderator/system_instruction.prompt +0 -0
  36. package/data/common/prompts/dungeon_master/compact_agent.prompt +24 -0
  37. package/data/common/prompts/dungeon_master/defaults_config.json +29 -0
  38. package/data/common/prompts/dungeon_master/perceive.json +33 -0
  39. package/data/common/prompts/dungeon_master/perceive.prompt +757 -0
  40. package/data/common/prompts/dungeon_master/system_instruction.prompt +0 -0
  41. package/data/common/prompts/room_moderator/moderate.json +34 -29
  42. package/data/common/prompts/room_moderator/moderate.prompt +230 -210
  43. package/data/common/prompts/story_moderator/moderate.prompt +5 -2
  44. package/data/common/prompts/story_moderator/moderate_to_alice.mock +6 -6
  45. package/data/common/prompts/story_moderator/moderate_to_bob.mock +6 -6
  46. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +2 -0
  47. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +34 -22
  48. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +1 -0
  49. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +4 -1
  50. package/dist-sdk/server/src/ai/agent-config.d.ts +1 -0
  51. package/dist-sdk/server/src/ai/agent-store.service.js +6 -4
  52. package/dist-sdk/server/src/ai/agent.d.ts +7 -0
  53. package/dist-sdk/server/src/ai/agent.js +33 -2
  54. package/dist-sdk/server/src/ai/artifact.service.d.ts +2 -0
  55. package/dist-sdk/server/src/ai/artifact.service.js +29 -1
  56. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +7 -0
  57. package/dist-sdk/server/src/ai/pack-artifacts.js +155 -0
  58. package/dist-sdk/server/src/app/stripe.controller.js +5 -0
  59. package/dist-sdk/server/src/app.controller.d.ts +18 -18
  60. package/dist-sdk/server/src/app.controller.js +249 -25
  61. package/dist-sdk/server/src/app.service.d.ts +30 -17
  62. package/dist-sdk/server/src/app.service.js +303 -35
  63. package/dist-sdk/server/src/auth/auth.controller.js +3 -2
  64. package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +1 -0
  65. package/dist-sdk/server/src/auth/owner-only.decorator.js +8 -0
  66. package/dist-sdk/server/src/auth/twilio.service.d.ts +5 -1
  67. package/dist-sdk/server/src/auth/twilio.service.js +5 -3
  68. package/dist-sdk/server/src/config/user-paths.service.d.ts +2 -0
  69. package/dist-sdk/server/src/config/user-paths.service.js +8 -0
  70. package/dist-sdk/server/src/room/artifact-store.service.js +10 -2
  71. package/dist-sdk/server/src/room/artifact.d.ts +1 -0
  72. package/dist-sdk/server/src/room/message.d.ts +2 -1
  73. package/dist-sdk/server/src/room/message.js +5 -4
  74. package/dist-sdk/server/src/room/room-config.d.ts +3 -0
  75. package/dist-sdk/server/src/room/room-store.service.d.ts +4 -2
  76. package/dist-sdk/server/src/room/room-store.service.js +46 -12
  77. package/dist-sdk/server/src/room/room.d.ts +29 -3
  78. package/dist-sdk/server/src/room/room.js +390 -122
  79. package/dist-sdk/server/src/sdk/briyah.js +12 -0
  80. package/dist-sdk/server/src/sdk/index.d.ts +4 -1
  81. package/dist-sdk/server/src/sdk/index.js +9 -1
  82. package/dist-sdk/server/src/story/story.service.js +10 -12
  83. package/dist-sdk/server/src/tools/native-tool.types.d.ts +31 -0
  84. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +22 -0
  85. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +59 -0
  86. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +24 -0
  87. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +11 -0
  88. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +5 -0
  89. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +1 -0
  90. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +154 -0
  91. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +9 -0
  92. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +20 -0
  93. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +2 -0
  94. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +1824 -0
  95. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +6 -0
  96. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +44 -0
  97. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +2 -0
  98. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +17293 -0
  99. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +5 -0
  100. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +41 -0
  101. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +250 -0
  102. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +16 -0
  103. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +2 -0
  104. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +3760 -0
  105. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +12 -0
  106. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +63 -0
  107. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +449 -0
  108. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +23 -0
  109. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +88 -0
  110. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.d.ts +20 -0
  111. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.js +109 -0
  112. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +30 -0
  113. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +329 -0
  114. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +9 -0
  115. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +100 -0
  116. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +117 -0
  117. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +1057 -0
  118. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +13 -0
  119. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +147 -0
  120. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +27 -0
  121. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +263 -0
  122. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +26 -0
  123. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +129 -0
  124. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +22 -0
  125. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +127 -0
  126. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +33 -0
  127. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +137 -0
  128. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +26 -0
  129. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +182 -0
  130. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +48 -0
  131. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +344 -0
  132. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +98 -0
  133. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +456 -0
  134. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +27 -0
  135. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +123 -0
  136. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +23 -0
  137. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +201 -0
  138. package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +3 -0
  139. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +35 -0
  140. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +2 -0
  141. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +323 -0
  142. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +3 -0
  143. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +117 -0
  144. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +2 -0
  145. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +122 -0
  146. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +2 -0
  147. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +157 -0
  148. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +32 -0
  149. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +203 -0
  150. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +4 -0
  151. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +465 -0
  152. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +2 -0
  153. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +116 -0
  154. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +4 -0
  155. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +234 -0
  156. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +6 -0
  157. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +616 -0
  158. package/dist-sdk/server/src/tools/packs/index.d.ts +7 -0
  159. package/dist-sdk/server/src/tools/packs/index.js +45 -0
  160. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +2 -2
  161. package/dist-sdk/server/src/tools/tool-execution.service.js +7 -6
  162. package/dist-sdk/shared/types/app.types.d.ts +63 -0
  163. package/docs/assets/hierarchy.js +1 -1
  164. package/docs/assets/navigation.js +1 -1
  165. package/docs/assets/search.js +1 -1
  166. package/docs/classes/Agent.html +51 -15
  167. package/docs/classes/Briyah.html +14 -14
  168. package/docs/classes/BriyahConfigService.html +5 -5
  169. package/docs/classes/NativeToolRegistry.html +21 -0
  170. package/docs/classes/Room.html +79 -29
  171. package/docs/classes/RoomMessage.html +32 -15
  172. package/docs/enums/MessageAction.html +3 -3
  173. package/docs/functions/availableToolPacks.html +2 -0
  174. package/docs/functions/dnd5eTools.html +5 -0
  175. package/docs/functions/enabledToolPacks.html +2 -0
  176. package/docs/functions/registerToolPacks.html +6 -0
  177. package/docs/hierarchy.html +1 -1
  178. package/docs/index.html +69 -3
  179. package/docs/interfaces/AgentInfo.html +17 -2
  180. package/docs/interfaces/AgentMessagesResponse.html +2 -2
  181. package/docs/interfaces/AppService.html +230 -181
  182. package/docs/interfaces/Artifact.html +15 -3
  183. package/docs/interfaces/ArtifactMetadata.html +5 -2
  184. package/docs/interfaces/ArtifactWriteOptions.html +21 -0
  185. package/docs/interfaces/AttachDocumentResponse.html +2 -2
  186. package/docs/interfaces/BriyahConfigOptions.html +9 -9
  187. package/docs/interfaces/ChapterInfo.html +2 -2
  188. package/docs/interfaces/Character.html +2 -2
  189. package/docs/interfaces/CreateAgentResponse.html +2 -2
  190. package/docs/interfaces/CreateRoomResponse.html +2 -2
  191. package/docs/interfaces/CreateStoryResponse.html +2 -2
  192. package/docs/interfaces/FileList.html +2 -2
  193. package/docs/interfaces/FileMetadata.html +3 -3
  194. package/docs/interfaces/IConfigService.html +3 -3
  195. package/docs/interfaces/LoggingOptions.html +6 -6
  196. package/docs/interfaces/Message.html +2 -2
  197. package/docs/interfaces/ModelInfo.html +2 -2
  198. package/docs/interfaces/NativeToolDefinition.html +11 -7
  199. package/docs/interfaces/PreparedPromptResponse.html +2 -2
  200. package/docs/interfaces/ProcessTextResponse.html +2 -2
  201. package/docs/interfaces/PromptFile.html +2 -2
  202. package/docs/interfaces/PromptFileContent.html +2 -2
  203. package/docs/interfaces/PromptFilesResponse.html +2 -2
  204. package/docs/interfaces/PromptFolder.html +2 -2
  205. package/docs/interfaces/PromptFoldersResponse.html +2 -2
  206. package/docs/interfaces/RoomDetails.html +15 -2
  207. package/docs/interfaces/RoomInfo.html +3 -2
  208. package/docs/interfaces/RoomMessageUpdate.html +2 -2
  209. package/docs/interfaces/RoomMessagesResponse.html +2 -2
  210. package/docs/interfaces/SendMessageResult.html +2 -2
  211. package/docs/interfaces/StoryErrorEvent.html +3 -3
  212. package/docs/interfaces/StoryIdea.html +2 -2
  213. package/docs/interfaces/StoryInfo.html +3 -3
  214. package/docs/interfaces/StoryIntroduceCharacterEvent.html +3 -3
  215. package/docs/interfaces/StoryProgressChapterEvent.html +3 -3
  216. package/docs/interfaces/StoryState.html +5 -5
  217. package/docs/interfaces/StoryStateEvent.html +3 -3
  218. package/docs/interfaces/ToolArtifact.html +8 -0
  219. package/docs/interfaces/ToolCaller.html +8 -0
  220. package/docs/interfaces/ToolDefinition.html +2 -2
  221. package/docs/interfaces/ToolHelpers.html +7 -3
  222. package/docs/interfaces/ToolParameter.html +2 -2
  223. package/docs/interfaces/ToolRoomAccess.html +51 -0
  224. package/docs/interfaces/ToolSummary.html +3 -2
  225. package/docs/interfaces/ToolsResponse.html +2 -2
  226. package/docs/interfaces/Transaction.html +2 -2
  227. package/docs/interfaces/TransactionHistoryResponse.html +2 -2
  228. package/docs/modules.html +1 -1
  229. package/docs/types/PromptScope.html +1 -1
  230. package/docs/types/ToolContext.html +2 -2
  231. package/docs/types/ToolRunResult.html +1 -1
  232. package/package.json +8 -5
  233. package/src/tools/packs/dnd5e/README.md +614 -0
  234. package/dist-sdk/server/src/ai/LLM/base-ai.service.spec.d.ts +0 -1
  235. package/dist-sdk/server/src/ai/LLM/base-ai.service.spec.js +0 -89
  236. package/dist-sdk/server/src/ai/LLM/comfyui-client.spec.d.ts +0 -1
  237. package/dist-sdk/server/src/ai/LLM/comfyui-client.spec.js +0 -143
  238. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.spec.d.ts +0 -1
  239. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.spec.js +0 -207
@@ -0,0 +1,616 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.rulesLookupTool = exports.levelUpTool = exports.awardXpTool = exports.inventoryTool = exports.conditionsTool = void 0;
37
+ const coerce_1 = require("../engine/coerce");
38
+ const character_1 = require("../engine/character");
39
+ const rules = __importStar(require("../engine/rules"));
40
+ const weapons_1 = require("../engine/weapons");
41
+ const items_1 = require("../engine/items");
42
+ const races_1 = require("../engine/races");
43
+ const feats_1 = require("../engine/feats");
44
+ const backgrounds_1 = require("../engine/backgrounds");
45
+ const gear_1 = require("../data/gear");
46
+ const backgrounds_2 = require("../data/backgrounds");
47
+ const feats_2 = require("../data/feats");
48
+ const campaign_items_1 = require("../engine/campaign-items");
49
+ const magic_items_1 = require("../data/magic-items");
50
+ const srd_1 = require("../data/srd");
51
+ const shared_1 = require("./shared");
52
+ const CHOICES_EXAMPLE = '{"hp":7,"asi":{"dex":1,"wis":1},"subclass":"Hunter","spells":["cure wounds","goodberry"]}';
53
+ exports.conditionsTool = {
54
+ name: 'conditions',
55
+ description: 'Add or remove conditions and exhaustion. "characters" is a semicolon-separated list of names. "add" and "remove" are semicolon-separated condition names from: blinded, charmed, deafened, frightened, grappled, incapacitated, invisible, paralyzed, petrified, poisoned, prone, restrained, stunned, unconscious. A condition may carry a duration after a colon, like "frightened:2 rounds". "exhaustion" sets the level from 0 to 6 and "exhaustion_delta" adjusts it. Returns each character\'s current conditions together with the mechanical effects they impose, so you can adjudicate without looking them up. Example: characters = "Goblin A; Goblin B", add = "frightened:2 rounds".',
56
+ parameters: [
57
+ {
58
+ name: 'characters',
59
+ type: 'string',
60
+ description: 'Semicolon-separated character names',
61
+ required: true,
62
+ },
63
+ {
64
+ name: 'add',
65
+ type: 'string',
66
+ description: 'Conditions to add, e.g. "prone; frightened:2 rounds"',
67
+ required: false,
68
+ },
69
+ { name: 'remove', type: 'string', description: 'Conditions to remove', required: false },
70
+ {
71
+ name: 'exhaustion',
72
+ type: 'number',
73
+ description: 'Set the exhaustion level, 0 to 6',
74
+ required: false,
75
+ },
76
+ {
77
+ name: 'exhaustion_delta',
78
+ type: 'number',
79
+ description: 'Adjust the exhaustion level up or down',
80
+ required: false,
81
+ },
82
+ ],
83
+ async handler(args, helpers) {
84
+ const room = (0, shared_1.requireRoom)(helpers);
85
+ const names = (0, coerce_1.list)(args.characters);
86
+ if (names.length === 0) {
87
+ throw new Error('No characters given. Example: "Goblin A; Goblin B".');
88
+ }
89
+ const toAdd = (0, coerce_1.list)(args.add).map(parseCondition);
90
+ const toRemove = (0, coerce_1.list)(args.remove).map((entry) => parseCondition(entry).name);
91
+ const unknown = [...toAdd.map((c) => c.name), ...toRemove].filter((name) => srd_1.CONDITIONS[name] === undefined);
92
+ if (unknown.length > 0) {
93
+ throw new Error(`Not a 5e condition: ${unknown.join(', ')}. Valid conditions: ${Object.keys(srd_1.CONDITIONS).join(', ')}.`);
94
+ }
95
+ const results = [];
96
+ for (const name of names) {
97
+ const { result } = (0, shared_1.mutateSheet)(room, name, (sheet) => {
98
+ const state = (0, character_1.cloneState)(sheet.state);
99
+ const changes = [];
100
+ for (const condition of toAdd) {
101
+ if ((0, character_1.addCondition)(state, condition.name, condition.duration)) {
102
+ changes.push(`+${condition.name}`);
103
+ }
104
+ }
105
+ for (const condition of toRemove) {
106
+ if ((0, character_1.removeCondition)(state, condition))
107
+ changes.push(`-${condition}`);
108
+ }
109
+ if (args.exhaustion !== undefined && args.exhaustion !== '') {
110
+ (0, character_1.setExhaustion)(state, (0, coerce_1.int)(args.exhaustion, 'exhaustion'));
111
+ changes.push(`exhaustion ${state.exh}`);
112
+ }
113
+ if (args.exhaustion_delta !== undefined && args.exhaustion_delta !== '') {
114
+ (0, character_1.setExhaustion)(state, state.exh + (0, coerce_1.int)(args.exhaustion_delta, 'exhaustion_delta'));
115
+ changes.push(`exhaustion ${state.exh}`);
116
+ }
117
+ return {
118
+ ok: true,
119
+ state,
120
+ summary: changes.length > 0
121
+ ? `${state.name}: ${changes.join(', ')}.`
122
+ : `${state.name} was already in that state.`,
123
+ };
124
+ });
125
+ if ((0, character_1.isRefusal)(result)) {
126
+ results.push((0, shared_1.toRefusalResult)(result.refusal));
127
+ continue;
128
+ }
129
+ const state = result.state;
130
+ results.push({
131
+ character: state.name,
132
+ applied: true,
133
+ summary: result.summary,
134
+ conditions: state.cond.map((c) => ({
135
+ name: c.n,
136
+ duration: c.dur,
137
+ effect: srd_1.CONDITIONS[c.n],
138
+ })),
139
+ exhaustion: {
140
+ level: state.exh,
141
+ effect: srd_1.EXHAUSTION_EFFECTS[state.exh],
142
+ },
143
+ incapacitated: rules.isIncapacitated(state) || undefined,
144
+ });
145
+ }
146
+ (0, shared_1.refreshPartyStatus)(room);
147
+ return results.length === 1
148
+ ? results[0]
149
+ : {
150
+ results,
151
+ summary: results
152
+ .map((r) => (r.applied ? r.summary : `refused: ${r.message}`))
153
+ .join(' '),
154
+ };
155
+ },
156
+ };
157
+ function parseCondition(entry) {
158
+ const match = /^(.*?)\s*:\s*(.+)$/.exec(entry.trim());
159
+ if (match)
160
+ return { name: match[1].trim().toLowerCase(), duration: match[2].trim() };
161
+ return { name: entry.trim().toLowerCase() };
162
+ }
163
+ exports.inventoryTool = {
164
+ name: 'inventory',
165
+ description: 'Change a character\'s gear and money. "add" and "remove" are semicolon-separated item entries with an optional quantity: "50 ft rope; arrows x20; potion of healing x2". "coin" adjusts money with signed amounts: "+150 gp; -3 sp". "transfer_to" moves the items in "remove" to another character instead of destroying them. "equip" and "unequip" mark items as worn or wielded; equipping armour or a shield recalculates armour class. "attune" and "unattune" handle magic items that require attunement — at most three at once, and an item that needs attunement gives nothing until it has it, so attune anything the party actually intends to use. A character who cannot pay, or does not carry what you are removing, is reported rather than going negative. Returns the updated gear, coin and armour class.',
166
+ parameters: [
167
+ { name: 'character', type: 'string', description: 'Whose inventory to change', required: true },
168
+ {
169
+ name: 'add',
170
+ type: 'string',
171
+ description: 'Items to add, e.g. "arrows x20; 50 ft rope"',
172
+ required: false,
173
+ },
174
+ { name: 'remove', type: 'string', description: 'Items to remove', required: false },
175
+ {
176
+ name: 'attune',
177
+ type: 'string',
178
+ description: `Magic items to attune to, semicolon-separated; at most ${magic_items_1.MAX_ATTUNED_ITEMS} at a time`,
179
+ required: false,
180
+ },
181
+ {
182
+ name: 'unattune',
183
+ type: 'string',
184
+ description: 'Magic items to stop being attuned to',
185
+ required: false,
186
+ },
187
+ {
188
+ name: 'coin',
189
+ type: 'string',
190
+ description: 'Signed money changes, e.g. "+150 gp; -3 sp"',
191
+ required: false,
192
+ },
193
+ {
194
+ name: 'transfer_to',
195
+ type: 'string',
196
+ description: 'Give the removed items to this character instead of destroying them',
197
+ required: false,
198
+ },
199
+ { name: 'equip', type: 'string', description: 'Items to wear or wield', required: false },
200
+ { name: 'unequip', type: 'string', description: 'Items to stop wearing', required: false },
201
+ ],
202
+ async handler(args, helpers) {
203
+ const room = (0, shared_1.requireRoom)(helpers);
204
+ const character = (0, coerce_1.str)(args.character, 'character');
205
+ const transferTo = args.transfer_to ? (0, coerce_1.str)(args.transfer_to, 'transfer_to') : '';
206
+ let transferred = [];
207
+ const campaignItems = (0, campaign_items_1.parseCampaignItems)(room.get(campaign_items_1.ITEMS_ARTIFACT)?.body);
208
+ const { result } = (0, shared_1.mutateSheet)(room, character, (sheet) => {
209
+ const state = (0, character_1.cloneState)(sheet.state);
210
+ const changes = [];
211
+ const problems = [];
212
+ const remarks = [];
213
+ const added = (0, character_1.addItems)(state, (0, coerce_1.list)(args.add));
214
+ if (added.length > 0)
215
+ changes.push(`gained ${added.join(', ')}`);
216
+ const removal = (0, character_1.removeItems)(state, (0, coerce_1.list)(args.remove));
217
+ if (removal.removed.length > 0) {
218
+ transferred = removal.removed.map((i) => ({ n: i.n, q: i.q }));
219
+ changes.push(`lost ${removal.removed.map((i) => (i.q > 1 ? `${i.n} x${i.q}` : i.n)).join(', ')}`);
220
+ }
221
+ if (removal.missing.length > 0) {
222
+ problems.push(`not carried: ${removal.missing.join(', ')}`);
223
+ }
224
+ const coinEntries = (0, coerce_1.list)(args.coin);
225
+ if (coinEntries.length > 0) {
226
+ const coin = (0, character_1.adjustCoin)(state, coinEntries);
227
+ if (!coin.ok)
228
+ return { ok: false, refusal: coin.refusal };
229
+ changes.push(`coin ${coin.changes.join(', ')}`);
230
+ }
231
+ const equipped = (0, character_1.setEquipped)(state, (0, coerce_1.list)(args.equip), true);
232
+ if (equipped.changed.length > 0)
233
+ changes.push(`equipped ${equipped.changed.join(', ')}`);
234
+ if (equipped.missing.length > 0) {
235
+ problems.push(`cannot equip what is not carried: ${equipped.missing.join(', ')}`);
236
+ }
237
+ const unequipped = (0, character_1.setEquipped)(state, (0, coerce_1.list)(args.unequip), false);
238
+ if (unequipped.changed.length > 0) {
239
+ changes.push(`stowed ${unequipped.changed.join(', ')}`);
240
+ }
241
+ const released = (0, character_1.setAttunement)(state, (0, coerce_1.list)(args.unattune), false, () => true);
242
+ if (released.changed.length > 0) {
243
+ changes.push(`no longer attuned to ${released.changed.join(', ')}`);
244
+ }
245
+ const attuning = (0, character_1.setAttunement)(state, (0, coerce_1.list)(args.attune), true, (itemName) => Boolean((0, items_1.resolveItem)(itemName, campaignItems).item?.attunement));
246
+ if (attuning.refusal)
247
+ return { ok: false, refusal: attuning.refusal };
248
+ if (attuning.changed.length > 0) {
249
+ changes.push(`attuned to ${attuning.changed.join(', ')}`);
250
+ }
251
+ if (attuning.unnecessary.length > 0) {
252
+ remarks.push(`needs no attunement, so nothing changed: ${attuning.unnecessary.join(', ')}`);
253
+ }
254
+ for (const name of [...released.missing, ...attuning.missing]) {
255
+ problems.push(`cannot attune to what is not carried: ${name}`);
256
+ }
257
+ if (changes.length === 0 && remarks.length === 0 && problems.length > 0) {
258
+ return {
259
+ ok: false,
260
+ refusal: {
261
+ violation: 'missing_item',
262
+ message: `${state.name}: ${problems.join('; ')}.`,
263
+ options: [
264
+ `Carrying: ${state.inv.map((i) => (i.q > 1 ? `${i.n} x${i.q}` : i.n)).join(', ') || 'nothing'}`,
265
+ ],
266
+ },
267
+ };
268
+ }
269
+ const weaponChanges = (0, weapons_1.syncWeaponAttacks)(state);
270
+ if (weaponChanges.added.length > 0) {
271
+ changes.push(`can now attack with ${weaponChanges.added.join(', ')}`);
272
+ }
273
+ if (weaponChanges.removed.length > 0) {
274
+ changes.push(`no longer has ${weaponChanges.removed.join(', ')} to attack with`);
275
+ }
276
+ return {
277
+ ok: true,
278
+ state,
279
+ summary: `${state.name}: ${changes.join('; ')}.`,
280
+ details: [...problems, ...remarks].length > 0 ? [...problems, ...remarks] : undefined,
281
+ };
282
+ });
283
+ if ((0, character_1.isRefusal)(result)) {
284
+ return (0, shared_1.toRefusalResult)(result.refusal);
285
+ }
286
+ let receivedBy;
287
+ if (transferTo && transferred.length > 0) {
288
+ const known = (0, shared_1.listCharacterNames)(room);
289
+ if (!(0, coerce_1.matchName)(transferTo, known)) {
290
+ throw new Error(`Cannot transfer to "${transferTo}" — no sheet by that name. Known sheets: ${known.join(', ')}. The items have been removed from ${result.state.name}; give them back with inventory add if this was a mistake.`);
291
+ }
292
+ const transfer = (0, shared_1.mutateSheet)(room, transferTo, (sheet) => {
293
+ const state = (0, character_1.cloneState)(sheet.state);
294
+ (0, character_1.addItems)(state, transferred.map((i) => (i.q > 1 ? `${i.n} x${i.q}` : i.n)));
295
+ return {
296
+ ok: true,
297
+ state,
298
+ summary: `${state.name} receives ${transferred.map((i) => i.n).join(', ')}.`,
299
+ };
300
+ });
301
+ if (!(0, character_1.isRefusal)(transfer.result))
302
+ receivedBy = transfer.result.state.name;
303
+ }
304
+ const state = result.state;
305
+ return {
306
+ applied: true,
307
+ character: state.name,
308
+ summary: result.summary,
309
+ notes: result.details,
310
+ transferredTo: receivedBy,
311
+ inventory: state.inv.map((item) => [
312
+ item.n,
313
+ item.q > 1 ? `x${item.q}` : '',
314
+ item.eq ? '(worn)' : '',
315
+ item.att ? '(attuned)' : '',
316
+ ]
317
+ .filter(Boolean)
318
+ .join(' ')),
319
+ attunement: `${(0, items_1.attunedItems)(state, campaignItems).length}/${magic_items_1.MAX_ATTUNED_ITEMS}`,
320
+ coin: (0, character_1.describeCoin)(state) || 'none',
321
+ armorClass: state.ac,
322
+ };
323
+ },
324
+ };
325
+ exports.awardXpTool = {
326
+ name: 'award_xp',
327
+ description: 'Award or deduct experience and report any level-up that becomes available. "characters" is a semicolon-separated list of names; leave it out for everyone with a sheet. "amount" is what each named character receives, or the total to divide evenly between them if "split" is true. When a character crosses a threshold this reports the new level and exactly what the player must choose, but does NOT apply it — call level_up once they have decided. Returns each character\'s new total and how far the next level is.',
328
+ parameters: [
329
+ { name: 'amount', type: 'number', description: 'Experience to award; may be negative', required: true },
330
+ {
331
+ name: 'characters',
332
+ type: 'string',
333
+ description: 'Semicolon-separated names, or omit for the whole party',
334
+ required: false,
335
+ },
336
+ {
337
+ name: 'split',
338
+ type: 'boolean',
339
+ description: 'Divide the amount evenly between the characters instead of giving each the full amount',
340
+ required: false,
341
+ },
342
+ { name: 'reason', type: 'string', description: 'What earned it', required: false },
343
+ ],
344
+ async handler(args, helpers) {
345
+ const room = (0, shared_1.requireRoom)(helpers);
346
+ const requested = (0, coerce_1.list)(args.characters);
347
+ const names = requested.length > 0 ? requested : (0, shared_1.listCharacterNames)(room);
348
+ if (names.length === 0)
349
+ throw new Error('No character sheets exist in this room yet.');
350
+ const total = (0, coerce_1.int)(args.amount, 'amount');
351
+ const each = (0, coerce_1.bool)(args.split) ? Math.floor(total / names.length) : total;
352
+ const results = [];
353
+ const levelUps = [];
354
+ for (const name of names) {
355
+ let need;
356
+ const { result } = (0, shared_1.mutateSheet)(room, name, (sheet) => {
357
+ const awarded = (0, character_1.awardExperience)(sheet.state, each);
358
+ need = awarded.need;
359
+ return awarded.result;
360
+ });
361
+ if ((0, character_1.isRefusal)(result)) {
362
+ results.push((0, shared_1.toRefusalResult)(result.refusal));
363
+ continue;
364
+ }
365
+ results.push({
366
+ character: result.state.name,
367
+ applied: true,
368
+ experience: result.state.xp,
369
+ summary: result.summary,
370
+ details: result.details,
371
+ });
372
+ if (need)
373
+ levelUps.push(need);
374
+ }
375
+ return {
376
+ awarded: each,
377
+ reason: args.reason ? (0, coerce_1.str)(args.reason, 'reason') : undefined,
378
+ results,
379
+ levelUpsAvailable: levelUps.length > 0 ? levelUps : undefined,
380
+ note: levelUps.length > 0
381
+ ? 'Tell each player what they must choose, then call level_up with their choices. Nothing has been levelled yet.'
382
+ : undefined,
383
+ };
384
+ },
385
+ };
386
+ exports.levelUpTool = {
387
+ name: 'level_up',
388
+ description: 'Apply a level increase after the player has chosen. "to_level" is the total level to reach. "choices" is a JSON object of what was chosen, for example ' +
389
+ CHOICES_EXAMPLE +
390
+ '. Omit "hp" to use the fixed average for the class hit die plus the Constitution modifier. Proficiency bonus, hit dice, spell slots, saving throws and skill modifiers are all recalculated, and experience is topped up to the threshold for the new level. For a multiclass character, name the class gaining the level in "choices". Returns the finished sheet.',
391
+ parameters: [
392
+ { name: 'character', type: 'string', description: 'Who is levelling up', required: true },
393
+ { name: 'to_level', type: 'number', description: 'The total level to reach', required: true },
394
+ {
395
+ name: 'choices',
396
+ type: 'string',
397
+ description: `A JSON object of the player's choices, e.g. ${CHOICES_EXAMPLE}`,
398
+ required: false,
399
+ },
400
+ ],
401
+ async handler(args, helpers) {
402
+ const room = (0, shared_1.requireRoom)(helpers);
403
+ const character = (0, coerce_1.str)(args.character, 'character');
404
+ const toLevel = (0, coerce_1.int)(args.to_level, 'to_level');
405
+ const choices = (0, coerce_1.jsonObject)(args.choices, 'choices', CHOICES_EXAMPLE);
406
+ const { result } = (0, shared_1.mutateSheet)(room, character, (sheet) => (0, character_1.applyLevelUp)(sheet.state, toLevel, choices));
407
+ if ((0, character_1.isRefusal)(result)) {
408
+ return (0, shared_1.toRefusalResult)(result.refusal);
409
+ }
410
+ (0, shared_1.refreshPartyStatus)(room);
411
+ return {
412
+ applied: true,
413
+ character: result.state.name,
414
+ summary: result.summary,
415
+ details: result.details,
416
+ headline: (0, shared_1.sheetHeadline)(result.state),
417
+ state: (0, shared_1.liveState)(result.state),
418
+ };
419
+ },
420
+ };
421
+ exports.rulesLookupTool = {
422
+ name: 'rules_lookup',
423
+ description: 'Look up a 5e rule, condition or table from the System Reference Document. "topic" is what you want: a condition (grappled), a rule (cover, falling, concentration, opportunity attack, two-weapon fighting, death saving throw, massive damage, temporary hit points, hiding, advantage, critical hit, short rest, long rest), a table (proficiency bonus, xp thresholds, exhaustion, spell slots ranger, hit dice), a piece of equipment (longsword, chain mail), a race (dwarf, hill dwarf, tiefling), a feat (grappler, or "feats" for the rule about taking one), or a background (acolyte, or "backgrounds" for the rule including how to customize one). Returns a short authoritative excerpt. Use this instead of guessing when a player questions a ruling.',
424
+ parameters: [
425
+ {
426
+ name: 'topic',
427
+ type: 'string',
428
+ description: 'The condition, rule, or table to look up',
429
+ required: true,
430
+ },
431
+ ],
432
+ async handler(args) {
433
+ const topic = (0, coerce_1.str)(args.topic, 'topic').toLowerCase().trim();
434
+ const condition = srd_1.CONDITIONS[topic];
435
+ if (condition) {
436
+ return {
437
+ topic,
438
+ kind: 'condition',
439
+ text: condition,
440
+ attribution: srd_1.SRD_ATTRIBUTION,
441
+ };
442
+ }
443
+ const rule = srd_1.RULES_TOPICS[topic] || srd_1.RULES_TOPICS[topic.replace(/s$/, '')];
444
+ if (rule) {
445
+ return { topic, kind: 'rule', text: rule, attribution: srd_1.SRD_ATTRIBUTION };
446
+ }
447
+ const table = lookupTable(topic);
448
+ if (table) {
449
+ return { topic, kind: 'table', ...table, attribution: srd_1.SRD_ATTRIBUTION };
450
+ }
451
+ const weapon = (0, weapons_1.resolveWeapon)(topic);
452
+ if (weapon.weapon) {
453
+ return {
454
+ topic,
455
+ kind: 'weapon',
456
+ text: (0, weapons_1.describeWeapon)(weapon.weapon),
457
+ weapon: weapon.weapon,
458
+ attribution: srd_1.SRD_ATTRIBUTION,
459
+ };
460
+ }
461
+ if (weapon.ambiguous) {
462
+ return {
463
+ topic,
464
+ found: false,
465
+ ambiguous: weapon.ambiguous,
466
+ message: `"${topic}" matches ${weapon.ambiguous.length} weapons. Ask again with the full name.`,
467
+ };
468
+ }
469
+ if (/^(carrying capacity|carry|encumbrance|encumbered|lifting)/.test(topic)) {
470
+ return {
471
+ topic,
472
+ kind: 'rule',
473
+ text: `Carrying capacity is Strength x${gear_1.CARRY_MULTIPLIER} pounds. You can push, drag or lift up to Strength x${gear_1.PUSH_DRAG_LIFT_MULTIPLIER}, and while pushing or dragging more than your carrying capacity your speed drops to 5 feet. Each size category above Medium doubles all of these; a Tiny creature halves them. ` +
474
+ `The optional encumbrance variant replaces the Strength column of the armour table: above Strength x${gear_1.ENCUMBERED_MULTIPLIER} you are encumbered and your speed drops by 10 feet, and above Strength x${gear_1.HEAVILY_ENCUMBERED_MULTIPLIER} you are heavily encumbered — speed drops by 20 feet and you have disadvantage on ability checks, attack rolls and saving throws using Strength, Dexterity or Constitution.`,
475
+ attribution: srd_1.SRD_ATTRIBUTION,
476
+ };
477
+ }
478
+ if (topic === 'background' || topic === 'backgrounds') {
479
+ return { topic, kind: 'rule', text: backgrounds_2.BACKGROUNDS_RULE, attribution: srd_1.SRD_ATTRIBUTION };
480
+ }
481
+ const background = (0, backgrounds_1.resolveBackground)(topic);
482
+ if (background.background) {
483
+ return {
484
+ topic,
485
+ kind: 'background',
486
+ text: (0, backgrounds_1.describeBackground)(background.background),
487
+ attribution: srd_1.SRD_ATTRIBUTION,
488
+ };
489
+ }
490
+ if (topic === 'feat' || topic === 'feats') {
491
+ return { topic, kind: 'rule', text: feats_2.FEATS_RULE, attribution: srd_1.SRD_ATTRIBUTION };
492
+ }
493
+ const feat = (0, feats_1.resolveFeat)(topic);
494
+ if (feat.feat) {
495
+ return {
496
+ topic,
497
+ kind: 'feat',
498
+ text: (0, feats_1.describeFeat)(feat.feat),
499
+ attribution: srd_1.SRD_ATTRIBUTION,
500
+ };
501
+ }
502
+ const race = (0, races_1.resolveRace)(topic);
503
+ if (race.race && !race.unknownSubrace) {
504
+ return {
505
+ topic,
506
+ kind: 'race',
507
+ text: (0, races_1.describeRace)(race.race, race.subrace),
508
+ attribution: srd_1.SRD_ATTRIBUTION,
509
+ };
510
+ }
511
+ const armor = srd_1.ARMOR[topic] || srd_1.ARMOR[topic.replace(/\s+armou?r$/, '')];
512
+ if (armor) {
513
+ const dex = armor.dex === 'full'
514
+ ? ' + Dex'
515
+ : armor.dex === 'capped'
516
+ ? ' + Dex (max 2)'
517
+ : '';
518
+ return {
519
+ topic,
520
+ kind: 'armor',
521
+ text: `**${armor.name}** — AC ${armor.baseAc}${dex}` +
522
+ (armor.strengthRequirement
523
+ ? `; needs Strength ${armor.strengthRequirement} or speed drops 10 ft`
524
+ : '') +
525
+ (armor.stealthDisadvantage ? '; disadvantage on Stealth' : ''),
526
+ armor,
527
+ attribution: srd_1.SRD_ATTRIBUTION,
528
+ };
529
+ }
530
+ const suggestions = [
531
+ ...Object.keys(srd_1.CONDITIONS),
532
+ ...Object.keys(srd_1.RULES_TOPICS),
533
+ 'xp thresholds',
534
+ 'hit dice',
535
+ 'skills',
536
+ 'spell slots <class>',
537
+ ...(0, weapons_1.weaponNames)().map((name) => name.toLowerCase()),
538
+ ...Object.keys(srd_1.ARMOR),
539
+ ...(0, races_1.raceNames)().map((name) => name.toLowerCase()),
540
+ ...(0, feats_1.featNames)().map((name) => name.toLowerCase()),
541
+ ...(0, backgrounds_1.backgroundNames)().map((name) => name.toLowerCase()),
542
+ 'feats',
543
+ 'backgrounds',
544
+ 'carrying capacity',
545
+ 'encumbrance',
546
+ ].filter((known) => known.includes(topic.split(' ')[0]) || topic.includes(known.split(' ')[0]));
547
+ return {
548
+ topic,
549
+ found: false,
550
+ message: `"${topic}" is not in the System Reference Document excerpts available here.`,
551
+ suggestions: suggestions.length > 0 ? suggestions.slice(0, 8) : undefined,
552
+ note: 'For anything beyond these excerpts, consult the rule documents attached to you.',
553
+ };
554
+ },
555
+ };
556
+ function lookupTable(topic) {
557
+ if (topic.includes('proficiency')) {
558
+ return {
559
+ text: 'Proficiency bonus by character level.',
560
+ table: srd_1.PROFICIENCY_BY_LEVEL.slice(1).map((bonus, index) => `level ${index + 1}: +${bonus}`),
561
+ };
562
+ }
563
+ if (topic.includes('xp') || topic.includes('experience')) {
564
+ return {
565
+ text: 'Experience needed to reach each level.',
566
+ table: srd_1.XP_THRESHOLDS.slice(2).map((xp, index) => `level ${index + 2}: ${xp}`),
567
+ };
568
+ }
569
+ if (topic.includes('exhaustion')) {
570
+ return {
571
+ text: 'Exhaustion is cumulative; a long rest reduces it by one.',
572
+ table: srd_1.EXHAUSTION_EFFECTS.map((effect, level) => `${level}: ${effect}`),
573
+ };
574
+ }
575
+ if (topic.includes('skill')) {
576
+ return {
577
+ text: 'Each skill and the ability it is measured against.',
578
+ table: Object.entries(srd_1.SKILL_ABILITY).map(([skill, ability]) => `${skill}: ${ability}`),
579
+ };
580
+ }
581
+ if (topic.includes('hit dice') || topic.includes('hit die')) {
582
+ return {
583
+ text: 'The hit die each class uses.',
584
+ table: Object.values(srd_1.CLASSES).map((c) => `${c.name}: ${c.hitDie}`),
585
+ };
586
+ }
587
+ if (topic.includes('slot') || topic.includes('caster')) {
588
+ const named = Object.keys(srd_1.CLASSES).find((key) => topic.includes(key));
589
+ if (named) {
590
+ const classRules = srd_1.CLASSES[named];
591
+ if (classRules.caster === 'none') {
592
+ return { text: `${classRules.name} is not a spellcaster in the SRD.` };
593
+ }
594
+ const slots = [1, 3, 5, 9, 13, 17, 20].map((level) => {
595
+ const state = {
596
+ class: [{ c: named, lvl: level, hd: classRules.hitDie }],
597
+ abil: {},
598
+ slots: {},
599
+ };
600
+ const expected = rules.expectedSpellSlots(state);
601
+ const summary = Object.entries(expected)
602
+ .map(([spellLevel, count]) => `L${spellLevel} x${count}`)
603
+ .join(', ') || 'none';
604
+ return `class level ${level}: ${summary}`;
605
+ });
606
+ return {
607
+ text: `Spell slots for a ${classRules.name} (${classRules.caster} caster).`,
608
+ table: slots,
609
+ };
610
+ }
611
+ return {
612
+ text: 'Name a class to see its spell slot progression, e.g. "spell slots ranger".',
613
+ };
614
+ }
615
+ return null;
616
+ }
@@ -0,0 +1,7 @@
1
+ import { NativeToolRegistry } from '../native-tool-registry.service';
2
+ import { dnd5eTools } from './dnd5e';
3
+ export declare function registerToolPacks(registry: NativeToolRegistry, packList: string | undefined): string[];
4
+ export declare function availableToolPacks(): string[];
5
+ export declare function enabledToolPacks(): string[];
6
+ export declare function resetEnabledToolPacks(): void;
7
+ export { dnd5eTools };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dnd5eTools = void 0;
4
+ exports.registerToolPacks = registerToolPacks;
5
+ exports.availableToolPacks = availableToolPacks;
6
+ exports.enabledToolPacks = enabledToolPacks;
7
+ exports.resetEnabledToolPacks = resetEnabledToolPacks;
8
+ const dnd5e_1 = require("./dnd5e");
9
+ Object.defineProperty(exports, "dnd5eTools", { enumerable: true, get: function () { return dnd5e_1.dnd5eTools; } });
10
+ const logger_1 = require("../../common/logger");
11
+ const PACKS = {
12
+ dnd5e: dnd5e_1.dnd5eTools,
13
+ };
14
+ const enabled = new Set();
15
+ function registerToolPacks(registry, packList) {
16
+ const names = (packList || '')
17
+ .split(',')
18
+ .map((name) => name.trim().toLowerCase())
19
+ .filter((name) => name.length > 0);
20
+ if (names.length === 0)
21
+ return [];
22
+ const registered = [];
23
+ for (const name of names) {
24
+ const pack = PACKS[name];
25
+ if (!pack) {
26
+ logger_1.logger.warn(`Unknown tool pack "${name}" in BRIYAH_TOOL_PACKS; available packs: ${Object.keys(PACKS).join(', ')}`);
27
+ continue;
28
+ }
29
+ const tools = pack().map((tool) => ({ ...tool, group: name }));
30
+ registry.registerTools(tools);
31
+ enabled.add(name);
32
+ registered.push(...tools.map((tool) => tool.name));
33
+ logger_1.logger.log(`Registered tool pack "${name}" with ${tools.length} tools`);
34
+ }
35
+ return registered;
36
+ }
37
+ function availableToolPacks() {
38
+ return Object.keys(PACKS);
39
+ }
40
+ function enabledToolPacks() {
41
+ return [...enabled];
42
+ }
43
+ function resetEnabledToolPacks() {
44
+ enabled.clear();
45
+ }