briyah 2.0.1 → 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 (313) hide show
  1. package/README.md +19 -10
  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 +123 -12
  111. package/dist-sdk/server/src/app.service.d.ts +23 -2
  112. package/dist-sdk/server/src/app.service.js +97 -106
  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/documents/pdf-conversion.d.ts +43 -0
  117. package/dist-sdk/server/src/documents/pdf-conversion.js +175 -0
  118. package/dist-sdk/server/src/room/room-store.service.js +5 -1
  119. package/dist-sdk/server/src/room/room.d.ts +15 -2
  120. package/dist-sdk/server/src/room/room.js +82 -23
  121. package/dist-sdk/server/src/rpg/rpg-models.d.ts +9 -0
  122. package/dist-sdk/server/src/rpg/rpg-models.js +128 -0
  123. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +10 -0
  124. package/dist-sdk/server/src/rpg/rpg-roster.js +71 -0
  125. package/dist-sdk/server/src/rpg/rpg.service.d.ts +29 -0
  126. package/dist-sdk/server/src/rpg/rpg.service.js +199 -0
  127. package/dist-sdk/server/src/sdk/index.d.ts +5 -2
  128. package/dist-sdk/server/src/sdk/index.js +8 -1
  129. package/dist-sdk/server/src/story/story.service.d.ts +2 -1
  130. package/dist-sdk/server/src/story/story.service.js +42 -4
  131. package/dist-sdk/server/src/tools/native-tool.types.d.ts +5 -0
  132. package/dist-sdk/server/src/tools/packs/acts/data/cards.d.ts +53 -0
  133. package/dist-sdk/server/src/tools/packs/acts/data/cards.js +54 -0
  134. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.d.ts +2 -0
  135. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.js +185 -0
  136. package/dist-sdk/server/src/tools/packs/acts/data/encounters.d.ts +12 -0
  137. package/dist-sdk/server/src/tools/packs/acts/data/encounters.js +102 -0
  138. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.d.ts +2 -0
  139. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.js +196 -0
  140. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.d.ts +2 -0
  141. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.js +1311 -0
  142. package/dist-sdk/server/src/tools/packs/acts/engine/cards.d.ts +5 -0
  143. package/dist-sdk/server/src/tools/packs/acts/engine/cards.js +27 -0
  144. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.d.ts +37 -0
  145. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.js +120 -0
  146. package/dist-sdk/server/src/tools/packs/acts/engine/dice.d.ts +20 -0
  147. package/dist-sdk/server/src/tools/packs/acts/engine/dice.js +41 -0
  148. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.d.ts +54 -0
  149. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.js +200 -0
  150. package/dist-sdk/server/src/tools/packs/acts/index.d.ts +2 -0
  151. package/dist-sdk/server/src/tools/packs/acts/index.js +24 -0
  152. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.d.ts +2 -0
  153. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.js +184 -0
  154. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.d.ts +2 -0
  155. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.js +107 -0
  156. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.d.ts +3 -0
  157. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.js +146 -0
  158. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.d.ts +4 -0
  159. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.js +241 -0
  160. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.d.ts +3 -0
  161. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.js +72 -0
  162. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.d.ts +2 -0
  163. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.js +75 -0
  164. package/dist-sdk/server/src/tools/packs/acts/tools/shared.d.ts +20 -0
  165. package/dist-sdk/server/src/tools/packs/acts/tools/shared.js +70 -0
  166. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.d.ts +4 -0
  167. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.js +215 -0
  168. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +0 -21
  169. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +1 -56
  170. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +10 -0
  171. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +67 -0
  172. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +5 -0
  173. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +7 -1
  174. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +4 -3
  175. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +6 -0
  176. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +92 -0
  177. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +32 -5
  178. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +177 -28
  179. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +1 -13
  180. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +15 -145
  181. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +7 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +11 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +5 -0
  184. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +45 -2
  185. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +3 -0
  186. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +21 -0
  187. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +45 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +6 -4
  189. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +17 -0
  190. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +56 -4
  191. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +3 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +117 -15
  193. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +2 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +96 -0
  195. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +40 -3
  196. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +36 -27
  197. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +7 -4
  198. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +15 -1
  199. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +73 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +40 -12
  201. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +68 -2
  202. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  203. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +119 -14
  204. package/dist-sdk/server/src/tools/packs/index.d.ts +2 -1
  205. package/dist-sdk/server/src/tools/packs/index.js +4 -1
  206. package/dist-sdk/server/src/tools/shared/coerce.d.ts +13 -0
  207. package/dist-sdk/server/src/tools/shared/coerce.js +147 -0
  208. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +3 -2
  209. package/dist-sdk/server/src/tools/tool-execution.service.js +4 -1
  210. package/dist-sdk/shared/types/app.types.d.ts +64 -0
  211. package/dist-sdk/shared/types/app.types.js +2 -1
  212. package/docs/assets/hierarchy.js +1 -1
  213. package/docs/assets/navigation.js +1 -1
  214. package/docs/assets/search.js +1 -1
  215. package/docs/classes/Agent.html +73 -73
  216. package/docs/classes/Briyah.html +16 -16
  217. package/docs/classes/BriyahConfigService.html +7 -7
  218. package/docs/classes/NativeToolRegistry.html +10 -10
  219. package/docs/classes/PackInstantiationService.html +7 -7
  220. package/docs/classes/PackService.html +13 -13
  221. package/docs/classes/Room.html +118 -93
  222. package/docs/classes/RoomMessage.html +22 -22
  223. package/docs/enums/MessageAction.html +18 -18
  224. package/docs/functions/actsTools.html +44 -0
  225. package/docs/functions/availableToolPacks.html +4 -4
  226. package/docs/functions/buildMarkdown.html +54 -0
  227. package/docs/functions/dnd5eTools.html +4 -4
  228. package/docs/functions/installToolPacks.html +4 -4
  229. package/docs/functions/pageMarker.html +45 -0
  230. package/docs/functions/registerToolPacks.html +4 -4
  231. package/docs/functions/splitMarkdownIntoPages.html +51 -0
  232. package/docs/functions/stripWrappingFence.html +52 -0
  233. package/docs/hierarchy.html +13 -9
  234. package/docs/index.html +11 -8
  235. package/docs/interfaces/AgentCreationOptions.html +12 -12
  236. package/docs/interfaces/AgentInfo.html +30 -30
  237. package/docs/interfaces/AgentMessagesResponse.html +8 -8
  238. package/docs/interfaces/AppService.html +271 -196
  239. package/docs/interfaces/Artifact.html +9 -9
  240. package/docs/interfaces/ArtifactMetadata.html +13 -13
  241. package/docs/interfaces/ArtifactWriteOptions.html +7 -7
  242. package/docs/interfaces/AttachDocumentResponse.html +6 -6
  243. package/docs/interfaces/BriyahConfigOptions.html +12 -12
  244. package/docs/interfaces/ChapterInfo.html +6 -6
  245. package/docs/interfaces/Character.html +10 -10
  246. package/docs/interfaces/ConversionAgent.html +78 -0
  247. package/docs/interfaces/CreateAgentResponse.html +5 -5
  248. package/docs/interfaces/CreateRoomResponse.html +6 -6
  249. package/docs/interfaces/CreateStoryResponse.html +5 -5
  250. package/docs/interfaces/FileList.html +5 -5
  251. package/docs/interfaces/FileMetadata.html +10 -10
  252. package/docs/interfaces/IConfigService.html +5 -5
  253. package/docs/interfaces/InstantiateModels.html +6 -6
  254. package/docs/interfaces/InstantiateRoomResult.html +7 -7
  255. package/docs/interfaces/LoadedPack.html +16 -16
  256. package/docs/interfaces/LoggingOptions.html +9 -9
  257. package/docs/interfaces/Message.html +9 -9
  258. package/docs/interfaces/ModelChoice.html +7 -7
  259. package/docs/interfaces/ModelInfo.html +8 -8
  260. package/docs/interfaces/NativeToolDefinition.html +10 -10
  261. package/docs/interfaces/PackAgentTemplate.html +9 -9
  262. package/docs/interfaces/PackRoomTemplate.html +11 -11
  263. package/docs/interfaces/PackView.html +20 -20
  264. package/docs/interfaces/PdfConversionOptions.html +102 -0
  265. package/docs/interfaces/PdfConversionResult.html +97 -0
  266. package/docs/interfaces/PdfMarkdownOptions.html +198 -0
  267. package/docs/interfaces/PdfMarkdownResult.html +106 -0
  268. package/docs/interfaces/PdfPageMarkdown.html +94 -0
  269. package/docs/interfaces/PreparedPromptResponse.html +6 -6
  270. package/docs/interfaces/ProcessTextResponse.html +10 -10
  271. package/docs/interfaces/PromptFile.html +7 -7
  272. package/docs/interfaces/PromptFileContent.html +8 -8
  273. package/docs/interfaces/PromptFilesResponse.html +5 -5
  274. package/docs/interfaces/PromptFolder.html +8 -8
  275. package/docs/interfaces/PromptFolderDefaults.html +19 -19
  276. package/docs/interfaces/PromptFolderDefaultsResponse.html +7 -7
  277. package/docs/interfaces/PromptFoldersResponse.html +5 -5
  278. package/docs/interfaces/RoomDetails.html +19 -19
  279. package/docs/interfaces/RoomErrorUpdate.html +8 -8
  280. package/docs/interfaces/RoomInfo.html +10 -10
  281. package/docs/interfaces/RoomMessageUpdate.html +13 -13
  282. package/docs/interfaces/RoomMessagesResponse.html +6 -6
  283. package/docs/interfaces/SendMessageResult.html +6 -6
  284. package/docs/interfaces/StoryErrorEvent.html +8 -8
  285. package/docs/interfaces/StoryIdea.html +8 -8
  286. package/docs/interfaces/StoryInfo.html +28 -28
  287. package/docs/interfaces/StoryIntroduceCharacterEvent.html +7 -7
  288. package/docs/interfaces/StoryProgressChapterEvent.html +6 -6
  289. package/docs/interfaces/StoryState.html +12 -12
  290. package/docs/interfaces/StoryStateEvent.html +7 -7
  291. package/docs/interfaces/ToolArtifact.html +9 -9
  292. package/docs/interfaces/ToolCaller.html +7 -7
  293. package/docs/interfaces/ToolDefinition.html +9 -9
  294. package/docs/interfaces/ToolHelpers.html +17 -8
  295. package/docs/interfaces/ToolPackDocuments.html +100 -0
  296. package/docs/interfaces/ToolParameter.html +8 -8
  297. package/docs/interfaces/ToolRoomAccess.html +14 -14
  298. package/docs/interfaces/ToolSummary.html +8 -8
  299. package/docs/interfaces/ToolsResponse.html +7 -7
  300. package/docs/interfaces/Transaction.html +13 -13
  301. package/docs/interfaces/TransactionHistoryResponse.html +6 -6
  302. package/docs/modules.html +8 -8
  303. package/docs/types/PackOrigin.html +4 -4
  304. package/docs/types/PromptScope.html +4 -4
  305. package/docs/types/RoomTurnMode.html +4 -4
  306. package/docs/types/RoomUpdate.html +4 -4
  307. package/docs/types/RosterOverrides.html +4 -4
  308. package/docs/types/ToolContext.html +4 -4
  309. package/docs/types/ToolRunResult.html +4 -4
  310. package/package.json +1 -1
  311. package/src/tools/packs/dnd5e/README.md +147 -66
  312. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.d.ts +0 -20
  313. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.js +0 -112
