briyah 2.0.2 → 2.0.4

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 (477) hide show
  1. package/LICENSE +216 -0
  2. package/README.md +43 -7
  3. package/data/common/config/LICENSE-model-prices.md +65 -0
  4. package/data/common/config/markup +1 -1
  5. package/data/common/config/model_prices.json +47443 -46295
  6. package/data/common/prompts/narrator/create_story.prompt +2 -0
  7. package/data/packs/dnd5e/agents/player.json +11 -11
  8. package/data/packs/dnd5e/prompts/character_creator/defaults_config.json +21 -20
  9. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +19 -12
  10. package/data/packs/dnd5e/prompts/dnd_player/perceive.prompt +10 -6
  11. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
  12. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +173 -2
  13. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +172 -3
  14. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +241 -5
  15. package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
  16. package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
  17. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
  18. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
  19. package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
  20. package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
  21. package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
  22. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +102 -3
  23. package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
  24. package/dist-sdk/server/src/ai/LLM/fal.service.js +55 -1
  25. package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
  26. package/dist-sdk/server/src/ai/LLM/googleai.service.js +42 -1
  27. package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
  28. package/dist-sdk/server/src/ai/LLM/grok.service.js +54 -2
  29. package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
  30. package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
  31. package/dist-sdk/server/src/ai/LLM/openai.service.js +80 -2
  32. package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
  33. package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +44 -2
  34. package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
  35. package/dist-sdk/server/src/ai/LLM/together.service.js +60 -2
  36. package/dist-sdk/server/src/ai/agent-config.d.ts +15 -0
  37. package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
  38. package/dist-sdk/server/src/ai/agent-factory.js +20 -0
  39. package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
  40. package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
  41. package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
  42. package/dist-sdk/server/src/ai/agent-store.service.js +166 -5
  43. package/dist-sdk/server/src/ai/agent.d.ts +196 -0
  44. package/dist-sdk/server/src/ai/agent.js +224 -11
  45. package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
  46. package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
  47. package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
  48. package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
  49. package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
  50. package/dist-sdk/server/src/ai/artifact.service.js +148 -3
  51. package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
  52. package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
  53. package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
  54. package/dist-sdk/server/src/ai/model_prices.js +91 -5
  55. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
  56. package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
  57. package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
  58. package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
  59. package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
  60. package/dist-sdk/server/src/app/balance-message.service.js +24 -0
  61. package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
  62. package/dist-sdk/server/src/app/balance.module.js +4 -0
  63. package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
  64. package/dist-sdk/server/src/app/balance.service.js +54 -0
  65. package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
  66. package/dist-sdk/server/src/app/stripe.controller.js +35 -0
  67. package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
  68. package/dist-sdk/server/src/app/stripe.service.js +62 -0
  69. package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
  70. package/dist-sdk/server/src/app/transaction.service.js +36 -0
  71. package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
  72. package/dist-sdk/server/src/app/user-service-factory.js +38 -1
  73. package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
  74. package/dist-sdk/server/src/app/user-service-manager.js +43 -0
  75. package/dist-sdk/server/src/app.controller.d.ts +87 -0
  76. package/dist-sdk/server/src/app.controller.js +272 -12
  77. package/dist-sdk/server/src/app.module.js +28 -6
  78. package/dist-sdk/server/src/app.service.d.ts +1662 -0
  79. package/dist-sdk/server/src/app.service.js +1862 -6
  80. package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
  81. package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
  82. package/dist-sdk/server/src/auth/auth.controller.js +46 -0
  83. package/dist-sdk/server/src/auth/auth.module.js +3 -2
  84. package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
  85. package/dist-sdk/server/src/auth/auth.service.js +39 -3
  86. package/dist-sdk/server/src/auth/jwt-auth.guard.js +18 -0
  87. package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
  88. package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
  89. package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
  90. package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
  91. package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
  92. package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
  93. package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
  94. package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
  95. package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
  96. package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
  97. package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
  98. package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
  99. package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
  100. package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
  101. package/dist-sdk/server/src/auth/session.guard.js +8 -0
  102. package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
  103. package/dist-sdk/server/src/auth/twilio.service.js +30 -4
  104. package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
  105. package/dist-sdk/server/src/auth/users.service.js +42 -0
  106. package/dist-sdk/server/src/common/errors.d.ts +20 -0
  107. package/dist-sdk/server/src/common/errors.js +21 -0
  108. package/dist-sdk/server/src/config/env-config.d.ts +7 -0
  109. package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
  110. package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
  111. package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
  112. package/dist-sdk/server/src/config/user-config.service.js +57 -0
  113. package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
  114. package/dist-sdk/server/src/config/user-paths.service.js +67 -0
  115. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
  116. package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
  117. package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
  118. package/dist-sdk/server/src/packs/pack-instantiation.service.js +99 -0
  119. package/dist-sdk/server/src/packs/pack-manifest.d.ts +100 -0
  120. package/dist-sdk/server/src/packs/pack-manifest.js +58 -0
  121. package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
  122. package/dist-sdk/server/src/packs/pack.service.js +98 -1
  123. package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
  124. package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
  125. package/dist-sdk/server/src/room/artifact.d.ts +18 -0
  126. package/dist-sdk/server/src/room/message.d.ts +64 -0
  127. package/dist-sdk/server/src/room/message.js +77 -2
  128. package/dist-sdk/server/src/room/nickname.d.ts +27 -0
  129. package/dist-sdk/server/src/room/nickname.js +41 -0
  130. package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
  131. package/dist-sdk/server/src/room/room-config.d.ts +26 -0
  132. package/dist-sdk/server/src/room/room-factory.d.ts +12 -0
  133. package/dist-sdk/server/src/room/room-factory.js +14 -0
  134. package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
  135. package/dist-sdk/server/src/room/room-message.service.js +28 -0
  136. package/dist-sdk/server/src/room/room-store.service.d.ts +177 -0
  137. package/dist-sdk/server/src/room/room-store.service.js +242 -5
  138. package/dist-sdk/server/src/room/room.d.ts +906 -1
  139. package/dist-sdk/server/src/room/room.js +1525 -34
  140. package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
  141. package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
  142. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +38 -3
  143. package/dist-sdk/server/src/rpg/rpg-roster.js +49 -49
  144. package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
  145. package/dist-sdk/server/src/rpg/rpg.service.js +108 -5
  146. package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
  147. package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
  148. package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
  149. package/dist-sdk/server/src/sdk/briyah.js +285 -7
  150. package/dist-sdk/server/src/sdk/index.d.ts +0 -1
  151. package/dist-sdk/server/src/sdk/index.js +24 -3
  152. package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
  153. package/dist-sdk/server/src/shared/shared.module.js +13 -5
  154. package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
  155. package/dist-sdk/server/src/story/story-message.service.js +43 -0
  156. package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
  157. package/dist-sdk/server/src/story/story-progress.service.js +23 -0
  158. package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
  159. package/dist-sdk/server/src/story/story-store.service.js +136 -1
  160. package/dist-sdk/server/src/story/story.service.d.ts +398 -0
  161. package/dist-sdk/server/src/story/story.service.js +829 -25
  162. package/dist-sdk/server/src/tools/core/index.d.ts +25 -0
  163. package/dist-sdk/server/src/tools/core/index.js +31 -0
  164. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +10 -0
  165. package/dist-sdk/server/src/tools/core/rename.tool.js +72 -0
  166. package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
  167. package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
  168. package/dist-sdk/server/src/tools/native-tool.types.d.ts +186 -0
  169. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
  170. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
  171. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
  172. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
  173. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
  174. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
  175. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
  176. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
  177. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
  178. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
  179. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
  180. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
  181. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
  184. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
  185. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
  186. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
  187. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
  189. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
  190. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
  191. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
  193. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
  195. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
  196. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
  197. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
  198. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
  199. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
  201. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
  202. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
  203. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
  204. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
  205. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
  206. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
  207. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
  208. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
  209. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
  210. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
  211. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
  212. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
  213. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
  214. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
  215. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
  216. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
  217. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
  218. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
  219. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
  220. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
  221. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
  222. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
  223. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
  224. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
  225. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
  226. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
  227. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
  228. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
  229. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +192 -0
  230. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +144 -0
  231. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
  232. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
  233. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
  234. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
  235. package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
  236. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
  237. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
  238. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
  239. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
  240. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
  241. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
  242. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
  243. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
  244. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
  245. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
  246. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
  247. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
  248. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
  249. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +164 -0
  250. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +188 -1
  251. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
  252. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +125 -1
  253. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
  254. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
  255. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
  256. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
  257. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  258. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
  259. package/dist-sdk/server/src/tools/packs/index.d.ts +52 -2
  260. package/dist-sdk/server/src/tools/packs/index.js +83 -9
  261. package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
  262. package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
  263. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +73 -0
  264. package/dist-sdk/server/src/tools/tool-execution.service.js +74 -0
  265. package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
  266. package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
  267. package/dist-sdk/shared/types/app.types.d.ts +285 -14
  268. package/dist-sdk/shared/types/app.types.js +3 -0
  269. package/package.json +167 -139
  270. package/data/common/config/random_words.txt +0 -2241
  271. package/data/common/story_ideas/biblical.json +0 -122
  272. package/data/common/story_ideas/fantasy.json +0 -82
  273. package/data/common/story_ideas/historical_fiction.json +0 -82
  274. package/data/common/story_ideas/science_fiction.json +0 -82
  275. package/data/packs/acts/agents/character-guide.json +0 -6
  276. package/data/packs/acts/agents/discipleship-mentor.json +0 -6
  277. package/data/packs/acts/agents/mentor-coach.json +0 -6
  278. package/data/packs/acts/agents/student.json +0 -13
  279. package/data/packs/acts/agents/table-moderator.json +0 -6
  280. package/data/packs/acts/artifacts/chapter-01-acts-1.md +0 -405
  281. package/data/packs/acts/artifacts/chapter-02-acts-2.md +0 -443
  282. package/data/packs/acts/artifacts/chapter-03-acts-3.md +0 -409
  283. package/data/packs/acts/artifacts/chapter-04-acts-4.md +0 -438
  284. package/data/packs/acts/artifacts/chapter-05-acts-5.md +0 -434
  285. package/data/packs/acts/artifacts/chapter-06-acts-6.md +0 -441
  286. package/data/packs/acts/artifacts/chapter-07-acts-7.md +0 -472
  287. package/data/packs/acts/artifacts/chapter-08-acts-8.md +0 -512
  288. package/data/packs/acts/artifacts/chapter-09-acts-9.md +0 -346
  289. package/data/packs/acts/artifacts/chapter-10-acts-10.md +0 -367
  290. package/data/packs/acts/artifacts/chapter-11-acts-11.md +0 -391
  291. package/data/packs/acts/artifacts/chapter-12-acts-12.md +0 -390
  292. package/data/packs/acts/artifacts/chapter-13-acts-13.md +0 -388
  293. package/data/packs/acts/artifacts/chapter-14-acts-14.md +0 -466
  294. package/data/packs/acts/artifacts/chapter-15-acts-15.md +0 -413
  295. package/data/packs/acts/artifacts/chapter-16-acts-16.md +0 -585
  296. package/data/packs/acts/artifacts/chapter-17-acts-17.md +0 -428
  297. package/data/packs/acts/artifacts/chapter-18-acts-18.md +0 -486
  298. package/data/packs/acts/artifacts/chapter-19-acts-19.md +0 -461
  299. package/data/packs/acts/artifacts/chapter-20-acts-20.md +0 -389
  300. package/data/packs/acts/artifacts/chapter-21-acts-21.md +0 -452
  301. package/data/packs/acts/artifacts/chapter-22-acts-22.md +0 -424
  302. package/data/packs/acts/artifacts/chapter-23-acts-23.md +0 -395
  303. package/data/packs/acts/artifacts/chapter-24-acts-24.md +0 -446
  304. package/data/packs/acts/artifacts/chapter-25-acts-25.md +0 -391
  305. package/data/packs/acts/artifacts/chapter-26-acts-26.md +0 -431
  306. package/data/packs/acts/artifacts/chapter-27-acts-27.md +0 -530
  307. package/data/packs/acts/artifacts/chapter-28-acts-28.md +0 -1871
  308. package/data/packs/acts/artifacts/chapters.manifest.json +0 -170
  309. package/data/packs/acts/artifacts/character_guide-creation.md +0 -112
  310. package/data/packs/acts/artifacts/discipleship_mentor-procedure.md +0 -154
  311. package/data/packs/acts/artifacts/discipleship_mentor-systems.md +0 -72
  312. package/data/packs/acts/artifacts/manifest.json +0 -197
  313. package/data/packs/acts/artifacts/stage-guide.md +0 -94
  314. package/data/packs/acts/pack.json +0 -6
  315. package/data/packs/acts/prompts/acts_player/defaults_config.json +0 -5
  316. package/data/packs/acts/prompts/acts_player/perceive.json +0 -29
  317. package/data/packs/acts/prompts/acts_player/perceive.prompt +0 -87
  318. package/data/packs/acts/prompts/acts_player/system_instruction.prompt +0 -0
  319. package/data/packs/acts/prompts/acts_room_moderator/defaults_config.json +0 -9
  320. package/data/packs/acts/prompts/acts_room_moderator/moderate.json +0 -34
  321. package/data/packs/acts/prompts/acts_room_moderator/moderate.prompt +0 -70
  322. package/data/packs/acts/prompts/acts_room_moderator/system_instruction.prompt +0 -0
  323. package/data/packs/acts/prompts/character_guide/defaults_config.json +0 -18
  324. package/data/packs/acts/prompts/character_guide/perceive.json +0 -29
  325. package/data/packs/acts/prompts/character_guide/perceive.prompt +0 -140
  326. package/data/packs/acts/prompts/character_guide/system_instruction.prompt +0 -0
  327. package/data/packs/acts/prompts/discipleship_mentor/defaults_config.json +0 -23
  328. package/data/packs/acts/prompts/discipleship_mentor/perceive.json +0 -33
  329. package/data/packs/acts/prompts/discipleship_mentor/perceive.prompt +0 -245
  330. package/data/packs/acts/prompts/discipleship_mentor/system_instruction.prompt +0 -0
  331. package/data/packs/acts/prompts/mentor_coach/defaults_config.json +0 -13
  332. package/data/packs/acts/prompts/mentor_coach/perceive.json +0 -29
  333. package/data/packs/acts/prompts/mentor_coach/perceive.prompt +0 -87
  334. package/data/packs/acts/prompts/mentor_coach/system_instruction.prompt +0 -0
  335. package/data/packs/acts/rooms/session.json +0 -14
  336. package/data/packs/acts/rooms/training.json +0 -58
  337. package/dist-sdk/server/src/tools/packs/acts/data/cards.d.ts +0 -53
  338. package/dist-sdk/server/src/tools/packs/acts/data/cards.js +0 -54
  339. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.d.ts +0 -2
  340. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.js +0 -185
  341. package/dist-sdk/server/src/tools/packs/acts/data/encounters.d.ts +0 -12
  342. package/dist-sdk/server/src/tools/packs/acts/data/encounters.js +0 -102
  343. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.d.ts +0 -2
  344. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.js +0 -196
  345. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.d.ts +0 -2
  346. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.js +0 -1311
  347. package/dist-sdk/server/src/tools/packs/acts/engine/cards.d.ts +0 -5
  348. package/dist-sdk/server/src/tools/packs/acts/engine/cards.js +0 -27
  349. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.d.ts +0 -37
  350. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.js +0 -120
  351. package/dist-sdk/server/src/tools/packs/acts/engine/dice.d.ts +0 -20
  352. package/dist-sdk/server/src/tools/packs/acts/engine/dice.js +0 -41
  353. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.d.ts +0 -54
  354. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.js +0 -200
  355. package/dist-sdk/server/src/tools/packs/acts/index.d.ts +0 -2
  356. package/dist-sdk/server/src/tools/packs/acts/index.js +0 -24
  357. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.d.ts +0 -2
  358. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.js +0 -184
  359. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.d.ts +0 -2
  360. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.js +0 -107
  361. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.d.ts +0 -3
  362. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.js +0 -146
  363. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.d.ts +0 -4
  364. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.js +0 -241
  365. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.d.ts +0 -3
  366. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.js +0 -72
  367. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.d.ts +0 -2
  368. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.js +0 -75
  369. package/dist-sdk/server/src/tools/packs/acts/tools/shared.d.ts +0 -20
  370. package/dist-sdk/server/src/tools/packs/acts/tools/shared.js +0 -70
  371. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.d.ts +0 -4
  372. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.js +0 -215
  373. package/docs/.nojekyll +0 -1
  374. package/docs/assets/hierarchy.js +0 -1
  375. package/docs/assets/highlight.css +0 -113
  376. package/docs/assets/icons.js +0 -18
  377. package/docs/assets/icons.svg +0 -1
  378. package/docs/assets/main.js +0 -60
  379. package/docs/assets/navigation.js +0 -1
  380. package/docs/assets/search.js +0 -1
  381. package/docs/assets/style.css +0 -1648
  382. package/docs/classes/Agent.html +0 -801
  383. package/docs/classes/Briyah.html +0 -296
  384. package/docs/classes/BriyahConfigService.html +0 -119
  385. package/docs/classes/NativeToolRegistry.html +0 -166
  386. package/docs/classes/PackInstantiationService.html +0 -157
  387. package/docs/classes/PackService.html +0 -247
  388. package/docs/classes/Room.html +0 -1338
  389. package/docs/classes/RoomMessage.html +0 -290
  390. package/docs/enums/MessageAction.html +0 -136
  391. package/docs/functions/actsTools.html +0 -44
  392. package/docs/functions/availableToolPacks.html +0 -41
  393. package/docs/functions/buildMarkdown.html +0 -54
  394. package/docs/functions/dnd5eTools.html +0 -44
  395. package/docs/functions/installToolPacks.html +0 -48
  396. package/docs/functions/pageMarker.html +0 -45
  397. package/docs/functions/registerToolPacks.html +0 -54
  398. package/docs/functions/splitMarkdownIntoPages.html +0 -51
  399. package/docs/functions/stripWrappingFence.html +0 -52
  400. package/docs/hierarchy.html +0 -46
  401. package/docs/index.html +0 -595
  402. package/docs/interfaces/AgentCreationOptions.html +0 -125
  403. package/docs/interfaces/AgentInfo.html +0 -218
  404. package/docs/interfaces/AgentMessagesResponse.html +0 -74
  405. package/docs/interfaces/AppService.html +0 -3337
  406. package/docs/interfaces/Artifact.html +0 -95
  407. package/docs/interfaces/ArtifactMetadata.html +0 -112
  408. package/docs/interfaces/ArtifactWriteOptions.html +0 -90
  409. package/docs/interfaces/AttachDocumentResponse.html +0 -62
  410. package/docs/interfaces/BriyahConfigOptions.html +0 -124
  411. package/docs/interfaces/ChapterInfo.html +0 -62
  412. package/docs/interfaces/Character.html +0 -86
  413. package/docs/interfaces/ConversionAgent.html +0 -78
  414. package/docs/interfaces/CreateAgentResponse.html +0 -56
  415. package/docs/interfaces/CreateRoomResponse.html +0 -62
  416. package/docs/interfaces/CreateStoryResponse.html +0 -56
  417. package/docs/interfaces/FileList.html +0 -56
  418. package/docs/interfaces/FileMetadata.html +0 -89
  419. package/docs/interfaces/IConfigService.html +0 -79
  420. package/docs/interfaces/InstantiateModels.html +0 -64
  421. package/docs/interfaces/InstantiateRoomResult.html +0 -70
  422. package/docs/interfaces/LoadedPack.html +0 -131
  423. package/docs/interfaces/LoggingOptions.html +0 -92
  424. package/docs/interfaces/Message.html +0 -84
  425. package/docs/interfaces/ModelChoice.html +0 -73
  426. package/docs/interfaces/ModelInfo.html +0 -74
  427. package/docs/interfaces/NativeToolDefinition.html +0 -107
  428. package/docs/interfaces/PackAgentTemplate.html +0 -101
  429. package/docs/interfaces/PackRoomTemplate.html +0 -108
  430. package/docs/interfaces/PackView.html +0 -172
  431. package/docs/interfaces/PdfConversionOptions.html +0 -102
  432. package/docs/interfaces/PdfConversionResult.html +0 -97
  433. package/docs/interfaces/PdfMarkdownOptions.html +0 -198
  434. package/docs/interfaces/PdfMarkdownResult.html +0 -106
  435. package/docs/interfaces/PdfPageMarkdown.html +0 -94
  436. package/docs/interfaces/PreparedPromptResponse.html +0 -62
  437. package/docs/interfaces/ProcessTextResponse.html +0 -86
  438. package/docs/interfaces/PromptFile.html +0 -70
  439. package/docs/interfaces/PromptFileContent.html +0 -76
  440. package/docs/interfaces/PromptFilesResponse.html +0 -56
  441. package/docs/interfaces/PromptFolder.html +0 -80
  442. package/docs/interfaces/PromptFolderDefaults.html +0 -155
  443. package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
  444. package/docs/interfaces/PromptFoldersResponse.html +0 -56
  445. package/docs/interfaces/RoomDetails.html +0 -151
  446. package/docs/interfaces/RoomErrorUpdate.html +0 -82
  447. package/docs/interfaces/RoomInfo.html +0 -88
  448. package/docs/interfaces/RoomMessageUpdate.html +0 -113
  449. package/docs/interfaces/RoomMessagesResponse.html +0 -62
  450. package/docs/interfaces/SendMessageResult.html +0 -62
  451. package/docs/interfaces/StoryErrorEvent.html +0 -84
  452. package/docs/interfaces/StoryIdea.html +0 -74
  453. package/docs/interfaces/StoryInfo.html +0 -198
  454. package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
  455. package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
  456. package/docs/interfaces/StoryState.html +0 -108
  457. package/docs/interfaces/StoryStateEvent.html +0 -76
  458. package/docs/interfaces/ToolArtifact.html +0 -85
  459. package/docs/interfaces/ToolCaller.html +0 -77
  460. package/docs/interfaces/ToolDefinition.html +0 -80
  461. package/docs/interfaces/ToolHelpers.html +0 -105
  462. package/docs/interfaces/ToolPackDocuments.html +0 -100
  463. package/docs/interfaces/ToolParameter.html +0 -74
  464. package/docs/interfaces/ToolRoomAccess.html +0 -227
  465. package/docs/interfaces/ToolSummary.html +0 -74
  466. package/docs/interfaces/ToolsResponse.html +0 -68
  467. package/docs/interfaces/Transaction.html +0 -104
  468. package/docs/interfaces/TransactionHistoryResponse.html +0 -62
  469. package/docs/modules.html +0 -53
  470. package/docs/types/PackOrigin.html +0 -34
  471. package/docs/types/PromptScope.html +0 -34
  472. package/docs/types/RoomTurnMode.html +0 -42
  473. package/docs/types/RoomUpdate.html +0 -36
  474. package/docs/types/RosterOverrides.html +0 -42
  475. package/docs/types/ToolContext.html +0 -40
  476. package/docs/types/ToolRunResult.html +0 -34
  477. package/src/tools/packs/dnd5e/README.md +0 -867
