briyah 2.0.3 → 2.0.5

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 (391) hide show
  1. package/README.md +55 -8
  2. package/data/common/config/LICENSE-model-prices.md +65 -0
  3. package/data/common/config/markup +1 -1
  4. package/data/common/config/model_prices.json +47443 -46295
  5. package/data/common/config/story_models.json +3 -3
  6. package/data/common/prompts/illustrator/describe_scene.prompt +4 -4
  7. package/data/common/prompts/narrator/create_story.prompt +2 -0
  8. package/data/common/prompts/perceive.prompt +1 -1
  9. package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +1 -1
  10. package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +1 -1
  11. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +795 -787
  12. package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +2 -1
  13. package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +1 -1
  14. package/data/packs/dnd5e/rooms/campaign.json +18 -15
  15. package/data/packs/dnd5e/rooms/table.json +17 -16
  16. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
  17. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +174 -3
  18. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +194 -3
  19. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +299 -19
  20. package/dist-sdk/server/src/ai/LLM/blank-image.d.ts +36 -0
  21. package/dist-sdk/server/src/ai/LLM/blank-image.js +80 -0
  22. package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
  23. package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
  24. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
  25. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
  26. package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
  27. package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
  28. package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
  29. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +103 -4
  30. package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
  31. package/dist-sdk/server/src/ai/LLM/fal.service.js +56 -2
  32. package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
  33. package/dist-sdk/server/src/ai/LLM/googleai.service.js +43 -2
  34. package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
  35. package/dist-sdk/server/src/ai/LLM/grok.service.js +55 -3
  36. package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
  37. package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
  38. package/dist-sdk/server/src/ai/LLM/openai.service.js +81 -3
  39. package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
  40. package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +45 -3
  41. package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
  42. package/dist-sdk/server/src/ai/LLM/together.service.js +61 -3
  43. package/dist-sdk/server/src/ai/agent-config.d.ts +15 -1
  44. package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
  45. package/dist-sdk/server/src/ai/agent-factory.js +20 -0
  46. package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
  47. package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
  48. package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
  49. package/dist-sdk/server/src/ai/agent-store.service.js +166 -7
  50. package/dist-sdk/server/src/ai/agent.d.ts +197 -2
  51. package/dist-sdk/server/src/ai/agent.js +225 -14
  52. package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
  53. package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
  54. package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
  55. package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
  56. package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
  57. package/dist-sdk/server/src/ai/artifact.service.js +148 -3
  58. package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
  59. package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
  60. package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
  61. package/dist-sdk/server/src/ai/model_prices.js +91 -5
  62. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
  63. package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
  64. package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
  65. package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
  66. package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
  67. package/dist-sdk/server/src/app/balance-message.service.js +24 -0
  68. package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
  69. package/dist-sdk/server/src/app/balance.module.js +4 -0
  70. package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
  71. package/dist-sdk/server/src/app/balance.service.js +54 -0
  72. package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
  73. package/dist-sdk/server/src/app/stripe.controller.js +35 -0
  74. package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
  75. package/dist-sdk/server/src/app/stripe.service.js +62 -0
  76. package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
  77. package/dist-sdk/server/src/app/transaction.service.js +36 -0
  78. package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
  79. package/dist-sdk/server/src/app/user-service-factory.js +46 -3
  80. package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
  81. package/dist-sdk/server/src/app/user-service-manager.js +43 -0
  82. package/dist-sdk/server/src/app.controller.d.ts +120 -0
  83. package/dist-sdk/server/src/app.controller.js +365 -14
  84. package/dist-sdk/server/src/app.module.js +28 -6
  85. package/dist-sdk/server/src/app.service.d.ts +1710 -4
  86. package/dist-sdk/server/src/app.service.js +1938 -20
  87. package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
  88. package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
  89. package/dist-sdk/server/src/auth/auth.controller.js +46 -0
  90. package/dist-sdk/server/src/auth/auth.module.js +3 -2
  91. package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
  92. package/dist-sdk/server/src/auth/auth.service.js +39 -3
  93. package/dist-sdk/server/src/auth/jwt-auth.guard.js +44 -0
  94. package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
  95. package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
  96. package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
  97. package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
  98. package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
  99. package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
  100. package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
  101. package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
  102. package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
  103. package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
  104. package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
  105. package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
  106. package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
  107. package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
  108. package/dist-sdk/server/src/auth/session.guard.js +8 -0
  109. package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
  110. package/dist-sdk/server/src/auth/twilio.service.js +30 -4
  111. package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
  112. package/dist-sdk/server/src/auth/users.service.js +42 -0
  113. package/dist-sdk/server/src/common/errors.d.ts +20 -0
  114. package/dist-sdk/server/src/common/errors.js +21 -0
  115. package/dist-sdk/server/src/config/env-config.d.ts +7 -0
  116. package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
  117. package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
  118. package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
  119. package/dist-sdk/server/src/config/user-config.service.js +57 -0
  120. package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
  121. package/dist-sdk/server/src/config/user-paths.service.js +67 -0
  122. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
  123. package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
  124. package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
  125. package/dist-sdk/server/src/packs/pack-instantiation.service.js +104 -0
  126. package/dist-sdk/server/src/packs/pack-manifest.d.ts +114 -0
  127. package/dist-sdk/server/src/packs/pack-manifest.js +69 -0
  128. package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
  129. package/dist-sdk/server/src/packs/pack.service.js +98 -1
  130. package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
  131. package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
  132. package/dist-sdk/server/src/room/artifact.d.ts +18 -0
  133. package/dist-sdk/server/src/room/illustration/illustration.service.d.ts +211 -0
  134. package/dist-sdk/server/src/room/illustration/illustration.service.js +771 -0
  135. package/dist-sdk/server/src/room/illustration/illustration.types.d.ts +101 -0
  136. package/dist-sdk/server/src/room/illustration/illustration.types.js +2 -0
  137. package/dist-sdk/server/src/room/message.d.ts +64 -0
  138. package/dist-sdk/server/src/room/message.js +77 -2
  139. package/dist-sdk/server/src/room/nickname.d.ts +26 -0
  140. package/dist-sdk/server/src/room/nickname.js +26 -0
  141. package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
  142. package/dist-sdk/server/src/room/room-config.d.ts +84 -1
  143. package/dist-sdk/server/src/room/room-config.js +19 -0
  144. package/dist-sdk/server/src/room/room-factory.d.ts +20 -0
  145. package/dist-sdk/server/src/room/room-factory.js +25 -0
  146. package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
  147. package/dist-sdk/server/src/room/room-message.service.js +28 -0
  148. package/dist-sdk/server/src/room/room-store.service.d.ts +184 -0
  149. package/dist-sdk/server/src/room/room-store.service.js +280 -6
  150. package/dist-sdk/server/src/room/room.d.ts +981 -1
  151. package/dist-sdk/server/src/room/room.js +1531 -27
  152. package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
  153. package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
  154. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +37 -0
  155. package/dist-sdk/server/src/rpg/rpg-roster.js +37 -0
  156. package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
  157. package/dist-sdk/server/src/rpg/rpg.service.js +108 -1
  158. package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
  159. package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
  160. package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
  161. package/dist-sdk/server/src/sdk/briyah.js +285 -7
  162. package/dist-sdk/server/src/sdk/index.js +23 -0
  163. package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
  164. package/dist-sdk/server/src/shared/shared.module.js +13 -5
  165. package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
  166. package/dist-sdk/server/src/story/story-message.service.js +43 -0
  167. package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
  168. package/dist-sdk/server/src/story/story-progress.service.js +23 -0
  169. package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
  170. package/dist-sdk/server/src/story/story-store.service.js +136 -1
  171. package/dist-sdk/server/src/story/story.service.d.ts +366 -9
  172. package/dist-sdk/server/src/story/story.service.js +825 -374
  173. package/dist-sdk/server/src/tools/core/illustrate.tool.d.ts +14 -0
  174. package/dist-sdk/server/src/tools/core/illustrate.tool.js +80 -0
  175. package/dist-sdk/server/src/tools/core/index.d.ts +22 -0
  176. package/dist-sdk/server/src/tools/core/index.js +24 -1
  177. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +8 -0
  178. package/dist-sdk/server/src/tools/core/rename.tool.js +11 -0
  179. package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
  180. package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
  181. package/dist-sdk/server/src/tools/native-tool.types.d.ts +266 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
  184. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
  185. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
  186. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
  187. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
  189. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
  190. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
  191. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
  193. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
  195. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
  196. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
  197. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
  198. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
  199. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
  201. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
  202. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
  203. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
  204. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
  205. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
  206. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
  207. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
  208. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
  209. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
  210. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
  211. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
  212. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
  213. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
  214. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
  215. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
  216. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
  217. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
  218. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
  219. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
  220. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
  221. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
  222. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
  223. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
  224. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
  225. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
  226. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
  227. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
  228. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
  229. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
  230. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
  231. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
  232. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
  233. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
  234. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
  235. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
  236. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
  237. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
  238. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
  239. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
  240. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
  241. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
  242. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +201 -0
  243. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +149 -0
  244. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
  245. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
  246. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
  247. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
  248. package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
  249. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
  250. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
  251. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
  252. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
  253. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
  254. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
  255. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
  256. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
  257. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
  258. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
  259. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
  260. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
  261. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
  262. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +194 -0
  263. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +263 -1
  264. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
  265. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +127 -2
  266. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
  267. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
  268. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
  269. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
  270. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  271. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
  272. package/dist-sdk/server/src/tools/packs/index.d.ts +49 -0
  273. package/dist-sdk/server/src/tools/packs/index.js +66 -0
  274. package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
  275. package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
  276. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +107 -3
  277. package/dist-sdk/server/src/tools/tool-execution.service.js +163 -19
  278. package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
  279. package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
  280. package/dist-sdk/shared/types/app.types.d.ts +328 -13
  281. package/dist-sdk/shared/types/app.types.js +18 -1
  282. package/package.json +167 -168
  283. package/data/common/config/random_words.txt +0 -2241
  284. package/data/common/story_ideas/biblical.json +0 -122
  285. package/data/common/story_ideas/fantasy.json +0 -82
  286. package/data/common/story_ideas/historical_fiction.json +0 -82
  287. package/data/common/story_ideas/science_fiction.json +0 -82
  288. package/docs/.nojekyll +0 -1
  289. package/docs/assets/hierarchy.js +0 -1
  290. package/docs/assets/highlight.css +0 -113
  291. package/docs/assets/icons.js +0 -18
  292. package/docs/assets/icons.svg +0 -1
  293. package/docs/assets/main.js +0 -60
  294. package/docs/assets/navigation.js +0 -1
  295. package/docs/assets/search.js +0 -1
  296. package/docs/assets/style.css +0 -1648
  297. package/docs/classes/Agent.html +0 -801
  298. package/docs/classes/Briyah.html +0 -296
  299. package/docs/classes/BriyahConfigService.html +0 -119
  300. package/docs/classes/NativeToolRegistry.html +0 -166
  301. package/docs/classes/PackInstantiationService.html +0 -157
  302. package/docs/classes/PackService.html +0 -247
  303. package/docs/classes/Room.html +0 -1434
  304. package/docs/classes/RoomMessage.html +0 -290
  305. package/docs/enums/MessageAction.html +0 -136
  306. package/docs/functions/availableToolPacks.html +0 -41
  307. package/docs/functions/buildMarkdown.html +0 -54
  308. package/docs/functions/dnd5eTools.html +0 -44
  309. package/docs/functions/installToolPacks.html +0 -51
  310. package/docs/functions/pageMarker.html +0 -45
  311. package/docs/functions/registerToolPacks.html +0 -54
  312. package/docs/functions/splitMarkdownIntoPages.html +0 -51
  313. package/docs/functions/stripWrappingFence.html +0 -52
  314. package/docs/hierarchy.html +0 -46
  315. package/docs/index.html +0 -595
  316. package/docs/interfaces/AgentCreationOptions.html +0 -125
  317. package/docs/interfaces/AgentInfo.html +0 -218
  318. package/docs/interfaces/AgentMessagesResponse.html +0 -74
  319. package/docs/interfaces/AppService.html +0 -3340
  320. package/docs/interfaces/Artifact.html +0 -95
  321. package/docs/interfaces/ArtifactMetadata.html +0 -112
  322. package/docs/interfaces/ArtifactWriteOptions.html +0 -90
  323. package/docs/interfaces/AttachDocumentResponse.html +0 -62
  324. package/docs/interfaces/BriyahConfigOptions.html +0 -124
  325. package/docs/interfaces/ChapterInfo.html +0 -62
  326. package/docs/interfaces/Character.html +0 -86
  327. package/docs/interfaces/ConversionAgent.html +0 -78
  328. package/docs/interfaces/CreateAgentResponse.html +0 -56
  329. package/docs/interfaces/CreateRoomResponse.html +0 -62
  330. package/docs/interfaces/CreateStoryResponse.html +0 -56
  331. package/docs/interfaces/FileList.html +0 -56
  332. package/docs/interfaces/FileMetadata.html +0 -89
  333. package/docs/interfaces/IConfigService.html +0 -79
  334. package/docs/interfaces/InstantiateModels.html +0 -64
  335. package/docs/interfaces/InstantiateRoomResult.html +0 -70
  336. package/docs/interfaces/LoadedPack.html +0 -131
  337. package/docs/interfaces/LoggingOptions.html +0 -92
  338. package/docs/interfaces/Message.html +0 -84
  339. package/docs/interfaces/ModelChoice.html +0 -73
  340. package/docs/interfaces/ModelInfo.html +0 -74
  341. package/docs/interfaces/NativeToolDefinition.html +0 -107
  342. package/docs/interfaces/PackAgentTemplate.html +0 -101
  343. package/docs/interfaces/PackRoomTemplate.html +0 -108
  344. package/docs/interfaces/PackView.html +0 -172
  345. package/docs/interfaces/PdfConversionOptions.html +0 -102
  346. package/docs/interfaces/PdfConversionResult.html +0 -97
  347. package/docs/interfaces/PdfMarkdownOptions.html +0 -198
  348. package/docs/interfaces/PdfMarkdownResult.html +0 -106
  349. package/docs/interfaces/PdfPageMarkdown.html +0 -94
  350. package/docs/interfaces/PreparedPromptResponse.html +0 -62
  351. package/docs/interfaces/ProcessTextResponse.html +0 -86
  352. package/docs/interfaces/PromptFile.html +0 -70
  353. package/docs/interfaces/PromptFileContent.html +0 -76
  354. package/docs/interfaces/PromptFilesResponse.html +0 -56
  355. package/docs/interfaces/PromptFolder.html +0 -80
  356. package/docs/interfaces/PromptFolderDefaults.html +0 -155
  357. package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
  358. package/docs/interfaces/PromptFoldersResponse.html +0 -56
  359. package/docs/interfaces/RoomDetails.html +0 -151
  360. package/docs/interfaces/RoomErrorUpdate.html +0 -82
  361. package/docs/interfaces/RoomInfo.html +0 -88
  362. package/docs/interfaces/RoomMessageUpdate.html +0 -113
  363. package/docs/interfaces/RoomMessagesResponse.html +0 -62
  364. package/docs/interfaces/SendMessageResult.html +0 -62
  365. package/docs/interfaces/StoryErrorEvent.html +0 -84
  366. package/docs/interfaces/StoryIdea.html +0 -74
  367. package/docs/interfaces/StoryInfo.html +0 -198
  368. package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
  369. package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
  370. package/docs/interfaces/StoryState.html +0 -108
  371. package/docs/interfaces/StoryStateEvent.html +0 -76
  372. package/docs/interfaces/ToolArtifact.html +0 -85
  373. package/docs/interfaces/ToolCaller.html +0 -77
  374. package/docs/interfaces/ToolDefinition.html +0 -80
  375. package/docs/interfaces/ToolHelpers.html +0 -105
  376. package/docs/interfaces/ToolPackDocuments.html +0 -100
  377. package/docs/interfaces/ToolParameter.html +0 -74
  378. package/docs/interfaces/ToolRoomAccess.html +0 -260
  379. package/docs/interfaces/ToolSummary.html +0 -74
  380. package/docs/interfaces/ToolsResponse.html +0 -68
  381. package/docs/interfaces/Transaction.html +0 -104
  382. package/docs/interfaces/TransactionHistoryResponse.html +0 -62
  383. package/docs/modules.html +0 -53
  384. package/docs/types/PackOrigin.html +0 -34
  385. package/docs/types/PromptScope.html +0 -34
  386. package/docs/types/RoomTurnMode.html +0 -42
  387. package/docs/types/RoomUpdate.html +0 -36
  388. package/docs/types/RosterOverrides.html +0 -42
  389. package/docs/types/ToolContext.html +0 -40
  390. package/docs/types/ToolRunResult.html +0 -34
  391. package/src/tools/packs/dnd5e/README.md +0 -867
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ /**
3
+ * Rules tables derived from the System Reference Document 5.1.
4
+ *
5
+ * SRD 5.1 is published by Wizards of the Coast under the Creative Commons
6
+ * Attribution 4.0 International licence. See LICENSE-SRD.md in this directory for
7
+ * the licence text and the required attribution, which {@link SRD_ATTRIBUTION}
8
+ * reproduces so it travels with any excerpt a tool returns.
9
+ *
10
+ * Only SRD 5.1 content belongs here. Do not add non-SRD material (named
11
+ * settings, non-SRD subclasses, non-SRD monsters or spells).
12
+ *
13
+ * These are code-versioned constants rather than data files under
14
+ * `server/data/`: that tree is user-mountable runtime state, while these tables
15
+ * must stay in lockstep with the functions in `engine/rules.ts` that read them.
16
+ */
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.CLASS_FEATURE_USES = exports.RULES_TOPICS = exports.ARMOR = exports.INCAPACITATING_CONDITIONS = exports.AUTO_FAIL_SAVE_CONDITIONS = exports.CHECK_DISADVANTAGE_CONDITIONS = exports.ATTACK_DISADVANTAGE_CONDITIONS = exports.MAX_EXHAUSTION = exports.EXHAUSTION_EFFECTS = exports.CONDITIONS = exports.WARLOCK_SLOTS = exports.FULL_CASTER_SLOTS = exports.CLASSES = exports.STANDARD_ASI_LEVELS = exports.XP_THRESHOLDS = exports.PROFICIENCY_BY_LEVEL = exports.SKILL_ABILITY = exports.ABILITY_NAMES = exports.ABILITIES = exports.SRD_ATTRIBUTION = void 0;
4
19
  exports.SRD_ATTRIBUTION = 'This work includes material from the System Reference Document 5.1 by Wizards of the Coast LLC, available under the Creative Commons Attribution 4.0 International License.';