package/docs/index.html CHANGED
@@ -1,5 +1,5 @@
1
- <!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Briyah SDK - v2.0.1</title><meta name="description" content="Documentation for Briyah SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script><script async src="assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar">
2
- <div class="tsd-toolbar-contents container"><a href="index.html" class="title">Briyah SDK - v2.0.1</a>
1
+ <!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Briyah SDK - v2.0.2</title><meta name="description" content="Documentation for Briyah SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script><script async src="assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar">
2
+ <div class="tsd-toolbar-contents container"><a href="index.html" class="title">Briyah SDK - v2.0.2</a>
3
3
  <div id="tsd-toolbar-links"><a href="https://github.com/your-org/briyah">GitHub</a><a href="https://www.npmjs.com/package/briyah">npm</a></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/>
4
4
  <ul role="listbox" id="tsd-search-results"></ul>
5
5
  <div id="tsd-search-status" aria-live="polite" aria-atomic="true">
@@ -7,7 +7,7 @@
7
7
  <div class="container container-main">
8
8
  <div class="col-content">
9
9
  <div class="tsd-page-title">
10
- <h1>Briyah SDK - v2.0.1</h1></div>
10
+ <h1>Briyah SDK - v2.0.2</h1></div>
11
11
  <div class="tsd-panel tsd-typography"><h1 id="briyah-sdk" class="tsd-anchor-link">Briyah SDK<a href="#briyah-sdk" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h1>
