briyah 2.0.1 → 2.0.3

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 (223) hide show
  1. package/LICENSE +216 -0
  2. package/README.md +19 -10
  3. package/data/common/config/markup +1 -1
  4. package/data/common/config/model_prices.json +46369 -46361
  5. package/data/common/config/rpg_models.json +60 -0
  6. package/data/common/prompts/narrator/create_chapter.prompt +12 -1
  7. package/data/common/prompts/pdf_converter/convert_pdf_page.prompt +8 -1
  8. package/data/common/prompts/perceive.prompt +287 -291
  9. package/data/packs/dnd5e/agents/player.json +11 -11
  10. package/data/packs/dnd5e/artifacts/background-acolyte.md +66 -0
  11. package/data/packs/dnd5e/artifacts/character_creator-basics.md +31 -13
  12. package/data/packs/dnd5e/artifacts/class-barbarian.md +4 -1
  13. package/data/packs/dnd5e/artifacts/class-bard.md +2 -1
  14. package/data/packs/dnd5e/artifacts/class-cleric.md +2 -1
  15. package/data/packs/dnd5e/artifacts/class-druid.md +3 -1
  16. package/data/packs/dnd5e/artifacts/class-fighter.md +3 -1
  17. package/data/packs/dnd5e/artifacts/class-monk.md +2 -1
  18. package/data/packs/dnd5e/artifacts/class-paladin.md +2 -1
  19. package/data/packs/dnd5e/artifacts/class-ranger.md +3 -1
  20. package/data/packs/dnd5e/artifacts/class-rogue.md +3 -1
  21. package/data/packs/dnd5e/artifacts/class-sorcerer.md +2 -1
  22. package/data/packs/dnd5e/artifacts/class-warlock.md +3 -1
  23. package/data/packs/dnd5e/artifacts/class-wizard.md +2 -1
  24. package/data/packs/dnd5e/artifacts/manifest.json +6 -0
  25. package/data/packs/dnd5e/pack.json +1 -1
  26. package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +491 -378
  27. package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +24 -7
  28. package/data/packs/dnd5e/prompts/character_creator/defaults_config.json +21 -31
  29. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +236 -99
  30. package/data/packs/dnd5e/prompts/dnd_player/defaults_config.json +5 -5
  31. package/data/packs/dnd5e/prompts/dnd_player/perceive.prompt +28 -10
  32. package/data/packs/dnd5e/prompts/dnd_room_moderator/defaults_config.json +9 -9
  33. package/data/packs/dnd5e/prompts/dnd_room_moderator/moderate.prompt +13 -10
  34. package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +32 -30
  35. package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +794 -764
  36. package/data/packs/dnd5e/rooms/campaign.json +15 -0
  37. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +3 -0
  38. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +40 -11
  39. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +1 -0
  40. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +16 -0
  41. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +5 -3
  42. package/dist-sdk/server/src/ai/agent-store.service.js +1 -1
  43. package/dist-sdk/server/src/ai/artifact.service.d.ts +2 -0
  44. package/dist-sdk/server/src/ai/artifact.service.js +6 -0
  45. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +2 -0
  46. package/dist-sdk/server/src/ai/pack-artifacts.js +65 -8
  47. package/dist-sdk/server/src/app/user-service-factory.js +6 -1
  48. package/dist-sdk/server/src/app/user-service-manager.js +1 -1
  49. package/dist-sdk/server/src/app.controller.d.ts +9 -1
  50. package/dist-sdk/server/src/app.controller.js +123 -12
  51. package/dist-sdk/server/src/app.service.d.ts +24 -2
  52. package/dist-sdk/server/src/app.service.js +123 -109
  53. package/dist-sdk/server/src/auth/auth.controller.js +4 -0
  54. package/dist-sdk/server/src/auth/auth.service.d.ts +2 -1
  55. package/dist-sdk/server/src/auth/dto/phone-login.dto.d.ts +2 -1
  56. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +43 -0
  57. package/dist-sdk/server/src/documents/pdf-conversion.js +175 -0
  58. package/dist-sdk/server/src/room/nickname.d.ts +1 -0
  59. package/dist-sdk/server/src/room/nickname.js +15 -0
  60. package/dist-sdk/server/src/room/room-store.service.d.ts +1 -0
  61. package/dist-sdk/server/src/room/room-store.service.js +9 -1
  62. package/dist-sdk/server/src/room/room.d.ts +43 -3
  63. package/dist-sdk/server/src/room/room.js +317 -35
  64. package/dist-sdk/server/src/rpg/rpg-models.d.ts +9 -0
  65. package/dist-sdk/server/src/rpg/rpg-models.js +128 -0
  66. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +8 -0
  67. package/dist-sdk/server/src/rpg/rpg-roster.js +34 -0
  68. package/dist-sdk/server/src/rpg/rpg.service.d.ts +29 -0
  69. package/dist-sdk/server/src/rpg/rpg.service.js +199 -0
  70. package/dist-sdk/server/src/sdk/index.d.ts +4 -2
  71. package/dist-sdk/server/src/sdk/index.js +6 -1
  72. package/dist-sdk/server/src/story/story.service.d.ts +2 -1
  73. package/dist-sdk/server/src/story/story.service.js +42 -4
  74. package/dist-sdk/server/src/tools/core/index.d.ts +3 -0
  75. package/dist-sdk/server/src/tools/core/index.js +9 -0
  76. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +2 -0
  77. package/dist-sdk/server/src/tools/core/rename.tool.js +61 -0
  78. package/dist-sdk/server/src/tools/native-tool.types.d.ts +15 -0
  79. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +0 -21
  80. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +1 -56
  81. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +10 -0
  82. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +67 -0
  83. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +5 -0
  84. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +7 -1
  85. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +4 -3
  86. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +6 -0
  87. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +92 -0
  88. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +32 -5
  89. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +177 -28
  90. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +1 -13
  91. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +15 -145
  92. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +7 -0
  93. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +11 -0
  94. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +5 -0
  95. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +45 -2
  96. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +3 -0
  97. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +21 -0
  98. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +45 -0
  99. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +6 -4
  100. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +17 -0
  101. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +56 -4
  102. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +3 -0
  103. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +117 -15
  104. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +2 -0
  105. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +96 -0
  106. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +40 -3
  107. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +36 -27
  108. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +7 -4
  109. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +15 -1
  110. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +73 -0
  111. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +49 -13
  112. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +68 -2
  113. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  114. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +119 -14
  115. package/dist-sdk/server/src/tools/packs/index.d.ts +2 -0
  116. package/dist-sdk/server/src/tools/packs/index.js +16 -5
  117. package/dist-sdk/server/src/tools/shared/coerce.d.ts +13 -0
  118. package/dist-sdk/server/src/tools/shared/coerce.js +147 -0
  119. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +3 -2
  120. package/dist-sdk/server/src/tools/tool-execution.service.js +4 -1
  121. package/dist-sdk/shared/types/app.types.d.ts +63 -0
  122. package/dist-sdk/shared/types/app.types.js +2 -1
  123. package/docs/assets/hierarchy.js +1 -1
  124. package/docs/assets/navigation.js +1 -1
  125. package/docs/assets/search.js +1 -1
  126. package/docs/classes/Agent.html +73 -73
  127. package/docs/classes/Briyah.html +16 -16
  128. package/docs/classes/BriyahConfigService.html +7 -7
  129. package/docs/classes/NativeToolRegistry.html +10 -10
  130. package/docs/classes/PackInstantiationService.html +7 -7
  131. package/docs/classes/PackService.html +13 -13
  132. package/docs/classes/Room.html +216 -95
  133. package/docs/classes/RoomMessage.html +22 -22
  134. package/docs/enums/MessageAction.html +18 -18
  135. package/docs/functions/availableToolPacks.html +5 -5
  136. package/docs/functions/buildMarkdown.html +54 -0
  137. package/docs/functions/dnd5eTools.html +4 -4
  138. package/docs/functions/installToolPacks.html +8 -5
  139. package/docs/functions/pageMarker.html +45 -0
  140. package/docs/functions/registerToolPacks.html +4 -4
  141. package/docs/functions/splitMarkdownIntoPages.html +51 -0
  142. package/docs/functions/stripWrappingFence.html +52 -0
  143. package/docs/hierarchy.html +13 -9
  144. package/docs/index.html +11 -8
  145. package/docs/interfaces/AgentCreationOptions.html +12 -12
  146. package/docs/interfaces/AgentInfo.html +30 -30
  147. package/docs/interfaces/AgentMessagesResponse.html +8 -8
  148. package/docs/interfaces/AppService.html +276 -198
  149. package/docs/interfaces/Artifact.html +9 -9
  150. package/docs/interfaces/ArtifactMetadata.html +13 -13
  151. package/docs/interfaces/ArtifactWriteOptions.html +7 -7
  152. package/docs/interfaces/AttachDocumentResponse.html +6 -6
  153. package/docs/interfaces/BriyahConfigOptions.html +12 -12
  154. package/docs/interfaces/ChapterInfo.html +6 -6
  155. package/docs/interfaces/Character.html +10 -10
  156. package/docs/interfaces/ConversionAgent.html +78 -0
  157. package/docs/interfaces/CreateAgentResponse.html +5 -5
  158. package/docs/interfaces/CreateRoomResponse.html +6 -6
  159. package/docs/interfaces/CreateStoryResponse.html +5 -5
  160. package/docs/interfaces/FileList.html +5 -5
  161. package/docs/interfaces/FileMetadata.html +10 -10
  162. package/docs/interfaces/IConfigService.html +5 -5
  163. package/docs/interfaces/InstantiateModels.html +6 -6
  164. package/docs/interfaces/InstantiateRoomResult.html +7 -7
  165. package/docs/interfaces/LoadedPack.html +16 -16
  166. package/docs/interfaces/LoggingOptions.html +9 -9
  167. package/docs/interfaces/Message.html +9 -9
  168. package/docs/interfaces/ModelChoice.html +7 -7
  169. package/docs/interfaces/ModelInfo.html +8 -8
  170. package/docs/interfaces/NativeToolDefinition.html +10 -10
  171. package/docs/interfaces/PackAgentTemplate.html +9 -9
  172. package/docs/interfaces/PackRoomTemplate.html +11 -11
  173. package/docs/interfaces/PackView.html +20 -20
  174. package/docs/interfaces/PdfConversionOptions.html +102 -0
  175. package/docs/interfaces/PdfConversionResult.html +97 -0
  176. package/docs/interfaces/PdfMarkdownOptions.html +198 -0
  177. package/docs/interfaces/PdfMarkdownResult.html +106 -0
  178. package/docs/interfaces/PdfPageMarkdown.html +94 -0
  179. package/docs/interfaces/PreparedPromptResponse.html +6 -6
  180. package/docs/interfaces/ProcessTextResponse.html +10 -10
  181. package/docs/interfaces/PromptFile.html +7 -7
  182. package/docs/interfaces/PromptFileContent.html +8 -8
  183. package/docs/interfaces/PromptFilesResponse.html +5 -5
  184. package/docs/interfaces/PromptFolder.html +8 -8
  185. package/docs/interfaces/PromptFolderDefaults.html +19 -19
  186. package/docs/interfaces/PromptFolderDefaultsResponse.html +7 -7
  187. package/docs/interfaces/PromptFoldersResponse.html +5 -5
  188. package/docs/interfaces/RoomDetails.html +19 -19
  189. package/docs/interfaces/RoomErrorUpdate.html +8 -8
  190. package/docs/interfaces/RoomInfo.html +10 -10
  191. package/docs/interfaces/RoomMessageUpdate.html +13 -13
  192. package/docs/interfaces/RoomMessagesResponse.html +6 -6
  193. package/docs/interfaces/SendMessageResult.html +6 -6
  194. package/docs/interfaces/StoryErrorEvent.html +8 -8
  195. package/docs/interfaces/StoryIdea.html +8 -8
  196. package/docs/interfaces/StoryInfo.html +28 -28
  197. package/docs/interfaces/StoryIntroduceCharacterEvent.html +7 -7
  198. package/docs/interfaces/StoryProgressChapterEvent.html +6 -6
  199. package/docs/interfaces/StoryState.html +12 -12
  200. package/docs/interfaces/StoryStateEvent.html +7 -7
  201. package/docs/interfaces/ToolArtifact.html +9 -9
  202. package/docs/interfaces/ToolCaller.html +7 -7
  203. package/docs/interfaces/ToolDefinition.html +9 -9
  204. package/docs/interfaces/ToolHelpers.html +17 -8
  205. package/docs/interfaces/ToolPackDocuments.html +100 -0
  206. package/docs/interfaces/ToolParameter.html +8 -8
  207. package/docs/interfaces/ToolRoomAccess.html +49 -16
  208. package/docs/interfaces/ToolSummary.html +8 -8
  209. package/docs/interfaces/ToolsResponse.html +7 -7
  210. package/docs/interfaces/Transaction.html +13 -13
  211. package/docs/interfaces/TransactionHistoryResponse.html +6 -6
  212. package/docs/modules.html +8 -8
  213. package/docs/types/PackOrigin.html +4 -4
  214. package/docs/types/PromptScope.html +4 -4
  215. package/docs/types/RoomTurnMode.html +4 -4
  216. package/docs/types/RoomUpdate.html +4 -4
  217. package/docs/types/RosterOverrides.html +4 -4
  218. package/docs/types/ToolContext.html +4 -4
  219. package/docs/types/ToolRunResult.html +4 -4
  220. package/package.json +32 -3
  221. package/src/tools/packs/dnd5e/README.md +147 -66
  222. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.d.ts +0 -20
  223. package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.js +0 -112