@@ -11,6 +26,7 @@ exports.ABILITY_NAMES = {
11
26
  wis: 'Wisdom',
12
27
  cha: 'Charisma',
13
28
  };
29
+ /** Every skill and the ability it is measured against. */
14
30
  exports.SKILL_ABILITY = {
15
31
  acrobatics: 'dex',
16
32
  'animal handling': 'wis',
@@ -31,14 +47,18 @@ exports.SKILL_ABILITY = {
31
47
  stealth: 'dex',
32
48
  survival: 'wis',
33
49
  };
50
+ /** Proficiency bonus by character level (index 0 is unused). */
34
51
  exports.PROFICIENCY_BY_LEVEL = [
35
52
  0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6,
36
53
  ];
54
+ /** Experience needed to reach each level (index 0 unused, index 1 is level 1). */
37
55
  exports.XP_THRESHOLDS = [
38
56
  0, 0, 300, 900, 2700, 6500, 14000, 23000, 34000, 48000, 64000, 85000, 100000, 120000, 140000,
39
57
  165000, 195000, 225000, 265000, 305000, 355000,
40
58
  ];
59
+ /** The Ability Score Improvement levels shared by ten of the twelve classes. */
41
60
  exports.STANDARD_ASI_LEVELS = [4, 8, 12, 16, 19];
61
+ /** The classes in SRD 5.1. */
42
62
  exports.CLASSES = {
43
63
  barbarian: {
44
64
  name: 'Barbarian',
@@ -240,8 +260,12 @@ exports.CLASSES = {
240
260
  asiLevels: exports.STANDARD_ASI_LEVELS,
241
261
  },
242
262
  };
263
+ /**
264
+ * Spell slots for a full caster, indexed by class level then spell level.
265
+ * Index 0 of each row is unused so slot level reads naturally.
266
+ */
243
267
  exports.FULL_CASTER_SLOTS = [
244
- [],
268
+ [], // level 0 unused
245
269
  [0, 2],
246
270
  [0, 3],
247
271
  [0, 4, 2],
@@ -263,8 +287,9 @@ exports.FULL_CASTER_SLOTS = [
263
287
  [0, 4, 3, 3, 3, 3, 2, 1, 1, 1],
264
288
  [0, 4, 3, 3, 3, 3, 2, 2, 1, 1],
265
289
  ];
290
+ /** Warlock pact magic: slots and the level they are cast at. */
266
291
  exports.WARLOCK_SLOTS = [
267
- { count: 0, level: 0 },
292
+ { count: 0, level: 0 }, // level 0 unused
268
293
  { count: 1, level: 1 },
269
294
  { count: 2, level: 1 },
270
295
  { count: 2, level: 2 },
@@ -286,6 +311,7 @@ exports.WARLOCK_SLOTS = [
286
311
  { count: 4, level: 5 },
287
312
  { count: 4, level: 5 },
288
313
  ];
314
+ /** The conditions in SRD 5.1, with the mechanical effects they impose. */
289
315
  exports.CONDITIONS = {
290
316
  blinded: "Can't see and automatically fails any ability check requiring sight. Attacks against the creature have advantage, and its own attacks have disadvantage.",
291
317
  charmed: "Can't attack the charmer or target them with harmful abilities or magical effects. The charmer has advantage on ability checks to interact socially with the creature.",
@@ -302,6 +328,7 @@ exports.CONDITIONS = {
302
328
  stunned: 'Is incapacitated, cannot move, and can speak only falteringly. It automatically fails Strength and Dexterity saving throws, and attacks against it have advantage.',
303
329
  unconscious: 'Is incapacitated, cannot move or speak, is unaware of its surroundings, drops what it is holding and falls prone. It automatically fails Strength and Dexterity saving throws, attacks against it have advantage, and any attack that hits from within 5 feet is a critical hit.',
304
330
  };
331
+ /** Exhaustion effects, cumulative, indexed by level. */
305
332
  exports.EXHAUSTION_EFFECTS = [
306
333
  'No effect.',
307
334
  'Disadvantage on ability checks.',
@@ -312,9 +339,16 @@ exports.EXHAUSTION_EFFECTS = [
312
339
  'Death.',
313
340
  ];
314
341
  exports.MAX_EXHAUSTION = 6;
342
+ /** Conditions that give the affected creature disadvantage on its attack rolls. */
315
343
  exports.ATTACK_DISADVANTAGE_CONDITIONS = ['blinded', 'frightened', 'poisoned', 'prone', 'restrained'];
344
+ /** Conditions that give the affected creature disadvantage on ability checks. */
316
345
  exports.CHECK_DISADVANTAGE_CONDITIONS = ['frightened', 'poisoned'];
346
+ /**
347
+ * Conditions under which Strength and Dexterity saving throws fail automatically.
348
+ * These do not impose disadvantage — there is no roll to make.
349
+ */
317
350
  exports.AUTO_FAIL_SAVE_CONDITIONS = ['paralyzed', 'petrified', 'stunned', 'unconscious'];
351
+ /** Conditions that prevent a creature acting at all. */
318
352
  exports.INCAPACITATING_CONDITIONS = [
319
353
  'incapacitated',
320
354
  'paralyzed',
@@ -354,6 +388,7 @@ exports.ARMOR = {
354
388
  stealthDisadvantage: true,
355
389
  },
356
390
  };
391
+ /** Short rules excerpts the DM can look up mid-play, keyed by topic. */
357
392
  exports.RULES_TOPICS = {
358
393
  cover: 'A target with half cover has +2 to AC and Dexterity saving throws; three-quarters cover gives +5. A target behind total cover cannot be targeted directly.',
359
394
  falling: 'A fall deals 1d6 bludgeoning damage per 10 feet fallen, to a maximum of 20d6, and the creature lands prone.',
@@ -370,13 +405,38 @@ exports.RULES_TOPICS = {
370
405
  'passive perception': 'Passive Perception is 10 plus your Wisdom (Perception) modifier, plus 5 if you have advantage or minus 5 if you have disadvantage.',
371
406
  'advantage': 'Roll two d20s and use the higher (advantage) or lower (disadvantage). Multiple sources of each do not stack, and having both at once cancels them out entirely.',
372
407
  'critical hit': 'When you score a critical hit, roll all of the attack’s damage dice twice and add them together, then add any relevant modifiers as normal.',
408
+ // Deliberately no 'proficiency bonus' or 'exhaustion' entries here: both are
409
+ // tables, and rules_lookup renders them from PROFICIENCY_BY_LEVEL and
410
+ // EXHAUSTION_EFFECTS. A prose duplicate would shadow the precise version.
373
411
  };
412
+ /**
413
+ * The limited-use features each class grants, by class key.
414
+ *
415
+ * `create_sheet` computes these the way it computes spell slots and hit dice, so a
416
+ * character arrives able to spend what it owns. Before this table every sheet was
417
+ * hand-patched afterwards — three campaigns running, every character, always for
418
+ * the same handful of pools — and a `spend` before the patch failed with "this
419
+ * character tracks no limited-use features".
420
+ *
421
+ * Warlock Pact Magic is deliberately absent: those are spell slots and the slot
422
+ * machinery already owns them, under `PACT_MAGIC_PREFIX`.
423
+ *
424
+ * Rangers and rogues have no such pool at any level, so they are absent rather than
425
+ * empty — a class missing from here grants nothing, which is the same answer.
426
+ *
427
+ * Note {@link ClassRules.shortRestFeatures}, which names some of the same keys. It
428
+ * predates this and nothing reads it; it records only *which* features recharge on a
429
+ * short rest, not how many uses or when they arrive, and it disagrees with the rules
430
+ * on a bard (whose inspiration is long-rest until Font of Inspiration at 5). Trust
431
+ * this table.
432
+ */
374
433
  exports.CLASS_FEATURE_USES = {
375
434
  barbarian: [
376
435
  {
377
436
  key: 'rage',
378
437
  name: 'Rage',
379
438
  from: 1,
439
+ // Unlimited at 20 (Primal Champion); held at six, which a tool can count.
380
440
  max: { byLevel: [[1, 2], [3, 3], [6, 4], [12, 5], [17, 6]] },
381
441
  reset: 'long',
382
442
  },
@@ -387,6 +447,8 @@ exports.CLASS_FEATURE_USES = {
387
447
  name: 'Bardic Inspiration',
388
448
  from: 1,
389
449
  max: { ability: 'cha', min: 1 },
450
+ // Long rest until Font of Inspiration at 5 makes it a short rest. The
451
+ // sheet is built at a level, so the reset is corrected on level-up.
390
452
  reset: 'long',
391
453
  },
392
454
  ],
@@ -424,6 +486,8 @@ exports.CLASS_FEATURE_USES = {
424
486
  reset: 'long',
425
487
  },
426
488
  {
489
+ // A pool of hit points rather than a count of uses, which is why it is
490
+ // five per level rather than a small number.
427
491
  key: 'lay_on_hands',
428
492
  name: 'Lay on Hands',
429
493
  from: 1,
@@ -1,23 +1,73 @@
1
+ /**
2
+ * The weapon table from the System Reference Document 5.1.
3
+ *
4
+ * Its purpose is to stop an attack line being invented. Before this, whoever
5
+ * built a sheet typed `{"n":"Longsword","atk":5,"dmg":"1d8+3"}` and worked the
6
+ * numbers out in their head — which is exactly the arithmetic the rest of the
7
+ * pack exists to take away from a model.
8
+ *
9
+ * Licensing is the same as the rest of `data/`: SRD 5.1 under CC-BY-4.0. See
10
+ * LICENSE-SRD.md.
11
+ */
12
+ /** Whether the weapon needs simple or martial proficiency. */
1
13
  export type WeaponCategory = 'simple' | 'martial';
14
+ /** Whether an attack with it uses Strength or Dexterity by default. */
2
15
  export type WeaponKind = 'melee' | 'ranged';
16
+ /**
17
+ * The properties that change how an attack is computed, as opposed to the ones
18
+ * that only change how it is narrated.
19
+ *
20
+ * `finesse` and `thrown` pick the ability; `versatile` gives a two-handed damage
21
+ * die; `ammunition`, `loading`, `heavy`, `light`, `reach` and `special` are
22
+ * carried through to the sheet so the Dungeon Master can apply them, but nothing
23
+ * here computes from them.
24
+ */
3
25
  export type WeaponProperty = 'ammunition' | 'finesse' | 'heavy' | 'light' | 'loading' | 'reach' | 'special' | 'thrown' | 'two-handed' | 'versatile';
4
26
  export interface WeaponRules {
5
27
  name: string;
6
28
  category: WeaponCategory;
7
29
  kind: WeaponKind;
30
+ /** Damage dice, or '0' for a weapon that deals none (the net). */
8
31
  dmg: string;
32
+ /** Damage type, absent for the net. */
9
33
  type?: string;
10
34
  props: WeaponProperty[];
35
+ /** The two-handed damage die for a versatile weapon. */
11
36
  versatile?: string;
37
+ /** Normal and long range in feet, for a thrown or ammunition weapon. */
12
38
  range?: string;
39
+ /** Reach in feet when it differs from the default 5. */
13
40
  reach?: string;
14
41
  weight?: string;
15
42
  cost?: string;
16
43
  }
44
+ /** Every SRD weapon, keyed by lowercase name. */
17
45
  export declare const WEAPONS: Record<string, WeaponRules>;
46
+ /**
47
+ * Alternative spellings, mapped to the table's key.
48
+ *
49
+ * Only ones that name a *single* weapon unambiguously. The SRD files the crossbows
50
+ * under a comma so they sort together, which nobody types, and the compound names
51
+ * get written both open and closed.
52
+ *
53
+ * Deliberately **not** here: bare `crossbow` and bare `bow`. Each matches several
54
+ * weapons, and silently resolving to whichever seemed likeliest is the same
55
+ * mistake as picking a monster out of an ambiguous name — the fuzzy tiers report
56
+ * the candidates instead, and the caller asks again.
57
+ */
18
58
  export declare const WEAPON_ALIASES: Record<string, string>;
59
+ /**
60
+ * What each class is proficient with, as the SRD writes it: a category, or a
61
+ * named list, or both.
62
+ *
63
+ * Kept here rather than on `ClassRules` because it is weapon data — the class
64
+ * tables in `srd.ts` describe progression, and a wizard's five permitted weapons
65
+ * belong next to the weapons.
66
+ */
19
67
  export interface WeaponProficiency {
68
+ /** Whole categories the class can use. */
20
69
  categories: WeaponCategory[];
70
+ /** Individual weapons on top of those categories, by table key. */
21
71
  weapons: string[];
22
72
  }
23
73
  export declare const CLASS_WEAPON_PROFICIENCY: Record<string, WeaponProficiency>;
@@ -1,7 +1,20 @@
1
1
  "use strict";
2
+ /**
3
+ * The weapon table from the System Reference Document 5.1.
4
+ *
5
+ * Its purpose is to stop an attack line being invented. Before this, whoever
6
+ * built a sheet typed `{"n":"Longsword","atk":5,"dmg":"1d8+3"}` and worked the
7
+ * numbers out in their head — which is exactly the arithmetic the rest of the
8
+ * pack exists to take away from a model.
9
+ *
10
+ * Licensing is the same as the rest of `data/`: SRD 5.1 under CC-BY-4.0. See
11
+ * LICENSE-SRD.md.
12
+ */
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.CLASS_WEAPON_PROFICIENCY = exports.WEAPON_ALIASES = exports.WEAPONS = void 0;
15
+ /** Every SRD weapon, keyed by lowercase name. */
4
16
  exports.WEAPONS = {
17
+ // Simple melee
5
18
  club: { name: 'Club', category: 'simple', kind: 'melee', dmg: '1d4', type: 'bludgeoning', props: ['light'], weight: '2 lb.', cost: '1 sp' },
6
19
  dagger: { name: 'Dagger', category: 'simple', kind: 'melee', dmg: '1d4', type: 'piercing', props: ['finesse', 'light', 'thrown'], range: '20/60 ft', weight: '1 lb.', cost: '2 gp' },
7
20
  greatclub: { name: 'Greatclub', category: 'simple', kind: 'melee', dmg: '1d8', type: 'bludgeoning', props: ['two-handed'], weight: '10 lb.', cost: '2 sp' },
@@ -12,10 +25,12 @@ exports.WEAPONS = {
12
25
  quarterstaff: { name: 'Quarterstaff', category: 'simple', kind: 'melee', dmg: '1d6', type: 'bludgeoning', props: ['versatile'], versatile: '1d8', weight: '4 lb.', cost: '2 sp' },
13
26
  sickle: { name: 'Sickle', category: 'simple', kind: 'melee', dmg: '1d4', type: 'slashing', props: ['light'], weight: '2 lb.', cost: '1 gp' },
14
27
  spear: { name: 'Spear', category: 'simple', kind: 'melee', dmg: '1d6', type: 'piercing', props: ['thrown', 'versatile'], versatile: '1d8', range: '20/60 ft', weight: '3 lb.', cost: '1 gp' },
28
+ // Simple ranged
15
29
  'crossbow, light': { name: 'Crossbow, light', category: 'simple', kind: 'ranged', dmg: '1d8', type: 'piercing', props: ['ammunition', 'loading', 'two-handed'], range: '80/320 ft', weight: '5 lb.', cost: '25 gp' },
16
30
  dart: { name: 'Dart', category: 'simple', kind: 'ranged', dmg: '1d4', type: 'piercing', props: ['finesse', 'thrown'], range: '20/60 ft', weight: '1/4 lb.', cost: '5 cp' },
17
31
  shortbow: { name: 'Shortbow', category: 'simple', kind: 'ranged', dmg: '1d6', type: 'piercing', props: ['ammunition', 'two-handed'], range: '80/320 ft', weight: '2 lb.', cost: '25 gp' },
18
32
  sling: { name: 'Sling', category: 'simple', kind: 'ranged', dmg: '1d4', type: 'bludgeoning', props: ['ammunition'], range: '30/120 ft', cost: '1 sp' },
33
+ // Martial melee
19
34
  battleaxe: { name: 'Battleaxe', category: 'martial', kind: 'melee', dmg: '1d8', type: 'slashing', props: ['versatile'], versatile: '1d10', weight: '4 lb.', cost: '10 gp' },
20
35
  flail: { name: 'Flail', category: 'martial', kind: 'melee', dmg: '1d8', type: 'bludgeoning', props: [], weight: '2 lb.', cost: '10 gp' },
21
36
  glaive: { name: 'Glaive', category: 'martial', kind: 'melee', dmg: '1d10', type: 'slashing', props: ['heavy', 'reach', 'two-handed'], reach: '10 ft', weight: '6 lb.', cost: '20 gp' },
@@ -34,12 +49,25 @@ exports.WEAPONS = {
34
49
  'war pick': { name: 'War pick', category: 'martial', kind: 'melee', dmg: '1d8', type: 'piercing', props: [], weight: '2 lb.', cost: '5 gp' },
35
50
  warhammer: { name: 'Warhammer', category: 'martial', kind: 'melee', dmg: '1d8', type: 'bludgeoning', props: ['versatile'], versatile: '1d10', weight: '2 lb.', cost: '15 gp' },
36
51
  whip: { name: 'Whip', category: 'martial', kind: 'melee', dmg: '1d4', type: 'slashing', props: ['finesse', 'reach'], reach: '10 ft', weight: '3 lb.', cost: '2 gp' },
52
+ // Martial ranged
37
53
  blowgun: { name: 'Blowgun', category: 'martial', kind: 'ranged', dmg: '1', type: 'piercing', props: ['ammunition', 'loading'], range: '25/100 ft', weight: '1 lb.', cost: '10 gp' },
38
54
  'crossbow, hand': { name: 'Crossbow, hand', category: 'martial', kind: 'ranged', dmg: '1d6', type: 'piercing', props: ['ammunition', 'light', 'loading'], range: '30/120 ft', weight: '3 lb.', cost: '75 gp' },
39
55
  'crossbow, heavy': { name: 'Crossbow, heavy', category: 'martial', kind: 'ranged', dmg: '1d10', type: 'piercing', props: ['ammunition', 'heavy', 'loading', 'two-handed'], range: '100/400 ft', weight: '18 lb.', cost: '50 gp' },
40
56
  longbow: { name: 'Longbow', category: 'martial', kind: 'ranged', dmg: '1d8', type: 'piercing', props: ['ammunition', 'heavy', 'two-handed'], range: '150/600 ft', weight: '2 lb.', cost: '50 gp' },
41
57
  net: { name: 'Net', category: 'martial', kind: 'ranged', dmg: '0', props: ['special', 'thrown'], range: '5/15 ft', weight: '3 lb.', cost: '1 gp' },
42
58
  };
59
+ /**
60
+ * Alternative spellings, mapped to the table's key.
61
+ *
62
+ * Only ones that name a *single* weapon unambiguously. The SRD files the crossbows
63
+ * under a comma so they sort together, which nobody types, and the compound names
64
+ * get written both open and closed.
65
+ *
66
+ * Deliberately **not** here: bare `crossbow` and bare `bow`. Each matches several
67
+ * weapons, and silently resolving to whichever seemed likeliest is the same
68
+ * mistake as picking a monster out of an ambiguous name — the fuzzy tiers report
69
+ * the candidates instead, and the caller asks again.
70
+ */
43
71
  exports.WEAPON_ALIASES = {
44
72
  'light crossbow': 'crossbow, light',
45
73
  'hand crossbow': 'crossbow, hand',
@@ -1,30 +1,122 @@
1
+ /**
2
+ * The room's bestiary: creature statistics that belong to one campaign rather
3
+ * than to the rules.
4
+ *
5
+ * Two sources resolve in order — the room's `Bestiary` artifact first, then the
6
+ * shipped SRD table. Campaign entries winning means a game can say "our goblins
7
+ * carry crossbows" and override the book, which mirrors how Briyah resolves tools
8
+ * native-first.
9
+ *
10
+ * The artifact carries a readable summary above a fenced `briyah-state` block, the
11
+ * same shape as a character sheet, for the same reason: the render is for the
12
+ * person running the game, the fence is what the tools read.
13
+ */
1
14
  import { MonsterBlock } from '../data/monsters';
2
15
  export declare const BESTIARY_ARTIFACT = "Bestiary";
16
+ /** How many names a listing returns before it asks the caller to narrow. */
3
17
  export declare const MONSTER_LIST_CAP = 60;
18
+ /** How many suggestions a failed lookup offers. */
4
19
  export declare const NEAR_MATCH_CAP = 8;
20
+ /** Where a resolved creature came from. */
5
21
  export type MonsterSource = 'bestiary' | 'srd';
22
+ /**
23
+ * The outcome of a creature lookup. Not a discriminated union: this project
24
+ * compiles with `strictNullChecks: false`, which disables narrowing on a
25
+ * discriminant, so a caller checks the fields directly.
26
+ */
6
27
  export interface MonsterLookup {
28
+ /** The creature, when exactly one matched. */
7
29
  block?: MonsterBlock;
8
30
  source?: MonsterSource;
31
+ /**
32
+ * The candidate names, when the query matched several. Reported rather than
33
+ * resolved: with a large table, "giant" matches a dozen creatures, and
34
+ * silently returning whichever was declared first is a wrong monster in a
35
+ * real fight.
36
+ */
9
37
  ambiguous?: string[];
10
38
  }
11
39
  export declare class BestiaryError extends Error {
12
40
  readonly violation: string;
13
41
  constructor(violation: string, message: string);
14
42
  }
43
+ /**
44
+ * Reads the campaign creatures out of a `Bestiary` artifact body.
45
+ * @param body The artifact body, or undefined when the artifact does not exist
46
+ * @returns Creature blocks keyed by lowercase name; empty when absent
47
+ * @throws {BestiaryError} When the state block exists but cannot be read, so a
48
+ * caller refuses to overwrite rather than destroying what survives.
49
+ */
15
50
  export declare function parseBestiary(body: string | undefined): Record<string, MonsterBlock>;
51
+ /**
52
+ * Resolves a creature name, preferring the campaign's own entry.
53
+ *
54
+ * An exact name is a single map lookup, which is the path taken almost every
55
+ * time. The loose tiers only run on a miss, and when they match more than one
56
+ * creature the ambiguity is returned rather than resolved.
57
+ * @param name The creature the caller asked for
58
+ * @param campaign Entries from {@link parseBestiary}, keyed by normalized name
59
+ * @returns The creature, the candidates, or an empty result
60
+ */
16
61
  export declare function resolveMonster(name: string, campaign: Record<string, MonsterBlock>): MonsterLookup;
17
62
  export interface MonsterListing {
18
63
  campaign: string[];
19
64
  shipped: string[];
20
65
  campaignTotal: number;
21
66
  shippedTotal: number;
67
+ /** True when either list was capped, so the caller knows to narrow. */
22
68
  truncated?: boolean;
23
69
  filter?: string;
24
70
  }
71
+ /**
72
+ * Lists the creatures available in this room, capped.
73
+ *
74
+ * Capped because the whole list goes into a tool result, and a result over
75
+ * 16 KB is replaced wholesale by a truncated string rather than being clipped —
76
+ * which would destroy the JSON exactly when the caller needs it most.
77
+ *
78
+ * **The filter matches a creature's kind and size as well as its name**, because
79
+ * those are the terms a person narrows by: a designer looking for fey creatures
80
+ * asks for "fey", which is nobody's *name* and every fey creature's `kind`. A
81
+ * name-only filter answered that with an empty list and a note saying anything
82
+ * unlisted needs defining — which reads as "this table has no fey creatures"
83
+ * rather than "ask a different way". `magic_item`'s filter already spans name,
84
+ * type and rarity for the same reason.
85
+ * @param campaign Entries from {@link parseBestiary}
86
+ * @param filter Optional substring, matched against name, kind and size
87
+ * @returns The listing, with totals so the caller can tell it was capped
88
+ */
25
89
  export declare function availableMonsters(campaign: Record<string, MonsterBlock>, filter?: string): MonsterListing;
90
+ /**
91
+ * Suggests creatures a failed lookup might have meant, scored by how many words
92
+ * of the query they contain. Bounded, so a miss never returns the whole table.
93
+ * @param name The name that failed to resolve
94
+ * @param campaign Entries from {@link parseBestiary}
95
+ * @param limit How many suggestions to return
96
+ * @returns The closest names, best first
97
+ */
26
98
  export declare function nearMonsters(name: string, campaign: Record<string, MonsterBlock>, limit?: number): string[];
99
+ /** Resets the shipped index. Only needed by tests that mutate the table. */
27
100
  export declare function resetShippedIndex(): void;
101
+ /**
102
+ * Fills in defaults and rejects a block that could not be run at a table.
103
+ * @param name The creature name the caller supplied
104
+ * @param raw The block as written
105
+ * @returns A block with every required field present
106
+ * @throws {BestiaryError} When the block is missing something a fight needs, or
107
+ * when a field is not the shape the renderer reads
108
+ */
28
109
  export declare function normalizeMonster(name: string, raw: any): MonsterBlock;
110
+ /**
111
+ * Renders the whole bestiary artifact from its entries.
112
+ * @param entries Creature blocks keyed by lowercase name
113
+ * @returns The artifact body
114
+ */
29
115
  export declare function renderBestiary(entries: Record<string, MonsterBlock>): string;
116
+ /**
117
+ * Renders one creature as readable markdown, in the order a stat block is
118
+ * written: what it is, what it can take, what it knows, then what it does.
119
+ * @param block The creature
120
+ * @returns A compact stat block
121
+ */
30
122
  export declare function describeMonster(block: MonsterBlock): string;