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
package/README.md CHANGED
@@ -67,6 +67,45 @@ agent.save(); // persist to disk
67
67
  await briyah.shutdown();
68
68
  ```
69
69
 
70
+ ## Upgrading to 2.0
71
+
72
+ 2.0 moves the D&D content into a **pack**. Three things change for a host coming from 1.5; the
73
+ first two are a line each, and the third is something to know about your data directory.
74
+
75
+ **The D&D prompt folders are now the pack's.** `dungeon_master`, `dnd_player`,
76
+ `character_creator`, `campaign_designer` and `dnd_room_moderator` belong to `dnd5e`. Enable the
77
+ pack for the user, and qualify the folder name:
78
+
79
+ ```typescript
80
+ app.packs.setEnabled('dnd5e', true); // per user, and required
81
+ await app.createAgentFromFolder({ folder: 'dnd5e:dungeon_master', /* ... */ });
82
+ ```
83
+
84
+ A bare `dungeon_master` also reaches the pack once it is enabled, so enabling alone is enough if
85
+ you would rather not touch the strings. Doing neither is what breaks: in 1.5 those folders sat in
86
+ `common/prompts` and the bare name resolved, and in 2.0 it falls through to the shared root
87
+ prompts instead. `createAgentFromFolder` now refuses that rather than building a generic agent
88
+ from it — see [Prompt Folders](#prompt-folders).
89
+
90
+ **`enabledToolPacks` is gone**, replaced by `installToolPacks`. Most hosts can delete the call
91
+ entirely: the `Briyah` constructor installs every bundled pack's tools already. `BRIYAH_TOOL_PACKS`
92
+ no longer does anything either, and is not read.
93
+
94
+ **`init()` rewrites two things under your data path.** Both are stated here because neither is
95
+ visible until it has happened:
96
+
97
+ - `{dataPath}/packs/<bundled pack>/` is **deleted and re-copied on every init**. A pack's
98
+ directory is package-canonical, so a host that hand-edits `packs/dnd5e/` loses those edits on
99
+ the next boot. Edit it as a user instead — the change lands in
100
+ `{dataPath}/user/<userId>/packs/dnd5e/`, an overlay that takes precedence — or install your own
101
+ pack under a name Briyah does not bundle, which is never touched.
102
+ - Any `common/prompts/<folder>` whose name a pack now owns is **moved** to
103
+ `{dataPath}/retired-prompts/<folder>`, and the move is logged as a warning. On a 1.5 data
104
+ directory that is the five D&D folders. Moved rather than deleted because a leftover copy
105
+ outranks the pack for a bare name and would silently shadow it. Nothing reads
106
+ `retired-prompts/`: keep it if you had local edits worth porting into an overlay, delete it
107
+ otherwise.
108
+
70
109
  ## Configuration
71
110
 
72
111
  ### BriyahConfigOptions
@@ -136,6 +175,11 @@ interface BriyahConfigOptions {
136
175
  - `USER_SERVICE_CACHE_TIMEOUT_MINUTES` - Cache timeout (overridden by constructor option)
137
176
  - `ALLOW_USER_AUTHORED_TOOLS` - `"true"` to let users author/run their own tools (overridden by the `allowUserAuthoredTools` option). Default off.
138
177
 
178
+ **Retired:**
179
+ - `BRIYAH_TOOL_PACKS` - Read in 1.5 to choose which tool packs to register. It is not read in
180
+ 2.0 and setting it does nothing. Every bundled pack's tools are registered at construction;
181
+ what a user can reach is decided by pack enablement and per-agent tool grants. See [Packs](#packs).
182
+
139
183
  ### Logging
140
184
 
141
185
  Briyah writes logs to `{dataPath}/logs/briyah.log` by default. Configure or disable via the `logging` option:
@@ -265,7 +309,10 @@ const emitter = appService.getRoomMessageEmitter(roomId); // 'update' events
265
309
 
266
310
  // Prompt folder defaults — the role's name, tools and documents, as the create-agent
267
311
  // dialog would fill them in. Read these rather than hard-coding a pack's tool names.
268
- const { defaults } = appService.getPromptFolderDefaults('dnd5e:dungeon_master');
312
+ // `exists` is false for a folder nothing ships, which otherwise looks identical to a
313
+ // folder that declares no defaults.
314
+ const { defaults, exists } = appService.getPromptFolderDefaults('dnd5e:dungeon_master');
315
+ appService.promptFolderExists('dnd5e:dungeon_master'); // the same question, alone
269
316
 
270
317
  // Or let the folder build the agent: applies those defaults, saves, and attaches the
271
318
  // folder's documents. Async (attaching is), unlike createAgent. `overrides` takes the
@@ -338,8 +385,26 @@ console.log(appService.listPromptFolders());
338
385
  // dnd5e:campaign_designer, dnd5e:battle_master, dnd5e:dnd_room_moderator
339
386
  ```
