briyah 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/README.md +55 -8
  2. package/data/common/config/LICENSE-model-prices.md +65 -0
  3. package/data/common/config/markup +1 -1
  4. package/data/common/config/model_prices.json +47443 -46295
  5. package/data/common/config/story_models.json +3 -3
  6. package/data/common/prompts/illustrator/describe_scene.prompt +4 -4
  7. package/data/common/prompts/narrator/create_story.prompt +2 -0
  8. package/data/common/prompts/perceive.prompt +1 -1
  9. package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +1 -1
  10. package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +1 -1
  11. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +795 -787
  12. package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +2 -1
  13. package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +1 -1
  14. package/data/packs/dnd5e/rooms/campaign.json +18 -15
  15. package/data/packs/dnd5e/rooms/table.json +17 -16
  16. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
  17. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +174 -3
  18. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +194 -3
  19. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +299 -19
  20. package/dist-sdk/server/src/ai/LLM/blank-image.d.ts +36 -0
  21. package/dist-sdk/server/src/ai/LLM/blank-image.js +80 -0
  22. package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
  23. package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
  24. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
  25. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
  26. package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
  27. package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
  28. package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
  29. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +103 -4
  30. package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
  31. package/dist-sdk/server/src/ai/LLM/fal.service.js +56 -2
  32. package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
  33. package/dist-sdk/server/src/ai/LLM/googleai.service.js +43 -2
  34. package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
  35. package/dist-sdk/server/src/ai/LLM/grok.service.js +55 -3
  36. package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
  37. package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
  38. package/dist-sdk/server/src/ai/LLM/openai.service.js +81 -3
  39. package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
  40. package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +45 -3
  41. package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
  42. package/dist-sdk/server/src/ai/LLM/together.service.js +61 -3
  43. package/dist-sdk/server/src/ai/agent-config.d.ts +15 -1
  44. package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
  45. package/dist-sdk/server/src/ai/agent-factory.js +20 -0
  46. package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
  47. package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
  48. package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
  49. package/dist-sdk/server/src/ai/agent-store.service.js +166 -7
  50. package/dist-sdk/server/src/ai/agent.d.ts +197 -2
  51. package/dist-sdk/server/src/ai/agent.js +225 -14
  52. package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
  53. package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
  54. package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
  55. package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
  56. package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
  57. package/dist-sdk/server/src/ai/artifact.service.js +148 -3
  58. package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
  59. package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
  60. package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
  61. package/dist-sdk/server/src/ai/model_prices.js +91 -5
  62. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
  63. package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
  64. package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
  65. package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
  66. package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
  67. package/dist-sdk/server/src/app/balance-message.service.js +24 -0
  68. package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
  69. package/dist-sdk/server/src/app/balance.module.js +4 -0
  70. package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
  71. package/dist-sdk/server/src/app/balance.service.js +54 -0
  72. package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
  73. package/dist-sdk/server/src/app/stripe.controller.js +35 -0
  74. package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
  75. package/dist-sdk/server/src/app/stripe.service.js +62 -0
  76. package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
  77. package/dist-sdk/server/src/app/transaction.service.js +36 -0
  78. package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
  79. package/dist-sdk/server/src/app/user-service-factory.js +46 -3
  80. package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
  81. package/dist-sdk/server/src/app/user-service-manager.js +43 -0
  82. package/dist-sdk/server/src/app.controller.d.ts +120 -0
  83. package/dist-sdk/server/src/app.controller.js +365 -14
  84. package/dist-sdk/server/src/app.module.js +28 -6
  85. package/dist-sdk/server/src/app.service.d.ts +1710 -4
  86. package/dist-sdk/server/src/app.service.js +1938 -20
  87. package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
  88. package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
  89. package/dist-sdk/server/src/auth/auth.controller.js +46 -0
  90. package/dist-sdk/server/src/auth/auth.module.js +3 -2
  91. package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
  92. package/dist-sdk/server/src/auth/auth.service.js +39 -3
  93. package/dist-sdk/server/src/auth/jwt-auth.guard.js +44 -0
  94. package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
  95. package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
  96. package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
  97. package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
  98. package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
  99. package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
  100. package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
  101. package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
  102. package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
  103. package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
  104. package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
  105. package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
  106. package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
  107. package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
  108. package/dist-sdk/server/src/auth/session.guard.js +8 -0
  109. package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
  110. package/dist-sdk/server/src/auth/twilio.service.js +30 -4
  111. package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
  112. package/dist-sdk/server/src/auth/users.service.js +42 -0
  113. package/dist-sdk/server/src/common/errors.d.ts +20 -0
  114. package/dist-sdk/server/src/common/errors.js +21 -0
  115. package/dist-sdk/server/src/config/env-config.d.ts +7 -0
  116. package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
  117. package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
  118. package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
  119. package/dist-sdk/server/src/config/user-config.service.js +57 -0
  120. package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
  121. package/dist-sdk/server/src/config/user-paths.service.js +67 -0
  122. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
  123. package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
  124. package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
  125. package/dist-sdk/server/src/packs/pack-instantiation.service.js +104 -0
  126. package/dist-sdk/server/src/packs/pack-manifest.d.ts +114 -0
  127. package/dist-sdk/server/src/packs/pack-manifest.js +69 -0
  128. package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
  129. package/dist-sdk/server/src/packs/pack.service.js +98 -1
  130. package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
  131. package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
  132. package/dist-sdk/server/src/room/artifact.d.ts +18 -0
  133. package/dist-sdk/server/src/room/illustration/illustration.service.d.ts +211 -0
  134. package/dist-sdk/server/src/room/illustration/illustration.service.js +771 -0
  135. package/dist-sdk/server/src/room/illustration/illustration.types.d.ts +101 -0
  136. package/dist-sdk/server/src/room/illustration/illustration.types.js +2 -0
  137. package/dist-sdk/server/src/room/message.d.ts +64 -0
  138. package/dist-sdk/server/src/room/message.js +77 -2
  139. package/dist-sdk/server/src/room/nickname.d.ts +26 -0
  140. package/dist-sdk/server/src/room/nickname.js +26 -0
  141. package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
  142. package/dist-sdk/server/src/room/room-config.d.ts +84 -1
  143. package/dist-sdk/server/src/room/room-config.js +19 -0
  144. package/dist-sdk/server/src/room/room-factory.d.ts +20 -0
  145. package/dist-sdk/server/src/room/room-factory.js +25 -0
  146. package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
  147. package/dist-sdk/server/src/room/room-message.service.js +28 -0
  148. package/dist-sdk/server/src/room/room-store.service.d.ts +184 -0
  149. package/dist-sdk/server/src/room/room-store.service.js +280 -6
  150. package/dist-sdk/server/src/room/room.d.ts +981 -1
  151. package/dist-sdk/server/src/room/room.js +1531 -27
  152. package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
  153. package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
  154. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +37 -0
  155. package/dist-sdk/server/src/rpg/rpg-roster.js +37 -0
  156. package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
  157. package/dist-sdk/server/src/rpg/rpg.service.js +108 -1
  158. package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
  159. package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
  160. package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
  161. package/dist-sdk/server/src/sdk/briyah.js +285 -7
  162. package/dist-sdk/server/src/sdk/index.js +23 -0
  163. package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
  164. package/dist-sdk/server/src/shared/shared.module.js +13 -5
  165. package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
  166. package/dist-sdk/server/src/story/story-message.service.js +43 -0
  167. package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
  168. package/dist-sdk/server/src/story/story-progress.service.js +23 -0
  169. package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
  170. package/dist-sdk/server/src/story/story-store.service.js +136 -1
  171. package/dist-sdk/server/src/story/story.service.d.ts +366 -9
  172. package/dist-sdk/server/src/story/story.service.js +825 -374
  173. package/dist-sdk/server/src/tools/core/illustrate.tool.d.ts +14 -0
  174. package/dist-sdk/server/src/tools/core/illustrate.tool.js +80 -0
  175. package/dist-sdk/server/src/tools/core/index.d.ts +22 -0
  176. package/dist-sdk/server/src/tools/core/index.js +24 -1
  177. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +8 -0
  178. package/dist-sdk/server/src/tools/core/rename.tool.js +11 -0
  179. package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
  180. package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
  181. package/dist-sdk/server/src/tools/native-tool.types.d.ts +266 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
  184. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
  185. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
  186. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
  187. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
  189. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
  190. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
  191. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
  193. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
  195. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
  196. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
  197. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
  198. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
  199. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
  201. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
  202. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
  203. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
  204. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
  205. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
  206. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
  207. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
  208. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
  209. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
  210. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
  211. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
  212. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
  213. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
  214. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
  215. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
  216. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
  217. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
  218. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
  219. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
  220. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
  221. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
  222. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
  223. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
  224. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
  225. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
  226. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
  227. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
  228. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
  229. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
  230. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
  231. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
  232. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
  233. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
  234. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
  235. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
  236. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
  237. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
  238. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
  239. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
  240. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
  241. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
  242. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +201 -0
  243. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +149 -0
  244. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
  245. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
  246. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
  247. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
  248. package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
  249. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
  250. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
  251. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
  252. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
  253. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
  254. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
  255. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
  256. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
  257. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
  258. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
  259. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
  260. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
  261. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
  262. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +194 -0
  263. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +263 -1
  264. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
  265. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +127 -2
  266. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
  267. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
  268. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
  269. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
  270. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  271. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
  272. package/dist-sdk/server/src/tools/packs/index.d.ts +49 -0
  273. package/dist-sdk/server/src/tools/packs/index.js +66 -0
  274. package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
  275. package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
  276. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +107 -3
  277. package/dist-sdk/server/src/tools/tool-execution.service.js +163 -19
  278. package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
  279. package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
  280. package/dist-sdk/shared/types/app.types.d.ts +328 -13
  281. package/dist-sdk/shared/types/app.types.js +18 -1
  282. package/package.json +167 -168
  283. package/data/common/config/random_words.txt +0 -2241
  284. package/data/common/story_ideas/biblical.json +0 -122
  285. package/data/common/story_ideas/fantasy.json +0 -82
  286. package/data/common/story_ideas/historical_fiction.json +0 -82
  287. package/data/common/story_ideas/science_fiction.json +0 -82
  288. package/docs/.nojekyll +0 -1
  289. package/docs/assets/hierarchy.js +0 -1
  290. package/docs/assets/highlight.css +0 -113
  291. package/docs/assets/icons.js +0 -18
  292. package/docs/assets/icons.svg +0 -1
  293. package/docs/assets/main.js +0 -60
  294. package/docs/assets/navigation.js +0 -1
  295. package/docs/assets/search.js +0 -1
  296. package/docs/assets/style.css +0 -1648
  297. package/docs/classes/Agent.html +0 -801
  298. package/docs/classes/Briyah.html +0 -296
  299. package/docs/classes/BriyahConfigService.html +0 -119
  300. package/docs/classes/NativeToolRegistry.html +0 -166
  301. package/docs/classes/PackInstantiationService.html +0 -157
  302. package/docs/classes/PackService.html +0 -247
  303. package/docs/classes/Room.html +0 -1434
  304. package/docs/classes/RoomMessage.html +0 -290
  305. package/docs/enums/MessageAction.html +0 -136
  306. package/docs/functions/availableToolPacks.html +0 -41
  307. package/docs/functions/buildMarkdown.html +0 -54
  308. package/docs/functions/dnd5eTools.html +0 -44
  309. package/docs/functions/installToolPacks.html +0 -51
  310. package/docs/functions/pageMarker.html +0 -45
  311. package/docs/functions/registerToolPacks.html +0 -54
  312. package/docs/functions/splitMarkdownIntoPages.html +0 -51
  313. package/docs/functions/stripWrappingFence.html +0 -52
  314. package/docs/hierarchy.html +0 -46
  315. package/docs/index.html +0 -595
  316. package/docs/interfaces/AgentCreationOptions.html +0 -125
  317. package/docs/interfaces/AgentInfo.html +0 -218
  318. package/docs/interfaces/AgentMessagesResponse.html +0 -74
  319. package/docs/interfaces/AppService.html +0 -3340
  320. package/docs/interfaces/Artifact.html +0 -95
  321. package/docs/interfaces/ArtifactMetadata.html +0 -112
  322. package/docs/interfaces/ArtifactWriteOptions.html +0 -90
  323. package/docs/interfaces/AttachDocumentResponse.html +0 -62
  324. package/docs/interfaces/BriyahConfigOptions.html +0 -124
  325. package/docs/interfaces/ChapterInfo.html +0 -62
  326. package/docs/interfaces/Character.html +0 -86
  327. package/docs/interfaces/ConversionAgent.html +0 -78
  328. package/docs/interfaces/CreateAgentResponse.html +0 -56
  329. package/docs/interfaces/CreateRoomResponse.html +0 -62
  330. package/docs/interfaces/CreateStoryResponse.html +0 -56
  331. package/docs/interfaces/FileList.html +0 -56
  332. package/docs/interfaces/FileMetadata.html +0 -89
  333. package/docs/interfaces/IConfigService.html +0 -79
  334. package/docs/interfaces/InstantiateModels.html +0 -64
  335. package/docs/interfaces/InstantiateRoomResult.html +0 -70
  336. package/docs/interfaces/LoadedPack.html +0 -131
  337. package/docs/interfaces/LoggingOptions.html +0 -92
  338. package/docs/interfaces/Message.html +0 -84
  339. package/docs/interfaces/ModelChoice.html +0 -73
  340. package/docs/interfaces/ModelInfo.html +0 -74
  341. package/docs/interfaces/NativeToolDefinition.html +0 -107
  342. package/docs/interfaces/PackAgentTemplate.html +0 -101
  343. package/docs/interfaces/PackRoomTemplate.html +0 -108
  344. package/docs/interfaces/PackView.html +0 -172
  345. package/docs/interfaces/PdfConversionOptions.html +0 -102
  346. package/docs/interfaces/PdfConversionResult.html +0 -97
  347. package/docs/interfaces/PdfMarkdownOptions.html +0 -198
  348. package/docs/interfaces/PdfMarkdownResult.html +0 -106
  349. package/docs/interfaces/PdfPageMarkdown.html +0 -94
  350. package/docs/interfaces/PreparedPromptResponse.html +0 -62
  351. package/docs/interfaces/ProcessTextResponse.html +0 -86
  352. package/docs/interfaces/PromptFile.html +0 -70
  353. package/docs/interfaces/PromptFileContent.html +0 -76
  354. package/docs/interfaces/PromptFilesResponse.html +0 -56
  355. package/docs/interfaces/PromptFolder.html +0 -80
  356. package/docs/interfaces/PromptFolderDefaults.html +0 -155
  357. package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
  358. package/docs/interfaces/PromptFoldersResponse.html +0 -56
  359. package/docs/interfaces/RoomDetails.html +0 -151
  360. package/docs/interfaces/RoomErrorUpdate.html +0 -82
  361. package/docs/interfaces/RoomInfo.html +0 -88
  362. package/docs/interfaces/RoomMessageUpdate.html +0 -113
  363. package/docs/interfaces/RoomMessagesResponse.html +0 -62
  364. package/docs/interfaces/SendMessageResult.html +0 -62
  365. package/docs/interfaces/StoryErrorEvent.html +0 -84
  366. package/docs/interfaces/StoryIdea.html +0 -74
  367. package/docs/interfaces/StoryInfo.html +0 -198
  368. package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
  369. package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
  370. package/docs/interfaces/StoryState.html +0 -108
  371. package/docs/interfaces/StoryStateEvent.html +0 -76
  372. package/docs/interfaces/ToolArtifact.html +0 -85
  373. package/docs/interfaces/ToolCaller.html +0 -77
  374. package/docs/interfaces/ToolDefinition.html +0 -80
  375. package/docs/interfaces/ToolHelpers.html +0 -105
  376. package/docs/interfaces/ToolPackDocuments.html +0 -100
  377. package/docs/interfaces/ToolParameter.html +0 -74
  378. package/docs/interfaces/ToolRoomAccess.html +0 -260
  379. package/docs/interfaces/ToolSummary.html +0 -74
  380. package/docs/interfaces/ToolsResponse.html +0 -68
  381. package/docs/interfaces/Transaction.html +0 -104
  382. package/docs/interfaces/TransactionHistoryResponse.html +0 -62
  383. package/docs/modules.html +0 -53
  384. package/docs/types/PackOrigin.html +0 -34
  385. package/docs/types/PromptScope.html +0 -34
  386. package/docs/types/RoomTurnMode.html +0 -42
  387. package/docs/types/RoomUpdate.html +0 -36
  388. package/docs/types/RosterOverrides.html +0 -42
  389. package/docs/types/ToolContext.html +0 -40
  390. package/docs/types/ToolRunResult.html +0 -34
  391. package/src/tools/packs/dnd5e/README.md +0 -867
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Which surface a session is for. Carried as the `mode` claim in the JWT, mirrored
3
+ * client-side, and also what a dedicated subdomain pins a visitor to.
4
+ *
5
+ * Presentational only. No server endpoint consults it — `ScopesGuard` reads `scope`
6
+ * and `OwnerOnly` reads `type` — so an 'rpg' session still reaches every @OwnerOnly
7
+ * route. `scope` is the field for authorization; do not start gating on this one.
8
+ */
1
9
  export type BriyahMode = 'agents' | 'stories' | 'rpg';
