briyah 2.0.0 → 2.0.2

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 (320) hide show
  1. package/README.md +263 -74
  2. package/data/common/config/markup +1 -1
  3. package/data/common/config/model_prices.json +46369 -46361
  4. package/data/common/config/rpg_models.json +60 -0
  5. package/data/common/prompts/narrator/create_chapter.prompt +12 -1
  6. package/data/common/prompts/pdf_converter/convert_pdf_page.prompt +8 -1
  7. package/data/common/prompts/perceive.prompt +287 -291
  8. package/data/packs/acts/agents/character-guide.json +6 -0
  9. package/data/packs/acts/agents/discipleship-mentor.json +6 -0
  10. package/data/packs/acts/agents/mentor-coach.json +6 -0
  11. package/data/packs/acts/agents/student.json +13 -0
  12. package/data/packs/acts/agents/table-moderator.json +6 -0
  13. package/data/packs/acts/artifacts/chapter-01-acts-1.md +405 -0
  14. package/data/packs/acts/artifacts/chapter-02-acts-2.md +443 -0
  15. package/data/packs/acts/artifacts/chapter-03-acts-3.md +409 -0
  16. package/data/packs/acts/artifacts/chapter-04-acts-4.md +438 -0
  17. package/data/packs/acts/artifacts/chapter-05-acts-5.md +434 -0
  18. package/data/packs/acts/artifacts/chapter-06-acts-6.md +441 -0
  19. package/data/packs/acts/artifacts/chapter-07-acts-7.md +472 -0
  20. package/data/packs/acts/artifacts/chapter-08-acts-8.md +512 -0
  21. package/data/packs/acts/artifacts/chapter-09-acts-9.md +346 -0
  22. package/data/packs/acts/artifacts/chapter-10-acts-10.md +367 -0
  23. package/data/packs/acts/artifacts/chapter-11-acts-11.md +391 -0
  24. package/data/packs/acts/artifacts/chapter-12-acts-12.md +390 -0
  25. package/data/packs/acts/artifacts/chapter-13-acts-13.md +388 -0
  26. package/data/packs/acts/artifacts/chapter-14-acts-14.md +466 -0
  27. package/data/packs/acts/artifacts/chapter-15-acts-15.md +413 -0
  28. package/data/packs/acts/artifacts/chapter-16-acts-16.md +585 -0
  29. package/data/packs/acts/artifacts/chapter-17-acts-17.md +428 -0
  30. package/data/packs/acts/artifacts/chapter-18-acts-18.md +486 -0
  31. package/data/packs/acts/artifacts/chapter-19-acts-19.md +461 -0
  32. package/data/packs/acts/artifacts/chapter-20-acts-20.md +389 -0
  33. package/data/packs/acts/artifacts/chapter-21-acts-21.md +452 -0
  34. package/data/packs/acts/artifacts/chapter-22-acts-22.md +424 -0
  35. package/data/packs/acts/artifacts/chapter-23-acts-23.md +395 -0
  36. package/data/packs/acts/artifacts/chapter-24-acts-24.md +446 -0
  37. package/data/packs/acts/artifacts/chapter-25-acts-25.md +391 -0
  38. package/data/packs/acts/artifacts/chapter-26-acts-26.md +431 -0
  39. package/data/packs/acts/artifacts/chapter-27-acts-27.md +530 -0
  40. package/data/packs/acts/artifacts/chapter-28-acts-28.md +1871 -0
  41. package/data/packs/acts/artifacts/chapters.manifest.json +170 -0
  42. package/data/packs/acts/artifacts/character_guide-creation.md +112 -0
  43. package/data/packs/acts/artifacts/discipleship_mentor-procedure.md +154 -0
  44. package/data/packs/acts/artifacts/discipleship_mentor-systems.md +72 -0
  45. package/data/packs/acts/artifacts/manifest.json +197 -0
  46. package/data/packs/acts/artifacts/stage-guide.md +94 -0
  47. package/data/packs/acts/pack.json +6 -0
  48. package/data/packs/acts/prompts/acts_player/defaults_config.json +5 -0
  49. package/data/packs/acts/prompts/acts_player/perceive.json +29 -0
  50. package/data/packs/acts/prompts/acts_player/perceive.prompt +87 -0
  51. package/data/packs/acts/prompts/acts_player/system_instruction.prompt +0 -0
  52. package/data/packs/acts/prompts/acts_room_moderator/defaults_config.json +9 -0
  53. package/data/packs/acts/prompts/acts_room_moderator/moderate.json +34 -0
  54. package/data/packs/acts/prompts/acts_room_moderator/moderate.prompt +70 -0
  55. package/data/packs/acts/prompts/acts_room_moderator/system_instruction.prompt +0 -0
  56. package/data/packs/acts/prompts/character_guide/defaults_config.json +18 -0
  57. package/data/packs/acts/prompts/character_guide/perceive.json +29 -0
  58. package/data/packs/acts/prompts/character_guide/perceive.prompt +140 -0
  59. package/data/packs/acts/prompts/character_guide/system_instruction.prompt +0 -0
  60. package/data/packs/acts/prompts/discipleship_mentor/defaults_config.json +23 -0
  61. package/data/packs/acts/prompts/discipleship_mentor/perceive.json +33 -0
  62. package/data/packs/acts/prompts/discipleship_mentor/perceive.prompt +245 -0
  63. package/data/packs/acts/prompts/discipleship_mentor/system_instruction.prompt +0 -0
  64. package/data/packs/acts/prompts/mentor_coach/defaults_config.json +13 -0
  65. package/data/packs/acts/prompts/mentor_coach/perceive.json +29 -0
  66. package/data/packs/acts/prompts/mentor_coach/perceive.prompt +87 -0
  67. package/data/packs/acts/prompts/mentor_coach/system_instruction.prompt +0 -0
  68. package/data/packs/acts/rooms/session.json +14 -0
  69. package/data/packs/acts/rooms/training.json +58 -0
  70. package/data/packs/dnd5e/artifacts/background-acolyte.md +66 -0
  71. package/data/packs/dnd5e/artifacts/character_creator-basics.md +31 -13
  72. package/data/packs/dnd5e/artifacts/class-barbarian.md +4 -1
  73. package/data/packs/dnd5e/artifacts/class-bard.md +2 -1
  74. package/data/packs/dnd5e/artifacts/class-cleric.md +2 -1
  75. package/data/packs/dnd5e/artifacts/class-druid.md +3 -1
  76. package/data/packs/dnd5e/artifacts/class-fighter.md +3 -1
  77. package/data/packs/dnd5e/artifacts/class-monk.md +2 -1
  78. package/data/packs/dnd5e/artifacts/class-paladin.md +2 -1
  79. package/data/packs/dnd5e/artifacts/class-ranger.md +3 -1
  80. package/data/packs/dnd5e/artifacts/class-rogue.md +3 -1
  81. package/data/packs/dnd5e/artifacts/class-sorcerer.md +2 -1
  82. package/data/packs/dnd5e/artifacts/class-warlock.md +3 -1
  83. package/data/packs/dnd5e/artifacts/class-wizard.md +2 -1
  84. package/data/packs/dnd5e/artifacts/manifest.json +6 -0
  85. package/data/packs/dnd5e/pack.json +1 -1
  86. package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +491 -378
  87. package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +24 -7
  88. package/data/packs/dnd5e/prompts/character_creator/defaults_config.json +2 -13
  89. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +217 -87
  90. package/data/packs/dnd5e/prompts/dnd_player/defaults_config.json +5 -5
  91. package/data/packs/dnd5e/prompts/dnd_player/perceive.prompt +18 -4
  92. package/data/packs/dnd5e/prompts/dnd_room_moderator/defaults_config.json +9 -9
  93. package/data/packs/dnd5e/prompts/dnd_room_moderator/moderate.prompt +13 -10
  94. package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +32 -30
  95. package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +794 -764
  96. package/data/packs/dnd5e/rooms/campaign.json +15 -0
  97. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +3 -0
  98. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +40 -11
  99. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +1 -0
  100. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +16 -0
  101. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +5 -3
  102. package/dist-sdk/server/src/ai/agent-store.service.js +1 -1
  103. package/dist-sdk/server/src/ai/artifact.service.d.ts +2 -0
  104. package/dist-sdk/server/src/ai/artifact.service.js +6 -0
  105. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +2 -0
  106. package/dist-sdk/server/src/ai/pack-artifacts.js +65 -8
  107. package/dist-sdk/server/src/app/user-service-factory.js +6 -1
  108. package/dist-sdk/server/src/app/user-service-manager.js +1 -1
  109. package/dist-sdk/server/src/app.controller.d.ts +9 -1
  110. package/dist-sdk/server/src/app.controller.js +124 -13
  111. package/dist-sdk/server/src/app.service.d.ts +25 -2
  112. package/dist-sdk/server/src/app.service.js +122 -110
  113. package/dist-sdk/server/src/auth/auth.controller.js +4 -0
  114. package/dist-sdk/server/src/auth/auth.service.d.ts +2 -1
  115. package/dist-sdk/server/src/auth/dto/phone-login.dto.d.ts +2 -1
  116. package/dist-sdk/server/src/config/prompt-resolver.d.ts +2 -0
  117. package/dist-sdk/server/src/config/prompt-resolver.js +14 -7
  118. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +43 -0
  119. package/dist-sdk/server/src/documents/pdf-conversion.js +175 -0
  120. package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +2 -1
  121. package/dist-sdk/server/src/packs/pack-instantiation.service.js +16 -5
  122. package/dist-sdk/server/src/room/room-message.service.d.ts +2 -1
  123. package/dist-sdk/server/src/room/room-message.service.js +3 -2
  124. package/dist-sdk/server/src/room/room-store.service.js +5 -1
  125. package/dist-sdk/server/src/room/room.d.ts +15 -2
  126. package/dist-sdk/server/src/room/room.js +86 -25
  127. package/dist-sdk/server/src/rpg/rpg-models.d.ts +9 -0
  128. package/dist-sdk/server/src/rpg/rpg-models.js +128 -0
  129. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +10 -0
  130. package/dist-sdk/server/src/rpg/rpg-roster.js +71 -0
  131. package/dist-sdk/server/src/rpg/rpg.service.d.ts +29 -0
  132. package/dist-sdk/server/src/rpg/rpg.service.js +199 -0
  133. package/dist-sdk/server/src/sdk/index.d.ts +7 -4
  134. package/dist-sdk/server/src/sdk/index.js +8 -1
  135. package/dist-sdk/server/src/story/story.service.d.ts +2 -1
  136. package/dist-sdk/server/src/story/story.service.js +42 -4
  137. package/dist-sdk/server/src/tools/native-tool.types.d.ts +5 -0
  138. package/dist-sdk/server/src/tools/packs/acts/data/cards.d.ts +53 -0
  139. package/dist-sdk/server/src/tools/packs/acts/data/cards.js +54 -0
  140. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.d.ts +2 -0
  141. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.js +185 -0
  142. package/dist-sdk/server/src/tools/packs/acts/data/encounters.d.ts +12 -0
  143. package/dist-sdk/server/src/tools/packs/acts/data/encounters.js +102 -0
  144. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.d.ts +2 -0
  145. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.js +196 -0
  146. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.d.ts +2 -0
  147. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.js +1311 -0
  148. package/dist-sdk/server/src/tools/packs/acts/engine/cards.d.ts +5 -0
  149. package/dist-sdk/server/src/tools/packs/acts/engine/cards.js +27 -0
  150. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.d.ts +37 -0
  151. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.js +120 -0
  152. package/dist-sdk/server/src/tools/packs/acts/engine/dice.d.ts +20 -0
  153. package/dist-sdk/server/src/tools/packs/acts/engine/dice.js +41 -0
  154. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.d.ts +54 -0
  155. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.js +200 -0
  156. package/dist-sdk/server/src/tools/packs/acts/index.d.ts +2 -0
  157. package/dist-sdk/server/src/tools/packs/acts/index.js +24 -0
  158. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.d.ts +2 -0
  159. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.js +184 -0
  160. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.d.ts +2 -0
  161. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.js +107 -0
  162. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.d.ts +3 -0
  163. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.js +146 -0
  164. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.d.ts +4 -0
  165. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.js +241 -0
  166. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.d.ts +3 -0
  167. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.js +72 -0
  168. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.d.ts +2 -0
  169. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.js +75 -0
  170. package/dist-sdk/server/src/tools/packs/acts/tools/shared.d.ts +20 -0
  171. package/dist-sdk/server/src/tools/packs/acts/tools/shared.js +70 -0
  172. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.d.ts +4 -0
  173. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.js +215 -0
  174. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +0 -21
  175. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +1 -56
  176. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +10 -0
  177. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +67 -0
  178. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +5 -0
  179. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +7 -1
  180. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +4 -3
  181. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +6 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +92 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +32 -5
  184. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +177 -28
  185. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +1 -13
  186. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +15 -145
  187. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +7 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +11 -0
  189. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +5 -0
  190. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +45 -2
  191. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +3 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +21 -0
  193. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +45 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +6 -4
  195. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +17 -0
  196. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +56 -4
  197. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +3 -0
  198. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +117 -15
  199. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +2 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +96 -0
  201. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +40 -3
  202. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +36 -27
  203. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +7 -4
  204. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +15 -1
  205. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +73 -0
  206. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +40 -12
  207. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +68 -2
  208. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  209. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +119 -14
  210. package/dist-sdk/server/src/tools/packs/index.d.ts +2 -1
  211. package/dist-sdk/server/src/tools/packs/index.js +4 -1
  212. package/dist-sdk/server/src/tools/shared/coerce.d.ts +13 -0
  213. package/dist-sdk/server/src/tools/shared/coerce.js +147 -0
  214. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +3 -2
  215. package/dist-sdk/server/src/tools/tool-execution.service.js +4 -1
  216. package/dist-sdk/shared/types/app.types.d.ts +73 -0
  217. package/dist-sdk/shared/types/app.types.js +2 -1
  218. package/docs/assets/hierarchy.js +1 -1
  219. package/docs/assets/highlight.css +7 -0
  220. package/docs/assets/navigation.js +1 -1
  221. package/docs/assets/search.js +1 -1
  222. package/docs/classes/Agent.html +73 -73
  223. package/docs/classes/Briyah.html +16 -16
  224. package/docs/classes/BriyahConfigService.html +7 -7
  225. package/docs/classes/NativeToolRegistry.html +10 -10
  226. package/docs/classes/PackInstantiationService.html +20 -9
  227. package/docs/classes/PackService.html +13 -13
  228. package/docs/classes/Room.html +118 -93
  229. package/docs/classes/RoomMessage.html +22 -22
  230. package/docs/enums/MessageAction.html +18 -18
  231. package/docs/functions/actsTools.html +44 -0
  232. package/docs/functions/availableToolPacks.html +4 -4
  233. package/docs/functions/buildMarkdown.html +54 -0
  234. package/docs/functions/dnd5eTools.html +4 -4
  235. package/docs/functions/installToolPacks.html +4 -4
  236. package/docs/functions/pageMarker.html +45 -0
  237. package/docs/functions/registerToolPacks.html +4 -4
  238. package/docs/functions/splitMarkdownIntoPages.html +51 -0
  239. package/docs/functions/stripWrappingFence.html +52 -0
  240. package/docs/hierarchy.html +13 -9
  241. package/docs/index.html +161 -44
  242. package/docs/interfaces/AgentCreationOptions.html +12 -12
  243. package/docs/interfaces/AgentInfo.html +30 -30
  244. package/docs/interfaces/AgentMessagesResponse.html +8 -8
  245. package/docs/interfaces/AppService.html +300 -194
  246. package/docs/interfaces/Artifact.html +9 -9
  247. package/docs/interfaces/ArtifactMetadata.html +13 -13
  248. package/docs/interfaces/ArtifactWriteOptions.html +7 -7
  249. package/docs/interfaces/AttachDocumentResponse.html +6 -6
  250. package/docs/interfaces/BriyahConfigOptions.html +12 -12
  251. package/docs/interfaces/ChapterInfo.html +6 -6
  252. package/docs/interfaces/Character.html +10 -10
  253. package/docs/interfaces/ConversionAgent.html +78 -0
  254. package/docs/interfaces/CreateAgentResponse.html +5 -5
  255. package/docs/interfaces/CreateRoomResponse.html +6 -6
  256. package/docs/interfaces/CreateStoryResponse.html +5 -5
  257. package/docs/interfaces/FileList.html +5 -5
  258. package/docs/interfaces/FileMetadata.html +10 -10
  259. package/docs/interfaces/IConfigService.html +5 -5
  260. package/docs/interfaces/InstantiateModels.html +6 -6
  261. package/docs/interfaces/InstantiateRoomResult.html +7 -7
  262. package/docs/interfaces/LoadedPack.html +16 -16
  263. package/docs/interfaces/LoggingOptions.html +9 -9
  264. package/docs/interfaces/Message.html +9 -9
  265. package/docs/interfaces/ModelChoice.html +7 -7
  266. package/docs/interfaces/ModelInfo.html +8 -8
  267. package/docs/interfaces/NativeToolDefinition.html +10 -10
  268. package/docs/interfaces/PackAgentTemplate.html +9 -9
  269. package/docs/interfaces/PackRoomTemplate.html +11 -11
  270. package/docs/interfaces/PackView.html +20 -20
  271. package/docs/interfaces/PdfConversionOptions.html +102 -0
  272. package/docs/interfaces/PdfConversionResult.html +97 -0
  273. package/docs/interfaces/PdfMarkdownOptions.html +198 -0
  274. package/docs/interfaces/PdfMarkdownResult.html +106 -0
  275. package/docs/interfaces/PdfPageMarkdown.html +94 -0
  276. package/docs/interfaces/PreparedPromptResponse.html +6 -6
  277. package/docs/interfaces/ProcessTextResponse.html +10 -10
  278. package/docs/interfaces/PromptFile.html +7 -7
  279. package/docs/interfaces/PromptFileContent.html +8 -8
  280. package/docs/interfaces/PromptFilesResponse.html +5 -5
  281. package/docs/interfaces/PromptFolder.html +8 -8
  282. package/docs/interfaces/PromptFolderDefaults.html +19 -19
  283. package/docs/interfaces/PromptFolderDefaultsResponse.html +21 -8
  284. package/docs/interfaces/PromptFoldersResponse.html +5 -5
  285. package/docs/interfaces/RoomDetails.html +19 -19
  286. package/docs/interfaces/RoomErrorUpdate.html +82 -0
  287. package/docs/interfaces/RoomInfo.html +10 -10
  288. package/docs/interfaces/RoomMessageUpdate.html +30 -15
  289. package/docs/interfaces/RoomMessagesResponse.html +6 -6
  290. package/docs/interfaces/SendMessageResult.html +6 -6
  291. package/docs/interfaces/StoryErrorEvent.html +8 -8
  292. package/docs/interfaces/StoryIdea.html +8 -8
  293. package/docs/interfaces/StoryInfo.html +28 -28
  294. package/docs/interfaces/StoryIntroduceCharacterEvent.html +7 -7
  295. package/docs/interfaces/StoryProgressChapterEvent.html +6 -6
  296. package/docs/interfaces/StoryState.html +12 -12
  297. package/docs/interfaces/StoryStateEvent.html +7 -7
  298. package/docs/interfaces/ToolArtifact.html +9 -9
  299. package/docs/interfaces/ToolCaller.html +7 -7
  300. package/docs/interfaces/ToolDefinition.html +9 -9
  301. package/docs/interfaces/ToolHelpers.html +17 -8
  302. package/docs/interfaces/ToolPackDocuments.html +100 -0
  303. package/docs/interfaces/ToolParameter.html +8 -8
  304. package/docs/interfaces/ToolRoomAccess.html +14 -14
  305. package/docs/interfaces/ToolSummary.html +8 -8
  306. package/docs/interfaces/ToolsResponse.html +7 -7
  307. package/docs/interfaces/Transaction.html +13 -13
  308. package/docs/interfaces/TransactionHistoryResponse.html +6 -6
  309. package/docs/modules.html +10 -10
  310. package/docs/types/PackOrigin.html +4 -4
  311. package/docs/types/PromptScope.html +4 -4
  312. package/docs/types/RoomTurnMode.html +4 -4
  313. package/docs/types/RoomUpdate.html +36 -0
  314. package/docs/types/RosterOverrides.html +42 -0
  315. package/docs/types/ToolContext.html +4 -4
  316. package/docs/types/ToolRunResult.html +4 -4
  317. package/package.json +1 -1
  318. package/src/tools/packs/dnd5e/README.md +186 -69
  319. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.d.ts +0 -20
  320. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.js +0 -112