@@ -0,0 +1,45 @@
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>pageMarker | Briyah SDK - v2.0.3</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.3</a>
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
+ <ul role="listbox" id="tsd-search-results"></ul>
5
+ <div id="tsd-search-status" aria-live="polite" aria-atomic="true">
6
+ <div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header>
7
+ <div class="container container-main">
8
+ <div class="col-content">
9
+ <div class="tsd-page-title">
10
+ <ul class="tsd-breadcrumb" aria-label="Breadcrumb">
11
+ <li><a href="" aria-current="page">pageMarker</a></li></ul>
12
+ <h1>Function pageMarker</h1></div>
13
+ <section class="tsd-panel">
14
+ <ul class="tsd-signatures">
15
+ <li class="">
16
+ <div class="tsd-signature tsd-anchor-link" id="pagemarker"><span class="tsd-kind-call-signature">pageMarker</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">pageNum</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#pagemarker" 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></div>
17
+ <div class="tsd-description">
18
+ <div class="tsd-comment tsd-typography"><p>The marker written between pages. An HTML comment, so it does not render.</p>
19
+ </div>
20
+ <div class="tsd-parameters">
21
+ <h4 class="tsd-parameters-title">Parameters</h4>
22
+ <ul class="tsd-parameter-list">
23
+ <li><span><span class="tsd-kind-parameter">pageNum</span>: <span class="tsd-signature-type">number</span></span></li></ul></div>
24
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><aside class="tsd-sources">
25
+ <ul>
26
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/683254ac85e228b874f6df02fc93a13893a152d5/server/src/documents/pdf-conversion.ts#L149">server/src/documents/pdf-conversion.ts:149</a></li></ul></aside></div></li></ul></section></div>
27
+ <div class="col-sidebar">
28
+ <div class="page-menu">
29
+ <div class="tsd-navigation settings">
30
+ <details class="tsd-accordion"><summary class="tsd-accordion-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>
31
+ <h3>Settings</h3></summary>
32
+ <div class="tsd-accordion-details">
33
+ <div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span>
34
+ <ul id="tsd-filter-options">
35
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
36
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
37
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div>
38
+ <div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
39
+ <div class="site-menu">
40
+ <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>
41
+ <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.3</a>
42
+ <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
43
+ <li>Loading...</li></ul></nav></div></div></div><footer>
44
+ <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
45
+ <div class="overlay"></div></body></html>
@@ -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>registerToolPacks | 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>registerToolPacks | Briyah SDK - v2.0.3</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.3</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">
@@ -32,7 +32,7 @@ registers nothing.</p>
32
32
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h4><p>The names of the tools that were registered</p>
33
33
  <aside class="tsd-sources">