2
10
  export declare const BRIYAH_MODES: readonly BriyahMode[];
3
11
  export interface AgentInfo {
@@ -19,6 +27,16 @@ export interface AgentInfo {
19
27
  beginInstruction: string;
20
28
  toolNames: string[];
21
29
  useModerator?: boolean;
30
+ /**
31
+ * Whether this agent could be its room's moderator: it is not human-controlled,
32
+ * and its prompt folder provides a `moderate.prompt`.
33
+ *
34
+ * Derived from the agent's prompt folder rather than stored, and by the same check
35
+ * that refuses a room whose moderator cannot moderate — so a moderator the UI
36
+ * offers is never one the server will reject. Populated where an agent is being
37
+ * looked at on its own or as part of a room's roster; the top-level agent list
38
+ * leaves it absent, because "could moderate" is a question about a room.
39
+ */
22
40
  canModerate?: boolean;
23
41
  privateContext?: string;
24
42
  promptCacheTTL?: number;
@@ -26,11 +44,26 @@ export interface AgentInfo {
26
44
  smallModelName?: string;
27
45
  ownerRoomId?: string;
28
46
  attachedArtifactIds?: string[];
47
+ /**
48
+ * The pack this agent is filed under, or absent when it is not filed.
49
+ *
50
+ * Drives grouping and filtering in the lists. An agent naming a pack that is not
51
+ * installed stays visible: deleting a pack must not hide the work it produced.
52
+ */
29
53
  pack?: string;
30
54
  }
31
55
  export interface CreateAgentResponse {
32
56
  agentId: string;
33
57
  }
58
+ /**
59
+ * The body of `POST /api/agents`.
60
+ *
61
+ * Everything an agent needs, so creating one is a single request. It used to carry
62
+ * only the first ten fields, which made every agent holding a tool grant a
63
+ * two-step job: create, then reopen the edit form. The optional fields here are
64
+ * the same ones {@link UpdateAgentRequest} carries, so nothing is settable only
65
+ * after the fact.
66
+ */
34
67
  export interface CreateAgentRequest {
35
68
  aiServiceName: string;
36
69
  agentName: string;
@@ -50,6 +83,13 @@ export interface CreateAgentRequest {
50
83
  maxHistoryMessages?: number;
51
84
  smallModelName?: string;
52
85
  }
86
+ /**
87
+ * The body of `POST /api/rooms/:roomId/agents`.
88
+ *
89
+ * The same shape as {@link CreateAgentRequest}, except that `agentName` is the
90
+ * bare name. The server prefixes it with the room's name and derives the nickname
91
+ * from the bare name, so the prefix never becomes what the agent is addressed as.
92
+ */
53
93
  export type CreateRoomAgentRequest = CreateAgentRequest;
54
94
  export interface UpdateAgentRequest {
55
95
  agentNickname?: string;
@@ -66,6 +106,7 @@ export interface UpdateAgentRequest {
66
106
  promptCacheTTL?: number;
67
107
  maxHistoryMessages?: number;
68
108
  smallModelName?: string;
109
+ /** Files the agent under a pack. Empty string clears it. See {@link AgentInfo.pack}. */
69
110
  pack?: string;
70
111
  }
71
112
  export interface ToolParameter {
@@ -73,6 +114,13 @@ export interface ToolParameter {
73
114
  type: 'string' | 'number' | 'boolean' | 'object' | 'array';
74
115
  description: string;
75
116
  required: boolean;
117
+ /**
118
+ * The exact set of values this parameter accepts. Rendered into the agent's
119
+ * prompt beside the parameter and enforced before the tool runs, so a bad
120
+ * value comes back as a correctable error instead of reaching the handler.
121
+ * Compared case-sensitively against the string form of the argument.
122
+ */
123
+ enum?: string[];
76
124
  }
77
125
  export interface ToolDefinition {
78
126
  name: string;
@@ -80,6 +128,8 @@ export interface ToolDefinition {
80
128
  parameters: ToolParameter[];
81
129
  code: string;
82
130
  timeoutMs?: number;
131
+ /** Per-call result budget in characters. See {@link NativeToolDefinition.maxResultChars}. */
132
+ maxResultChars?: number;
83
133
  }
84
134
  export interface ToolSummary {
85
135
  name: string;
@@ -107,10 +157,43 @@ export interface RoomInfo {
107
157
  name: string;
108
158
  goal: string;
109
159
  agentCount: number;
160
+ /** The pack this room is filed under. See {@link AgentInfo.pack}. */
110
161
  pack?: string;
111
162
  totalCost?: number;
112
163
  }
164
+ /**
165
+ * How a room decides which agents respond to a message.
166
+ * - 'broadcast': every agent responds and one reply is selected. The default.
167
+ * - 'directed': only the message's targets respond (the room leader when there
168
+ * are none). Other agents still hear the message without generating a reply,
169
+ * which is what lets a leader agent control the order of a turn-based room.
170
+ */
113
171
  export type RoomTurnMode = 'broadcast' | 'directed';
172
+ /**
173
+ * When a room asks its illustrator for a picture.
174
+ * - 'off': never.
175
+ * - 'on-request': only when an agent calls the `illustrate` tool. The default.
176
+ * - 'auto': also whenever the scene changes, which is how stories behave.
177
+ *
178
+ * 'auto' is opt-in rather than the default because a game master that restates
179
+ * the situation on every response — as the dnd5e Dungeon Master is told to —
180
+ * would otherwise buy an image on every tool call.
181
+ */
182
+ export type RoomIllustrationMode = 'off' | 'on-request' | 'auto';
183
+ /**
184
+ * The `image_models.json` entry that means "draw nothing".
185
+ *
186
+ * A real entry rather than a blank, because turning pictures off for one room is a
187
+ * different intent from not choosing a model — a blank falls back to the server's
188
+ * `DEFAULT_IMAGE_MODEL`, and this does not.
189
+ *
190
+ * The client spells the same string out itself rather than importing this. A value
191
+ * import from here is not safe there: Vite resolves `.js` before `.ts` and this
192
+ * directory is gitignored for compiled output, so a stale `app.types.js` would hand
193
+ * the client `undefined` while type-checking passed against the `.ts`. Change this
194
+ * and `RoomSettings.svelte` has to change with it.
195
+ */
196
+ export declare const NO_IMAGES = "No images";
114
197
  export interface RoomDetails {
115
198
  id: string;
116
199
  name: string;
@@ -118,12 +201,33 @@ export interface RoomDetails {
118
201
  baseRoomDir?: string;
119
202
  agentIds: string[];
120
203
  agents?: AgentInfo[];
204
+ /** The pack this room is filed under. Editable. See {@link AgentInfo.pack}. */
121
205
  pack?: string;
122
206
  roomLeader?: string;
123
207
  turnMode?: RoomTurnMode;
208
+ /** Entry in image_models.json. Absent uses DEFAULT_IMAGE_MODEL; {@link NO_IMAGES} disables. */
209
+ imageModel?: string;
210
+ /** Absent means 'on-request'. See {@link RoomIllustrationMode}. */
211
+ illustrationMode?: RoomIllustrationMode;
212
+ /**
213
+ * Nickname of the agent that places messages it cannot route mechanically.
214
+ * Only consulted in 'moderated' mode. Absent falls back to the first agent in
215
+ * the room, which is how story rooms have always chosen their moderator.
216
+ */
124
217
  moderator?: string;
218
+ /**
219
+ * What Begin sends to the room leader to open the conversation. Blank or absent
220
+ * means the room offers no Begin. See `RoomConfig.beginInstruction`.
221
+ */
222
+ beginInstruction?: string;
125
223
  isPublished?: boolean;
126
224
  templateRoomId?: string;
225
+ /**
226
+ * Live turn state, the same fields {@link RoomMessageUpdate} carries over SSE.
227
+ * Without them a client that just loaded the page shows an idle room until the
228
+ * next update arrives, which for a turn-based room means it cannot tell whose
229
+ * turn it is until someone moves.
230
+ */
127
231
  isPaused?: boolean;
128
232
  currentSpeaker?: string | null;
129
233
  processingInProgress?: boolean;
@@ -132,20 +236,23 @@ export interface CreateRoomResponse {
132
236
  roomId: string;
133
237
  baseRoomDir?: string;
134
238
  }
239
+ /**
240
+ * Represents the action type of a message
241
+ */
135
242
  export declare enum MessageAction {
136
- THINK = "think",
137
- WHISPER = "whisper",
138
- SPEAK = "speak",
139
- SHOUT = "shout",
140
- MODERATE = "moderate",
141
- RELAY = "relay",
142
- RELAY_SILENT = "relay_silent",
143
- PUBLISH = "publish",
144
- EXECUTE = "execute",
145
- COMMISSION = "commission",
146
- DELIVER = "deliver",
147
- TOOL = "tool",
148
- ADJOURN = "adjourn",
243
+ THINK = "think",// Inaudible message, only stays in the history of the sender
244
+ WHISPER = "whisper",// Only specified targets can hear this message
245
+ SPEAK = "speak",// Every agent hears this message. Multiple agents may speak at once.
246
+ SHOUT = "shout",// Overrides all other conversations
247
+ MODERATE = "moderate",// Sent to moderator for routing (story rooms only)
248
+ RELAY = "relay",// Sent by moderator to the agents who should hear the message (logs to room)
249
+ RELAY_SILENT = "relay_silent",// Sent by moderator to route a message without logging to room
250
+ PUBLISH = "publish",// Publish new room artifact
251
+ EXECUTE = "execute",// Run a granted tool; result returns privately to the caller
252
+ COMMISSION = "commission",// Delegate a task to named agents; sender waits for all DELIVERs
253
+ DELIVER = "deliver",// Terminal response of a commissioned agent, targeted at the commissioner
254
+ TOOL = "tool",// Log-only notice of a tool execution (never perceived by agents)
255
+ ADJOURN = "adjourn",// Expresses an opinion to halt
149
256
  SYSTEM = "system"
150
257
  }
151
258
  export interface Message {
@@ -178,6 +285,7 @@ export interface AgentMessageUpdate {
178
285
  totalCost?: number;
179
286
  }
180
287
  export interface RoomMessageUpdate {
288
+ /** Discriminates this from {@link RoomErrorUpdate} on the same channel. */
181
289
  type?: 'state';
182
290
  roomId: string;
183
291
  latestMessage?: Message;
@@ -186,14 +294,32 @@ export interface RoomMessageUpdate {
186
294
  isPaused?: boolean;
187
295
  currentSpeaker?: string | null;
188
296
  processingInProgress?: boolean;
297
+ /**
298
+ * The room is idle pending the human agent's input.
299
+ *
300
+ * True while a human holds the floor, and *also* true for an idle room with no
301
+ * speaker, nothing queued and nothing in flight — including the moment between
302
+ * a message being accepted and processing starting. So it answers "may the
303
+ * human send something", not "is the human being asked something". For the
304
+ * latter, compare {@link currentSpeaker} against the human's nickname.
305
+ */
189
306
  waitingForHuman?: boolean;
190
307
  }
308
+ /**
309
+ * A turn that died, delivered on the room's `'update'` channel.
310
+ *
311
+ * Same event name as {@link RoomMessageUpdate} rather than `'error'`: an
312
+ * EventEmitter throws when an `'error'` event has no listener, which would take
313
+ * down a host that only subscribed to updates.
314
+ */
191
315
  export interface RoomErrorUpdate {
192
316
  type: 'error';
317
+ /** Error class name, e.g. `'InsufficientBalanceError'` */
193
318
  errorType?: string;
194
319
  message: string;
195
320
  timestamp: number;
196
321
  }
322
+ /** Everything a room's `'update'` event can carry. */
197
323
  export type RoomUpdate = RoomMessageUpdate | RoomErrorUpdate;
198
324
  export interface ModelInfo {
199
325
  name: string;
@@ -216,7 +342,9 @@ export interface StoryModelEntry {
216
342
  service: string;
217
343
  model: string;
218
344
  small_model?: string;
345
+ /** Service used for the moderator and illustrator agents. Falls back to `service` when omitted. */
219
346
  moderator_service?: string;
347
+ /** Model used for the moderator and illustrator agents. Falls back to `model` when omitted. */
220
348
  moderator_model?: string;
221
349
  cost: string;
222
350
  }
@@ -224,14 +352,19 @@ export interface StoryModelConfig {
224
352
  service: string;
225
353
  model: string;
226
354
  smallModel?: string;
355
+ /** Service for the moderator/illustrator agents (defaults to `service`). */
227
356
  moderatorService: string;
357
+ /** Model for the moderator/illustrator agents (defaults to `model`). */
228
358
  moderatorModel: string;
229
359
  }
230
360
  export type PromptScope = 'common' | 'user';
231
361
  export interface PromptFolder {
362
+ /** What to send back: `dungeon_master`, or `dnd5e:dungeon_master` for a pack's. */
232
363
  name: string;
233
364
  scope: PromptScope;
365
+ /** The pack this folder belongs to; absent for the user's own and common folders. */
234
366
  pack?: string;
367
+ /** The folder without its pack prefix. Absent when it equals `name`. */
235
368
  folder?: string;
236
369
  }
237
370
  export interface PromptFoldersResponse {
@@ -240,6 +373,7 @@ export interface PromptFoldersResponse {
240
373
  export interface PromptFile {
241
374
  name: string;
242
375
  scope: PromptScope;
376
+ /** The pack the file came from; absent for a user's own or a common file. */
243
377
  pack?: string;
244
378
  }
245
379
  export interface PromptFilesResponse {
@@ -248,20 +382,44 @@ export interface PromptFilesResponse {
248
382
  export interface FileList {
249
383
  files: string[];
250
384
  }
385
+ /**
386
+ * Which directory tier a prompt file came from.
387
+ *
388
+ * Finer than {@link PromptScope}, which only distinguishes the user's own files
389
+ * from shared ones. A `pack-overlay` file is the user's private copy-on-write
390
+ * edit of a `pack` file, so it reports `scope: 'user'` while being a different
391
+ * thing from a file in the user's own prompts directory.
392
+ */
251
393
  export type PromptTier = 'common' | 'user' | 'pack' | 'pack-overlay';
252
394
  export interface PromptFileContent {
253
395
  content: string;
254
396
  scope?: PromptScope;
397
+ /** The pack the file came from, set even when the folder was referenced bare. */
255
398
  pack?: string;
256
399
  tier?: PromptTier;
257
400
  }
401
+ /**
402
+ * Agent settings a prompt folder declares in its `defaults_config.json`, used to
403
+ * pre-fill the create-agent form when that folder is selected.
404
+ *
405
+ * Every field is optional and mirrors a field on the create-agent form. A folder
406
+ * that ships one spares the user having to know, for instance, which seven of the
407
+ * seventeen 5e tools a character creator needs.
408
+ */
258
409
  export interface PromptFolderDefaults {
259
410
  agentName?: string;
260
411
  agentNickname?: string;
261
412
  description?: string;
413
+ /** Names of the tools to grant. Names with no registered tool are dropped. */
262
414
  toolNames?: string[];
415
+ /**
416
+ * Artifact ids to offer as attachments, pre-ticked in the create-agent dialog.
417
+ * Ids that resolve to nothing are dropped. Attaching stays the user's choice:
418
+ * a document sits in the cached prefix of every call the agent makes.
419
+ */
263
420
  documentIds?: string[];
264
421
  reasoningEffort?: 'low' | 'medium' | 'high' | null;
422
+ /** Cap on a single response. 0 or absent leaves the provider's default. */
265
423
  maxOutputTokens?: number;
266
424
  beginInstruction?: string;
267
425
  allowSearch?: boolean;
@@ -273,8 +431,19 @@ export interface PromptFolderDefaults {
273
431
  smallModelName?: string;
274
432
  }
275
433
  export interface PromptFolderDefaultsResponse {
434
+ /** Empty when the folder declares no defaults, or its file could not be parsed. */
276
435
  defaults: PromptFolderDefaults;
436
+ /** Which directory the file was found in; omitted when there is no file. */
277
437
  scope?: PromptScope;
438
+ /**
439
+ * Whether the folder itself exists.
440
+ *
441
+ * Empty `defaults` says nothing on its own: a folder that declares none and a
442
+ * folder that is not there both have none. This is what tells the two apart —
443
+ * false means the reference will fall back to the shared root prompts and
444
+ * produce a generic agent. A bare name for a pack the user has not enabled
445
+ * reports false, because that is how it will behave.
446
+ */
278
447
  exists: boolean;
279
448
  }
280
449
  export interface CreatePromptFolderRequest {
@@ -289,8 +458,10 @@ export interface UpdatePromptFileRequest {
289
458
  content: string;
290
459
  fileType: 'prompt' | 'json';
291
460
  }
461
+ /** Who installed a pack, which decides whether the user may delete it. */
292
462
  export type PackOrigin = 'host' | 'user';
293
463
  export interface PackSummary {
464
+ /** Directory name, and the prefix on its prompt folders (`dnd5e:dungeon_master`). */
294
465
  pack: string;
295
466
  title: string;
296
467
  description?: string;
@@ -303,7 +474,9 @@ export interface PackSummary {
303
474
  agents: number;
304
475
  rooms: number;
305
476
  };
477
+ /** Tools the pack grants that the host has not registered. Non-empty means a warning. */
306
478
  missingTools: string[];
479
+ /** Packs it declares a dependency on that this user has not enabled. */
307
480
  missingPacks: string[];
308
481
  }
309
482
  export interface PacksResponse {
@@ -313,6 +486,7 @@ export interface PackAgentTemplateSummary {
313
486
  key: string;
314
487
  label: string;
315
488
  promptFolder: string;
489
+ /** Which model tier the template wants; supplied at instantiation. */
316
490
  modelRole?: 'primary' | 'economy';
317
491
  }
318
492
  export interface PackRoomTemplateSummary {
@@ -326,6 +500,7 @@ export interface PackDetails extends PackSummary {
326
500
  promptFolders: string[];
327
501
  agents: PackAgentTemplateSummary[];
328
502
  rooms: PackRoomTemplateSummary[];
503
+ /** Every tool the pack asks for, derived from its grants rather than declared. */
329
504
  requiresTools: string[];
330
505
  }
331
506
  export interface SetPackEnabledRequest {
@@ -335,19 +510,36 @@ export interface CreatePackRequest {
335
510
  name: string;
336
511
  title?: string;
337
512
  }
513
+ /**
514
+ * The models an instantiate request supplies.
515
+ *
516
+ * A pack's template names a *role* rather than a model, because a model id goes
517
+ * stale and assumes the host's provider keys. The caller says what each role means
518
+ * here. `economy` falls back to the primary when omitted, so one model is enough
519
+ * to get a working room — just not a cheap one.
520
+ */
338
521
  export interface InstantiateModelsRequest {
339
522
  aiServiceName: string;
340
523
  aiModel: string;
524
+ /** Same-service smaller model, used for mechanical prompts like compaction. */
341
525
  smallModelName?: string;
526
+ /** Service for `modelRole: 'economy'` agents. Defaults to `aiServiceName`. */
342
527
  economyServiceName?: string;
528
+ /** Model for `modelRole: 'economy'` agents. Omit to use the primary for everything. */
343
529
  economyModel?: string;
344
530
  }
345
531
  export interface InstantiatePackRoomRequest extends InstantiateModelsRequest {
532
+ /** Overrides the template's room name. Suffixed if it collides with an existing room. */
346
533
  name?: string;
347
534
  }
348
535
  export interface InstantiatePackRoomResponse {
349
536
  roomId: string;
350
537
  agentIds: string[];
538
+ /**
539
+ * What did not go as the template asked, without stopping the room — a document
540
+ * that failed to attach, for instance. Surfaced rather than swallowed: a document
541
+ * that silently fails to attach is a capability the agent appears to have.
542
+ */
351
543
  warnings: string[];
352
544
  }
353
545
  export interface InstantiatePackAgentRequest extends InstantiateModelsRequest {
@@ -358,51 +550,99 @@ export interface InstantiatePackAgentResponse {
358
550
  agentId: string;
359
551
  warnings: string[];
360
552
  }
553
+ /**
554
+ * One entry in `server/data/common/config/rpg_models.json`.
555
+ *
556
+ * The same list serves two dropdowns — the campaign's quality tier and each AI
557
+ * player's model — which is why an entry carries both roles. Host-wide config rather
558
+ * than pack content: it names model ids and assumes the host's provider keys, which a
559
+ * pack may not do.
560
+ */
361
561
  export interface RpgModelEntry {
562
+ /** The friendly name both dropdowns show and the API accepts. Unique in the file. */
362
563
  name: string;
363
564
  description: string;
364
565
  service: string;
566
+ /** An AI player's model, and the crew's `modelRole: 'primary'` — the Dungeon Master. */
365
567
  model: string;
568
+ /** Same-service smaller model, for mechanical prompts like compaction. */
366
569
  small_model?: string;
570
+ /** The `modelRole: 'economy'` tier: the four cheap crew agents. Falls back to primary. */
367
571
  economy_service?: string;
368
572
  economy_model?: string;
573
+ /** True for the entry the quality picker preselects. Expected on exactly one. */
369
574
  default_quality?: boolean;
575
+ /** Relative cost, as a string. Presentational, as {@link StoryModelEntry.cost} is. */
370
576
  cost: string;
371
577
  }
578
+ /**
579
+ * A model as the client is offered one.
580
+ *
581
+ * Projected down from {@link RpgModelEntry} rather than served as stored: the service
582
+ * and model id are the host's business, and a browser that never learns them cannot
583
+ * ask for one that is not on the list.
584
+ */
372
585
  export interface RpgModelOption {
373
586
  name: string;
374
587
  description: string;
375
588
  cost?: string;
589
+ /** True for the entry to preselect. */
376
590
  isDefault?: boolean;
377
591
  }
378
592
  export interface RpgPlayerRequest {
593
+ /**
594
+ * A seat, not a character.
595
+ *
596
+ * Deliberately unnamed: a player is seated as `Player One` and renamed to their
597
+ * character during character creation, once they have chosen one. Naming them
598
+ * here meant choosing a character before the game had told anyone what the
599
+ * choices were.
600
+ */
379
601
  isHuman: boolean;
602
+ /** An {@link RpgModelOption} name. Required when isHuman is false, unused when true. */
380
603
  modelName?: string;
604
+ /** How the character behaves, stored as the agent's privateContext. AI players only. */
381
605
  personality?: string;
382
606
  }
383
607
  export interface CreateRpgCampaignRequest {
384
608
  name: string;
609
+ /**
610
+ * An {@link RpgModelOption} name. Its model runs the Dungeon Master and its economy
611
+ * tier the other four crew agents. Absent takes the file's default.
612
+ */
385
613
  quality?: string;
614
+ /** In seating order. At least one, at least one of them human. */
386
615
  players: RpgPlayerRequest[];
387
616
  }
388
617
  export interface RpgPlayerInfo {
389
618
  agentId: string;
619
+ /** What the room routes by, and what the roster shows. */
390
620
  nickname: string;
391
621
  isHuman: boolean;
622
+ /** The friendly name, resolved back from the agent's service and model. */
392
623
  modelName?: string;
393
624
  personality?: string;
394
625
  totalCost: number;
395
626
  }
627
+ /** One of the hidden agents, so a campaign can say what is running its table. */
396
628
  export interface RpgCrewInfo {
397
629
  agentId: string;
398
630
  nickname: string;
631
+ /** The pack template's key: dungeon_master, battle_master, table_moderator, ... */
399
632
  role: string;
400
633
  }
401
634
  export interface RpgCampaignInfo {
635
+ /** The template room's id: what the campaign is, and what deleting it deletes. */
402
636
  campaignId: string;
403
637
  name: string;
638
+ /**
639
+ * The published instance's id — the public link, and the room that is actually
640
+ * played. Absent when the campaign has no instance, which only happens if one was
641
+ * deleted by hand.
642
+ */
404
643
  instanceId?: string;
405
644
  playerCount: number;
645
+ /** Nicknames in seating order, for a one-line roster in a listing. */
406
646
  playerNames: string[];
407
647
  totalCost: number;
408
648
  createdAt: string;
@@ -415,8 +655,10 @@ export interface RpgCampaignDetails extends RpgCampaignInfo {
415
655
  export interface CreateRpgCampaignResponse {
416
656
  campaignId: string;
417
657
  instanceId: string;
658
+ /** A path, never an absolute URL: the origin is the browser's business. */
418
659
  publicPath: string;
419
660
  players: RpgPlayerInfo[];
661
+ /** What did not go to plan without stopping the campaign, e.g. an unattached document. */
420
662
  warnings: string[];
421
663
  }
422
664
  export interface ProcessTextResponse {
@@ -443,7 +685,18 @@ export interface ArtifactMetadata {
443
685
  size: number;
444
686
  mimeType?: string;
445
687
  description?: string;
688
+ /**
689
+ * Where the artifact comes from. Absent means `'user'` — only documents shipped
690
+ * by a tool pack are `'common'`, and those are read-only.
691
+ */
446
692
  scope?: PromptScope;
693
+ /**
694
+ * The pack that ships this document, absent for a user's own artifact.
695
+ *
696
+ * Set server-side rather than parsed out of the id in the client: the id's shape
697
+ * is `pack-artifacts.ts`'s business, and a second implementation of the split is
698
+ * how the `.`-versus-`/` confusion spreads.
699
+ */
447
700
  pack?: string;
448
701
  }
449
702
  export interface Artifact {
@@ -503,6 +756,11 @@ export interface StoryInfo {
503
756
  totalOutputTokens: number;
504
757
  turnNumber: number;
505
758
  declinedCharacters?: string[];
759
+ /**
760
+ * Unacknowledged narrator suggestion. Persisted so clients that connect (or
761
+ * reconnect) after the narrator emits can still see the prompt. Cleared when
762
+ * the player accepts (`introduceCharacter` / `progressStory`) or declines.
763
+ */
506
764
  pendingSuggestion?: StoryIntroduceCharacterEvent | StoryProgressChapterEvent;
507
765
  }
508
766
  export interface CreateStoryResponse {
@@ -517,31 +775,78 @@ export interface StoryFrameworkResponse {
517
775
  }
518
776
  export interface StoryState {
519
777
  storyId: string;
778
+ /** The most recent message added to the room */
520
779
  latestRoomMessage: Message;
780
+ /** Agent name of the human player's character — compare to `currentSpeaker` to detect player turns */
521
781
  userAgentName: string;
782
+ /**
783
+ * UI display string for the player prompt, e.g. `"What does Elena do next?"`.
784
+ * Do **not** use this to detect whether it is the player's turn — use
785
+ * `currentSpeaker === userAgentName` instead.
786
+ */
522
787
  humanPrompt: string;
788
+ /** Agent name of whoever is next to act, or `null` if no specific speaker is designated */
523
789
  currentSpeaker?: string | null;
524
790
  totalCost: number;
525
791
  totalInputTokens: number;
526
792
  totalOutputTokens: number;
527
793
  }
794
+ /**
795
+ * Payload emitted on the `'story-state'` event of the story message emitter.
796
+ *
797
+ * Fires after every room turn with the complete updated game state.
798
+ *
799
+ * **Turn detection:** Use `state.currentSpeaker === state.userAgentName` to check
800
+ * whether it is the human player's turn. Do **not** use `state.humanPrompt` for
801
+ * this — it is a UI display string (e.g. `"What does Elena do next?"`) and is
802
+ * present even when it is not the player's turn.
803
+ */
528
804
  export interface StoryStateEvent {
529
805
  type: 'story-state';
530
806
  state: StoryState;
531
807
  timestamp: number;
532
808
  }
809
+ /**
810
+ * Payload emitted on the `'suggest-introduce-character'` event of the story message
811
+ * emitter. Fired when the narrator decides a new character should enter the story.
812
+ *
813
+ * The host app should present this to the player before acting:
814
+ * - **Accept:** call `introduceCharacterToStory({ name: event.characterName, fromNarratorSuggestion: true })`
815
+ * - **Reject:** call `declineCharacter(storyId, event.characterName)`
816
+ */
533
817
  export interface StoryIntroduceCharacterEvent {
534
818
  type: 'suggest-introduce-character';
819
+ /** Name of the character the narrator wants to introduce */
535
820
  characterName?: string;
536
821
  timestamp: number;
537
822
  }
823
+ /**
824
+ * Payload emitted on the `'suggest-progress-chapter'` event of the story message
825
+ * emitter. Fired when the narrator decides the story is ready to advance to the
826
+ * next chapter.
827
+ *
828
+ * The host app should present this to the player before acting:
829
+ * - **Accept:** call `progressStory(storyId)`
830
+ * - **Stay in current chapter:** ignore the event (no rejection call needed)
831
+ */
538
832
  export interface StoryProgressChapterEvent {
539
833
  type: 'suggest-progress-chapter';
540
834
  timestamp: number;
541
835
  }
836
+ /**
837
+ * Payload emitted on the `'story-error'` event of the story message emitter.
838
+ *
839
+ * Fired when the story engine encounters a fatal error during room processing.
840
+ * Named `'story-error'` rather than `'error'` to avoid the Node.js behaviour of
841
+ * throwing an uncaught exception when an `'error'` event has no listeners.
842
+ *
843
+ * Check `event.errorType === 'InsufficientBalanceError'` to detect balance failures
844
+ * and prompt the user to add credits.
845
+ */
542
846
  export interface StoryErrorEvent {
543
847
  type: 'story-error';
544
848
  message: string;
849
+ /** Error class name, e.g. `'InsufficientBalanceError'` */
545
850
  errorType?: string;
546
851
  timestamp: number;
547
852
  }
@@ -550,8 +855,18 @@ export interface ChaptersResponse {
550
855
  }
551
856
  export interface ProgressCharacterResponse {
552
857
  description?: string;
858
+ /**
859
+ * The updated profile body. Omitted by `progress_character` when
860
+ * `no_changes` is true (the existing profile is left untouched).
861
+ */
553
862
  character_profile?: string;
863
+ /** Updated inventory artifact body, if the character's items or conditions changed. */
554
864
  inventory?: string;
865
+ /**
866
+ * Set by `progress_character` when the character was not significantly
867
+ * affected by recent events. When true, the caller leaves the existing
868
+ * profile, inventory, and portrait unchanged.
869
+ */
555
870
  no_changes?: boolean;
556
871
  }
557
872
  export interface CreatePaymentIntentRequest {
@@ -1,7 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageAction = exports.BRIYAH_MODES = void 0;
3
+ exports.MessageAction = exports.NO_IMAGES = exports.BRIYAH_MODES = void 0;
4
4
  exports.BRIYAH_MODES = ['agents', 'stories', 'rpg'];
5
+ /**
6
+ * The `image_models.json` entry that means "draw nothing".
7
+ *
8
+ * A real entry rather than a blank, because turning pictures off for one room is a
9
+ * different intent from not choosing a model — a blank falls back to the server's
10
+ * `DEFAULT_IMAGE_MODEL`, and this does not.
11
+ *
12
+ * The client spells the same string out itself rather than importing this. A value
13
+ * import from here is not safe there: Vite resolves `.js` before `.ts` and this
14
+ * directory is gitignored for compiled output, so a stale `app.types.js` would hand
15
+ * the client `undefined` while type-checking passed against the `.ts`. Change this
16
+ * and `RoomSettings.svelte` has to change with it.
17
+ */
18
+ exports.NO_IMAGES = 'No images';
19
+ /**
20
+ * Represents the action type of a message
21
+ */
5
22
  var MessageAction;
6
23
  (function (MessageAction) {
7
24
  MessageAction["THINK"] = "think";