@@ -5,21 +5,34 @@ const coerce_1 = require("../engine/coerce");
5
5
  const encounter_1 = require("../engine/encounter");
6
6
  const sheet_1 = require("../engine/sheet");
7
7
  const shared_1 = require("./shared");
8
- function isDown(room, combatant) {
9
- if (!combatant.foe)
10
- return false;
11
- const artifact = room.get((0, sheet_1.foeArtifactName)(combatant.name));
12
- if (!artifact)
13
- return true;
14
- try {
15
- return (0, sheet_1.parseSheet)(artifact.body).hp.cur <= 0;
16
- }
17
- catch {
18
- return false;
19
- }
8
+ function readOutcome(room, state) {
9
+ return state.order.map((combatant) => {
10
+ let sheet;
11
+ try {
12
+ sheet = (0, shared_1.loadSheet)(room, combatant.name).state;
13
+ }
14
+ catch {
15
+ return { name: combatant.name, hitPoints: '—', status: 'unknown' };
16
+ }
17
+ const outcome = {
18
+ name: sheet.name,
19
+ hitPoints: `${sheet.hp.cur}/${sheet.hp.max}`,
20
+ status: describeStanding(sheet),
21
+ };
22
+ if (outcome.status === 'dying') {
23
+ outcome.deathSaves = `${sheet.deathSaves.s} success / ${sheet.deathSaves.f} failure`;
24
+ }
25
+ if (sheet.cond.length > 0)
26
+ outcome.conditions = sheet.cond.map((c) => c.n);
27
+ return outcome;
28
+ });
20
29
  }
21
- function downNames(room, state) {
22
- return state.order.filter((c) => isDown(room, c)).map((c) => c.name);
30
+ function describeStanding(sheet) {
31
+ if (sheet.hp.cur > 0)
32
+ return 'standing';
33
+ if (sheet.foe || sheet.deathSaves.f >= 3)
34
+ return 'dead';
35
+ return sheet.stable ? 'stable' : 'dying';
23
36
  }
24
37
  function describe(room, state) {
25
38
  const up = (0, encounter_1.currentCombatant)(state);
@@ -33,13 +46,13 @@ function describe(room, state) {
33
46
  initiative: c.init,
34
47
  acted: i < state.turn,
35
48
  up: i === state.turn,
36
- down: isDown(room, c) || undefined,
49
+ down: (0, shared_1.isDown)(room, c) || undefined,
37
50
  })),
38
51
  };