340
387
 
341
- See [Packs](#packs) — **if you are building on `dnd5e` you have to enable it first**, or the
342
- folder name will not resolve and you will get a generic agent.
388
+ See [Packs](#packs) — **if you are building on `dnd5e` you have to enable it first**, or a bare
389
+ folder name will not reach it.
390
+
391
+ ### When a folder name is wrong
392
+
393
+ A prompt lookup always ends at the shared root prompts, so a folder that does not exist does not
394
+ fail — it produces a working, generic agent. Three things now say so instead:
395
+
396
+ ```typescript
397
+ appService.promptFolderExists('dnd5e:dungeon_master'); // false if the pack is not installed
398
+ const { defaults, exists } = appService.getPromptFolderDefaults('dungeon_master');
399
+ // exists distinguishes "no such folder" from "a folder that declares no defaults":
400
+ // both give you `defaults: {}`. A bare pack folder reports false until the pack is enabled.
401
+ ```
402
+
403
+ - `createAgentFromFolder` and `createRoomAgentFromFolder` **throw** a `NotFoundError` naming the
404
+ folder. The whole point of those calls is the folder's recipe — its tools, its documents, its
405
+ nickname — and a folder that is not there has none.
406
+ - `createAgent` **warns** and carries on, since it takes all of that from its arguments and the
407
+ folder is only one of them. The warning is in `{dataPath}/logs/briyah.log`.
343
408
 
344
409
  **The folder is the sixth argument to `createAgent`, and it defaults to `'default'`** — a
345
410
  generic conversational agent. Passing a role folder is what makes the agent that role:
@@ -395,9 +460,29 @@ and its tools grantable:
395
460
  const appService = briyah.getAppService('user-123');
396
461
 
397
462
  appService.packs.listPacks();
398
- // [{ pack: 'dnd5e', title: 'D&D 5th Edition', origin: 'host', enabled: false,
399
- // counts: { prompts: 6, documents: 16, agents: 6, rooms: 1 },
400
- // missingTools: [], missingPacks: [] }]
463
+ // [{
464
+ // name: 'dnd5e', // <- the id; `title` is for display
465
+ // title: 'D&D 5th Edition',
466
+ // description: 'Run a fifth-edition tabletop game in a room: ...',
467
+ // version: '1.0.0',
468
+ // dir: '/srv/app/briyah-data/packs/dnd5e',
469
+ // origin: 'host', // 'host' installed it, or 'user' created it
470
+ // enabled: false,
471
+ // promptFolders: ['battle_master', 'campaign_designer', 'character_creator',
472
+ // 'dnd_player', 'dnd_room_moderator', 'dungeon_master'],
473
+ // agents: [{ key: 'dungeon_master', promptFolder: 'dungeon_master',
474
+ // label: 'Dungeon Master', modelRole: 'primary' }, ...],
475
+ // rooms: [{ key: 'table', name: 'D&D Table', goal: '...', turnMode: 'directed',
476
+ // agents: [{ key: 'table_moderator' }, ...],
477
+ // roomLeader: 'dungeon_master', moderator: 'table_moderator' }],
478
+ // documentCount: 16,
479
+ // requiresTools: ['apply_hp', 'check', 'roll_dice', ...], // derived from its grants
480
+ // requiresPacks: [],
481
+ // missingTools: [], // requiresTools this process has not registered
482
+ // missingPacks: [], // requiresPacks this user has not enabled
483
+ // }]
484
+ // The REST API returns a trimmed version of this (`pack` instead of `name`, and a
485
+ // `counts` object) — `listPacks()` in-process returns the `PackView` above.
401
486
 
402
487
  appService.packs.setEnabled('dnd5e', true);
403
488
  ```
@@ -433,12 +518,39 @@ const { roomId, agentIds, warnings } = await appService.packInstantiation.instan
433
518
  economy: { aiServiceName: 'Anthropic', aiModel: 'claude-haiku-4-5-20251001' },
434
519
  },
435
520
  'Tuesday Night Game', // optional; auto-suffixed if the name is taken
521
+ // optional; per-agent overrides, keyed by the template's own key for the seat
522
+ { player: { agentName: 'Homer', agentNickname: 'Homer' } },
436
523
  );
437
524
  ```
438
525
 
439
526
  That is a six-agent room with `turnMode: 'directed'`, the Dungeon Master as leader, a table
440
527
  moderator, and every agent already carrying its tool grants and rules documents.
441
528
 
529
+ **Naming the player.** The template's player seat ships as `PlayerOne`, which is not what the
530
+ person at the keyboard is called. The fifth argument changes any seat: the keys are the room
531
+ template's `agents[].key` (`table_moderator`, `dungeon_master`, `battle_master`,
532
+ `character_creator`, `campaign_designer`, `player` for `dnd5e:table`), and the value is the same
533
+ `PromptFolderDefaults` shape as a folder's own defaults, applied over them. A key no seat has is
534
+ refused before the room is created, rather than quietly doing nothing.
535
+
536
+ **More than one player.** The template seats one. Add the others afterwards with
537
+ `createRoomAgentFromFolder`, which is the same call instantiation makes per agent — a room-owned
538
+ agent, named after the room, deleted with it:
539
+
540
+ ```typescript
541
+ await appService.createRoomAgentFromFolder(roomId, {
542
+ folder: 'dnd5e:dnd_player',
543
+ aiServiceName: 'Anthropic',
544
+ aiModel: 'claude-haiku-4-5-20251001',
545
+ overrides: { agentName: 'Vex', agentNickname: 'Vex', description: 'A wary scout.' },
546
+ pack: 'dnd5e', // files it under the pack, so it hides and lists with one
547
+ packAgentKey: 'player', // records which template it came from
548
+ });
549
+ ```
550
+
551
+ Do it after `instantiateRoom` returns, not during: the room already has its moderator by then, so
552
+ a player carrying `useModerator: true` has one to route through.
553
+
442
554
  A template names a **role** rather than a model — `primary` or `economy` — because a model id goes
443
555
  stale and assumes your provider keys. The Dungeon Master takes the primary; the agents that do
444
556
  bookkeeping rather than prose take the economy one. Omit `economy` and everything uses the
@@ -847,15 +959,18 @@ it and then stops rather than generating a reply, which is what yields the floor
847
959
  every change with the newest message and the room's state.
848
960
 
849
961
  ```typescript
850
- import { Briyah, dnd5eTools } from 'briyah';
962
+ import { Briyah } from 'briyah';
963
+ import type { RoomUpdate } from 'briyah';
851
964
  import * as readline from 'node:readline/promises';
852
965
 
853
- const briyah = new Briyah({ dataPath: './briyah-data', tools: dnd5eTools() });
966
+ // The constructor installs every bundled pack's tools already; pass `tools` only to
967
+ // filter or wrap them, or to add your own.
968
+ const briyah = new Briyah({ dataPath: './briyah-data' });
854
969
  await briyah.init(); // seeds prompt folders and the packs
855
970
  const app = briyah.getAppService('user-123');
856
971
 
857
- // Enable the pack for this user, or a bare folder name will not reach it and every
858
- // agent below would come out generic. Enabling is per user; registering is not.
972
+ // Enable the pack for this user, or a bare folder name will not reach it. Enabling is
973
+ // per user; installing is not.
859
974
  app.packs.setEnabled('dnd5e', true);
860
975
 
861
976
  const dm = app.createAgent(
@@ -898,7 +1013,7 @@ let atKeyboard = false; // the handler is async; without this it re-ent
898
1013
  let replyTo = 'DM'; // who last spoke to the player
899
1014
  let replyAs: 'speak' | 'whisper' = 'speak';
900
1015
 
901
- app.getRoomMessageEmitter(roomId).on('update', async (state) => {
1016
+ app.getRoomMessageEmitter(roomId).on('update', async (state: RoomUpdate) => {
902
1017
  if (state.type === 'error') { // a turn failed — see "Errors" below
903
1018
  console.error(`[${state.errorType}] ${state.message}`);
904
1019
  return;
@@ -907,13 +1022,19 @@ app.getRoomMessageEmitter(roomId).on('update', async (state) => {
907
1022
  const message = state.latestMessage;
908
1023
  if (message && state.messageIndex !== undefined && state.messageIndex > lastIndex) {
909
1024
  lastIndex = state.messageIndex; // the emitter can repeat a state
910
- if (message.sender !== 'Homer') console.log(`${message.sender}: ${message.content}`);
911
- // Answer whoever addressed you, the way they addressed you. During session
912
- // zero that is the designer or the creator, whispering — replying to the DM
913
- // instead drops the interview.
914
- if (message.targets?.includes('Homer') && message.sender !== 'Homer') {
915
- replyTo = message.sender;
916
- replyAs = message.action === 'whisper' ? 'whisper' : 'speak';
1025
+ // Everything the room logged comes down this stream, an agent's thinking
1026
+ // and its tool calls included. Nobody at the table hears either, and a DM
1027
+ // thinking out loud is the adventure with its answers written in.
1028
+ const audible = message.action !== 'think' && message.action !== 'tool';
1029
+ if (audible && message.sender !== 'Homer') {
1030
+ console.log(`${message.sender}: ${message.content}`);
1031
+ // Answer whoever addressed you, the way they addressed you. During
1032
+ // session zero that is the designer or the creator, whispering —
1033
+ // replying to the DM instead drops the interview.
1034
+ if (message.targets?.includes('Homer')) {
1035
+ replyTo = message.sender;
1036
+ replyAs = message.action === 'whisper' ? 'whisper' : 'speak';
1037
+ }
917
1038
  }
918
1039
  }
919
1040
 
@@ -937,14 +1058,30 @@ app.getRoomMessageEmitter(roomId).on('update', async (state) => {
937
1058
  await app.sendRoomMessage(roomId, 'Begin the adventure.', 'Homer', 'speak', ['DM']);
938
1059
  ```
939
1060
 
940
- **The emitter payload** carries `latestMessage`, `messageIndex`, `totalCost`, `isPaused`,
941
- `currentSpeaker`, `processingInProgress` and `waitingForHuman`. `messageIndex` counts messages
942
- with thoughts and tool notices excluded, so compare it against a list fetched the same way —
943
- `getRoomMessages(roomId)` — or refetch when they disagree.
944
-
945
- **Errors** arrive on the same emitter as `{type: 'error', errorType, message}`. Check for it
946
- first, as above: a turn that dies — most often on a spent balance — otherwise just goes quiet,
947
- with no message and nothing to await.
1061
+ **The emitter payload** is `RoomUpdate`, a two-member union discriminated by `type` —
1062
+ `RoomMessageUpdate` (`type: 'state'`) and `RoomErrorUpdate` (`type: 'error'`). Both are exported,
1063
+ so the narrowing above compiles under `strict` with nothing hand-written. A state update carries
1064
+ `latestMessage`, `messageIndex`, `totalCost`, `isPaused`, `currentSpeaker`,
1065
+ `processingInProgress` and `waitingForHuman`. A state update carries **every** message the room
1066
+ logged — thoughts and tool notices included — and `messageIndex` is that message's own index, so
1067
+ it lines up with `getRoomMessages(roomId, 0, true)` and a gap between the two is a real gap
1068
+ rather than a difference of bookkeeping. Drop what a host does not want on `action`, as the loop
1069
+ above does; asking the room for a narrower list instead leaves the two counting differently, and
1070
+ nothing in the update can say by how much.
1071
+
1072
+ **Errors** arrive on the same emitter, as `{type: 'error', errorType, message, timestamp}`. Same
1073
+ event name rather than `'error'`, because an EventEmitter throws when an `'error'` event has no
1074
+ listener and that would take down a host that subscribed only to updates. Check for it first, as
1075
+ above: a turn that dies — most often on a spent balance — otherwise just goes quiet, with no
1076
+ message and nothing to await.
1077
+
1078
+ **`waitingForHuman` means "the human may send something", not "the human is being asked
1079
+ something".** It is true while a human holds the floor, and also true for an idle room — no
1080
+ speaker, nothing queued, nothing in flight — which includes the gap between `sendRoomMessage`
1081
+ accepting a line and processing starting. Gate a prompt on it alone and you open a second one
1082
+ before the table has said a word. `currentSpeaker === <the human's nickname>` is the test for
1083
+ "it is their turn", which is what the loop above uses; `waitingForHuman` is the right test for
1084
+ whether to enable a composer.
948
1085
 
949
1086
  **`sendRoomMessage`'s `action` defaults to `'moderate'`**, not `'speak'`. Pass the action you
950
1087
  mean. A message sent out of turn is refused rather than thrown: the result is
@@ -952,80 +1089,122 @@ mean. A message sent out of turn is refused rather than thrown: the result is
952
1089
 
953
1090
  **The `sender` string must be an `agentNickname`** — that is the name the room routes by.
954
1091
 
1092
+ **The `replyTo`/`replyAs` bookkeeping is only for a table with no moderator.** This room has
1093
+ none, so the player's line has to name its own recipient. Give the human agent
1094
+ `useModerator: true` in a room that has a moderator and all of it goes away — the room forces the
1095
+ message to `moderate`, clears the targets, and the moderator decides who answers. That is how the
1096
+ `dnd5e` room template ships; see [Example 11](#example-11-seating-a-whole-dd-table).
1097
+
955
1098
  Two notes for a long-running process. Call `await briyah.shutdown()` before exiting or it will
956
1099
  hang on open handles. And a room with no human-controlled agent never stops on its own: the
957
1100
  agents talk until the leader adjourns.
958
1101
 
959
1102
  ### Example 11: Seating a whole D&D table
960
1103
 
961
- Example 10 seats a Dungeon Master and players, which is enough to see the loop but not enough
962
- to play. The `dungeon_master` prompt whispers a **campaign designer** to build the world and a
963
- **character creator** to build sheets, so a table without those two has a leader whose own
964
- instructions reference agents that are not there.
1104
+ Example 10 seats a Dungeon Master and players, which is enough to see the loop but not enough to
1105
+ play. The `dungeon_master` prompt whispers a **campaign designer** to build the world and a
1106
+ **character creator** to build sheets, and hands fights to a **battle master**, so a table
1107
+ without those three has a leader whose own instructions reference agents that are not there.
965
1108
 
966
- The other half is that each role needs its folder's tool grants and pack documents.
967
- `createAgentFromFolder` reads the folder's `defaults_config.json` and applies all of it — the
968
- same wiring the web client's create-agent dialog performs — so you never transcribe eighteen
969
- tool names or thirteen document ids by hand, and nothing drifts when the pack changes.
1109
+ The pack ships that table as a room template, and instantiating it is the whole of the setup:
970
1110
 
971
1111
  ```typescript
972
- import { Briyah, dnd5eTools } from 'briyah';
1112
+ import { Briyah } from 'briyah';
973
1113
 
974
- const briyah = new Briyah({ dataPath: './briyah-data', tools: dnd5eTools() });
1114
+ const briyah = new Briyah({ dataPath: './briyah-data' });
975
1115
  await briyah.init();
976
1116
  const app = briyah.getAppService('cli-user');
977
1117
 
978
- // Per user, and required: a bare folder name only reaches the pack once it is enabled.
979
- app.packs.setEnabled('dnd5e', true);
1118
+ app.packs.setEnabled('dnd5e', true); // per user, and required
1119
+
1120
+ const { roomId, warnings } = await app.packInstantiation.instantiateRoom(
1121
+ 'dnd5e',
1122
+ 'table',
1123
+ {
1124
+ primary: { aiServiceName: 'Anthropic', aiModel: 'claude-sonnet-5' },
1125
+ economy: { aiServiceName: 'Anthropic', aiModel: 'claude-haiku-4-5' },
1126
+ },
1127
+ 'Campaign — Homer',
1128
+ { player: { agentName: 'Homer', agentNickname: 'Homer' } },
1129
+ );
1130
+ warnings.forEach((warning) => console.warn(warning));
1131
+ ```
1132
+
1133
+ That is six agents — moderator, Dungeon Master, battle master, character creator, campaign
1134
+ designer, and Homer at the keyboard — each with its folder's tool grants and rules documents,
1135
+ `turnMode: 'directed'`, the Dungeon Master leading, and the moderator created before the agents
1136
+ that route through it. Then run the loop from Example 10.
1137
+
1138
+ **The goal.** The template's goal describes the game in general. A first session usually wants
1139
+ one that says what has *not* happened yet, or the Dungeon Master opens a scene for characters
1140
+ who have no sheets:
1141
+
1142
+ ```typescript
1143
+ await app.editRoom(roomId, 'Campaign — Homer',
1144
+ 'A fifth-edition campaign for Homer. Nothing is prepared: no campaign has been designed ' +
1145
+ 'and no character has a sheet. Run session zero first — have the Campaign Designer ' +
1146
+ 'interview Homer and publish the Campaign document, then hand the Character Creator one ' +
1147
+ 'player at a time until every sheet exists — and only then open the first scene.');
1148
+ ```
1149
+
1150
+ **Models by role.** The Dungeon Master reasons and makes every tool call, and is the only agent
1151
+ the template puts on the primary model. Everyone else is `economy`, including the campaign
1152
+ designer, whose output is long but infrequent:
980
1153
 
1154
+ | Role | `modelRole` | Suggested |
1155
+ |---|---|---|
1156
+ | Dungeon Master | `primary` | `claude-sonnet-5` |
1157
+ | Battle master, character creator, campaign designer, moderator | `economy` | `claude-haiku-4-5` |
1158
+ | Players, human and AI | `economy` | `claude-haiku-4-5` |
1159
+
1160
+ Pass only `primary` and everything runs on it.
1161
+
1162
+ **The moderator, and what it saves your loop.** The shipped table seats one
1163
+ (`dnd5e:dnd_room_moderator`), and the player template sets `useModerator: true`. That pairing is
1164
+ not decoration: when a human agent has the flag, the room forces their message to `moderate` and
1165
+ clears its targets — server-side, whatever action you passed — and the moderator decides who
1166
+ hears it and who answers. A person typing a line does not know whether they are answering the
1167
+ designer's interview question or the DM's "what do you do", and with a moderator they do not have
1168
+ to: the `replyTo`/`replyAs` mirroring in Example 10 exists only because that table has none.
1169
+
1170
+ Skip the moderator when nothing addresses the player except the leader. Then the Dungeon Master
1171
+ names who acts next in a `directed` room, which is the same job for less money. If any agent has
1172
+ `useModerator: true`, the room must name a moderator or `createRoom` raises a `ValidationError`.
1173
+
1174
+ **Building it by hand.** If you want the pieces rather than the template, `createAgentFromFolder`
1175
+ reads a folder's `defaults_config.json` and applies all of it — the same wiring the web client's
1176
+ create-agent dialog performs — so you never transcribe eighteen tool names or thirteen document
1177
+ ids, and nothing drifts when the pack changes:
1178
+
1179
+ ```typescript
981
1180
  const from = (folder: string, aiModel: string, overrides = {}) =>
982
1181
  app.createAgentFromFolder({ folder, aiServiceName: 'Anthropic', aiModel, overrides });
983
1182
 
984
- const dm = await from('dnd5e:dungeon_master', 'claude-sonnet-5');
985
- const designer = await from('dnd5e:campaign_designer', 'claude-sonnet-5');
986
- const creator = await from('dnd5e:character_creator', 'claude-haiku-4-5');
1183
+ const mod = await from('dnd5e:dnd_room_moderator', 'claude-haiku-4-5');
1184
+ const dm = await from('dnd5e:dungeon_master', 'claude-sonnet-5');
1185
+ const marshal = await from('dnd5e:battle_master', 'claude-haiku-4-5');
1186
+ const designer = await from('dnd5e:campaign_designer', 'claude-haiku-4-5');
1187
+ const creator = await from('dnd5e:character_creator', 'claude-haiku-4-5');
987
1188
 
988
1189
  const you = await from('dnd5e:dnd_player', 'claude-haiku-4-5', {
989
- agentNickname: 'Homer',
1190
+ agentName: 'Homer', agentNickname: 'Homer',
990
1191
  description: 'A player character with no sheet yet, played by a person.',
991
- controlledByHuman: true,
992
- });
993
- const vex = await from('dnd5e:dnd_player', 'claude-haiku-4-5', {
994
- agentNickname: 'Vex', description: 'A wary scout.',
1192
+ controlledByHuman: true, useModerator: true,
995
1193
  });
996
1194
 
997
- // The goal is read by every agent every turn. Say what has *not* happened yet, or the
998
- // Dungeon Master opens a scene for characters who have no sheets.
999
1195
  const { roomId } = await app.createRoom(
1000
1196
  'Campaign — Homer',
1001
- 'A fifth-edition campaign for Homer and Vex. Nothing is prepared: no campaign has been ' +
1002
- 'designed and no character has a sheet. Run session zero first — have the Campaign ' +
1003
- 'Designer interview Homer and publish the Campaign document, then hand the Character ' +
1004
- 'Creator one player at a time until both sheets exist — and only then open the first scene.',
1005
- [dm.id!, designer.id!, creator.id!, you.id!, vex.id!],
1006
- 'DM',
1007
- 'directed',
1197
+ 'A fifth-edition campaign for Homer. ...',
1198
+ [mod.id!, dm.id!, marshal.id!, designer.id!, creator.id!, you.id!],
1199
+ 'DM', // roomLeader
1200
+ 'directed', // turnMode
1201
+ 'Moderator', // moderator — required, because Homer has useModerator
1008
1202
  );
1009
1203
  ```
1010
1204
 
1011
- Then run the loop from Example 10. Session zero is whispered, which is why that loop mirrors
1012
- the action it replies with.
1013
-
1014
- **Models by role.** The Dungeon Master reasons and makes every tool call; the specialists run a
1015
- few dozen times per campaign; the players are cheap.
1016
-
1017
- | Role | Model |
1018
- |---|---|
1019
- | Dungeon Master, campaign designer | `claude-sonnet-5` |
1020
- | Character creator | `claude-haiku-4-5` |
1021
- | Players, human and AI | `claude-haiku-4-5` |
1022
-
1023
- **Moderators.** `createRoom`'s sixth argument names one, and the `dnd_room_moderator` folder
1024
- provides one. A 5e table does **not** need it: the Dungeon Master leads a `directed` room and
1025
- names who acts next, which is the same job. A moderator earns its place when no agent is in
1026
- charge of the turn order — several people talking at once, or a room whose members address each
1027
- other freely. If you give an agent `useModerator: true`, the room must have one or `createRoom`
1028
- raises a `ValidationError`.
1205
+ The nicknames come from the folders: `Moderator`, `DM`, `Marshal`, `Designer`, `Creator`. These
1206
+ agents are free-standing rather than room-owned, so they appear in `listAgents()` and outlive the
1207
+ room; `createRoomAgentFromFolder` is the room-owned equivalent, and is what the template uses.
1029
1208
 
1030
1209
  **Resuming.** `listRooms()` gives saved campaigns; `getRoomDetails(roomId)` gives the roster,
1031
1210
  where `agents[].controlledByHuman` identifies the person's character. Then
@@ -1042,6 +1221,10 @@ Briyah stores data in the following structure:
1042
1221
  │ ├── config/ # LLM pricing and image-model config
1043
1222
  │ ├── prompts/ # Global prompt templates
1044
1223
  │ └── published-agents.json # Published agent mappings
1224
+ ├── packs/ # Installed packs, one directory each
1225
+ │ └── {pack}/ # pack.json, prompts/, artifacts/, agents/, rooms/
1226
+ ├── retired-prompts/ # Folders a pack took over; see "Upgrading to 2.0"
1227
+ ├── logs/ # briyah.log
1045
1228
  └── user/
1046
1229
  └── {userId}/ # Per-user data
1047
1230
  ├── agents/ # Agent configs and histories (one JSON per agent)
@@ -1049,11 +1232,17 @@ Briyah stores data in the following structure:
1049
1232
  ├── stories/ # Story state
1050
1233
  ├── tools/ # User-defined tools (one JSON per tool)
1051
1234
  ├── prompts/ # User-specific prompts
1235
+ ├── packs/{pack}/ # This user's edits to a pack, or a pack they created
1236
+ ├── artifacts/ # This user's own documents
1052
1237
  ├── upload/ # User file attachments
1053
1238
  ├── transactions/ # Transaction records
1054
- └── userconfig/ # User preferences and balance
1239
+ └── userconfig/ # User preferences, balance, and enabled packs
1055
1240
  ```
1056
1241
 
1242
+ `init()` seeds `common/` additively and **replaces** every bundled pack under `packs/` — see
1243
+ [Upgrading to 2.0](#upgrading-to-20) for exactly what is rewritten and where your own edits
1244
+ belong instead.
1245
+
1057
1246
  ## Multi-Instance Support
1058
1247
 
1059
1248
  You can create multiple Briyah instances with different configurations:
@@ -1 +1 @@
1
- 17.18821978000002
1
+ 23.256423440000034