@@ -1,4 +1,20 @@
1
1
  "use strict";
2
+ /**
3
+ * Carrying capacity, and the optional encumbrance variant.
4
+ *
5
+ * Two regimes, and the difference matters. The **base rule** is always in force and
6
+ * is almost never binding — capacity is Strength × 15, "high enough that most
7
+ * characters don't usually have to worry about it" — so the only thing it changes is
8
+ * a speed of 5 feet while dragging something too heavy.
9
+ *
10
+ * The **variant** is opt-in, and turning it on has a consequence the rules state
11
+ * outright: "when you use this variant, ignore the Strength column of the Armor
12
+ * table." So a character playing with encumbrance stops taking the heavy-armour
13
+ * speed penalty and starts taking a weight penalty instead. Applying both would
14
+ * charge them twice for the same plate mail.
15
+ *
16
+ * Pure, with no room access, like the rest of `engine/`.
17
+ */
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
19
  exports.itemWeight = itemWeight;
4
20
  exports.carriedWeight = carriedWeight;
@@ -8,6 +24,7 @@ exports.encumbrance = encumbrance;
8
24
  exports.describeEncumbrance = describeEncumbrance;
9
25
  const gear_1 = require("../data/gear");
10
26
  const coerce_1 = require("./coerce");
27
+ /** Size categories, for the multiplier a creature's size applies to capacity. */
11
28
  const SIZE_FACTOR = {
12
29
  tiny: 0.5,
13
30
  small: 1,
@@ -16,6 +33,18 @@ const SIZE_FACTOR = {
16
33
  huge: 4,
17
34
  gargantuan: 8,
18
35
  };
36
+ /**
37
+ * What one of an item weighs, in pounds.
38
+ *
39
+ * Three lookups, in order, and each earns its place. An exact name; then the same
40
+ * words with a comma swapped round, because the SRD files things for sorting rather
41
+ * than for reading — `Clothes, common` is what a person writes as "common clothes",
42
+ * exactly as `Crossbow, light` is a light crossbow. Then a bundle: the SRD prices
43
+ * ammunition twenty at a time, so `Arrows (20) — 1 lb.` means one arrow weighs a
44
+ * twentieth of a pound and a sheet saying `arrows x40` should come to two.
45
+ * @param name The item as written on the sheet
46
+ * @returns Pounds for one, or null when the SRD never prints a weight for it
47
+ */
19
48
  function itemWeight(name) {
20
49
  const key = (0, coerce_1.nameKey)(name || '');
21
50
  if (!key)
@@ -28,6 +57,7 @@ function itemWeight(name) {
28
57
  if (gear_1.ITEM_WEIGHTS[swapped] !== undefined)
29
58
  return gear_1.ITEM_WEIGHTS[swapped];
30
59
  }
60
+ // A bundle: an entry of the same name with a trailing count.
31
61
  for (const [candidate, weight] of Object.entries(gear_1.ITEM_WEIGHTS)) {
32
62
  const bundle = new RegExp(`^${key} (\\d+)$`).exec(candidate);
33
63
  if (bundle)
@@ -35,6 +65,11 @@ function itemWeight(name) {
35
65
  }
36
66
  return null;
37
67
  }
68
+ /**
69
+ * Adds up what the character is carrying.
70
+ * @param state The character
71
+ * @returns The total, and whatever could not be weighed
72
+ */
38
73
  function carriedWeight(state) {
39
74
  let pounds = 0;
40
75
  const unweighed = [];
@@ -46,13 +81,23 @@ function carriedWeight(state) {
46
81
  }
47
82
  pounds += each * Math.max(Number(item.q) || 0, 0);
48
83
  }
84
+ // Coin has a weight in 5e — fifty pieces to the pound, whatever the metal.
49
85
  const coins = Object.values(state.coin || {}).reduce((sum, amount) => sum + Math.max(Number(amount) || 0, 0), 0);
50
86
  pounds += coins / 50;
51
87
  return { pounds: Math.round(pounds * 100) / 100, unweighed };
52
88
  }
89
+ /** The size multiplier a creature's size applies to what it can carry. */
53
90
  function sizeFactor(state) {
54
91
  return SIZE_FACTOR[String(state.size || 'medium').toLowerCase()] ?? 1;
55
92
  }
93
+ /**
94
+ * What this character can carry.
95
+ *
96
+ * Size adjusts every figure: "for each size category above Medium, double the
97
+ * creature's carrying capacity ... for a Tiny creature, halve these weights."
98
+ * @param state The character
99
+ * @returns The capacity and the variant's thresholds
100
+ */
56
101
  function carryingCapacity(state) {
57
102
  const strength = Math.max(Number(state.abil.str) || 10, 1);
58
103
  const factor = sizeFactor(state);
@@ -63,9 +108,19 @@ function carryingCapacity(state) {
63
108
  heavilyEncumberedAt: strength * gear_1.HEAVILY_ENCUMBERED_MULTIPLIER * factor,
64
109
  };
65
110
  }
111
+ /** True when this character plays with the optional encumbrance variant. */
66
112
  function usesVariant(state) {
67
113
  return state.encumbrance === true;
68
114
  }
115
+ /**
116
+ * Works out the character's encumbrance.
117
+ *
118
+ * Without the variant only one thing bites: carrying more than capacity, which the
119
+ * base rules cover by dropping speed to 5 feet while you drag it. With the variant,
120
+ * the two thresholds apply instead.
121
+ * @param state The character
122
+ * @returns The tier and what it costs
123
+ */
69
124
  function encumbrance(state) {
70
125
  const carried = carriedWeight(state);
71
126
  const capacity = carryingCapacity(state);
@@ -73,6 +128,9 @@ function encumbrance(state) {
73
128
  if (carried.pounds > capacity.capacity) {
74
129
  return {
75
130
  tier: 'over capacity',
131
+ // "While pushing or dragging weight in excess of your carrying
132
+ // capacity, your speed drops to 5 feet." Expressed as a penalty large
133
+ // enough to floor any speed at 5, which `effectiveSpeed` clamps.
76
134
  speedPenalty: Infinity,
77
135
  disadvantage: variant,
78
136
  carried,
@@ -119,6 +177,7 @@ function encumbrance(state) {
119
177
  variant,
120
178
  };
121
179
  }
180
+ /** A readable line for the sheet and for `read_sheet`. */
122
181
  function describeEncumbrance(state) {
123
182
  const { tier, carried, capacity, variant } = encumbrance(state);
124
183
  const unweighed = carried.unweighed.length > 0
@@ -1,22 +1,76 @@
1
+ /**
2
+ * Resolving a feat, checking whether a character may take it, and applying it.
3
+ *
4
+ * A feat a character has taken is recorded on the sheet by name, whether or not the
5
+ * SRD carries it. Only a known feat has its prerequisite checked and its grants
6
+ * applied — an unknown one is still recorded, because a character who took Great
7
+ * Weapon Master should not silently have taken nothing.
8
+ *
9
+ * Pure, with no room access, like the rest of `engine/`.
10
+ */
1
11
  import { FeatRules } from '../data/feats';
2
12
  import type { SheetState } from './sheet';
3
13
  export interface FeatLookup {
4
14
  feat?: FeatRules;
15
+ /** Candidate names when a partial name matched several. */
5
16
  ambiguous?: string[];
6
17
  }
18
+ /** Resets the feat index. Only needed by tests that mutate the table. */
7
19
  export declare function resetFeatIndex(): void;
20
+ /**
21
+ * Resolves a feat name against the SRD table.
22
+ * @param name The feat as written
23
+ * @returns The feat, the candidates, or an empty result for one not in the SRD
24
+ */
8
25
  export declare function resolveFeat(name: string): FeatLookup;
26
+ /** Every SRD feat name. */
9
27
  export declare function featNames(): string[];
28
+ /** The feats a character has taken, in the order taken. */
10
29
  export declare function takenFeats(state: SheetState): string[];
30
+ /** True when the character already has this feat, however it was spelled. */
11
31
  export declare function hasFeat(state: SheetState, name: string): boolean;
32
+ /**
33
+ * Why the character cannot take this feat, if they cannot.
34
+ *
35
+ * Only checks what is expressible as a number. A prose prerequisite is returned as
36
+ * a line for the Dungeon Master to judge rather than being guessed at.
37
+ * @param state The character
38
+ * @param feat The feat
39
+ * @returns Blocking reasons, empty when the prerequisite is met
40
+ */
12
41
  export declare function prerequisiteProblems(state: SheetState, feat: FeatRules): string[];
42
+ /** A prose prerequisite the tools cannot check, for the caller to pass on. */
13
43
  export declare function prerequisiteNote(feat: FeatRules): string | undefined;
14
44
  export interface FeatApplication {
45
+ /** The name recorded on the sheet. */
15
46
  name: string;
47
+ /** True when the SRD table knew it and its grants were applied. */
16
48
  known: boolean;
49
+ /** What the feat changed, for the caller to report. */
17
50
  changes: string[];
51
+ /** Anything the caller still has to do by hand. */
18
52
  notes: string[];
19
53
  }
54
+ /**
55
+ * Records a feat on the character and applies whatever it grants.
56
+ *
57
+ * The caller is expected to have checked the prerequisite and the duplicate first;
58
+ * this does the recording. An unknown feat is recorded with a note rather than
59
+ * refused, so a table playing with feats beyond the SRD is not blocked by a table
60
+ * that only has one.
61
+ * @param state The character, mutated in place
62
+ * @param name The feat as the player named it
63
+ * @returns What was recorded and what it changed
64
+ */
20
65
  export declare function applyFeat(state: SheetState, name: string): FeatApplication;
66
+ /**
67
+ * Weapon proficiencies a character's feats grant.
68
+ *
69
+ * Derived rather than stored, the same as class and racial proficiency, so it is
70
+ * consulted whenever an attack line is built.
71
+ * @param state The character
72
+ * @returns Weapon keys, empty when no feat grants any
73
+ */
21
74
  export declare function featWeaponProficiencies(state: SheetState): string[];
75
+ /** Renders a feat as readable markdown, for a rules lookup. */
22
76
  export declare function describeFeat(feat: FeatRules): string;
@@ -1,4 +1,14 @@
1
1
  "use strict";
2
+ /**
3
+ * Resolving a feat, checking whether a character may take it, and applying it.
4
+ *
5
+ * A feat a character has taken is recorded on the sheet by name, whether or not the
6
+ * SRD carries it. Only a known feat has its prerequisite checked and its grants
7
+ * applied — an unknown one is still recorded, because a character who took Great
8
+ * Weapon Master should not silently have taken nothing.
9
+ *
10
+ * Pure, with no room access, like the rest of `engine/`.
11
+ */
2
12
  Object.defineProperty(exports, "__esModule", { value: true });
3
13
  exports.resetFeatIndex = resetFeatIndex;
4
14
  exports.resolveFeat = resolveFeat;
@@ -23,9 +33,15 @@ function featIndex() {
23
33
  }
24
34
  return featIndexCache;
25
35
  }
36
+ /** Resets the feat index. Only needed by tests that mutate the table. */
26
37
  function resetFeatIndex() {
27
38
  featIndexCache = null;
28
39
  }
40
+ /**
41
+ * Resolves a feat name against the SRD table.
42
+ * @param name The feat as written
43
+ * @returns The feat, the candidates, or an empty result for one not in the SRD
44
+ */
29
45
  function resolveFeat(name) {
30
46
  const key = (0, coerce_1.nameKey)(name || '');
31
47
  if (!key)
@@ -41,16 +57,28 @@ function resolveFeat(name) {
41
57
  }
42
58
  return {};
43
59
  }
60
+ /** Every SRD feat name. */
44
61
  function featNames() {
45
62
  return Object.values(feats_1.SRD_FEATS).map((feat) => feat.name).sort();
46
63
  }
64
+ /** The feats a character has taken, in the order taken. */
47
65
  function takenFeats(state) {
48
66
  return Array.isArray(state.feats) ? state.feats : [];
49
67
  }
68
+ /** True when the character already has this feat, however it was spelled. */
50
69
  function hasFeat(state, name) {
51
70
  const key = (0, coerce_1.nameKey)(name);
52
71
  return takenFeats(state).some((taken) => (0, coerce_1.nameKey)(taken) === key);
53
72
  }
73
+ /**
74
+ * Why the character cannot take this feat, if they cannot.
75
+ *
76
+ * Only checks what is expressible as a number. A prose prerequisite is returned as
77
+ * a line for the Dungeon Master to judge rather than being guessed at.
78
+ * @param state The character
79
+ * @param feat The feat
80
+ * @returns Blocking reasons, empty when the prerequisite is met
81
+ */
54
82
  function prerequisiteProblems(state, feat) {
55
83
  const problems = [];
56
84
  for (const [ability, minimum] of Object.entries(feat.prerequisite?.abil || {})) {
@@ -61,9 +89,21 @@ function prerequisiteProblems(state, feat) {
61
89
  }
62
90
  return problems;
63
91
  }
92
+ /** A prose prerequisite the tools cannot check, for the caller to pass on. */
64
93
  function prerequisiteNote(feat) {
65
94
  return feat.prerequisite?.text;
66
95
  }
96
+ /**
97
+ * Records a feat on the character and applies whatever it grants.
98
+ *
99
+ * The caller is expected to have checked the prerequisite and the duplicate first;
100
+ * this does the recording. An unknown feat is recorded with a note rather than
101
+ * refused, so a table playing with feats beyond the SRD is not blocked by a table
102
+ * that only has one.
103
+ * @param state The character, mutated in place
104
+ * @param name The feat as the player named it
105
+ * @returns What was recorded and what it changed
106
+ */
67
107
  function applyFeat(state, name) {
68
108
  const { feat } = resolveFeat(name);
69
109
  const recorded = feat ? feat.name : name.trim();
@@ -106,6 +146,14 @@ function applyFeat(state, name) {
106
146
  }
107
147
  return result;
108
148
  }
149
+ /**
150
+ * Weapon proficiencies a character's feats grant.
151
+ *
152
+ * Derived rather than stored, the same as class and racial proficiency, so it is
153
+ * consulted whenever an attack line is built.
154
+ * @param state The character
155
+ * @returns Weapon keys, empty when no feat grants any
156
+ */
109
157
  function featWeaponProficiencies(state) {
110
158
  const out = [];
111
159
  for (const taken of takenFeats(state)) {
@@ -114,6 +162,7 @@ function featWeaponProficiencies(state) {
114
162
  }
115
163
  return out;
116
164
  }
165
+ /** Renders a feat as readable markdown, for a rules lookup. */
117
166
  function describeFeat(feat) {
118
167
  const lines = [`## ${feat.name}`];
119
168
  const abil = Object.entries(feat.prerequisite?.abil || {})
@@ -1,7 +1,49 @@
1
+ /**
2
+ * Turning a stat block into a combatant the tools can operate on.
3
+ *
4
+ * A monster gets the same shape a character has, because `check`, `apply_hp`,
5
+ * `conditions` and `spend` all resolve their target by name through `loadSheet` —
6
+ * one shape means every one of them works on a monster with no second code path.
7
+ * `check` in particular compares an attack to armour class, which `roll_dice` cannot
8
+ * do, so a placed monster's attacks are adjudicated by the tool rather than by eye.
9
+ *
10
+ * Pure, with no room access, like the rest of `engine/`.
11
+ */
1
12
  import { MonsterBlock } from '../data/monsters';
2
13
  import { SheetState } from './sheet';
3
14
  import { Rng } from './dice';
15
+ /** How a group of identical creatures is labelled: Goblin A, Goblin B, ... */
4
16
  export declare const FOE_LABELS = "ABCDEFGHIJKL";
17
+ /**
18
+ * Names the members of a group, so the fight has distinct targets.
19
+ * @param blockName The creature's name
20
+ * @param count How many are present
21
+ * @returns One name per creature; a lone creature keeps its plain name
22
+ */
5
23
  export declare function foeNames(blockName: string, count: number): string[];
24
+ /**
25
+ * Rolls one creature's hit points.
26
+ *
27
+ * A group rolls individually so the party cannot infer one creature's remaining
28
+ * total from another's. Without hit dice there is nothing to roll and the block's
29
+ * printed average stands.
30
+ * @param block The creature
31
+ * @param rng The random source
32
+ * @returns The hit point total, never below 1
33
+ */
6
34
  export declare function rollFoeHitPoints(block: MonsterBlock, rng?: Rng): number;
35
+ /**
36
+ * Builds a combatant from a stat block.
37
+ *
38
+ * Most of it is a direct copy: `MonsterAttack` and {@link AttackEntry} are the same
39
+ * shape but for a `reach`/`range` rename. The fields a monster has no answer for are
40
+ * left empty rather than invented — no class, no hit dice, no spell slots, no
41
+ * proficiency bonus. Nothing reads them for a foe.
42
+ *
43
+ * @param block The creature
44
+ * @param name What this particular one is called, e.g. 'Goblin B'
45
+ * @param hp Its rolled hit point total
46
+ * @param owner The agent the sheet belongs to — the one running the fight
47
+ * @returns The combatant's state
48
+ */
7
49
  export declare function buildFoe(block: MonsterBlock, name: string, hp: number, owner?: string): SheetState;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ /**
3
+ * Turning a stat block into a combatant the tools can operate on.
4
+ *
5
+ * A monster gets the same shape a character has, because `check`, `apply_hp`,
6
+ * `conditions` and `spend` all resolve their target by name through `loadSheet` —
7
+ * one shape means every one of them works on a monster with no second code path.
8
+ * `check` in particular compares an attack to armour class, which `roll_dice` cannot
9
+ * do, so a placed monster's attacks are adjudicated by the tool rather than by eye.
10
+ *
11
+ * Pure, with no room access, like the rest of `engine/`.
12
+ */
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.FOE_LABELS = void 0;
4
15
  exports.foeNames = foeNames;
@@ -7,17 +18,48 @@ exports.buildFoe = buildFoe;
7
18
  const srd_1 = require("../data/srd");
8
19
  const sheet_1 = require("./sheet");
9
20
  const dice_1 = require("./dice");
21
+ /** How a group of identical creatures is labelled: Goblin A, Goblin B, ... */
10
22
  exports.FOE_LABELS = 'ABCDEFGHIJKL';
23
+ /**
24
+ * Names the members of a group, so the fight has distinct targets.
25
+ * @param blockName The creature's name
26
+ * @param count How many are present
27
+ * @returns One name per creature; a lone creature keeps its plain name
28
+ */
11
29
  function foeNames(blockName, count) {
12
30
  if (count <= 1)
13
31
  return [blockName];
14
32
  return Array.from({ length: count }, (_, i) => `${blockName} ${exports.FOE_LABELS[i]}`);
15
33
  }
34
+ /**
35
+ * Rolls one creature's hit points.
36
+ *
37
+ * A group rolls individually so the party cannot infer one creature's remaining
38
+ * total from another's. Without hit dice there is nothing to roll and the block's
39
+ * printed average stands.
40
+ * @param block The creature
41
+ * @param rng The random source
42
+ * @returns The hit point total, never below 1
43
+ */
16
44
  function rollFoeHitPoints(block, rng = dice_1.defaultRng) {
17
45
  if (!block.hpDice)
18
46
  return Math.max(block.hp, 1);
19
47
  return Math.max((0, dice_1.rollOne)(block.hpDice, rng).total, 1);
20
48
  }
49
+ /**
50
+ * Builds a combatant from a stat block.
51
+ *
52
+ * Most of it is a direct copy: `MonsterAttack` and {@link AttackEntry} are the same
53
+ * shape but for a `reach`/`range` rename. The fields a monster has no answer for are
54
+ * left empty rather than invented — no class, no hit dice, no spell slots, no
55
+ * proficiency bonus. Nothing reads them for a foe.
56
+ *
57
+ * @param block The creature
58
+ * @param name What this particular one is called, e.g. 'Goblin B'
59
+ * @param hp Its rolled hit point total
60
+ * @param owner The agent the sheet belongs to — the one running the fight
61
+ * @returns The combatant's state
62
+ */
21
63
  function buildFoe(block, name, hp, owner) {
22
64
  const abil = {};
23
65
  for (const ability of srd_1.ABILITIES) {
@@ -32,8 +74,12 @@ function buildFoe(block, name, hp, owner) {
32
74
  };
33
75
  if (attack.type)
34
76
  entry.type = attack.type;
77
+ // A stat block calls it reach; a sheet calls it range. Same thing.
35
78
  if (attack.reach)
36
79
  entry.range = String(attack.reach);
80
+ // The rider is half the attack. Dropped here, a wolf's bite arrives at the
81
+ // table as damage with no saving throw, and the prone it should have caused
82
+ // is not forgotten by the agent running the fight — it never reached them.
37
83
  if (attack.note)
38
84
  entry.note = String(attack.note);
39
85
  return entry;
@@ -50,7 +96,11 @@ function buildFoe(block, name, hp, owner) {
50
96
  name,
51
97
  owner,
52
98
  foe: true,
99
+ // What it is, so the render and a reader can tell a wight from a wolf.
53
100
  race: [block.size, block.kind].filter(Boolean).join(' ') || undefined,
101
+ // No class, and therefore no level, hit dice, proficiency bonus or slots.
102
+ // `recomputeDerived` refuses to touch a foe for this reason: there is
103
+ // nothing to rebuild these from, and trying would overwrite the stat block.
54
104
  class: [],
55
105
  abil,
56
106
  saveProf: [],
@@ -62,11 +112,15 @@ function buildFoe(block, name, hp, owner) {
62
112
  hp: { max: Math.max(hp, 1), cur: Math.max(hp, 1), temp: 0 },
63
113
  hd: {},
64
114
  ac: Number(block.ac) || 10,
115
+ // The block's speed is prose ('30 ft., fly 40 ft.'); the sheet wants a
116
+ // number, so the walking figure is taken and the rest stays in the prose.
65
117
  speed: parseWalkingSpeed(block.speed),
66
118
  initBonus: Math.floor((abil.dex - 10) / 2),
67
119
  slots: {},
68
120
  uses: {},
69
121
  attacks,
122
+ // Carried because it is what tells a creature allowed a second attack in a
123
+ // round from one that is not, which `check` enforces.
70
124
  multiattack: block.multiattack || undefined,
71
125
  cond: [],
72
126
  exh: 0,
@@ -80,6 +134,11 @@ function buildFoe(block, name, hp, owner) {
80
134
  xp: 0,
81
135
  };
82
136
  }
137
+ /**
138
+ * The walking speed out of a stat block's prose.
139
+ * @param speed The block's speed line, e.g. '30 ft., fly 60 ft.'
140
+ * @returns The walking speed in feet, defaulting to 30
141
+ */
83
142
  function parseWalkingSpeed(speed) {
84
143
  const match = /^\s*(\d+)\s*ft/i.exec(String(speed || ''));
85
144
  return match ? Number(match[1]) : 30;
@@ -1,21 +1,93 @@
1
+ /**
2
+ * The guides: which classes and backgrounds a table allows, and where one lives
3
+ * once it has been handed to the agents who need it.
4
+ *
5
+ * **The files are the list.** A `class-*.md` or `background-*.md` document in the
6
+ * pack's `artifacts/` directory is a class a character may be built as or a
7
+ * background they may take, and there is no second list anywhere agreeing or
8
+ * disagreeing with it — so a table adds one by dropping in a file, and nothing here
9
+ * has to change. That is the reason names are derived from file names rather than
10
+ * read from {@link CLASSES} or {@link BACKGROUNDS}, which carry only what the SRD
11
+ * covers and only the parts a tool computes from.
12
+ *
13
+ * The two kinds differ in what the file has to carry, and that difference is worth
14
+ * keeping straight. A class document is **prose nothing computes from**: the pack
15
+ * derives hit dice, saves and slots itself, and the document holds the features. A
16
+ * background document is prose too, but a background's *grants* — two skills, the
17
+ * equipment package, the coin — are applied by `create_sheet` from
18
+ * `data/backgrounds.ts`, which the SRD's one background is in and a table's own are
19
+ * not. So a dropped-in background is offered, read and shared like any other, and
20
+ * its skills and gear are passed in the spec by the creator, exactly as the SRD's
21
+ * customization rule already has them do.
22
+ *
23
+ * Pure: names in, names out. The room half is {@link shareGuide} in
24
+ * `tools/shared.ts`, and the reading half is `helpers.packDocuments`.
25
+ */
26
+ /** The pack these documents ship in — the same name as this directory. */
1
27
  export declare const DND5E_PACK = "dnd5e";
28
+ /** One kind of guide document: how its files are named, and how a shared one is filed. */
2
29
  export interface GuideKind {
30
+ /** What the kind is called, for messages. */
3
31
  label: string;
32
+ /** The file-name prefix that marks a document as one of these. */
4
33
  prefix: string;
34
+ /** The prefix of the room artifact a shared one is filed under. */
5
35
  artifactPrefix: string;
6
36
  }
7
37
  export declare const CLASS_GUIDE: GuideKind;
8
38
  export declare const BACKGROUND_GUIDE: GuideKind;
39
+ /**
40
+ * How much of a guide a tool result carries.
41
+ *
42
+ * The result cap is 16 KB and `truncateResult` replaces an oversized result with a
43
+ * mangled *string* rather than clipping it, destroying the JSON — so a document
44
+ * dropped in by a table has to be bounded here rather than trusted. The shipped
45
+ * class documents run 2.2–5.7 KB, so this only ever binds on somebody's own file,
46
+ * and the shared artifact still holds the whole thing.
47
+ */
9
48
  export declare const MAX_GUIDE_CHARS = 12000;
49
+ /** A guide document, as resolved from the files the pack ships. */
10
50
  export interface Guide {
51
+ /** The class or background as a person writes it, e.g. `Wizard`. */
11
52
  name: string;
53
+ /** The pack document's file name, e.g. `class-wizard.md`. */
12
54
  fileName: string;
13
55
  }
56
+ /**
57
+ * The class or background a document file describes.
58
+ * @param kind Which kind of document it is
59
+ * @param fileName A file name carrying that kind's prefix
60
+ * @returns The name, e.g. `Blood Hunter` for `class-blood-hunter.md`
61
+ */
14
62
  export declare function guideNameFromFile(kind: GuideKind, fileName: string): string;
63
+ /**
64
+ * Every class or background the pack has a document for.
65
+ * @param kind Which kind to pick out
66
+ * @param files File names from `helpers.packDocuments.list`
67
+ * @returns One entry per document, in the order the files came in
68
+ */
15
69
  export declare function listGuides(kind: GuideKind, files: readonly string[]): Guide[];
70
+ /** What a name resolved to, with ambiguity reported rather than settled. */
16
71
  export interface GuideMatch {
17
72
  guide?: Guide;
73
+ /** Set when the name matched several documents; the guide is then absent. */
18
74
  ambiguous?: string[];
19
75
  }
76
+ /**
77
+ * Resolves a name against the documents that exist.
78
+ *
79
+ * Loose in the same tiers as every other lookup in the pack, and ambiguity is
80
+ * reported rather than guessed at — picking one of two classes for a player would
81
+ * be a whole character built wrong.
82
+ * @param wanted The name as the model supplied it
83
+ * @param guides Every document of the kind being looked for
84
+ * @returns The match, or the candidates when there is more than one
85
+ */
20
86
  export declare function resolveGuide(wanted: string, guides: readonly Guide[]): GuideMatch;
87
+ /**
88
+ * The room artifact a guide is shared through.
89
+ * @param kind Which kind of document it is
90
+ * @param name The class or background name
91
+ * @returns The artifact name, e.g. `Class: Wizard` or `Background: Acolyte`
92
+ */
21
93
  export declare function guideArtifactName(kind: GuideKind, name: string): string;
@@ -1,4 +1,29 @@
1
1
  "use strict";
2
+ /**
3
+ * The guides: which classes and backgrounds a table allows, and where one lives
4
+ * once it has been handed to the agents who need it.
5
+ *
6
+ * **The files are the list.** A `class-*.md` or `background-*.md` document in the
7
+ * pack's `artifacts/` directory is a class a character may be built as or a
8
+ * background they may take, and there is no second list anywhere agreeing or
9
+ * disagreeing with it — so a table adds one by dropping in a file, and nothing here
10
+ * has to change. That is the reason names are derived from file names rather than
11
+ * read from {@link CLASSES} or {@link BACKGROUNDS}, which carry only what the SRD
12
+ * covers and only the parts a tool computes from.
13
+ *
14
+ * The two kinds differ in what the file has to carry, and that difference is worth
15
+ * keeping straight. A class document is **prose nothing computes from**: the pack
16
+ * derives hit dice, saves and slots itself, and the document holds the features. A
17
+ * background document is prose too, but a background's *grants* — two skills, the
18
+ * equipment package, the coin — are applied by `create_sheet` from
19
+ * `data/backgrounds.ts`, which the SRD's one background is in and a table's own are
20
+ * not. So a dropped-in background is offered, read and shared like any other, and
21
+ * its skills and gear are passed in the spec by the creator, exactly as the SRD's
22
+ * customization rule already has them do.
23
+ *
24
+ * Pure: names in, names out. The room half is {@link shareGuide} in
25
+ * `tools/shared.ts`, and the reading half is `helpers.packDocuments`.
26
+ */
2
27
  Object.defineProperty(exports, "__esModule", { value: true });
3
28
  exports.MAX_GUIDE_CHARS = exports.BACKGROUND_GUIDE = exports.CLASS_GUIDE = exports.DND5E_PACK = void 0;
4
29
  exports.guideNameFromFile = guideNameFromFile;
@@ -7,6 +32,7 @@ exports.resolveGuide = resolveGuide;
7
32
  exports.guideArtifactName = guideArtifactName;
8
33
  const coerce_1 = require("./coerce");
9
34
  const sheet_1 = require("./sheet");
35
+ /** The pack these documents ship in — the same name as this directory. */
10
36
  exports.DND5E_PACK = 'dnd5e';
11
37
  exports.CLASS_GUIDE = {
12
38
  label: 'class',
@@ -18,7 +44,22 @@ exports.BACKGROUND_GUIDE = {
18
44
  prefix: 'background-',
19
45
  artifactPrefix: 'Background: ',
20
46
  };
47
+ /**
48
+ * How much of a guide a tool result carries.
49
+ *
50
+ * The result cap is 16 KB and `truncateResult` replaces an oversized result with a
51
+ * mangled *string* rather than clipping it, destroying the JSON — so a document
52
+ * dropped in by a table has to be bounded here rather than trusted. The shipped
53
+ * class documents run 2.2–5.7 KB, so this only ever binds on somebody's own file,
54
+ * and the shared artifact still holds the whole thing.
55
+ */
21
56
  exports.MAX_GUIDE_CHARS = 12_000;
57
+ /**
58
+ * The class or background a document file describes.
59
+ * @param kind Which kind of document it is
60
+ * @param fileName A file name carrying that kind's prefix
61
+ * @returns The name, e.g. `Blood Hunter` for `class-blood-hunter.md`
62
+ */
22
63
  function guideNameFromFile(kind, fileName) {
23
64
  return (0, sheet_1.titleCase)(fileName
24
65
  .slice(kind.prefix.length)
@@ -26,11 +67,27 @@ function guideNameFromFile(kind, fileName) {
26
67
  .replace(/[-_]+/g, ' ')
27
68
  .trim());
28
69
  }
70
+ /**
71
+ * Every class or background the pack has a document for.
72
+ * @param kind Which kind to pick out
73
+ * @param files File names from `helpers.packDocuments.list`
74
+ * @returns One entry per document, in the order the files came in
75
+ */
29
76
  function listGuides(kind, files) {
30
77
  return files
31
78
  .filter((file) => file.toLowerCase().startsWith(kind.prefix))
32
79
  .map((fileName) => ({ fileName, name: guideNameFromFile(kind, fileName) }));
33
80
  }
81
+ /**
82
+ * Resolves a name against the documents that exist.
83
+ *
84
+ * Loose in the same tiers as every other lookup in the pack, and ambiguity is
85
+ * reported rather than guessed at — picking one of two classes for a player would
86
+ * be a whole character built wrong.
87
+ * @param wanted The name as the model supplied it
88
+ * @param guides Every document of the kind being looked for
89
+ * @returns The match, or the candidates when there is more than one
90
+ */
34
91
  function resolveGuide(wanted, guides) {
35
92
  const names = guides.map((guide) => guide.name);
36
93
  const matched = (0, coerce_1.matchNames)(wanted, names);
@@ -40,6 +97,12 @@ function resolveGuide(wanted, guides) {
40
97
  return { ambiguous: matched };
41
98
  return { guide: guides.find((guide) => guide.name === matched[0]) };
42
99
  }
100
+ /**
101
+ * The room artifact a guide is shared through.
102
+ * @param kind Which kind of document it is
103
+ * @param name The class or background name
104
+ * @returns The artifact name, e.g. `Class: Wizard` or `Background: Acolyte`
105
+ */
43
106
  function guideArtifactName(kind, name) {
44
107
  return `${kind.artifactPrefix}${name}`;
45
108
  }