39
52
  }
40
53
  exports.encounterTool = {
41
54
  name: 'encounter',
42
- description: 'Read or advance the fight in progress. "action" is status (the default — the round, the initiative order, and whose turn it is), next (mark the current combatant done and move to the next, rolling into the next round at the end of the order), remove (take a combatant out of the order entirely), or end (finish the fight and clear its monsters). A dead monster is skipped automatically by "next", so you never call on a corpse; a dying character is not skipped, because their turn is when they roll a death saving throw. Use "next" once per turn instead of re-copying the order into your situation line — the stored order cannot drift, and a re-copied one did.',
55
+ description: 'Read or advance the fight in progress. "action" is status (the default — the round, the initiative order, and whose turn it is), next (mark the current combatant done and move to the next, rolling into the next round at the end of the order), remove (take a combatant out of the order entirely), or end (finish the fight and clear its monsters). A dead monster is skipped automatically by "next", so you never call on a corpse; a dying character is not skipped, because their turn is when they roll a death saving throw. Use "next" once per turn instead of re-copying the order into your situation line — the stored order cannot drift, and a re-copied one did. "end" also returns "outcome": every combatant\'s hit points, conditions and death saves read off their sheets. Report the fight from that and not from memory — it is the difference between a character who is dying and one who is dead, and a report written from memory has got that wrong.',
43
56
  parameters: [
44
57
  {
45
58
  name: 'action',
@@ -73,12 +86,14 @@ exports.encounterTool = {
73
86
  throw e;
74
87
  }
75
88
  if (action === 'end') {
89
+ const outcome = state ? readOutcome(room, state) : undefined;
76
90
  const cleared = (0, shared_1.clearFoes)(room);
77
91
  room.remove(sheet_1.ENCOUNTER_ARTIFACT);
78
92
  return {
79
93
  ended: true,
80
94
  clearedMonsters: cleared.length > 0 ? cleared : undefined,
81
- note: 'The encounter is over. Report the outcome to the room leader and stop.',
95
+ outcome,
96
+ note: 'The encounter is over. Report the outcome to the room leader and stop. Report it from "outcome" above and not from memory — it is read from the sheets, so a character it calls dying is alive and still rolling death saving throws, whatever was said during the fight.',
82
97
  };
83
98
  }
84
99
  if (!state) {
@@ -105,16 +120,16 @@ exports.encounterTool = {
105
120
  options: [`In the order: ${state.order.map((c) => c.name).join(', ')}`],
106
121
  };
107
122
  }
108
- writeEncounter(room, state);
123
+ (0, shared_1.writeEncounter)(room, state);
109
124
  return { removed: name, ...describe(room, state) };
110
125
  }
111
126
  if (action !== 'next') {
112
127
  throw new Error(`"${action}" is not an action. Use status, next, remove, or end.`);
113
128
  }
114
129
  const before = state.round;
115
- const { combatant, skipped } = (0, encounter_1.advanceTurn)(state, (c) => isDown(room, c));
116
- writeEncounter(room, state);
117
- const remaining = (0, shared_1.listFoeNames)(room).filter((name) => !isDown(room, { name, init: 0, foe: true }));
130
+ const { combatant, skipped } = (0, encounter_1.advanceTurn)(state, (c) => (0, shared_1.isDown)(room, c));
131
+ (0, shared_1.writeEncounter)(room, state);
132
+ const remaining = (0, shared_1.listFoeNames)(room).filter((name) => !(0, shared_1.isDown)(room, { name, init: 0, foe: true }));
118
133
  return {
119
134
  ...describe(room, state),
120
135
  newRound: state.round > before ? state.round : undefined,
@@ -126,9 +141,3 @@ exports.encounterTool = {
126
141
  };
127
142
  },
128
143
  };
129
- function writeEncounter(room, state) {
130
- room.update(sheet_1.ENCOUNTER_ARTIFACT, () => (0, encounter_1.renderEncounter)(state, downNames(room, state)), {
131
- viewers: room.agentNicknames,
132
- transient: true,
133
- });
134
- }
@@ -11,7 +11,7 @@ const DEFINE_EXAMPLE = '{"name":"Kesh\'s enforcer","ac":15,"hp":58,"hpDice":"9d8
11
11
  const MAX_INSTANCES = 12;
12
12
  exports.statBlockTool = {
13
13
  name: 'stat_block',
14
- description: 'Get a creature\'s statistics, or define one for this campaign. Reading: give "creature" a name and you get armour class, hit points, speed, ability scores, saving throw bonuses, attacks with their bonus and damage dice, traits, non-attack actions such as breath weapons, reactions, legendary actions, and any resistances — everything needed to run it. Use the creature\'s full name: a partial name that matches several creatures comes back asking which one you meant, rather than guessing. Set "creature" to "list" to see what is available, with "filter" to narrow it. Defining: pass "define" as a JSON object to add or replace a creature in this campaign\'s bestiary, which is where anything not built in belongs; a bestiary entry always wins over the built-in table, so you can override one too. "traits", "actions", "reactions" and "legendary.options" are each a list of named paragraphs — [{"n":"Name","text":"What it does."}] — so give every one of them its own entry rather than writing several into one string. "resist", "immune", "vuln" and "condImmune" are lists of words. Set "count" to get individually rolled hit point totals for a group, labelled A, B, C — you track those yourself as the fight runs. Example define: ' +
14
+ description: 'Get a creature\'s statistics, or define one for this campaign. Reading: give "creature" a name and you get armour class, hit points, speed, ability scores, saving throw bonuses, attacks with their bonus and damage dice, traits, non-attack actions such as breath weapons, reactions, legendary actions, and any resistances — everything needed to run it. Use the creature\'s full name: a partial name that matches several creatures comes back asking which one you meant, rather than guessing. Set "creature" to "list" to see what is available, with "filter" to narrow it by name, kind or size — "filter": "fey", "filter": "undead", "filter": "dragon", "filter": "huge" all work, as does part of a name like "giant". Defining: pass "define" as a JSON object to add or replace a creature in this campaign\'s bestiary, which is where anything not built in belongs; a bestiary entry always wins over the built-in table, so you can override one too. "traits", "actions", "reactions" and "legendary.options" are each a list of named paragraphs — [{"n":"Name","text":"What it does."}] — so give every one of them its own entry rather than writing several into one string. "resist", "immune", "vuln" and "condImmune" are lists of words. Set "count" to get individually rolled hit point totals for a group, labelled A, B, C — you track those yourself as the fight runs. Example define: ' +
15
15
  DEFINE_EXAMPLE,
16
16
  parameters: [
17
17
  {
@@ -41,7 +41,7 @@ exports.statBlockTool = {
41
41
  {
42
42
  name: 'filter',
43
43
  type: 'string',
44
- description: 'With creature = "list", show only names containing this text, e.g. "giant"',
44
+ description: 'With creature = "list", show only creatures whose name, kind or size contains this text — "fey", "fiend", "undead", "beast", "huge", or part of a name like "giant"',
45
45
  required: false,
46
46
  },
47
47
  ],
@@ -65,8 +65,11 @@ exports.statBlockTool = {
65
65
  filter: available.filter,
66
66
  truncated: available.truncated,
67
67
  note: available.truncated
68
- ? `Only the first names are shown. Narrow with the "filter" parameter, e.g. filter: "giant".`
69
- : `Anything not listed needs defining with the "define" parameter before it can be run. Campaign entries override built-in ones of the same name.`,
68
+ ? `Only the first names are shown. Narrow with the "filter" parameter, which matches name, kind and size — e.g. filter: "giant", filter: "fey", filter: "huge".`
69
+ : `Anything not listed needs defining with the "define" parameter before it can be run. Campaign entries override built-in ones of the same name.` +
70
+ (available.filter
71
+ ? ` This is everything matching "${available.filter}" by name, kind or size — try a different word before concluding the table has none.`
72
+ : ''),
70
73
  };
71
74
  }
72
75
  const resolved = (0, bestiary_1.resolveMonster)(creature, campaign);
@@ -1,5 +1,7 @@
1
- import { ToolHelpers, ToolRoomAccess } from '../../../native-tool.types';
1
+ import { ToolHelpers, ToolPackDocuments, ToolRoomAccess } from '../../../native-tool.types';
2
+ import { GuideKind } from '../engine/guides';
2
3
  import { MutationResult, Refusal } from '../engine/character';
4
+ import { Combatant, EncounterState } from '../engine/encounter';
3
5
  import { SheetError, SheetState } from '../engine/sheet';
4
6
  export interface RefusalResult {
5
7
  applied: false;
@@ -10,6 +12,7 @@ export interface RefusalResult {
10
12
  state?: Record<string, any>;
11
13
  }
12
14
  export declare function requireRoom(helpers: ToolHelpers): ToolRoomAccess;
15
+ export declare function requirePackDocuments(helpers: ToolHelpers): ToolPackDocuments;
13
16
  export interface LoadedSheet {
14
17
  artifactName: string;
15
18
  characterName: string;
@@ -19,6 +22,10 @@ export interface LoadedSheet {
19
22
  }
20
23
  export declare function listCharacterNames(room: ToolRoomAccess): string[];
21
24
  export declare function listFoeNames(room: ToolRoomAccess): string[];
25
+ export declare function isDown(room: ToolRoomAccess, combatant: Combatant): boolean;
26
+ export declare function downNames(room: ToolRoomAccess, state: EncounterState): string[];
27
+ export declare function readEncounter(room: ToolRoomAccess): EncounterState | null;
28
+ export declare function writeEncounter(room: ToolRoomAccess, state: EncounterState): void;
22
29
  export declare function clearFoes(room: ToolRoomAccess, keep?: string[]): string[];
23
30
  export declare function loadSheet(room: ToolRoomAccess, name: string): LoadedSheet;
24
31
  export declare function mutateSheet(room: ToolRoomAccess, name: string, mutate: (sheet: LoadedSheet) => MutationResult): {
@@ -27,6 +34,13 @@ export declare function mutateSheet(room: ToolRoomAccess, name: string, mutate:
27
34
  };
28
35
  export declare function writeNewSheet(room: ToolRoomAccess, state: SheetState, notes: string, replace: boolean): string;
29
36
  export declare function refreshPartyStatus(room: ToolRoomAccess): string;
37
+ export interface GuideShare {
38
+ artifactName: string;
39
+ viewers: string[];
40
+ unknown: string[];
41
+ created: boolean;
42
+ }
43
+ export declare function shareGuide(room: ToolRoomAccess, kind: GuideKind, name: string, body: string, players: readonly string[]): GuideShare;
30
44
  export declare function partyLine(state: SheetState): string;
31
45
  export declare function toRefusalResult(refusal: Refusal, state?: SheetState): RefusalResult;
32
46
  export declare function liveState(state: SheetState): Record<string, any>;
@@ -1,20 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireRoom = requireRoom;
4
+ exports.requirePackDocuments = requirePackDocuments;
4
5
  exports.listCharacterNames = listCharacterNames;
5
6
  exports.listFoeNames = listFoeNames;
7
+ exports.isDown = isDown;
8
+ exports.downNames = downNames;
9
+ exports.readEncounter = readEncounter;
10
+ exports.writeEncounter = writeEncounter;
6
11
  exports.clearFoes = clearFoes;
7
12
  exports.loadSheet = loadSheet;
8
13
  exports.mutateSheet = mutateSheet;
9
14
  exports.writeNewSheet = writeNewSheet;
10
15
  exports.refreshPartyStatus = refreshPartyStatus;
16
+ exports.shareGuide = shareGuide;
11
17
  exports.partyLine = partyLine;
12
18
  exports.toRefusalResult = toRefusalResult;
13
19
  exports.liveState = liveState;
14
20
  exports.sheetErrorToRefusal = sheetErrorToRefusal;
15
21
  exports.sheetHeadline = sheetHeadline;
22
+ const guides_1 = require("../engine/guides");
16
23
  const coerce_1 = require("../engine/coerce");
17
24
  const character_1 = require("../engine/character");
25
+ const encounter_1 = require("../engine/encounter");
18
26
  const sheet_1 = require("../engine/sheet");
19
27
  const rules_1 = require("../engine/rules");
20
28
  function requireRoom(helpers) {
@@ -23,6 +31,12 @@ function requireRoom(helpers) {
23
31
  }
24
32
  return helpers.room;
25
33
  }
34
+ function requirePackDocuments(helpers) {
35
+ if (!helpers.packDocuments) {
36
+ throw new Error('This tool needs to read the pack\'s documents, and this deployment provides no access to them.');
37
+ }
38
+ return helpers.packDocuments;
39
+ }
26
40
  function listCharacterNames(room) {
27
41
  return room
28
42
  .list()
@@ -32,6 +46,36 @@ function listCharacterNames(room) {
32
46
  function listFoeNames(room) {
33
47
  return room.list().filter(sheet_1.isFoeArtifact).map(sheet_1.foeNameFromArtifact);
34
48
  }
49
+ function isDown(room, combatant) {
50
+ if (!combatant.foe)
51
+ return false;
52
+ const artifact = room.get((0, sheet_1.foeArtifactName)(combatant.name));
53
+ if (!artifact)
54
+ return true;
55
+ try {
56
+ return (0, sheet_1.parseSheet)(artifact.body).hp.cur <= 0;
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ }
62
+ function downNames(room, state) {
63
+ return state.order.filter((c) => isDown(room, c)).map((c) => c.name);
64
+ }
65
+ function readEncounter(room) {
66
+ try {
67
+ return (0, encounter_1.parseEncounter)(room.get(sheet_1.ENCOUNTER_ARTIFACT)?.body);
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ }
73
+ function writeEncounter(room, state) {
74
+ room.update(sheet_1.ENCOUNTER_ARTIFACT, () => (0, encounter_1.renderEncounter)(state, downNames(room, state)), {
75
+ viewers: room.agentNicknames,
76
+ transient: true,
77
+ });
78
+ }
35
79
  function clearFoes(room, keep = []) {
36
80
  const kept = new Set(keep.map((name) => (0, coerce_1.nameKey)(name)));
37
81
  const removed = listFoeNames(room).filter((name) => !kept.has((0, coerce_1.nameKey)(name)));
@@ -99,6 +143,9 @@ function mutateSheet(room, name, mutate) {
99
143
  creator: sheet.state.owner,
100
144
  transient: true,
101
145
  });
146
+ if (!(0, character_1.isRefusal)(result) && !result.state.foe) {
147
+ refreshPartyStatus(room);
148
+ }
102
149
  return { result, sheet };
103
150
  }
104
151
  function writeNewSheet(room, state, notes, replace) {
@@ -138,6 +185,29 @@ function refreshPartyStatus(room) {
138
185
  });
139
186
  return body;
140
187
  }
188
+ function shareGuide(room, kind, name, body, players) {
189
+ const artifactName = (0, guides_1.guideArtifactName)(kind, name);
190
+ const unknown = [];
191
+ const wanted = new Set([room.caller.nickname]);
192
+ for (const player of players) {
193
+ const matched = (0, coerce_1.matchName)(player, room.agentNicknames);
194
+ if (matched)
195
+ wanted.add(matched);
196
+ else
197
+ unknown.push(player);
198
+ }
199
+ const existing = room.get(artifactName);
200
+ for (const viewer of existing?.viewers || [])
201
+ wanted.add(viewer);
202
+ const viewers = room.agentNicknames.filter((nickname) => wanted.has(nickname));
203
+ const unchanged = existing?.body === body &&
204
+ existing.viewers.length === viewers.length &&
205
+ viewers.every((nickname) => existing.viewers.includes(nickname));
206
+ if (!unchanged) {
207
+ room.update(artifactName, () => body, { viewers });
208
+ }
209
+ return { artifactName, viewers, unknown, created: !existing };
210
+ }
141
211
  function partyLine(state) {
142
212
  const parts = [`${state.hp.cur}/${(0, rules_1.effectiveMaxHp)(state)} HP`];
143
213
  if (state.hp.temp > 0)
@@ -150,6 +220,9 @@ function partyLine(state) {
150
220
  parts.push(state.cond.map((c) => c.n).join('/'));
151
221
  if (state.exh > 0)
152
222
  parts.push(`exhaustion ${state.exh}`);
223
+ for (const boon of state.boons || []) {
224
+ parts.push(`holding ${boon.n} ${boon.die}${boon.from ? ` from ${boon.from}` : ''}`);
225
+ }
153
226
  if (state.hp.cur === 0) {
154
227
  parts.push(state.deathSaves.f >= 3
155
228
  ? 'dead'
@@ -35,21 +35,21 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.patchSheetTool = exports.readSheetTool = exports.createSheetTool = void 0;
37
37
  const coerce_1 = require("../engine/coerce");
38
+ const guides_1 = require("../engine/guides");
38
39
  const character_1 = require("../engine/character");
39
40
  const rules = __importStar(require("../engine/rules"));
40
41
  const races_1 = require("../engine/races");
41
- const backgrounds_1 = require("../engine/backgrounds");
42
42
  const encumbrance_1 = require("../engine/encumbrance");
43
43
  const feats_1 = require("../engine/feats");
44
44
  const spells_1 = require("../engine/spells");
45
45
  const srd_1 = require("../data/srd");
46
46
  const sheet_1 = require("../engine/sheet");
47
47
  const shared_1 = require("./shared");
48
- const SPEC_EXAMPLE = '{"class":"Ranger","subclass":"Hunter","level":3,"race":"Wood Elf","background":"Outlander","alignment":"NG","abilities":{"str":10,"dex":16,"con":14,"int":11,"wis":15,"cha":9},"skills":["perception","stealth","survival"],"equipment":["studded leather","longbow","arrows x40"],"attacks":[{"n":"Longbow","atk":5,"dmg":"1d8+3","type":"piercing"}],"spells":["hunter\'s mark"],"backstory":"Raised by the Emberwood circle."}';
48
+ const SPEC_EXAMPLE = '{"class":"Ranger","subclass":"Hunter","level":3,"race":"Wood Elf","background":"Outlander","alignment":"NG","abilities":{"str":10,"dex":16,"con":14,"int":11,"wis":15,"cha":9},"skills":["perception","stealth","survival"],"languages":["Giant"],"equipment":["studded leather","longbow","arrows x40"],"attacks":[{"n":"Longbow","atk":5,"dmg":"1d8+3","type":"piercing"}],"spells":["hunter\'s mark"],"backstory":"Raised by the Emberwood circle."}';
49
49
  const SET_EXAMPLE = '{"ac":18,"hp.max":32,"speed":25,"resist":["fire"],"uses.channel_divinity.cur":0}';
50
50
  exports.createSheetTool = {
51
51
  name: 'create_sheet',
52
- description: 'Create a character sheet. "character" is the character\'s name. "spec" is a JSON object describing them; only the class is genuinely required and everything else is derived or defaulted. Hit points, armour class, proficiency bonus, saving throws, skill modifiers, spell slots and hit dice are all computed from the 5e rules, so do not work them out yourself. Put tool proficiencies the player *chose* in "tools", e.g. "tools":["Lute","Drum","Flute"] for a bard — the ones their class, race and background grant outright are added for you, and the result says which choices are still owed. Include a "backstory" string to seed the sheet\'s notes section, which later tool calls never overwrite. "owner" is the nickname of the agent who plays this character — set it, because the sheet is made readable to that agent alone, and because it is how the rest of the table is told who they are: the owning agent\'s public description becomes the character\'s name, race and class, replacing whatever placeholder they were created with. Set "replace" to true to overwrite an existing sheet. Example spec: ' +
52
+ description: 'Create a character sheet. "character" is the character\'s name. "spec" is a JSON object describing them; only the class is genuinely required and everything else is derived or defaulted. Hit points, armour class, proficiency bonus, saving throws, skill modifiers, spell slots and hit dice are all computed from the 5e rules, so do not work them out yourself. Put tool proficiencies the player *chose* in "tools", e.g. "tools":["Lute","Drum","Flute"] for a bard — the ones their class, race and background grant outright are added for you, and the result says which choices are still owed. Put languages the player *chose* in "languages" — a background\'s and the extra one a race lets them pick — since no tool here knows what a background grants; what the race speaks natively is added for you. Include a "backstory" string to seed the sheet\'s notes section, which later tool calls never overwrite. "owner" is the nickname of the agent who plays this character — set it, because the sheet is made readable to that agent alone, and because it is how the rest of the table is told who they are: the owning agent\'s public description becomes the character\'s name, race and class, replacing whatever placeholder they were created with. The class\'s own rules are shared with that agent at the same time, as a "Class: ..." document they read from then on, so a player always knows their own features. Set "replace" to true to overwrite an existing sheet. Example spec: ' +
53
53
  SPEC_EXAMPLE,
54
54
  parameters: [
55
55
  { name: 'character', type: 'string', description: "The character's name", required: true },
@@ -81,7 +81,6 @@ exports.createSheetTool = {
81
81
  const owner = args.owner ? (0, coerce_1.str)(args.owner, 'owner') : undefined;
82
82
  const state = (0, character_1.buildCharacter)(name, spec, owner);
83
83
  const raceResult = (0, character_1.lastRaceResult)();
84
- const backgroundResult = (0, character_1.lastBackgroundResult)();
85
84
  const classToolResult = (0, character_1.lastClassToolResult)();
86
85
  for (const item of state.inv) {
87
86
  if (isWorn(item.n))
@@ -94,11 +93,14 @@ exports.createSheetTool = {
94
93
  (0, shared_1.refreshPartyStatus)(room);
95
94
  const identity = publicIdentity(state);
96
95
  const described = state.owner ? room.setDescription(state.owner, identity) : false;
96
+ const guides = shareGuidesForCharacter(room, helpers.packDocuments, state);
97
97
  return {
98
98
  created: artifactName,
99
99
  headline: (0, shared_1.sheetHeadline)(state),
100
100
  owner: state.owner,
101
101
  publicIdentity: described ? identity : undefined,
102
+ classGuides: guides.classes.length > 0 ? guides.classes : undefined,
103
+ classesWithoutRules: guides.missingClasses.length > 0 ? guides.missingClasses : undefined,
102
104
  spellsOffList: (() => {
103
105
  const off = (0, spells_1.offListSpells)(state, state.spells || []);
104
106
  return off.length > 0
@@ -109,12 +111,11 @@ exports.createSheetTool = {
109
111
  })(),
110
112
  background: state.bg
111
113
  ? {
112
- applied: backgroundResult.background || state.bg,
113
- inTheSrd: backgroundResult.known,
114
- granted: backgroundResult.changes.length > 0 ? backgroundResult.changes : undefined,
115
- stillToChoose: backgroundResult.outstanding.length > 0
116
- ? backgroundResult.outstanding
117
- : undefined,
114
+ recorded: state.bg,
115
+ shared: guides.background,
116
+ stillToChoose: [
117
+ `Nothing is granted automatically. Check that ${state.bg}'s two skills are in "skills", any languages it grants in "languages", its gear in "equipment" and its coin in "coin" — read them with rules_lookup topic "${state.bg}" if you have not.`,
118
+ ],
118
119
  }
119
120
  : undefined,
120
121
  race: raceResult.race
@@ -138,6 +139,7 @@ exports.createSheetTool = {
138
139
  : undefined,
139
140
  }
140
141
  : undefined,
142
+ languages: state.languages?.length ? state.languages : undefined,
141
143
  derived: {
142
144
  hitPoints: `${state.hp.cur}/${state.hp.max}`,
143
145
  armorClass: `${state.ac} (${rules.computeArmorClass(state).explanation})`,
@@ -156,6 +158,33 @@ exports.createSheetTool = {
156
158
  };
157
159
  },
158
160
  };
161
+ function shareGuidesForCharacter(room, documents, state) {
162
+ const result = { classes: [], missingClasses: [] };
163
+ if (!documents)
164
+ return result;
165
+ const players = state.owner ? [state.owner] : [];
166
+ const share = (kind, wanted) => {
167
+ const guides = (0, guides_1.listGuides)(kind, documents.list(guides_1.DND5E_PACK, kind.prefix));
168
+ const match = (0, guides_1.resolveGuide)(wanted, guides);
169
+ const body = match.guide ? documents.read(guides_1.DND5E_PACK, match.guide.fileName) : null;
170
+ if (!match.guide || !body || !body.trim())
171
+ return undefined;
172
+ const shared = (0, shared_1.shareGuide)(room, kind, match.guide.name, body, players);
173
+ return `${shared.artifactName} — read by ${shared.viewers.join(', ')}`;
174
+ };
175
+ for (const entry of state.class) {
176
+ const wanted = srd_1.CLASSES[entry.c]?.name || entry.c;
177
+ const line = share(guides_1.CLASS_GUIDE, wanted);
178
+ if (line)
179
+ result.classes.push(line);
180
+ else
181
+ result.missingClasses.push(wanted);
182
+ }
183
+ if (state.bg) {
184
+ result.background = share(guides_1.BACKGROUND_GUIDE, state.bg);
185
+ }
186
+ return result;
187
+ }
159
188
  function publicIdentity(state) {
160
189
  const classes = state.class
161
190
  .map((entry) => {
@@ -240,10 +269,9 @@ exports.readSheetTool = {
240
269
  };
241
270
  }
242
271
  if (wants('background') && state.bg) {
243
- const feature = (0, backgrounds_1.backgroundFeature)(state);
244
272
  result.background = {
245
273
  name: state.bg,
246
- feature: feature ? `${feature.n}. ${feature.text}` : undefined,
274
+ note: `Read what it grants with rules_lookup topic "${state.bg}". Anything recorded for this character is in the notes.`,
247
275
  };
248
276
  }
249
277
  if (wants('race') && state.race) {
@@ -184,7 +184,7 @@ function findPlanned(plan, name) {
184
184
  }
185
185
  exports.spendTool = {
186
186
  name: 'spend',
187
- description: 'Spend or restore a limited resource on a character sheet. "resource" is slot, hit_die, or the name of a feature or item on the sheet such as favored_foe, "Channel Divinity", or "healer\'s kit". "level" is required when resource is slot and must be 1 to 9. "amount" defaults to 1; a negative amount restores. If the character has no such resource or none remaining, nothing is changed and you are told so along with what they do still have — so you can rely on this tool to enforce the rules rather than tracking counts yourself. Returns the remaining count.',
187
+ description: 'Spend or restore a limited resource on a character sheet. "resource" is slot, hit_die, or the name of a feature or item on the sheet such as favored_foe, "Channel Divinity", or "healer\'s kit". "level" is required when resource is slot and must be 1 to 9. "amount" defaults to 1; a negative amount restores. If the character has no such resource or none remaining, nothing is changed and you are told so along with what they do still have — so you can rely on this tool to enforce the rules rather than tracking counts yourself. Returns the remaining count. Set "target" when the resource hands a die to somebody else — Bardic Inspiration, Bless, Guidance: the giver spends it and the target is recorded as holding the die, so it is offered back when a roll of theirs comes close. To use a held die, call spend on the holder with the boon name and no target. It rolls the die, adds it to the roll that character just made, says whether the total now beats the DC, and rolls the damage itself when the die turns a miss into a hit — so apply the damage with apply_hp and do not roll it again. The roll has to have happened already: a die is added to a d20 after it is rolled, and spending one with nothing to add it to is refused.',
188
188
  parameters: [
189
189
  { name: 'character', type: 'string', description: 'Whose resource to spend', required: true },
190
190
  {
@@ -205,6 +205,18 @@ exports.spendTool = {
205
205
  description: 'How many to spend; negative restores. Defaults to 1.',
206
206
  required: false,
207
207
  },
208
+ {
209
+ name: 'target',
210
+ type: 'string',
211
+ description: 'Who receives the die, for a resource that hands one to another character',
212
+ required: false,
213
+ },
214
+ {
215
+ name: 'die',
216
+ type: 'string',
217
+ description: "The die handed over, e.g. d6. Defaults to the Bardic Inspiration die for the giver's level, or d4.",
218
+ required: false,
219
+ },
208
220
  ],
209
221
  async handler(args, helpers) {
210
222
  const room = (0, shared_1.requireRoom)(helpers);
@@ -212,18 +224,72 @@ exports.spendTool = {
212
224
  const resource = (0, coerce_1.str)(args.resource, 'resource');
213
225
  const amount = args.amount !== undefined && args.amount !== '' ? (0, coerce_1.int)(args.amount, 'amount', 1) : 1;
214
226
  const level = args.level !== undefined && args.level !== '' ? (0, coerce_1.int)(args.level, 'level') : undefined;
227
+ const target = args.target ? (0, coerce_1.str)(args.target, 'target') : undefined;
228
+ if (!target && holdsBoon(room, character, resource)) {
229
+ const used = (0, shared_1.mutateSheet)(room, character, (sheet) => (0, character_1.spendBoon)(sheet.state, resource));
230
+ if ((0, character_1.isRefusal)(used.result)) {
231
+ return (0, shared_1.toRefusalResult)(used.result.refusal, reloadState(room, character));
232
+ }
233
+ return {
234
+ character: used.result.state.name,
235
+ applied: true,
236
+ summary: used.result.summary,
237
+ details: used.result.details,
238
+ roll: used.result.applied,
239
+ state: (0, shared_1.liveState)(used.result.state),
240
+ };
241
+ }
215
242
  const { result } = (0, shared_1.mutateSheet)(room, character, (sheet) => (0, character_1.spendResource)(sheet.state, resource, amount, level));
216
243
  if ((0, character_1.isRefusal)(result)) {
217
244
  return (0, shared_1.toRefusalResult)(result.refusal, reloadState(room, character));
218
245
  }
246
+ let granted;
247
+ if (target && amount > 0) {
248
+ const die = args.die ? (0, coerce_1.str)(args.die, 'die') : boonDie(result.state, resource);
249
+ const grant = (0, shared_1.mutateSheet)(room, target, (sheet) => (0, character_1.grantBoon)(sheet.state, { n: boonName(resource), die, from: result.state.name }));
250
+ if ((0, character_1.isRefusal)(grant.result)) {
251
+ return (0, shared_1.toRefusalResult)(grant.result.refusal, reloadState(room, target));
252
+ }
253
+ granted = grant.result.summary;
254
+ }
219
255
  return {
220
256
  character: result.state.name,
221
257
  applied: true,
222
- summary: result.summary,
258
+ summary: granted ? `${result.summary} ${granted}` : result.summary,
259
+ details: result.details,
223
260
  state: (0, shared_1.liveState)(result.state),
224
261
  };
225
262
  },
226
263
  };
264
+ function holdsBoon(room, character, resource) {
265
+ try {
266
+ const wanted = resource.trim().toLowerCase();
267
+ return ((0, shared_1.loadSheet)(room, character).state.boons || []).some((boon) => boon.n.toLowerCase() === wanted || boon.n.toLowerCase().includes(wanted));
268
+ }
269
+ catch {
270
+ return false;
271
+ }
272
+ }
273
+ function boonDie(giver, resource) {
274
+ if (!resource.trim().toLowerCase().includes('inspiration'))
275
+ return 'd4';
276
+ const bard = giver.class.find((entry) => entry.c === 'bard');
277
+ const level = bard ? Number(bard.lvl) || 1 : 1;
278
+ if (level >= 15)
279
+ return 'd12';
280
+ if (level >= 10)
281
+ return 'd10';
282
+ if (level >= 5)
283
+ return 'd8';
284
+ return 'd6';
285
+ }
286
+ function boonName(resource) {
287
+ return resource
288
+ .trim()
289
+ .split(/\s+/)
290
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
291
+ .join(' ');
292
+ }
227
293
  function reloadState(room, character) {
228
294
  try {
229
295
  return (0, shared_1.loadSheet)(room, character).state;
@@ -2,5 +2,6 @@ import { NativeToolDefinition } from '../../../native-tool.types';
2
2
  export declare const conditionsTool: NativeToolDefinition;
3
3
  export declare const inventoryTool: NativeToolDefinition;
4
4
  export declare const awardXpTool: NativeToolDefinition;
5
+ export declare const awardCoinTool: NativeToolDefinition;
5
6
  export declare const levelUpTool: NativeToolDefinition;
6
7
  export declare const rulesLookupTool: NativeToolDefinition;