briyah 2.0.3 → 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 (371) hide show
  1. package/README.md +43 -7
  2. package/data/common/config/LICENSE-model-prices.md +65 -0
  3. package/data/common/config/model_prices.json +47443 -46295
  4. package/data/common/prompts/narrator/create_story.prompt +2 -0
  5. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
  6. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +173 -2
  7. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +172 -3
  8. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +241 -5
  9. package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
  10. package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
  11. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
  12. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
  13. package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
  14. package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
  15. package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
  16. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +102 -3
  17. package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
  18. package/dist-sdk/server/src/ai/LLM/fal.service.js +55 -1
  19. package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
  20. package/dist-sdk/server/src/ai/LLM/googleai.service.js +42 -1
  21. package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
  22. package/dist-sdk/server/src/ai/LLM/grok.service.js +54 -2
  23. package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
  24. package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
  25. package/dist-sdk/server/src/ai/LLM/openai.service.js +80 -2
  26. package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
  27. package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +44 -2
  28. package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
  29. package/dist-sdk/server/src/ai/LLM/together.service.js +60 -2
  30. package/dist-sdk/server/src/ai/agent-config.d.ts +15 -0
  31. package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
  32. package/dist-sdk/server/src/ai/agent-factory.js +20 -0
  33. package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
  34. package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
  35. package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
  36. package/dist-sdk/server/src/ai/agent-store.service.js +166 -5
  37. package/dist-sdk/server/src/ai/agent.d.ts +196 -0
  38. package/dist-sdk/server/src/ai/agent.js +224 -11
  39. package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
  40. package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
  41. package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
  42. package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
  43. package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
  44. package/dist-sdk/server/src/ai/artifact.service.js +148 -3
  45. package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
  46. package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
  47. package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
  48. package/dist-sdk/server/src/ai/model_prices.js +91 -5
  49. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
  50. package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
  51. package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
  52. package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
  53. package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
  54. package/dist-sdk/server/src/app/balance-message.service.js +24 -0
  55. package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
  56. package/dist-sdk/server/src/app/balance.module.js +4 -0
  57. package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
  58. package/dist-sdk/server/src/app/balance.service.js +54 -0
  59. package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
  60. package/dist-sdk/server/src/app/stripe.controller.js +35 -0
  61. package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
  62. package/dist-sdk/server/src/app/stripe.service.js +62 -0
  63. package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
  64. package/dist-sdk/server/src/app/transaction.service.js +36 -0
  65. package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
  66. package/dist-sdk/server/src/app/user-service-factory.js +38 -1
  67. package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
  68. package/dist-sdk/server/src/app/user-service-manager.js +43 -0
  69. package/dist-sdk/server/src/app.controller.d.ts +87 -0
  70. package/dist-sdk/server/src/app.controller.js +272 -12
  71. package/dist-sdk/server/src/app.module.js +28 -6
  72. package/dist-sdk/server/src/app.service.d.ts +1661 -0
  73. package/dist-sdk/server/src/app.service.js +1837 -4
  74. package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
  75. package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
  76. package/dist-sdk/server/src/auth/auth.controller.js +46 -0
  77. package/dist-sdk/server/src/auth/auth.module.js +3 -2
  78. package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
  79. package/dist-sdk/server/src/auth/auth.service.js +39 -3
  80. package/dist-sdk/server/src/auth/jwt-auth.guard.js +18 -0
  81. package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
  82. package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
  83. package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
  84. package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
  85. package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
  86. package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
  87. package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
  88. package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
  89. package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
  90. package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
  91. package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
  92. package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
  93. package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
  94. package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
  95. package/dist-sdk/server/src/auth/session.guard.js +8 -0
  96. package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
  97. package/dist-sdk/server/src/auth/twilio.service.js +30 -4
  98. package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
  99. package/dist-sdk/server/src/auth/users.service.js +42 -0
  100. package/dist-sdk/server/src/common/errors.d.ts +20 -0
  101. package/dist-sdk/server/src/common/errors.js +21 -0
  102. package/dist-sdk/server/src/config/env-config.d.ts +7 -0
  103. package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
  104. package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
  105. package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
  106. package/dist-sdk/server/src/config/user-config.service.js +57 -0
  107. package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
  108. package/dist-sdk/server/src/config/user-paths.service.js +67 -0
  109. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
  110. package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
  111. package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
  112. package/dist-sdk/server/src/packs/pack-instantiation.service.js +99 -0
  113. package/dist-sdk/server/src/packs/pack-manifest.d.ts +100 -0
  114. package/dist-sdk/server/src/packs/pack-manifest.js +58 -0
  115. package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
  116. package/dist-sdk/server/src/packs/pack.service.js +98 -1
  117. package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
  118. package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
  119. package/dist-sdk/server/src/room/artifact.d.ts +18 -0
  120. package/dist-sdk/server/src/room/message.d.ts +64 -0
  121. package/dist-sdk/server/src/room/message.js +77 -2
  122. package/dist-sdk/server/src/room/nickname.d.ts +26 -0
  123. package/dist-sdk/server/src/room/nickname.js +26 -0
  124. package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
  125. package/dist-sdk/server/src/room/room-config.d.ts +26 -0
  126. package/dist-sdk/server/src/room/room-factory.d.ts +12 -0
  127. package/dist-sdk/server/src/room/room-factory.js +14 -0
  128. package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
  129. package/dist-sdk/server/src/room/room-message.service.js +28 -0
  130. package/dist-sdk/server/src/room/room-store.service.d.ts +176 -0
  131. package/dist-sdk/server/src/room/room-store.service.js +238 -5
  132. package/dist-sdk/server/src/room/room.d.ts +878 -0
  133. package/dist-sdk/server/src/room/room.js +1291 -23
  134. package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
  135. package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
  136. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +37 -0
  137. package/dist-sdk/server/src/rpg/rpg-roster.js +37 -0
  138. package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
  139. package/dist-sdk/server/src/rpg/rpg.service.js +103 -0
  140. package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
  141. package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
  142. package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
  143. package/dist-sdk/server/src/sdk/briyah.js +285 -7
  144. package/dist-sdk/server/src/sdk/index.js +23 -0
  145. package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
  146. package/dist-sdk/server/src/shared/shared.module.js +13 -5
  147. package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
  148. package/dist-sdk/server/src/story/story-message.service.js +43 -0
  149. package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
  150. package/dist-sdk/server/src/story/story-progress.service.js +23 -0
  151. package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
  152. package/dist-sdk/server/src/story/story-store.service.js +136 -1
  153. package/dist-sdk/server/src/story/story.service.d.ts +398 -0
  154. package/dist-sdk/server/src/story/story.service.js +829 -25
  155. package/dist-sdk/server/src/tools/core/index.d.ts +22 -0
  156. package/dist-sdk/server/src/tools/core/index.js +22 -0
  157. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +8 -0
  158. package/dist-sdk/server/src/tools/core/rename.tool.js +11 -0
  159. package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
  160. package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
  161. package/dist-sdk/server/src/tools/native-tool.types.d.ts +176 -0
  162. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
  163. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
  164. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
  165. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
  166. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
  167. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
  168. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
  169. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
  170. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
  171. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
  172. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
  173. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
  174. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
  175. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
  176. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
  177. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
  178. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
  179. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
  180. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
  181. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
  184. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
  185. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
  186. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
  187. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
  189. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
  190. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
  191. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
  193. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
  195. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
  196. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
  197. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
  198. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
  199. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
  201. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
  202. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
  203. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
  204. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
  205. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
  206. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
  207. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
  208. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
  209. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
  210. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
  211. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
  212. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
  213. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
  214. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
  215. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
  216. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
  217. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
  218. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
  219. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
  220. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
  221. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
  222. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +192 -0
  223. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +144 -0
  224. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
  225. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
  226. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
  227. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
  228. package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
  229. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
  230. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
  231. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
  232. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
  233. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
  234. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
  235. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
  236. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
  237. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
  238. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
  239. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
  240. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
  241. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
  242. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +164 -0
  243. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +188 -1
  244. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
  245. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +116 -0
  246. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
  247. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
  248. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
  249. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
  250. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  251. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
  252. package/dist-sdk/server/src/tools/packs/index.d.ts +49 -0
  253. package/dist-sdk/server/src/tools/packs/index.js +66 -0
  254. package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
  255. package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
  256. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +73 -0
  257. package/dist-sdk/server/src/tools/tool-execution.service.js +74 -0
  258. package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
  259. package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
  260. package/dist-sdk/shared/types/app.types.d.ts +285 -13
  261. package/dist-sdk/shared/types/app.types.js +3 -0
  262. package/package.json +167 -168
  263. package/data/common/config/random_words.txt +0 -2241
  264. package/data/common/story_ideas/biblical.json +0 -122
  265. package/data/common/story_ideas/fantasy.json +0 -82
  266. package/data/common/story_ideas/historical_fiction.json +0 -82
  267. package/data/common/story_ideas/science_fiction.json +0 -82
  268. package/docs/.nojekyll +0 -1
  269. package/docs/assets/hierarchy.js +0 -1
  270. package/docs/assets/highlight.css +0 -113
  271. package/docs/assets/icons.js +0 -18
  272. package/docs/assets/icons.svg +0 -1
  273. package/docs/assets/main.js +0 -60
  274. package/docs/assets/navigation.js +0 -1
  275. package/docs/assets/search.js +0 -1
  276. package/docs/assets/style.css +0 -1648
  277. package/docs/classes/Agent.html +0 -801
  278. package/docs/classes/Briyah.html +0 -296
  279. package/docs/classes/BriyahConfigService.html +0 -119
  280. package/docs/classes/NativeToolRegistry.html +0 -166
  281. package/docs/classes/PackInstantiationService.html +0 -157
  282. package/docs/classes/PackService.html +0 -247
  283. package/docs/classes/Room.html +0 -1434
  284. package/docs/classes/RoomMessage.html +0 -290
  285. package/docs/enums/MessageAction.html +0 -136
  286. package/docs/functions/availableToolPacks.html +0 -41
  287. package/docs/functions/buildMarkdown.html +0 -54
  288. package/docs/functions/dnd5eTools.html +0 -44
  289. package/docs/functions/installToolPacks.html +0 -51
  290. package/docs/functions/pageMarker.html +0 -45
  291. package/docs/functions/registerToolPacks.html +0 -54
  292. package/docs/functions/splitMarkdownIntoPages.html +0 -51
  293. package/docs/functions/stripWrappingFence.html +0 -52
  294. package/docs/hierarchy.html +0 -46
  295. package/docs/index.html +0 -595
  296. package/docs/interfaces/AgentCreationOptions.html +0 -125
  297. package/docs/interfaces/AgentInfo.html +0 -218
  298. package/docs/interfaces/AgentMessagesResponse.html +0 -74
  299. package/docs/interfaces/AppService.html +0 -3340
  300. package/docs/interfaces/Artifact.html +0 -95
  301. package/docs/interfaces/ArtifactMetadata.html +0 -112
  302. package/docs/interfaces/ArtifactWriteOptions.html +0 -90
  303. package/docs/interfaces/AttachDocumentResponse.html +0 -62
  304. package/docs/interfaces/BriyahConfigOptions.html +0 -124
  305. package/docs/interfaces/ChapterInfo.html +0 -62
  306. package/docs/interfaces/Character.html +0 -86
  307. package/docs/interfaces/ConversionAgent.html +0 -78
  308. package/docs/interfaces/CreateAgentResponse.html +0 -56
  309. package/docs/interfaces/CreateRoomResponse.html +0 -62
  310. package/docs/interfaces/CreateStoryResponse.html +0 -56
  311. package/docs/interfaces/FileList.html +0 -56
  312. package/docs/interfaces/FileMetadata.html +0 -89
  313. package/docs/interfaces/IConfigService.html +0 -79
  314. package/docs/interfaces/InstantiateModels.html +0 -64
  315. package/docs/interfaces/InstantiateRoomResult.html +0 -70
  316. package/docs/interfaces/LoadedPack.html +0 -131
  317. package/docs/interfaces/LoggingOptions.html +0 -92
  318. package/docs/interfaces/Message.html +0 -84
  319. package/docs/interfaces/ModelChoice.html +0 -73
  320. package/docs/interfaces/ModelInfo.html +0 -74
  321. package/docs/interfaces/NativeToolDefinition.html +0 -107
  322. package/docs/interfaces/PackAgentTemplate.html +0 -101
  323. package/docs/interfaces/PackRoomTemplate.html +0 -108
  324. package/docs/interfaces/PackView.html +0 -172
  325. package/docs/interfaces/PdfConversionOptions.html +0 -102
  326. package/docs/interfaces/PdfConversionResult.html +0 -97
  327. package/docs/interfaces/PdfMarkdownOptions.html +0 -198
  328. package/docs/interfaces/PdfMarkdownResult.html +0 -106
  329. package/docs/interfaces/PdfPageMarkdown.html +0 -94
  330. package/docs/interfaces/PreparedPromptResponse.html +0 -62
  331. package/docs/interfaces/ProcessTextResponse.html +0 -86
  332. package/docs/interfaces/PromptFile.html +0 -70
  333. package/docs/interfaces/PromptFileContent.html +0 -76
  334. package/docs/interfaces/PromptFilesResponse.html +0 -56
  335. package/docs/interfaces/PromptFolder.html +0 -80
  336. package/docs/interfaces/PromptFolderDefaults.html +0 -155
  337. package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
  338. package/docs/interfaces/PromptFoldersResponse.html +0 -56
  339. package/docs/interfaces/RoomDetails.html +0 -151
  340. package/docs/interfaces/RoomErrorUpdate.html +0 -82
  341. package/docs/interfaces/RoomInfo.html +0 -88
  342. package/docs/interfaces/RoomMessageUpdate.html +0 -113
  343. package/docs/interfaces/RoomMessagesResponse.html +0 -62
  344. package/docs/interfaces/SendMessageResult.html +0 -62
  345. package/docs/interfaces/StoryErrorEvent.html +0 -84
  346. package/docs/interfaces/StoryIdea.html +0 -74
  347. package/docs/interfaces/StoryInfo.html +0 -198
  348. package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
  349. package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
  350. package/docs/interfaces/StoryState.html +0 -108
  351. package/docs/interfaces/StoryStateEvent.html +0 -76
  352. package/docs/interfaces/ToolArtifact.html +0 -85
  353. package/docs/interfaces/ToolCaller.html +0 -77
  354. package/docs/interfaces/ToolDefinition.html +0 -80
  355. package/docs/interfaces/ToolHelpers.html +0 -105
  356. package/docs/interfaces/ToolPackDocuments.html +0 -100
  357. package/docs/interfaces/ToolParameter.html +0 -74
  358. package/docs/interfaces/ToolRoomAccess.html +0 -260
  359. package/docs/interfaces/ToolSummary.html +0 -74
  360. package/docs/interfaces/ToolsResponse.html +0 -68
  361. package/docs/interfaces/Transaction.html +0 -104
  362. package/docs/interfaces/TransactionHistoryResponse.html +0 -62
  363. package/docs/modules.html +0 -53
  364. package/docs/types/PackOrigin.html +0 -34
  365. package/docs/types/PromptScope.html +0 -34
  366. package/docs/types/RoomTurnMode.html +0 -42
  367. package/docs/types/RoomUpdate.html +0 -36
  368. package/docs/types/RosterOverrides.html +0 -42
  369. package/docs/types/ToolContext.html +0 -40
  370. package/docs/types/ToolRunResult.html +0 -34
  371. package/src/tools/packs/dnd5e/README.md +0 -867
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /** The sheet tools: create a character, read a sheet, and patch it directly. */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -80,8 +81,12 @@ exports.createSheetTool = {
80
81
  const spec = (0, coerce_1.jsonObject)(args.spec, 'spec', SPEC_EXAMPLE);
81
82
  const owner = args.owner ? (0, coerce_1.str)(args.owner, 'owner') : undefined;
82
83
  const state = (0, character_1.buildCharacter)(name, spec, owner);
84
+ // Read immediately: they describe the build that just happened.
83
85
  const raceResult = (0, character_1.lastRaceResult)();
84
86
  const classToolResult = (0, character_1.lastClassToolResult)();
87
+ // The spec lists equipment as plain names, so armour and shields are worn
88
+ // automatically — otherwise every new character would start at 10 + Dex
89
+ // and need a second call to fix their armour class.
85
90
  for (const item of state.inv) {
86
91
  if (isWorn(item.n))
87
92
  item.eq = true;
@@ -91,8 +96,20 @@ exports.createSheetTool = {
91
96
  const notes = spec.backstory ? `## Backstory\n${spec.backstory}` : '';
92
97
  const artifactName = (0, shared_1.writeNewSheet)(room, state, notes, (0, coerce_1.bool)(args.replace));
93
98
  (0, shared_1.refreshPartyStatus)(room);
99
+ // Give the owning agent a public identity, so the rest of the table knows
100
+ // who they are rather than reading whatever placeholder they were created
101
+ // with. Done here rather than left to a separate call because the sheet
102
+ // already knows the answer, and because this is the one moment in the game
103
+ // when invalidating everyone's cached prompt is cheap: play has not started.
104
+ // Deliberately carries no level or state — those change, and this must not.
94
105
  const identity = publicIdentity(state);
95
106
  const described = state.owner ? room.setDescription(state.owner, identity) : false;
107
+ // The room routes by nickname, so the player becomes their character. This is
108
+ // what replaced the old rule that a character had to be called whatever its
109
+ // player was called — a workaround for the room having two names for one
110
+ // person, which cost one campaign about a quarter of its calls. Reported
111
+ // rather than fatal: a refused rename loses a routing convenience, while
112
+ // failing here would throw away a finished character.
96
113
  const renamed = state.owner ? room.renameAgent(state.owner, state.name) : undefined;
97
114
  const guides = shareGuidesForCharacter(room, helpers.packDocuments, state);
98
115
  return {
@@ -110,6 +127,9 @@ exports.createSheetTool = {
110
127
  classGuides: guides.classes.length > 0 ? guides.classes : undefined,
111
128
  classesWithoutRules: guides.missingClasses.length > 0 ? guides.missingClasses : undefined,
112
129
  spellsOffList: (() => {
130
+ // Reported, never refused: a subclass, a racial trait or an item can
131
+ // all grant a spell off-list, so blocking would be wrong more often
132
+ // than right. Naming it lets a genuine mistake be noticed.
113
133
  const off = (0, spells_1.offListSpells)(state, state.spells || []);
114
134
  return off.length > 0
115
135
  ? off.map((entry) => entry.onLists
@@ -117,6 +137,11 @@ exports.createSheetTool = {
117
137
  : `${entry.spell} is not an SRD spell`)
118
138
  : undefined;
119
139
  })(),
140
+ // The name is recorded and nothing else is applied, because a background is
141
+ // a document rather than a table: its skills, languages, gear and coin are
142
+ // read off `rules_lookup` and passed in this same spec. Said on every build
143
+ // rather than only when something looks wrong, since a background whose
144
+ // skills were never passed is invisible on the finished sheet.
120
145
  background: state.bg
121
146
  ? {
122
147
  recorded: state.bg,
@@ -138,6 +163,8 @@ exports.createSheetTool = {
138
163
  }
139
164
  : undefined,
140
165
  raceProblems: raceResult.problems.length > 0 ? raceResult.problems : undefined,
166
+ // Every source's tools in one place, because a player choosing them needs
167
+ // the whole picture and the three grants report separately above.
141
168
  tools: state.toolProf.length > 0 || classToolResult.outstanding.length > 0
142
169
  ? {
143
170
  proficient: state.toolProf.length > 0 ? state.toolProf : undefined,
@@ -147,6 +174,10 @@ exports.createSheetTool = {
147
174
  : undefined,
148
175
  }
149
176
  : undefined,
177
+ // Reported as a list rather than a count, because nothing here knows how
178
+ // many a character is owed: the race's extras are data, a background's are
179
+ // prose in a document. Showing what landed is what lets a creator check it
180
+ // against the two sources itself.
150
181
  languages: state.languages?.length ? state.languages : undefined,
151
182
  derived: {
152
183
  hitPoints: `${state.hp.cur}/${state.hp.max}`,
@@ -166,10 +197,34 @@ exports.createSheetTool = {
166
197
  };
167
198
  },
168
199
  };
200
+ /**
201
+ * Gives the character's own player the documents for the class and background they
202
+ * just took.
203
+ *
204
+ * Done here rather than left to the creator's next tool call because this is the
205
+ * moment a choice becomes a fact, and because a player who never receives it has no
206
+ * other route to their own features — they hold no tools, and their sheet carries
207
+ * feature *names* rather than what those features do. `class_guide` and
208
+ * `rules_lookup` remain the way the *creator* reads one while a player is still
209
+ * choosing; this is the half that cannot be forgotten.
210
+ *
211
+ * Best effort by construction. A missing document or a deployment with no document
212
+ * access must not fail a sheet that is otherwise built. A **class** with no document
213
+ * is reported, because a class the table has no rules for is a real problem; a
214
+ * **background** with none is not reported here, because a background outside the
215
+ * SRD is ordinary legal play — `create_sheet`'s own `background.stillToChoose`
216
+ * already says its skills and gear are the creator's to supply.
217
+ *
218
+ * @param room The room access
219
+ * @param documents Pack document access, absent from the tool-test panel
220
+ * @param state The character that was just built
221
+ * @returns What was shared, and which classes have no rules here
222
+ */
169
223
  function shareGuidesForCharacter(room, documents, state) {
170
224
  const result = { classes: [], missingClasses: [] };
171
225
  if (!documents)
172
226
  return result;
227
+ // No owner means nobody to give it to; the creator reads them through its lookups.
173
228
  const players = state.owner ? [state.owner] : [];
174
229
  const share = (kind, wanted) => {
175
230
  const guides = (0, guides_1.listGuides)(kind, documents.list(guides_1.DND5E_PACK, kind.prefix));
@@ -193,6 +248,16 @@ function shareGuidesForCharacter(room, documents, state) {
193
248
  }
194
249
  return result;
195
250
  }
251
+ /**
252
+ * The one-line identity the rest of the table sees, e.g.
253
+ * `Thorin Ironfoot — Mountain Dwarf Fighter`.
254
+ *
255
+ * Carries only what will not change for the life of the character. Level, hit
256
+ * points and conditions belong in the party summary, which is re-rendered from
257
+ * the sheets and costs nothing to update.
258
+ * @param state The finished character
259
+ * @returns The public identity line
260
+ */
196
261
  function publicIdentity(state) {
197
262
  const classes = state.class
198
263
  .map((entry) => {
@@ -203,6 +268,7 @@ function publicIdentity(state) {
203
268
  const descriptors = [state.race, classes].filter(Boolean).join(' ');
204
269
  return descriptors ? `${state.name} — ${descriptors}` : state.name;
205
270
  }
271
+ /** Whether an item is armour or a shield, and so affects armour class when worn. */
206
272
  function isWorn(itemName) {
207
273
  const key = itemName.toLowerCase();
208
274
  return /\bshield\b/.test(key) || srd_1.ARMOR[key] !== undefined;
@@ -256,6 +322,8 @@ exports.readSheetTool = {
256
322
  if (wants('feats') && (0, feats_1.takenFeats)(state).length > 0) {
257
323
  result.feats = (0, feats_1.takenFeats)(state).map((name) => {
258
324
  const { feat } = (0, feats_1.resolveFeat)(name);
325
+ // Full text for a feat the SRD carries; the name alone for one from
326
+ // outside it, since there is nothing to quote.
259
327
  return feat ? (0, feats_1.describeFeat)(feat) : `${name} (not an SRD feat)`;
260
328
  });
261
329
  }
@@ -267,6 +335,8 @@ exports.readSheetTool = {
267
335
  pushDragLift: load.capacity.pushDragLift,
268
336
  tier: load.tier,
269
337
  variantInUse: load.variant,
338
+ // Named rather than assumed weightless: the SRD prints no weight
339
+ // for vestments or a holy symbol, so the total is a floor.
270
340
  unweighed: load.carried.unweighed.length > 0 ? load.carried.unweighed : undefined,
271
341
  thresholds: load.variant
272
342
  ? {
@@ -279,6 +349,9 @@ exports.readSheetTool = {
279
349
  if (wants('background') && state.bg) {
280
350
  result.background = {
281
351
  name: state.bg,
352
+ // The name is all the sheet holds. A background is a document rather
353
+ // than a table, so what it grants was applied by whoever read it, and
354
+ // its prose is in the `Background: <name>` document.
282
355
  note: `Read what it grants with rules_lookup topic "${state.bg}". Anything recorded for this character is in the notes.`,
283
356
  };
284
357
  }
@@ -290,6 +363,8 @@ exports.readSheetTool = {
290
363
  speed: `${rules.effectiveSpeed(state).speed} ft`,
291
364
  darkvision: state.darkvision ? `${state.darkvision} ft` : undefined,
292
365
  languages: state.languages,
366
+ // Full text here, unlike the sheet render, because this is asked
367
+ // for explicitly rather than carried in a prompt every turn.
293
368
  traits: traits.map((trait) => `${trait.n}. ${trait.text}`),
294
369
  };
295
370
  }
@@ -315,6 +390,8 @@ exports.readSheetTool = {
315
390
  .skillNames()
316
391
  .map((skill) => [(0, sheet_1.titleCase)(skill), (0, sheet_1.signed)(rules.skillModifier(state, skill))]));
317
392
  result.passivePerception = rules.passivePerception(state);
393
+ // Under skills because that is what they are: the other thing a character
394
+ // is proficient at, and the DM asking what someone is good at wants both.
318
395
  if (state.toolProf.length > 0)
319
396
  result.toolProficiencies = state.toolProf;
320
397
  }
@@ -343,6 +420,7 @@ exports.readSheetTool = {
343
420
  result.conditions = state.cond.map((c) => ({
344
421
  name: c.n,
345
422
  duration: c.dur,
423
+ // The DM should not have to look these up to adjudicate.
346
424
  effect: srd_1.CONDITIONS[c.n] || 'Not a standard condition; adjudicate as described.',
347
425
  }));
348
426
  result.exhaustion = {
@@ -407,6 +485,8 @@ exports.patchSheetTool = {
407
485
  const sheet = (0, shared_1.loadSheet)(room, character);
408
486
  const candidate = (0, character_1.cloneState)(sheet.state);
409
487
  const applied = [];
488
+ // Every path is checked before anything is written, so a call that names one
489
+ // bad field changes nothing rather than half-applying.
410
490
  const rejected = [...Object.keys(set), ...Object.keys(append)]
411
491
  .map((path) => ({ path, problem: pathProblem(candidate, path) }))
412
492
  .filter((entry) => entry.problem);
@@ -431,6 +511,9 @@ exports.patchSheetTool = {
431
511
  for (const [path, value] of Object.entries(append)) {
432
512
  const target = getPath(candidate, path);
433
513
  if (!Array.isArray(target)) {
514
+ // A refusal rather than a throw: the caller asked for something the
515
+ // rules of the sheet do not allow, and the useful reply names what
516
+ // it could have done instead.
434
517
  return {
435
518
  applied: false,
436
519
  violation: 'not_a_list',
@@ -482,9 +565,28 @@ exports.patchSheetTool = {
482
565
  };
483
566
  },
484
567
  };
568
+ /** Reads a dotted path out of state. */
485
569
  function getPath(state, path) {
486
570
  return path.split('.').reduce((node, key) => (node === undefined ? undefined : node[key]), state);
487
571
  }
572
+ /**
573
+ * Why a dotted path cannot be written, or '' when it can.
574
+ *
575
+ * Two ways a path can be unwritable, both of which would otherwise pass silently:
576
+ *
577
+ * - **An unknown root.** `SheetState` ends in an index signature so a future field
578
+ * survives an old sheet — which also means a typo like `abilities.wis` would be
579
+ * accepted as a brand new top-level key that nothing reads, and reported as
580
+ * `applied: true`.
581
+ * - **A non-object in the middle.** `race` is a string, so `race.traits` would hang
582
+ * a property off it. Left to {@link setPath} the string is replaced by an object,
583
+ * and the next `resolveRace` calls `.toLowerCase()` on it — a `TypeError` several
584
+ * frames away that says nothing about sheets.
585
+ *
586
+ * @param state The sheet being patched
587
+ * @param path The dotted path the caller asked for
588
+ * @returns A sentence naming the problem, or '' when the path is writable
589
+ */
488
590
  function pathProblem(state, path) {
489
591
  const keys = String(path).split('.');
490
592
  const root = keys[0];
@@ -497,6 +599,8 @@ function pathProblem(state, path) {
497
599
  for (let i = 0; i < keys.length - 1; i++) {
498
600
  const value = node[keys[i]];
499
601
  if (value === undefined || value === null) {
602
+ // A new nested key under a real field is fine — `uses.rage` is how a
603
+ // feature pool is added.
500
604
  return '';
501
605
  }
502
606
  if (typeof value !== 'object' || Array.isArray(value)) {
@@ -507,6 +611,13 @@ function pathProblem(state, path) {
507
611
  }
508
612
  return '';
509
613
  }
614
+ /**
615
+ * Writes a dotted path into state, creating intermediate objects.
616
+ *
617
+ * Only ever called on a path {@link pathProblem} has cleared. The guard below is a
618
+ * backstop for a caller that forgets — silently replacing a non-object with `{}`
619
+ * corrupts the field it was meant to write inside.
620
+ */
510
621
  function setPath(state, path, value) {
511
622
  const keys = path.split('.');
512
623
  let node = state;
@@ -521,6 +632,11 @@ function setPath(state, path, value) {
521
632
  }
522
633
  node[keys[keys.length - 1]] = value;
523
634
  }
635
+ /**
636
+ * Checks the invariants a sheet must satisfy after a direct edit.
637
+ * @param state The candidate state
638
+ * @returns A description of the first problem, or null when consistent
639
+ */
524
640
  function validate(state) {
525
641
  if (!Number.isFinite(state.hp.max) || state.hp.max < 1) {
526
642
  return `Hit point maximum must be at least 1, but would be ${state.hp.max}.`;
@@ -1,2 +1,15 @@
1
+ /**
2
+ * The `spell` tool: what a spell does, and what a class can take.
3
+ *
4
+ * The last of the three lookups — creatures, items, spells — and the same
5
+ * reasoning as the other two: the Dungeon Master must never invent what a spell
6
+ * does, and "the wizard casts fireball, what happens?" should cost one cheap call
7
+ * rather than a guess or a handoff.
8
+ *
9
+ * Unlike `stat_block` and `magic_item` there is no `define`. Nothing in the pack
10
+ * computes from a spell, so a homebrew one needs prose in the `Campaign` document
11
+ * and a name on the sheet — both of which already work — rather than a fourth
12
+ * campaign artifact holding fields no tool reads.
13
+ */
1
14
  import { NativeToolDefinition } from '../../../native-tool.types';
2
15
  export declare const spellTool: NativeToolDefinition;
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ /**
3
+ * The `spell` tool: what a spell does, and what a class can take.
4
+ *
5
+ * The last of the three lookups — creatures, items, spells — and the same
6
+ * reasoning as the other two: the Dungeon Master must never invent what a spell
7
+ * does, and "the wizard casts fireball, what happens?" should cost one cheap call
8
+ * rather than a guess or a handoff.
9
+ *
10
+ * Unlike `stat_block` and `magic_item` there is no `define`. Nothing in the pack
11
+ * computes from a spell, so a homebrew one needs prose in the `Campaign` document
12
+ * and a name on the sheet — both of which already work — rather than a fourth
13
+ * campaign artifact holding fields no tool reads.
14
+ */
2
15
  Object.defineProperty(exports, "__esModule", { value: true });
3
16
  exports.spellTool = void 0;
4
17
  const coerce_1 = require("../engine/coerce");
@@ -69,10 +82,14 @@ exports.spellTool = {
69
82
  spell: resolved.spell.name,
70
83
  details: compact(resolved.spell),
71
84
  entry: (0, spells_1.describeSpell)(resolved.spell),
85
+ // `entry` is SRD prose, so the attribution travels with it the way
86
+ // `rules_lookup` does. Every spell here is SRD — there is no campaign
87
+ // spell table — so this is unconditional.
72
88
  attribution: srd_1.SRD_ATTRIBUTION,
73
89
  };
74
90
  },
75
91
  };
92
+ /** Lists spells for a class and level. */
76
93
  function list(args) {
77
94
  const forClass = args.for_class ? (0, coerce_1.str)(args.for_class, 'for_class').toLowerCase() : undefined;
78
95
  if (forClass && !srd_1.CLASSES[forClass]) {
@@ -100,6 +117,7 @@ function list(args) {
100
117
  : 'Pass "for_class" to see only what one class can cast.',
101
118
  };
102
119
  }
120
+ /** The machine-readable half: what a caller filters or checks by. */
103
121
  function compact(spell) {
104
122
  return {
105
123
  level: spell.level === 0 ? 'cantrip' : spell.level,
@@ -1,3 +1,4 @@
1
+ /** The tools that change a character's live state: hit points, rests, resources. */
1
2
  import { NativeToolDefinition } from '../../../native-tool.types';
2
3
  export declare const applyHpTool: NativeToolDefinition;
3
4
  export declare const restTool: NativeToolDefinition;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /** The tools that change a character's live state: hit points, rests, resources. */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.spendTool = exports.restTool = exports.applyHpTool = void 0;
4
5
  const coerce_1 = require("../engine/coerce");
@@ -166,6 +167,7 @@ exports.restTool = {
166
167
  };
167
168
  },
168
169
  };
170
+ /** Parses `Thalia:2; Dorn:1` into a name-to-count plan. */
169
171
  function parseHitDicePlan(raw) {
170
172
  return (0, coerce_1.list)(raw)
171
173
  .map((entry) => {
@@ -225,6 +227,8 @@ exports.spendTool = {
225
227
  const amount = args.amount !== undefined && args.amount !== '' ? (0, coerce_1.int)(args.amount, 'amount', 1) : 1;
226
228
  const level = args.level !== undefined && args.level !== '' ? (0, coerce_1.int)(args.level, 'level') : undefined;
227
229
  const target = args.target ? (0, coerce_1.str)(args.target, 'target') : undefined;
230
+ // No target, and the character is already holding a die of this name: this is
231
+ // the spend that *uses* one rather than one that grants it.
228
232
  if (!target && holdsBoon(room, character, resource)) {
229
233
  const used = (0, shared_1.mutateSheet)(room, character, (sheet) => (0, character_1.spendBoon)(sheet.state, resource));
230
234
  if ((0, character_1.isRefusal)(used.result)) {
@@ -243,6 +247,8 @@ exports.spendTool = {
243
247
  if ((0, character_1.isRefusal)(result)) {
244
248
  return (0, shared_1.toRefusalResult)(result.refusal, reloadState(room, character));
245
249
  }
250
+ // The giver's counter is down; now put the die somewhere it can be used. Done
251
+ // after the spend, so a refused spend hands out nothing.
246
252
  let granted;
247
253
  if (target && amount > 0) {
248
254
  const die = args.die ? (0, coerce_1.str)(args.die, 'die') : boonDie(result.state, resource);
@@ -256,11 +262,13 @@ exports.spendTool = {
256
262
  character: result.state.name,
257
263
  applied: true,
258
264
  summary: granted ? `${result.summary} ${granted}` : result.summary,
265
+ // Carries what spending the use does, for gear that says so.
259
266
  details: result.details,
260
267
  state: (0, shared_1.liveState)(result.state),
261
268
  };
262
269
  },
263
270
  };
271
+ /** Whether a character is already holding a die of this name, waiting to be spent. */
264
272
  function holdsBoon(room, character, resource) {
265
273
  try {
266
274
  const wanted = resource.trim().toLowerCase();
@@ -270,6 +278,16 @@ function holdsBoon(room, character, resource) {
270
278
  return false;
271
279
  }
272
280
  }
281
+ /**
282
+ * The die a resource hands over when the caller does not say which.
283
+ *
284
+ * Bardic Inspiration is the one that scales, and it scales with the *bard's* level
285
+ * rather than the recipient's. Everything else in the SRD that works this way —
286
+ * Bless, Guidance, Resistance — is a d4.
287
+ * @param giver The character spending the resource
288
+ * @param resource What was spent
289
+ * @returns A die expression such as 'd6'
290
+ */
273
291
  function boonDie(giver, resource) {
274
292
  if (!resource.trim().toLowerCase().includes('inspiration'))
275
293
  return 'd4';
@@ -283,6 +301,7 @@ function boonDie(giver, resource) {
283
301
  return 'd8';
284
302
  return 'd6';
285
303
  }
304
+ /** 'bardic inspiration' becomes 'Bardic Inspiration', so the sheet reads properly. */
286
305
  function boonName(resource) {
287
306
  return resource
288
307
  .trim()
@@ -290,6 +309,10 @@ function boonName(resource) {
290
309
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
291
310
  .join(' ');
292
311
  }
312
+ /**
313
+ * Reads state back so a refusal can report what the character does still have.
314
+ * A failure here must not mask the refusal itself, so it degrades to no state.
315
+ */
293
316
  function reloadState(room, character) {
294
317
  try {
295
318
  return (0, shared_1.loadSheet)(room, character).state;
@@ -1,3 +1,4 @@
1
+ /** Conditions, inventory, experience, levelling, and rules lookup. */
1
2
  import { NativeToolDefinition } from '../../../native-tool.types';
2
3
  export declare const conditionsTool: NativeToolDefinition;
3
4
  export declare const inventoryTool: NativeToolDefinition;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /** Conditions, inventory, experience, levelling, and rules lookup. */
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -90,6 +91,8 @@ exports.conditionsTool = {
90
91
  }
91
92
  const toAdd = (0, coerce_1.list)(args.add).map(parseCondition);
92
93
  const toRemove = (0, coerce_1.list)(args.remove).map((entry) => parseCondition(entry).name);
94
+ // Reject an unknown condition before touching any sheet, so a typo cannot
95
+ // leave half the party updated.
93
96
  const unknown = [...toAdd.map((c) => c.name), ...toRemove].filter((name) => srd_1.CONDITIONS[name] === undefined);
94
97
  if (unknown.length > 0) {
95
98
  throw new Error(`Not a 5e condition: ${unknown.join(', ')}. Valid conditions: ${Object.keys(srd_1.CONDITIONS).join(', ')}.`);
@@ -155,6 +158,7 @@ exports.conditionsTool = {
155
158
  };
156
159
  },
157
160
  };
161
+ /** Splits `frightened:2 rounds` into a name and a duration. */
158
162
  function parseCondition(entry) {
159
163
  const match = /^(.*?)\s*:\s*(.+)$/.exec(entry.trim());
160
164
  if (match)
@@ -205,6 +209,8 @@ exports.inventoryTool = {
205
209
  const character = (0, coerce_1.str)(args.character, 'character');
206
210
  const transferTo = args.transfer_to ? (0, coerce_1.str)(args.transfer_to, 'transfer_to') : '';
207
211
  let transferred = [];
212
+ // Read once, outside the mutation: campaign items answer whether an item
213
+ // needs attunement at all, and `room.update` must not be re-entered.
208
214
  const campaignItems = (0, campaign_items_1.parseCampaignItems)(room.get(campaign_items_1.ITEMS_ARTIFACT)?.body);
209
215
  const { result } = (0, shared_1.mutateSheet)(room, character, (sheet) => {
210
216
  const state = (0, character_1.cloneState)(sheet.state);
@@ -244,12 +250,17 @@ exports.inventoryTool = {
244
250
  changes.push(`no longer attuned to ${released.changed.join(', ')}`);
245
251
  }
246
252
  const attuning = (0, character_1.setAttunement)(state, (0, coerce_1.list)(args.attune), true, (itemName) => Boolean((0, items_1.resolveItem)(itemName, campaignItems).item?.attunement));
253
+ // Exceeding the limit is a rule, so it refuses and says what is attuned
254
+ // rather than throwing — the player picks what to give up.
247
255
  if (attuning.refusal)
248
256
  return { ok: false, refusal: attuning.refusal };
249
257
  if (attuning.changed.length > 0) {
250
258
  changes.push(`attuned to ${attuning.changed.join(', ')}`);
251
259
  }
252
260
  if (attuning.unnecessary.length > 0) {
261
+ // Information, not a failure: the item works without attunement, so
262
+ // nothing is wrong. Kept out of `problems` so it cannot become the
263
+ // sole reason the whole call refuses.
253
264
  remarks.push(`needs no attunement, so nothing changed: ${attuning.unnecessary.join(', ')}`);
254
265
  }
255
266
  for (const name of [...released.missing, ...attuning.missing]) {
@@ -267,6 +278,10 @@ exports.inventoryTool = {
267
278
  },
268
279
  };
269
280
  }
281
+ // Gaining or losing a weapon changes what they can attack with, so the
282
+ // attack list follows the gear. Only entries whose name is exactly a
283
+ // table weapon are touched; a magic weapon or a hand-written line is
284
+ // left alone.
270
285
  const weaponChanges = (0, weapons_1.syncWeaponAttacks)(state);
271
286
  if (weaponChanges.added.length > 0) {
272
287
  changes.push(`can now attack with ${weaponChanges.added.join(', ')}`);
@@ -284,6 +299,8 @@ exports.inventoryTool = {
284
299
  if ((0, character_1.isRefusal)(result)) {
285
300
  return (0, shared_1.toRefusalResult)(result.refusal);
286
301
  }
302
+ // A transfer is two writes rather than one, so the recipient's sheet is
303
+ // only touched once the giver's has actually changed.
287
304
  let receivedBy;
288
305
  if (transferTo && transferred.length > 0) {
289
306
  const known = (0, shared_1.listCharacterNames)(room);
@@ -417,6 +434,8 @@ exports.awardCoinTool = {
417
434
  const entries = (0, coerce_1.list)(args.amount);
418
435
  if (entries.length === 0)
419
436
  throw new Error('No amount given, e.g. "150 gp".');
437
+ // Splitting is the default: a purse found in a chest is one pile, unlike
438
+ // experience, which the rules give to each character.
420
439
  const split = args.split === undefined || args.split === '' ? true : (0, coerce_1.bool)(args.split);
421
440
  const division = split
422
441
  ? (0, character_1.divideCoin)(entries, names.length)
@@ -424,6 +443,8 @@ exports.awardCoinTool = {
424
443
  if ('refusal' in division && division.refusal) {
425
444
  return (0, shared_1.toRefusalResult)(division.refusal);
426
445
  }
446
+ // Every share is tested against a copy before any sheet is written. A split
447
+ // cost that half the party can afford must not leave half of them charged.
427
448
  for (let i = 0; i < names.length; i++) {
428
449
  const sheet = (0, shared_1.loadSheet)(room, names[i]);
429
450
  const trial = (0, character_1.adjustCoin)((0, character_1.cloneState)(sheet.state), division.shares[i].entries);
@@ -531,6 +552,9 @@ exports.rulesLookupTool = {
531
552
  if (table) {
532
553
  return { topic, kind: 'table', ...table, attribution: srd_1.SRD_ATTRIBUTION };
533
554
  }
555
+ // Equipment is looked up here rather than through a tool of its own: it is
556
+ // a table like any other, and the pack already has as many tools as a turn
557
+ // can chain.
534
558
  const weapon = (0, weapons_1.resolveWeapon)(topic);
535
559
  if (weapon.weapon) {
536
560
  return {
@@ -558,6 +582,11 @@ exports.rulesLookupTool = {
558
582
  attribution: srd_1.SRD_ATTRIBUTION,
559
583
  };
560
584
  }
585
+ // Backgrounds come from the pack's `background-*.md` documents first and the
586
+ // SRD table second, so a table adds one by dropping in a file. Unlike a class,
587
+ // a background outside the list is still legal play — the SRD's own
588
+ // customization rule says so — which is why the listing is a menu rather than
589
+ // an authority, and why nothing here refuses a name it does not know.
561
590
  const documented = (0, guides_1.listGuides)(guides_1.BACKGROUND_GUIDE, helpers.packDocuments?.list(guides_1.DND5E_PACK, guides_1.BACKGROUND_GUIDE.prefix) || []);
562
591
  if (topic === 'background' || topic === 'backgrounds') {
563
592
  return {
@@ -594,6 +623,10 @@ exports.rulesLookupTool = {
594
623
  message: `"${topic}" matches ${background.ambiguous.length} backgrounds. Ask again with the full name.`,
595
624
  };
596
625
  }
626
+ // Before the feats and the races, because "tools" must reach the rule rather
627
+ // than fall through the loose matchers to something that merely starts with a
628
+ // 't'. The categories are listed with it, since the next question is always
629
+ // which tools there are.
597
630
  if (/^(tool|tools|tool proficienc|artisans? tools|gaming set|musical instrument)/.test(topic)) {
598
631
  return {
599
632
  topic,
@@ -657,6 +690,7 @@ exports.rulesLookupTool = {
657
690
  attribution: srd_1.SRD_ATTRIBUTION,
658
691
  };
659
692
  }
693
+ // Suggest rather than just failing: the model's next call should succeed.
660
694
  const suggestions = [
661
695
  ...Object.keys(srd_1.CONDITIONS),
662
696
  ...Object.keys(srd_1.RULES_TOPICS),
@@ -685,6 +719,7 @@ exports.rulesLookupTool = {
685
719
  };
686
720
  },
687
721
  };
722
+ /** Renders the numeric tables, which do not fit the prose-excerpt shape. */
688
723
  function lookupTable(topic) {
689
724
  if (topic.includes('proficiency')) {
690
725
  return {
@@ -1,8 +1,57 @@
1
+ /**
2
+ * Built-in tool packs: sets of native tools that ship with Briyah.
3
+ *
4
+ * Registration is process-global, matching how native tools work generally. What
5
+ * used to gate it — `BRIYAH_TOOL_PACKS` — no longer does: a pack's tools are
6
+ * registered at boot and *enablement is per user*, held in their config and
7
+ * applied where tools are listed rather than where they are registered. See
8
+ * `packs/pack.service.ts`.
9
+ *
10
+ * Registering everything is safe because registration alone grants nothing. A
11
+ * tool reaches an agent only through `agent.toolNames`, and
12
+ * `AppService.listNativeToolSummaries` will not offer a tool whose pack the user
13
+ * has not switched on.
14
+ */
1
15
  import { NativeToolRegistry } from '../native-tool-registry.service';
2
16
  import { NativeToolDefinition } from '../native-tool.types';
3
17
  import { dnd5eTools } from './dnd5e';
18
+ /**
19
+ * Registers the core tools and every built-in pack's tools.
20
+ *
21
+ * Core first, so a pack that shipped a colliding name would overwrite it loudly
22
+ * through `registerTool`'s warning rather than the other way round. `packs.spec.ts`
23
+ * is what actually stops that happening.
24
+ *
25
+ * @param registry The process-wide native tool registry
26
+ * @returns The names of the tools that were registered
27
+ */
4
28
  export declare function installToolPacks(registry: NativeToolRegistry): string[];
29
+ /**
30
+ * Registers the named tool packs into the native registry.
31
+ *
32
+ * Kept alongside {@link installToolPacks} for an SDK host that wants only some of
33
+ * the built-in packs' tools in its process.
34
+ *
35
+ * @param registry The process-wide native tool registry
36
+ * @param packList A comma-separated list of pack names. Empty or undefined
37
+ * registers nothing.
38
+ * @returns The names of the tools that were registered
39
+ */
5
40
  export declare function registerToolPacks(registry: NativeToolRegistry, packList: string | undefined): string[];
41
+ /**
42
+ * Registers one pack's tools under a name.
43
+ *
44
+ * For a pack that is not in {@link PACKS}: one this repository runs but does not
45
+ * publish, or one an SDK host wrote itself. `main.ts` registers `acts` this way,
46
+ * and `main.ts` is excluded from the SDK build, so the published package has no
47
+ * path to it at all.
48
+ *
49
+ * @param registry The process-wide native tool registry
50
+ * @param name The pack name, stamped on every tool as its group
51
+ * @param tools The pack's tool definitions
52
+ * @returns The names of the tools that were registered
53
+ */
6
54
  export declare function registerPack(registry: NativeToolRegistry, name: string, tools: NativeToolDefinition[]): string[];
55
+ /** The names of the packs that ship with the package. */
7
56
  export declare function availableToolPacks(): string[];
8
57
  export { dnd5eTools };