34
34
  <ul>
35
- <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/1a8dc08591eb0354e3644da7a14d27b30625ced5/server/src/tools/packs/index.ts#L47">server/src/tools/packs/index.ts:47</a></li></ul></aside></div></li></ul></section></div>
35
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/683254ac85e228b874f6df02fc93a13893a152d5/server/src/tools/packs/index.ts#L72">server/src/tools/packs/index.ts:72</a></li></ul></aside></div></li></ul></section></div>
36
36
  <div class="col-sidebar">
37
37
  <div class="page-menu">
38
38
  <div class="tsd-navigation settings">
@@ -47,7 +47,7 @@ registers nothing.</p>
47
47
  <div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
48
48
  <div class="site-menu">
49
49
  <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>
50
- <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.1</a>
50
+ <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.3</a>
51
51
  <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
52
52
  <li>Loading...</li></ul></nav></div></div></div><footer>
53
53
  <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
@@ -0,0 +1,51 @@
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>splitMarkdownIntoPages | Briyah SDK - v2.0.3</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.3</a>
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
+ <ul role="listbox" id="tsd-search-results"></ul>
5
+ <div id="tsd-search-status" aria-live="polite" aria-atomic="true">
6
+ <div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header>
7
+ <div class="container container-main">
8
+ <div class="col-content">
9
+ <div class="tsd-page-title">
10
+ <ul class="tsd-breadcrumb" aria-label="Breadcrumb">
11
+ <li><a href="" aria-current="page">splitMarkdownIntoPages</a></li></ul>
12
+ <h1>Function splitMarkdownIntoPages</h1></div>
13
+ <section class="tsd-panel">
14
+ <ul class="tsd-signatures">
15
+ <li class="">
16
+ <div class="tsd-signature tsd-anchor-link" id="splitmarkdownintopages"><span class="tsd-kind-call-signature">splitMarkdownIntoPages</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">markdown</span><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> <a href="../interfaces/PdfPageMarkdown.html" class="tsd-signature-type tsd-kind-interface">PdfPageMarkdown</a><span class="tsd-signature-symbol">[]</span><a href="#splitmarkdownintopages" 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></div>
17
+ <div class="tsd-description">
18
+ <div class="tsd-comment tsd-typography"><p>Splits a converted document back into its pages on the <code>&lt;!-- Page N --&gt;</code> markers.</p>
19
+ <p>The inverse of <a href="buildMarkdown.html" class="tsd-kind-function">buildMarkdown</a>, and the reason the markers are machine
20
+ readable at all: re-running the pages that failed means finding them, converting
21
+ them, and splicing them back.</p>
22
+ </div>
23
+ <div class="tsd-parameters">
24
+ <h4 class="tsd-parameters-title">Parameters</h4>
25
+ <ul class="tsd-parameter-list">
26
+ <li><span><span class="tsd-kind-parameter">markdown</span>: <span class="tsd-signature-type">string</span></span>
27
+ <div class="tsd-comment tsd-typography"><p>A document this module produced, or any Markdown</p>
28
+ </div></li></ul></div>
29
+ <h4 class="tsd-returns-title">Returns <a href="../interfaces/PdfPageMarkdown.html" class="tsd-signature-type tsd-kind-interface">PdfPageMarkdown</a><span class="tsd-signature-symbol">[]</span></h4><p>One entry per page; the whole document as page 1 when it carries no markers</p>
30
+ <aside class="tsd-sources">
31
+ <ul>
32
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/683254ac85e228b874f6df02fc93a13893a152d5/server/src/documents/pdf-conversion.ts#L166">server/src/documents/pdf-conversion.ts:166</a></li></ul></aside></div></li></ul></section></div>
33
+ <div class="col-sidebar">
34
+ <div class="page-menu">
35
+ <div class="tsd-navigation settings">
36
+ <details class="tsd-accordion"><summary class="tsd-accordion-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>
37
+ <h3>Settings</h3></summary>
38
+ <div class="tsd-accordion-details">
39
+ <div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span>
40
+ <ul id="tsd-filter-options">
41
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
42
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
43
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div>
44
+ <div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
45
+ <div class="site-menu">
46
+ <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>
47
+ <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.3</a>
48
+ <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
49
+ <li>Loading...</li></ul></nav></div></div></div><footer>
50
+ <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
51
+ <div class="overlay"></div></body></html>
@@ -0,0 +1,52 @@
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>stripWrappingFence | Briyah SDK - v2.0.3</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.3</a>
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
+ <ul role="listbox" id="tsd-search-results"></ul>
5
+ <div id="tsd-search-status" aria-live="polite" aria-atomic="true">
6
+ <div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header>
7
+ <div class="container container-main">
8
+ <div class="col-content">
9
+ <div class="tsd-page-title">
10
+ <ul class="tsd-breadcrumb" aria-label="Breadcrumb">
11
+ <li><a href="" aria-current="page">stripWrappingFence</a></li></ul>
12
+ <h1>Function stripWrappingFence</h1></div>
13
+ <section class="tsd-panel">
14
+ <ul class="tsd-signatures">
15
+ <li class="">
16
+ <div class="tsd-signature tsd-anchor-link" id="stripwrappingfence"><span class="tsd-kind-call-signature">stripWrappingFence</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">text</span><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> <span class="tsd-signature-type">string</span><a href="#stripwrappingfence" 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></div>
17
+ <div class="tsd-description">
18
+ <div class="tsd-comment tsd-typography"><p>Unwraps a response the model fenced as one ```markdown block.</p>
19
+ <p>The prompt asks for bare Markdown and mostly gets it, but a page comes back
20
+ wrapped often enough that the fence markers end up as literal content in the
21
+ artifact. Only a fence that opens at the very start and closes at the very end is
22
+ stripped, so a page whose real content is a code block is left alone.</p>
23
+ </div>
24
+ <div class="tsd-parameters">
25
+ <h4 class="tsd-parameters-title">Parameters</h4>
26
+ <ul class="tsd-parameter-list">
27
+ <li><span><span class="tsd-kind-parameter">text</span>: <span class="tsd-signature-type">string</span></span>
28
+ <div class="tsd-comment tsd-typography"><p>The model's response</p>
29
+ </div></li></ul></div>
30
+ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><p>The response with a wrapping fence removed</p>
31
+ <aside class="tsd-sources">
32
+ <ul>
33
+ <li>Defined in <a href="https://github.com/WilhiteSoftwareLLC/briyah/blob/683254ac85e228b874f6df02fc93a13893a152d5/server/src/documents/pdf-conversion.ts#L142">server/src/documents/pdf-conversion.ts:142</a></li></ul></aside></div></li></ul></section></div>
34
+ <div class="col-sidebar">
35
+ <div class="page-menu">
36
+ <div class="tsd-navigation settings">
37
+ <details class="tsd-accordion"><summary class="tsd-accordion-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>
38
+ <h3>Settings</h3></summary>
39
+ <div class="tsd-accordion-details">
40
+ <div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span>
41
+ <ul id="tsd-filter-options">
42
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
43
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
44
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div>
45
+ <div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
46
+ <div class="site-menu">
47
+ <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>
48
+ <nav class="tsd-navigation"><a href="../modules.html">Briyah SDK - v2.0.3</a>
49
+ <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
50
+ <li>Loading...</li></ul></nav></div></div></div><footer>
51
+ <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
52
+ <div class="overlay"></div></body></html>
@@ -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.3</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.3</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,20 +7,24 @@
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.3</h1></div>
11
11
  <h2>Hierarchy Summary</h2>
12
12
  <ul class="tsd-full-hierarchy">
13
- <li data-refl="1925" id="IConfigService"><a href="interfaces/IConfigService.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>IConfigService</a>
13
+ <li data-refl="2087" id="IConfigService"><a href="interfaces/IConfigService.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>IConfigService</a>
14
14
  <ul>
15
15
  <li data-refl="71" id="BriyahConfigService"><a href="classes/BriyahConfigService.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Class"><use href="assets/icons.svg#icon-128"></use></svg>BriyahConfigService</a></li></ul></li></ul>
16
16
  <ul class="tsd-full-hierarchy">
17
- <li data-refl="1198" id="LoadedPack"><a href="interfaces/LoadedPack.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>LoadedPack</a>
17
+ <li data-refl="1287" id="LoadedPack"><a href="interfaces/LoadedPack.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>LoadedPack</a>
18
18
  <ul>
19
- <li data-refl="1109" id="PackView"><a href="interfaces/PackView.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>PackView</a></li></ul></li></ul>
19
+ <li data-refl="1198" id="PackView"><a href="interfaces/PackView.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>PackView</a></li></ul></li></ul>
20
20
  <ul class="tsd-full-hierarchy">
21
- <li data-refl="820" id="Message"><a href="interfaces/Message.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>Message</a>
21
+ <li data-refl="895" id="Message"><a href="interfaces/Message.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>Message</a>
22
22
  <ul>
23
- <li data-refl="1870" id="RoomMessage"><a href="classes/RoomMessage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Class"><use href="assets/icons.svg#icon-128"></use></svg>RoomMessage</a></li></ul></li></ul></div>
23
+ <li data-refl="2032" id="RoomMessage"><a href="classes/RoomMessage.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Class"><use href="assets/icons.svg#icon-128"></use></svg>RoomMessage</a></li></ul></li></ul>
24
+ <ul class="tsd-full-hierarchy">
25
+ <li data-refl="739" id="PdfConversionOptions"><a href="interfaces/PdfConversionOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>PdfConversionOptions</a>
26
+ <ul>
27
+ <li data-refl="693" id="PdfMarkdownOptions"><a href="interfaces/PdfMarkdownOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Interface"><use href="assets/icons.svg#icon-256"></use></svg>PdfMarkdownOptions</a></li></ul></li></ul></div>
24
28
  <div class="col-sidebar">
25
29
  <div class="page-menu">
26
30
  <div class="tsd-navigation settings">
@@ -35,7 +39,7 @@
35
39
  <div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div>
36
40
  <div class="site-menu">
37
41
  <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>
38
- <nav class="tsd-navigation"><a href="modules.html">Briyah SDK - v2.0.1</a>
42
+ <nav class="tsd-navigation"><a href="modules.html">Briyah SDK - v2.0.3</a>
39
43
  <ul class="tsd-small-nested-navigation" id="tsd-nav-container">
40
44
  <li>Loading...</li></ul></nav></div></div></div><footer>
41
45
  <p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer>
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.3</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.3</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.3</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.3</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>