12
12
  <p>Briyah is an SDK for AI agents, multi-agent rooms, and interactive stories. It wraps the Briyah runtime as a single class with per-user data isolation and balance tracking, and supports Anthropic, OpenAI, Google, Grok, DeepSeek, Together, and Fal as LLM providers.</p>
13
13
  <p>What's in the package:</p>
@@ -380,16 +380,19 @@ where one person speaks at a time.</p>
380
380
  it and then stops rather than generating a reply, which is what yields the floor to your console.</p>
381
381
  <p><strong>The room message emitter</strong> — the only way to see the conversation as it happens. It fires on
382
382
  every change with the newest message and the room's state.</p>
383
- <pre><code class="typescript"><span class="hl-3">import</span><span class="hl-1"> { </span><span class="hl-4">Briyah</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&#39;briyah&#39;</span><span class="hl-1">;</span><br/><span class="hl-3">import</span><span class="hl-1"> </span><span class="hl-3">type</span><span class="hl-1"> { </span><span class="hl-4">RoomUpdate</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&#39;briyah&#39;</span><span class="hl-1">;</span><br/><span class="hl-3">import</span><span class="hl-1"> </span><span class="hl-6">*</span><span class="hl-1"> </span><span class="hl-3">as</span><span class="hl-1"> </span><span class="hl-4">readline</span><span class="hl-1"> </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&#39;node:readline/promises&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">// The constructor installs every bundled pack&#39;s tools already; pass `tools` only to</span><br/><span class="hl-5">// filter or wrap them, or to add your own.</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">briyah</span><span class="hl-1"> = </span><span class="hl-6">new</span><span class="hl-1"> </span><span class="hl-0">Briyah</span><span class="hl-1">({ </span><span class="hl-4">dataPath:</span><span class="hl-1"> </span><span class="hl-2">&#39;./briyah-data&#39;</span><span class="hl-1"> });</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">briyah</span><span class="hl-1">.</span><span class="hl-0">init</span><span class="hl-1">(); </span><span class="hl-5">// seeds prompt folders and the packs</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">app</span><span class="hl-1"> = </span><span class="hl-4">briyah</span><span class="hl-1">.</span><span class="hl-0">getAppService</span><span class="hl-1">(</span><span class="hl-2">&#39;user-123&#39;</span><span class="hl-1">);</span><br/><br/><span class="hl-5">// Enable the pack for this user, or a bare folder name will not reach it. Enabling is</span><br/><span class="hl-5">// per user; installing is not.</span><br/><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-4">packs</span><span class="hl-1">.</span><span class="hl-0">setEnabled</span><span class="hl-1">(</span><span class="hl-2">&#39;dnd5e&#39;</span><span class="hl-1">, </span><span class="hl-6">true</span><span class="hl-1">);</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">dm</span><span class="hl-1"> = </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createAgent</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;Anthropic&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Dungeon Master&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Runs the game.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;claude-sonnet-5&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;dnd5e:dungeon_master&#39;</span><span class="hl-1">, </span><span class="hl-6">undefined</span><span class="hl-1">, </span><span class="hl-6">null</span><span class="hl-1">, </span><span class="hl-8">0</span><span class="hl-1">, </span><span class="hl-2">&#39;&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> { </span><span class="hl-4">toolNames:</span><span class="hl-1"> [</span><span class="hl-2">&#39;roll_dice&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;check&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;apply_hp&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;stat_block&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;read_sheet&#39;</span><span class="hl-1">] },</span><br/><span class="hl-1">);</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">rogue</span><span class="hl-1"> = </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createAgent</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;Anthropic&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Vex&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Vex&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;A wary scout.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;claude-haiku-4-5&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;dnd5e:dnd_player&#39;</span><span class="hl-1">,</span><br/><span class="hl-1">);</span><br/><span class="hl-5">// The seventh argument is what makes this one wait for a person.</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">you</span><span class="hl-1"> = </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createAgent</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;Anthropic&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;A hopeful bard.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;claude-haiku-4-5&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;dnd5e:dnd_player&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">true</span><span class="hl-1">,</span><br/><span class="hl-1">);</span><br/><br/><span class="hl-5">// createAgent builds the agent in memory; save() writes it to disk. Without this the</span><br/><span class="hl-5">// table exists for this process only and is gone on restart.</span><br/><span class="hl-1">[</span><span class="hl-4">dm</span><span class="hl-1">, </span><span class="hl-4">rogue</span><span class="hl-1">, </span><span class="hl-4">you</span><span class="hl-1">].</span><span class="hl-0">forEach</span><span class="hl-1">((</span><span class="hl-4">agent</span><span class="hl-1">) </span><span class="hl-6">=&gt;</span><span class="hl-1"> </span><span class="hl-4">agent</span><span class="hl-1">.</span><span class="hl-0">save</span><span class="hl-1">());</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">attachArtifactToAgent</span><span class="hl-1">(</span><span class="hl-4">dm</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-2">&#39;pack:dnd5e.dungeon_master-procedure&#39;</span><span class="hl-1">);</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">attachArtifactToAgent</span><span class="hl-1">(</span><span class="hl-4">rogue</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-2">&#39;pack:dnd5e.class-rogue&#39;</span><span class="hl-1">);</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">attachArtifactToAgent</span><span class="hl-1">(</span><span class="hl-4">you</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-2">&#39;pack:dnd5e.class-bard&#39;</span><span class="hl-1">);</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> { </span><span class="hl-7">roomId</span><span class="hl-1"> } = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createRoom</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;The Sunken Barrow&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;A three-room dungeon crawl.&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> [</span><span class="hl-4">dm</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-4">rogue</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-4">you</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!],</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">, </span><span class="hl-5">// roomLeader — answers anything the room cannot place</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;directed&#39;</span><span class="hl-1">, </span><span class="hl-5">// turnMode</span><br/><span class="hl-1">);</span><br/><br/><span class="hl-5">// A room loaded from disk has no state-change callback, so its emitter would never</span><br/><span class="hl-5">// fire. Harmless on a room you just created; required for one you resumed.</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">ensureRoomStateCallback</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">);</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">io</span><span class="hl-1"> = </span><span class="hl-4">readline</span><span class="hl-1">.</span><span class="hl-0">createInterface</span><span class="hl-1">({ </span><span class="hl-4">input:</span><span class="hl-1"> </span><span class="hl-4">process</span><span class="hl-1">.</span><span class="hl-4">stdin</span><span class="hl-1">, </span><span class="hl-4">output:</span><span class="hl-1"> </span><span class="hl-4">process</span><span class="hl-1">.</span><span class="hl-4">stdout</span><span class="hl-1"> });</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">lastIndex</span><span class="hl-1"> = -</span><span class="hl-8">1</span><span class="hl-1">;</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">atKeyboard</span><span class="hl-1"> = </span><span class="hl-6">false</span><span class="hl-1">; </span><span class="hl-5">// the handler is async; without this it re-enters</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">replyTo</span><span class="hl-1"> = </span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">; </span><span class="hl-5">// who last spoke to the player</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">replyAs</span><span class="hl-1">: </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1"> | </span><span class="hl-2">&#39;whisper&#39;</span><span class="hl-1"> = </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">getRoomMessageEmitter</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">).</span><span class="hl-0">on</span><span class="hl-1">(</span><span class="hl-2">&#39;update&#39;</span><span class="hl-1">, </span><span class="hl-6">async</span><span class="hl-1"> (</span><span class="hl-4">state</span><span class="hl-1">: </span><span class="hl-9">RoomUpdate</span><span class="hl-1">) </span><span class="hl-6">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">type</span><span class="hl-1"> === </span><span class="hl-2">&#39;error&#39;</span><span class="hl-1">) { </span><span class="hl-5">// a turn failed — see &quot;Errors&quot; below</span><br/><span class="hl-1"> </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">(</span><span class="hl-2">`[</span><span class="hl-6">${</span><span class="hl-4">state</span><span class="hl-10">.</span><span class="hl-4">errorType</span><span class="hl-6">}</span><span class="hl-2">] </span><span class="hl-6">${</span><span class="hl-4">state</span><span class="hl-10">.</span><span class="hl-4">message</span><span class="hl-6">}</span><span class="hl-2">`</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-3">return</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">message</span><span class="hl-1"> = </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">latestMessage</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">message</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">messageIndex</span><span class="hl-1"> !== </span><span class="hl-6">undefined</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">messageIndex</span><span class="hl-1"> &gt; </span><span class="hl-4">lastIndex</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">lastIndex</span><span class="hl-1"> = </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">messageIndex</span><span class="hl-1">; </span><span class="hl-5">// the emitter can repeat a state</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">sender</span><span class="hl-1"> !== </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">) </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">`</span><span class="hl-6">${</span><span class="hl-4">message</span><span class="hl-10">.</span><span class="hl-4">sender</span><span class="hl-6">}</span><span class="hl-2">: </span><span class="hl-6">${</span><span class="hl-4">message</span><span class="hl-10">.</span><span class="hl-4">content</span><span class="hl-6">}</span><span class="hl-2">`</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-5">// Answer whoever addressed you, the way they addressed you. During session</span><br/><span class="hl-1"> </span><span class="hl-5">// zero that is the designer or the creator, whispering — replying to the DM</span><br/><span class="hl-1"> </span><span class="hl-5">// instead drops the interview.</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">targets</span><span class="hl-1">?.</span><span class="hl-0">includes</span><span class="hl-1">(</span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">) &amp;&amp; </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">sender</span><span class="hl-1"> !== </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">replyTo</span><span class="hl-1"> = </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">sender</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">replyAs</span><span class="hl-1"> = </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">action</span><span class="hl-1"> === </span><span class="hl-2">&#39;whisper&#39;</span><span class="hl-1"> ? </span><span class="hl-2">&#39;whisper&#39;</span><span class="hl-1"> : </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><br/><span class="hl-1"> </span><span class="hl-5">// The floor is the player&#39;s only when the room *names* them. `waitingForHuman`</span><br/><span class="hl-1"> </span><span class="hl-5">// is also true for a moment after sendRoomMessage clears currentSpeaker and</span><br/><span class="hl-1"> </span><span class="hl-5">// before processing starts, so gating on it alone opens a second prompt before</span><br/><span class="hl-1"> </span><span class="hl-5">// the table has said a word.</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (!</span><span class="hl-4">atKeyboard</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">currentSpeaker</span><span class="hl-1"> === </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">atKeyboard</span><span class="hl-1"> = </span><span class="hl-6">true</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">try</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">line</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">io</span><span class="hl-1">.</span><span class="hl-0">question</span><span class="hl-1">(</span><span class="hl-2">&#39;&gt; &#39;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">result</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">sendRoomMessage</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">, </span><span class="hl-4">line</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-4">replyAs</span><span class="hl-1">, [</span><span class="hl-4">replyTo</span><span class="hl-1">]);</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (!</span><span class="hl-4">result</span><span class="hl-1">.</span><span class="hl-4">accepted</span><span class="hl-1">) </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">`(not your turn — </span><span class="hl-6">${</span><span class="hl-4">result</span><span class="hl-10">.</span><span class="hl-4">reason</span><span class="hl-6">}</span><span class="hl-2">)`</span><span class="hl-1">);</span><br/><span class="hl-1"> } </span><span class="hl-3">finally</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">atKeyboard</span><span class="hl-1"> = </span><span class="hl-6">false</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span><br/><br/><span class="hl-5">// The emitter only fires on a *change*, so the opening line comes from here.</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">sendRoomMessage</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">, </span><span class="hl-2">&#39;Begin the adventure.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1">, [</span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">]);</span>
383
+ <pre><code class="typescript"><span class="hl-3">import</span><span class="hl-1"> { </span><span class="hl-4">Briyah</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&#39;briyah&#39;</span><span class="hl-1">;</span><br/><span class="hl-3">import</span><span class="hl-1"> </span><span class="hl-3">type</span><span class="hl-1"> { </span><span class="hl-4">RoomUpdate</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&#39;briyah&#39;</span><span class="hl-1">;</span><br/><span class="hl-3">import</span><span class="hl-1"> </span><span class="hl-6">*</span><span class="hl-1"> </span><span class="hl-3">as</span><span class="hl-1"> </span><span class="hl-4">readline</span><span class="hl-1"> </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&#39;node:readline/promises&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">// The constructor installs every bundled pack&#39;s tools already; pass `tools` only to</span><br/><span class="hl-5">// filter or wrap them, or to add your own.</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">briyah</span><span class="hl-1"> = </span><span class="hl-6">new</span><span class="hl-1"> </span><span class="hl-0">Briyah</span><span class="hl-1">({ </span><span class="hl-4">dataPath:</span><span class="hl-1"> </span><span class="hl-2">&#39;./briyah-data&#39;</span><span class="hl-1"> });</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">briyah</span><span class="hl-1">.</span><span class="hl-0">init</span><span class="hl-1">(); </span><span class="hl-5">// seeds prompt folders and the packs</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">app</span><span class="hl-1"> = </span><span class="hl-4">briyah</span><span class="hl-1">.</span><span class="hl-0">getAppService</span><span class="hl-1">(</span><span class="hl-2">&#39;user-123&#39;</span><span class="hl-1">);</span><br/><br/><span class="hl-5">// Enable the pack for this user, or a bare folder name will not reach it. Enabling is</span><br/><span class="hl-5">// per user; installing is not.</span><br/><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-4">packs</span><span class="hl-1">.</span><span class="hl-0">setEnabled</span><span class="hl-1">(</span><span class="hl-2">&#39;dnd5e&#39;</span><span class="hl-1">, </span><span class="hl-6">true</span><span class="hl-1">);</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">dm</span><span class="hl-1"> = </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createAgent</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;Anthropic&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Dungeon Master&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Runs the game.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;claude-sonnet-5&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;dnd5e:dungeon_master&#39;</span><span class="hl-1">, </span><span class="hl-6">undefined</span><span class="hl-1">, </span><span class="hl-6">null</span><span class="hl-1">, </span><span class="hl-8">0</span><span class="hl-1">, </span><span class="hl-2">&#39;&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> { </span><span class="hl-4">toolNames:</span><span class="hl-1"> [</span><span class="hl-2">&#39;roll_dice&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;check&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;apply_hp&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;stat_block&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;read_sheet&#39;</span><span class="hl-1">] },</span><br/><span class="hl-1">);</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">rogue</span><span class="hl-1"> = </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createAgent</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;Anthropic&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Vex&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Vex&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;A wary scout.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;claude-haiku-4-5&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;dnd5e:dnd_player&#39;</span><span class="hl-1">,</span><br/><span class="hl-1">);</span><br/><span class="hl-5">// The seventh argument is what makes this one wait for a person.</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">you</span><span class="hl-1"> = </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createAgent</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;Anthropic&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;A hopeful bard.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;claude-haiku-4-5&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;dnd5e:dnd_player&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-6">true</span><span class="hl-1">,</span><br/><span class="hl-1">);</span><br/><br/><span class="hl-5">// createAgent builds the agent in memory; save() writes it to disk. Without this the</span><br/><span class="hl-5">// table exists for this process only and is gone on restart.</span><br/><span class="hl-1">[</span><span class="hl-4">dm</span><span class="hl-1">, </span><span class="hl-4">rogue</span><span class="hl-1">, </span><span class="hl-4">you</span><span class="hl-1">].</span><span class="hl-0">forEach</span><span class="hl-1">((</span><span class="hl-4">agent</span><span class="hl-1">) </span><span class="hl-6">=&gt;</span><span class="hl-1"> </span><span class="hl-4">agent</span><span class="hl-1">.</span><span class="hl-0">save</span><span class="hl-1">());</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">attachArtifactToAgent</span><span class="hl-1">(</span><span class="hl-4">dm</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-2">&#39;pack:dnd5e.dungeon_master-procedure&#39;</span><span class="hl-1">);</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">attachArtifactToAgent</span><span class="hl-1">(</span><span class="hl-4">rogue</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-2">&#39;pack:dnd5e.class-rogue&#39;</span><span class="hl-1">);</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">attachArtifactToAgent</span><span class="hl-1">(</span><span class="hl-4">you</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-2">&#39;pack:dnd5e.class-bard&#39;</span><span class="hl-1">);</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> { </span><span class="hl-7">roomId</span><span class="hl-1"> } = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">createRoom</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;The Sunken Barrow&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;A three-room dungeon crawl.&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> [</span><span class="hl-4">dm</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-4">rogue</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!, </span><span class="hl-4">you</span><span class="hl-1">.</span><span class="hl-4">id</span><span class="hl-1">!],</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">, </span><span class="hl-5">// roomLeader — answers anything the room cannot place</span><br/><span class="hl-1"> </span><span class="hl-2">&#39;directed&#39;</span><span class="hl-1">, </span><span class="hl-5">// turnMode</span><br/><span class="hl-1">);</span><br/><br/><span class="hl-5">// A room loaded from disk has no state-change callback, so its emitter would never</span><br/><span class="hl-5">// fire. Harmless on a room you just created; required for one you resumed.</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">ensureRoomStateCallback</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">);</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">io</span><span class="hl-1"> = </span><span class="hl-4">readline</span><span class="hl-1">.</span><span class="hl-0">createInterface</span><span class="hl-1">({ </span><span class="hl-4">input:</span><span class="hl-1"> </span><span class="hl-4">process</span><span class="hl-1">.</span><span class="hl-4">stdin</span><span class="hl-1">, </span><span class="hl-4">output:</span><span class="hl-1"> </span><span class="hl-4">process</span><span class="hl-1">.</span><span class="hl-4">stdout</span><span class="hl-1"> });</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">lastIndex</span><span class="hl-1"> = -</span><span class="hl-8">1</span><span class="hl-1">;</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">atKeyboard</span><span class="hl-1"> = </span><span class="hl-6">false</span><span class="hl-1">; </span><span class="hl-5">// the handler is async; without this it re-enters</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">replyTo</span><span class="hl-1"> = </span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">; </span><span class="hl-5">// who last spoke to the player</span><br/><span class="hl-6">let</span><span class="hl-1"> </span><span class="hl-4">replyAs</span><span class="hl-1">: </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1"> | </span><span class="hl-2">&#39;whisper&#39;</span><span class="hl-1"> = </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">getRoomMessageEmitter</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">).</span><span class="hl-0">on</span><span class="hl-1">(</span><span class="hl-2">&#39;update&#39;</span><span class="hl-1">, </span><span class="hl-6">async</span><span class="hl-1"> (</span><span class="hl-4">state</span><span class="hl-1">: </span><span class="hl-9">RoomUpdate</span><span class="hl-1">) </span><span class="hl-6">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">type</span><span class="hl-1"> === </span><span class="hl-2">&#39;error&#39;</span><span class="hl-1">) { </span><span class="hl-5">// a turn failed — see &quot;Errors&quot; below</span><br/><span class="hl-1"> </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">(</span><span class="hl-2">`[</span><span class="hl-6">${</span><span class="hl-4">state</span><span class="hl-10">.</span><span class="hl-4">errorType</span><span class="hl-6">}</span><span class="hl-2">] </span><span class="hl-6">${</span><span class="hl-4">state</span><span class="hl-10">.</span><span class="hl-4">message</span><span class="hl-6">}</span><span class="hl-2">`</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-3">return</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">message</span><span class="hl-1"> = </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">latestMessage</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">message</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">messageIndex</span><span class="hl-1"> !== </span><span class="hl-6">undefined</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">messageIndex</span><span class="hl-1"> &gt; </span><span class="hl-4">lastIndex</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">lastIndex</span><span class="hl-1"> = </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">messageIndex</span><span class="hl-1">; </span><span class="hl-5">// the emitter can repeat a state</span><br/><span class="hl-1"> </span><span class="hl-5">// Everything the room logged comes down this stream, an agent&#39;s thinking</span><br/><span class="hl-1"> </span><span class="hl-5">// and its tool calls included. Nobody at the table hears either, and a DM</span><br/><span class="hl-1"> </span><span class="hl-5">// thinking out loud is the adventure with its answers written in.</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">audible</span><span class="hl-1"> = </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">action</span><span class="hl-1"> !== </span><span class="hl-2">&#39;think&#39;</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">action</span><span class="hl-1"> !== </span><span class="hl-2">&#39;tool&#39;</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">audible</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">sender</span><span class="hl-1"> !== </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">`</span><span class="hl-6">${</span><span class="hl-4">message</span><span class="hl-10">.</span><span class="hl-4">sender</span><span class="hl-6">}</span><span class="hl-2">: </span><span class="hl-6">${</span><span class="hl-4">message</span><span class="hl-10">.</span><span class="hl-4">content</span><span class="hl-6">}</span><span class="hl-2">`</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-5">// Answer whoever addressed you, the way they addressed you. During</span><br/><span class="hl-1"> </span><span class="hl-5">// session zero that is the designer or the creator, whispering —</span><br/><span class="hl-1"> </span><span class="hl-5">// replying to the DM instead drops the interview.</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (</span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">targets</span><span class="hl-1">?.</span><span class="hl-0">includes</span><span class="hl-1">(</span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">)) {</span><br/><span class="hl-1"> </span><span class="hl-4">replyTo</span><span class="hl-1"> = </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">sender</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">replyAs</span><span class="hl-1"> = </span><span class="hl-4">message</span><span class="hl-1">.</span><span class="hl-4">action</span><span class="hl-1"> === </span><span class="hl-2">&#39;whisper&#39;</span><span class="hl-1"> ? </span><span class="hl-2">&#39;whisper&#39;</span><span class="hl-1"> : </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><br/><span class="hl-1"> </span><span class="hl-5">// The floor is the player&#39;s only when the room *names* them. `waitingForHuman`</span><br/><span class="hl-1"> </span><span class="hl-5">// is also true for a moment after sendRoomMessage clears currentSpeaker and</span><br/><span class="hl-1"> </span><span class="hl-5">// before processing starts, so gating on it alone opens a second prompt before</span><br/><span class="hl-1"> </span><span class="hl-5">// the table has said a word.</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (!</span><span class="hl-4">atKeyboard</span><span class="hl-1"> &amp;&amp; </span><span class="hl-4">state</span><span class="hl-1">.</span><span class="hl-4">currentSpeaker</span><span class="hl-1"> === </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-4">atKeyboard</span><span class="hl-1"> = </span><span class="hl-6">true</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">try</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">line</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">io</span><span class="hl-1">.</span><span class="hl-0">question</span><span class="hl-1">(</span><span class="hl-2">&#39;&gt; &#39;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">result</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">sendRoomMessage</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">, </span><span class="hl-4">line</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-4">replyAs</span><span class="hl-1">, [</span><span class="hl-4">replyTo</span><span class="hl-1">]);</span><br/><span class="hl-1"> </span><span class="hl-3">if</span><span class="hl-1"> (!</span><span class="hl-4">result</span><span class="hl-1">.</span><span class="hl-4">accepted</span><span class="hl-1">) </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">`(not your turn — </span><span class="hl-6">${</span><span class="hl-4">result</span><span class="hl-10">.</span><span class="hl-4">reason</span><span class="hl-6">}</span><span class="hl-2">)`</span><span class="hl-1">);</span><br/><span class="hl-1"> } </span><span class="hl-3">finally</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">atKeyboard</span><span class="hl-1"> = </span><span class="hl-6">false</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span><br/><br/><span class="hl-5">// The emitter only fires on a *change*, so the opening line comes from here.</span><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">app</span><span class="hl-1">.</span><span class="hl-0">sendRoomMessage</span><span class="hl-1">(</span><span class="hl-4">roomId</span><span class="hl-1">, </span><span class="hl-2">&#39;Begin the adventure.&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;Homer&#39;</span><span class="hl-1">, </span><span class="hl-2">&#39;speak&#39;</span><span class="hl-1">, [</span><span class="hl-2">&#39;DM&#39;</span><span class="hl-1">]);</span>
384
384
  </code><button type="button">Copy</button></pre>
385
385
 
386
386
  <p><strong>The emitter payload</strong> is <code>RoomUpdate</code>, a two-member union discriminated by <code>type</code> —
387
387
  <code>RoomMessageUpdate</code> (<code>type: 'state'</code>) and <code>RoomErrorUpdate</code> (<code>type: 'error'</code>). Both are exported,
388
388
  so the narrowing above compiles under <code>strict</code> with nothing hand-written. A state update carries
389
389
  <code>latestMessage</code>, <code>messageIndex</code>, <code>totalCost</code>, <code>isPaused</code>, <code>currentSpeaker</code>,
390
- <code>processingInProgress</code> and <code>waitingForHuman</code>. <code>messageIndex</code> counts messages with thoughts and
391
- tool notices excluded, so compare it against a list fetched the same way —
392
- <code>getRoomMessages(roomId)</code> — or refetch when they disagree.</p>
390
+ <code>processingInProgress</code> and <code>waitingForHuman</code>. A state update carries <strong>every</strong> message the room
391
+ logged — thoughts and tool notices included — and <code>messageIndex</code> is that message's own index, so
392
+ it lines up with <code>getRoomMessages(roomId, 0, true)</code> and a gap between the two is a real gap
393
+ rather than a difference of bookkeeping. Drop what a host does not want on <code>action</code>, as the loop
394
+ above does; asking the room for a narrower list instead leaves the two counting differently, and
395
+ nothing in the update can say by how much.</p>
393
396
  <p><strong>Errors</strong> arrive on the same emitter, as <code>{type: 'error', errorType, message, timestamp}</code>. Same
394
397
  event name rather than <code>'error'</code>, because an EventEmitter throws when an <code>'error'</code> event has no
395
398
  listener and that would take down a host that subscribed only to updates. Check for it first, as
@@ -585,7 +588,7 @@ belong instead.</p>
585
588
  <li><a href="#cache-not-working-as-expected"><span>Cache not working as expected</span></a></li></ul></li></ul></div></details></div>
586
589
  <div class="site-menu">
587
590
  <nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/your-org/briyah" class="tsd-nav-link">GitHub</a><a href="https://www.npmjs.com/package/briyah" class="tsd-nav-link">npm</a></nav>
588
- <nav class="tsd-navigation"><a href="modules.html">Briyah SDK - v2.0.1</a>
591
+ <nav class="tsd-navigation"><a href="modules.html">Briyah SDK - v2.0.2</a>
589
592
  <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
590
593
  <li>Loading...</li></ul></nav></div></div></div><footer>
591
594
  <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
@@ -1,5 +1,5 @@
1
- <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>AgentCreationOptions | Briyah SDK - v2.0.1</title><meta name="description" content="Documentation for Briyah SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar">
2
- <div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Briyah SDK - v2.0.1</a>
1
+ <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>AgentCreationOptions | Briyah SDK - v2.0.2</title><meta name="description" content="Documentation for Briyah SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar">
2
+ <div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Briyah SDK - v2.0.2</a>
3
3
  <div id="tsd-toolbar-links"><a href="https://github.com/your-org/briyah">GitHub</a><a href="https://www.npmjs.com/package/briyah">npm</a></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/>
4
4
  <ul role="listbox" id="tsd-search-results"></ul>
5
5
  <div id="tsd-search-status" aria-live="polite" aria-atomic="true">
@@ -20,7 +20,7 @@ created and then edited.</p>
20
20
  </div></section>
21
21
  <div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">AgentCreationOptions</span> <span class="tsd-signature-symbol">{</span><br/>    <a class="tsd-kind-property" href="#allowsearch">allowSearch</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#maxhistorymessages">maxHistoryMessages</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#ownerroomid">ownerRoomId</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#privatecontext">privateContext</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#promptcachettl">promptCacheTTL</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#smallmodelname">smallModelName</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#toolnames">toolNames</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="#usemoderator">useModerator</a><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources">
22
22
  <ul>
23
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L94">server/src/app.service.ts:94</a></li></ul></aside>
23
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L103">server/src/app.service.ts:103</a></li></ul></aside>
24
24
  <section class="tsd-panel-group tsd-index-group">
25
25
  <section class="tsd-panel tsd-index-panel">
26
26
  <details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>
@@ -46,14 +46,14 @@ created and then edited.</p>
46
46
  <div class="tsd-comment tsd-typography"><p>Enable the provider's web search, where it has one.</p>
47
47
  </div><aside class="tsd-sources">
48
48
  <ul>
49
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L96">server/src/app.service.ts:96</a></li></ul></aside></section>
49
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L105">server/src/app.service.ts:105</a></li></ul></aside></section>
50
50
  <section class="tsd-panel tsd-member">
51
51
  <h3 class="tsd-anchor-link" id="maxhistorymessages"><code class="tsd-tag">Optional</code><span>max<wbr/>History<wbr/>Messages</span><a href="#maxhistorymessages" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
52
52
  <div class="tsd-signature"><span class="tsd-kind-property">maxHistoryMessages</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div>
53
53
  <div class="tsd-comment tsd-typography"><p>Rolling history window: keep only the last N messages.</p>
54
54
  </div><aside class="tsd-sources">
55
55
  <ul>
56
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L110">server/src/app.service.ts:110</a></li></ul></aside></section>
56
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L119">server/src/app.service.ts:119</a></li></ul></aside></section>
57
57
  <section class="tsd-panel tsd-member">
58
58
  <h3 class="tsd-anchor-link" id="ownerroomid"><code class="tsd-tag">Optional</code><span>owner<wbr/>Room<wbr/>Id</span><a href="#ownerroomid" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
59
59
  <div class="tsd-signature"><span class="tsd-kind-property">ownerRoomId</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div>
@@ -61,35 +61,35 @@ created and then edited.</p>
61
61
  <a href="AppService.html#listagents" class="tsd-kind-method">AppService.listAgents</a> and deleted with its room.</p>
62
62
  </div><aside class="tsd-sources">
63
63
  <ul>
64
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L117">server/src/app.service.ts:117</a></li></ul></aside></section>
64
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L126">server/src/app.service.ts:126</a></li></ul></aside></section>
65
65
  <section class="tsd-panel tsd-member">
66
66
  <h3 class="tsd-anchor-link" id="privatecontext"><code class="tsd-tag">Optional</code><span>private<wbr/>Context</span><a href="#privatecontext" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
67
67
  <div class="tsd-signature"><span class="tsd-kind-property">privateContext</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div>
68
68
  <div class="tsd-comment tsd-typography"><p>Notes only this agent sees.</p>
69
69
  </div><aside class="tsd-sources">
70
70
  <ul>
71
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L106">server/src/app.service.ts:106</a></li></ul></aside></section>
71
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L115">server/src/app.service.ts:115</a></li></ul></aside></section>
72
72
  <section class="tsd-panel tsd-member">
73
73
  <h3 class="tsd-anchor-link" id="promptcachettl"><code class="tsd-tag">Optional</code><span>prompt<wbr/>Cache<wbr/>TTL</span><a href="#promptcachettl" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
74
74
  <div class="tsd-signature"><span class="tsd-kind-property">promptCacheTTL</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div>
75
75
  <div class="tsd-comment tsd-typography"><p>Minutes to keep the prompt cache alive; above 5 selects the 1-hour cache.</p>
76
76
  </div><aside class="tsd-sources">
77
77
  <ul>
78
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L108">server/src/app.service.ts:108</a></li></ul></aside></section>
78
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L117">server/src/app.service.ts:117</a></li></ul></aside></section>
79
79
  <section class="tsd-panel tsd-member">
80
80
  <h3 class="tsd-anchor-link" id="smallmodelname"><code class="tsd-tag">Optional</code><span>small<wbr/>Model<wbr/>Name</span><a href="#smallmodelname" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
81
81
  <div class="tsd-signature"><span class="tsd-kind-property">smallModelName</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span></div>
82
82
  <div class="tsd-comment tsd-typography"><p>A cheaper same-service model for mechanical prompts.</p>
83
83
  </div><aside class="tsd-sources">
84
84
  <ul>
85
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L112">server/src/app.service.ts:112</a></li></ul></aside></section>
85
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L121">server/src/app.service.ts:121</a></li></ul></aside></section>
86
86
  <section class="tsd-panel tsd-member">
87
87
  <h3 class="tsd-anchor-link" id="toolnames"><code class="tsd-tag">Optional</code><span>tool<wbr/>Names</span><a href="#toolnames" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
88
88
  <div class="tsd-signature"><span class="tsd-kind-property">toolNames</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></div>
89
89
  <div class="tsd-comment tsd-typography"><p>Names of tools this agent may run with EXECUTE.</p>
90
90
  </div><aside class="tsd-sources">
91
91
  <ul>
92
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L98">server/src/app.service.ts:98</a></li></ul></aside></section>
92
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L107">server/src/app.service.ts:107</a></li></ul></aside></section>
93
93
  <section class="tsd-panel tsd-member">
94
94
  <h3 class="tsd-anchor-link" id="usemoderator"><code class="tsd-tag">Optional</code><span>use<wbr/>Moderator</span><a href="#usemoderator" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3>
95
95
  <div class="tsd-signature"><span class="tsd-kind-property">useModerator</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div>
@@ -98,7 +98,7 @@ human-controlled agent it also removes the action and target pickers from
98
98
  the room's composer. See <a href="../classes/Agent.html#usemoderator" class="tsd-kind-property">Agent.useModerator</a>.</p>
99
99
  </div><aside class="tsd-sources">
100
100
  <ul>
101
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/app.service.ts#L104">server/src/app.service.ts:104</a></li></ul></aside></section></section></details></div>
101
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/dfdc570ca693648160e8071102843097cd4c2cbc/server/src/app.service.ts#L113">server/src/app.service.ts:113</a></li></ul></aside></section></section></details></div>
102
102
  <div class="col-sidebar">
103
103
  <div class="page-menu">
104
104
  <div class="tsd-navigation settings">
@@ -118,7 +118,7 @@ the room's composer. See <a href="../classes/Agent.html#usemoderator" class="tsd
118
118
  <div><a href="#allowsearch"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>allow<wbr/>Search</span></a><a href="#maxhistorymessages"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>max<wbr/>History<wbr/>Messages</span></a><a href="#ownerroomid"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>owner<wbr/>Room<wbr/>Id</span></a><a href="#privatecontext"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>private<wbr/>Context</span></a><a href="#promptcachettl"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>prompt<wbr/>Cache<wbr/>TTL</span></a><a href="#smallmodelname"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>small<wbr/>Model<wbr/>Name</span></a><a href="#toolnames"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>tool<wbr/>Names</span></a><a href="#usemoderator"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>use<wbr/>Moderator</span></a></div></details></div></details></div>
119
119
  <div class="site-menu">
120
120
  <nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://github.com/your-org/briyah" class="tsd-nav-link">GitHub</a><a href="https://www.npmjs.com/package/briyah" class="tsd-nav-link">npm</a></nav>
121
- <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.1</a>
121
+ <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.2</a>
122
122
  <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
123
123
  <li>Loading...</li></ul></nav></div></div></div><footer>
124
124
  <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>