briyah 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (477) hide show
  1. package/LICENSE +216 -0
  2. package/README.md +43 -7
  3. package/data/common/config/LICENSE-model-prices.md +65 -0
  4. package/data/common/config/markup +1 -1
  5. package/data/common/config/model_prices.json +47443 -46295
  6. package/data/common/prompts/narrator/create_story.prompt +2 -0
  7. package/data/packs/dnd5e/agents/player.json +11 -11
  8. package/data/packs/dnd5e/prompts/character_creator/defaults_config.json +21 -20
  9. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +19 -12
  10. package/data/packs/dnd5e/prompts/dnd_player/perceive.prompt +10 -6
  11. package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
  12. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +173 -2
  13. package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +172 -3
  14. package/dist-sdk/server/src/ai/LLM/base-ai.service.js +241 -5
  15. package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
  16. package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
  17. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
  18. package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
  19. package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
  20. package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
  21. package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
  22. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +102 -3
  23. package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
  24. package/dist-sdk/server/src/ai/LLM/fal.service.js +55 -1
  25. package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
  26. package/dist-sdk/server/src/ai/LLM/googleai.service.js +42 -1
  27. package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
  28. package/dist-sdk/server/src/ai/LLM/grok.service.js +54 -2
  29. package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
  30. package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
  31. package/dist-sdk/server/src/ai/LLM/openai.service.js +80 -2
  32. package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
  33. package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +44 -2
  34. package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
  35. package/dist-sdk/server/src/ai/LLM/together.service.js +60 -2
  36. package/dist-sdk/server/src/ai/agent-config.d.ts +15 -0
  37. package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
  38. package/dist-sdk/server/src/ai/agent-factory.js +20 -0
  39. package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
  40. package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
  41. package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
  42. package/dist-sdk/server/src/ai/agent-store.service.js +166 -5
  43. package/dist-sdk/server/src/ai/agent.d.ts +196 -0
  44. package/dist-sdk/server/src/ai/agent.js +224 -11
  45. package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
  46. package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
  47. package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
  48. package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
  49. package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
  50. package/dist-sdk/server/src/ai/artifact.service.js +148 -3
  51. package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
  52. package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
  53. package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
  54. package/dist-sdk/server/src/ai/model_prices.js +91 -5
  55. package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
  56. package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
  57. package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
  58. package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
  59. package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
  60. package/dist-sdk/server/src/app/balance-message.service.js +24 -0
  61. package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
  62. package/dist-sdk/server/src/app/balance.module.js +4 -0
  63. package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
  64. package/dist-sdk/server/src/app/balance.service.js +54 -0
  65. package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
  66. package/dist-sdk/server/src/app/stripe.controller.js +35 -0
  67. package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
  68. package/dist-sdk/server/src/app/stripe.service.js +62 -0
  69. package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
  70. package/dist-sdk/server/src/app/transaction.service.js +36 -0
  71. package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
  72. package/dist-sdk/server/src/app/user-service-factory.js +38 -1
  73. package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
  74. package/dist-sdk/server/src/app/user-service-manager.js +43 -0
  75. package/dist-sdk/server/src/app.controller.d.ts +87 -0
  76. package/dist-sdk/server/src/app.controller.js +272 -12
  77. package/dist-sdk/server/src/app.module.js +28 -6
  78. package/dist-sdk/server/src/app.service.d.ts +1662 -0
  79. package/dist-sdk/server/src/app.service.js +1862 -6
  80. package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
  81. package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
  82. package/dist-sdk/server/src/auth/auth.controller.js +46 -0
  83. package/dist-sdk/server/src/auth/auth.module.js +3 -2
  84. package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
  85. package/dist-sdk/server/src/auth/auth.service.js +39 -3
  86. package/dist-sdk/server/src/auth/jwt-auth.guard.js +18 -0
  87. package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
  88. package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
  89. package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
  90. package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
  91. package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
  92. package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
  93. package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
  94. package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
  95. package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
  96. package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
  97. package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
  98. package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
  99. package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
  100. package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
  101. package/dist-sdk/server/src/auth/session.guard.js +8 -0
  102. package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
  103. package/dist-sdk/server/src/auth/twilio.service.js +30 -4
  104. package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
  105. package/dist-sdk/server/src/auth/users.service.js +42 -0
  106. package/dist-sdk/server/src/common/errors.d.ts +20 -0
  107. package/dist-sdk/server/src/common/errors.js +21 -0
  108. package/dist-sdk/server/src/config/env-config.d.ts +7 -0
  109. package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
  110. package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
  111. package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
  112. package/dist-sdk/server/src/config/user-config.service.js +57 -0
  113. package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
  114. package/dist-sdk/server/src/config/user-paths.service.js +67 -0
  115. package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
  116. package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
  117. package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
  118. package/dist-sdk/server/src/packs/pack-instantiation.service.js +99 -0
  119. package/dist-sdk/server/src/packs/pack-manifest.d.ts +100 -0
  120. package/dist-sdk/server/src/packs/pack-manifest.js +58 -0
  121. package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
  122. package/dist-sdk/server/src/packs/pack.service.js +98 -1
  123. package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
  124. package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
  125. package/dist-sdk/server/src/room/artifact.d.ts +18 -0
  126. package/dist-sdk/server/src/room/message.d.ts +64 -0
  127. package/dist-sdk/server/src/room/message.js +77 -2
  128. package/dist-sdk/server/src/room/nickname.d.ts +27 -0
  129. package/dist-sdk/server/src/room/nickname.js +41 -0
  130. package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
  131. package/dist-sdk/server/src/room/room-config.d.ts +26 -0
  132. package/dist-sdk/server/src/room/room-factory.d.ts +12 -0
  133. package/dist-sdk/server/src/room/room-factory.js +14 -0
  134. package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
  135. package/dist-sdk/server/src/room/room-message.service.js +28 -0
  136. package/dist-sdk/server/src/room/room-store.service.d.ts +177 -0
  137. package/dist-sdk/server/src/room/room-store.service.js +242 -5
  138. package/dist-sdk/server/src/room/room.d.ts +906 -1
  139. package/dist-sdk/server/src/room/room.js +1525 -34
  140. package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
  141. package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
  142. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +38 -3
  143. package/dist-sdk/server/src/rpg/rpg-roster.js +49 -49
  144. package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
  145. package/dist-sdk/server/src/rpg/rpg.service.js +108 -5
  146. package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
  147. package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
  148. package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
  149. package/dist-sdk/server/src/sdk/briyah.js +285 -7
  150. package/dist-sdk/server/src/sdk/index.d.ts +0 -1
  151. package/dist-sdk/server/src/sdk/index.js +24 -3
  152. package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
  153. package/dist-sdk/server/src/shared/shared.module.js +13 -5
  154. package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
  155. package/dist-sdk/server/src/story/story-message.service.js +43 -0
  156. package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
  157. package/dist-sdk/server/src/story/story-progress.service.js +23 -0
  158. package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
  159. package/dist-sdk/server/src/story/story-store.service.js +136 -1
  160. package/dist-sdk/server/src/story/story.service.d.ts +398 -0
  161. package/dist-sdk/server/src/story/story.service.js +829 -25
  162. package/dist-sdk/server/src/tools/core/index.d.ts +25 -0
  163. package/dist-sdk/server/src/tools/core/index.js +31 -0
  164. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +10 -0
  165. package/dist-sdk/server/src/tools/core/rename.tool.js +72 -0
  166. package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
  167. package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
  168. package/dist-sdk/server/src/tools/native-tool.types.d.ts +186 -0
  169. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
  170. package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
  171. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
  172. package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
  173. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
  174. package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
  175. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
  176. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
  177. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
  178. package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
  179. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
  180. package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
  181. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
  182. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
  183. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
  184. package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
  185. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
  186. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
  187. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
  188. package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
  189. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
  190. package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
  191. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
  192. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
  193. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
  194. package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
  195. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
  196. package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
  197. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
  198. package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
  199. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
  200. package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
  201. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
  202. package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
  203. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
  204. package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
  205. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
  206. package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
  207. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
  208. package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
  209. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
  210. package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
  211. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
  212. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
  213. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
  214. package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
  215. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
  216. package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
  217. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
  218. package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
  219. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
  220. package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
  221. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
  222. package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
  223. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
  224. package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
  225. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
  226. package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
  227. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
  228. package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
  229. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +192 -0
  230. package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +144 -0
  231. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
  232. package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
  233. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
  234. package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
  235. package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
  236. package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
  237. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
  238. package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
  239. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
  240. package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
  241. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
  242. package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
  243. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
  244. package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
  245. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
  246. package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
  247. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
  248. package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
  249. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +164 -0
  250. package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +188 -1
  251. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
  252. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +125 -1
  253. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
  254. package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
  255. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
  256. package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
  257. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
  258. package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
  259. package/dist-sdk/server/src/tools/packs/index.d.ts +52 -2
  260. package/dist-sdk/server/src/tools/packs/index.js +83 -9
  261. package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
  262. package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
  263. package/dist-sdk/server/src/tools/tool-execution.service.d.ts +73 -0
  264. package/dist-sdk/server/src/tools/tool-execution.service.js +74 -0
  265. package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
  266. package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
  267. package/dist-sdk/shared/types/app.types.d.ts +285 -14
  268. package/dist-sdk/shared/types/app.types.js +3 -0
  269. package/package.json +167 -139
  270. package/data/common/config/random_words.txt +0 -2241
  271. package/data/common/story_ideas/biblical.json +0 -122
  272. package/data/common/story_ideas/fantasy.json +0 -82
  273. package/data/common/story_ideas/historical_fiction.json +0 -82
  274. package/data/common/story_ideas/science_fiction.json +0 -82
  275. package/data/packs/acts/agents/character-guide.json +0 -6
  276. package/data/packs/acts/agents/discipleship-mentor.json +0 -6
  277. package/data/packs/acts/agents/mentor-coach.json +0 -6
  278. package/data/packs/acts/agents/student.json +0 -13
  279. package/data/packs/acts/agents/table-moderator.json +0 -6
  280. package/data/packs/acts/artifacts/chapter-01-acts-1.md +0 -405
  281. package/data/packs/acts/artifacts/chapter-02-acts-2.md +0 -443
  282. package/data/packs/acts/artifacts/chapter-03-acts-3.md +0 -409
  283. package/data/packs/acts/artifacts/chapter-04-acts-4.md +0 -438
  284. package/data/packs/acts/artifacts/chapter-05-acts-5.md +0 -434
  285. package/data/packs/acts/artifacts/chapter-06-acts-6.md +0 -441
  286. package/data/packs/acts/artifacts/chapter-07-acts-7.md +0 -472
  287. package/data/packs/acts/artifacts/chapter-08-acts-8.md +0 -512
  288. package/data/packs/acts/artifacts/chapter-09-acts-9.md +0 -346
  289. package/data/packs/acts/artifacts/chapter-10-acts-10.md +0 -367
  290. package/data/packs/acts/artifacts/chapter-11-acts-11.md +0 -391
  291. package/data/packs/acts/artifacts/chapter-12-acts-12.md +0 -390
  292. package/data/packs/acts/artifacts/chapter-13-acts-13.md +0 -388
  293. package/data/packs/acts/artifacts/chapter-14-acts-14.md +0 -466
  294. package/data/packs/acts/artifacts/chapter-15-acts-15.md +0 -413
  295. package/data/packs/acts/artifacts/chapter-16-acts-16.md +0 -585
  296. package/data/packs/acts/artifacts/chapter-17-acts-17.md +0 -428
  297. package/data/packs/acts/artifacts/chapter-18-acts-18.md +0 -486
  298. package/data/packs/acts/artifacts/chapter-19-acts-19.md +0 -461
  299. package/data/packs/acts/artifacts/chapter-20-acts-20.md +0 -389
  300. package/data/packs/acts/artifacts/chapter-21-acts-21.md +0 -452
  301. package/data/packs/acts/artifacts/chapter-22-acts-22.md +0 -424
  302. package/data/packs/acts/artifacts/chapter-23-acts-23.md +0 -395
  303. package/data/packs/acts/artifacts/chapter-24-acts-24.md +0 -446
  304. package/data/packs/acts/artifacts/chapter-25-acts-25.md +0 -391
  305. package/data/packs/acts/artifacts/chapter-26-acts-26.md +0 -431
  306. package/data/packs/acts/artifacts/chapter-27-acts-27.md +0 -530
  307. package/data/packs/acts/artifacts/chapter-28-acts-28.md +0 -1871
  308. package/data/packs/acts/artifacts/chapters.manifest.json +0 -170
  309. package/data/packs/acts/artifacts/character_guide-creation.md +0 -112
  310. package/data/packs/acts/artifacts/discipleship_mentor-procedure.md +0 -154
  311. package/data/packs/acts/artifacts/discipleship_mentor-systems.md +0 -72
  312. package/data/packs/acts/artifacts/manifest.json +0 -197
  313. package/data/packs/acts/artifacts/stage-guide.md +0 -94
  314. package/data/packs/acts/pack.json +0 -6
  315. package/data/packs/acts/prompts/acts_player/defaults_config.json +0 -5
  316. package/data/packs/acts/prompts/acts_player/perceive.json +0 -29
  317. package/data/packs/acts/prompts/acts_player/perceive.prompt +0 -87
  318. package/data/packs/acts/prompts/acts_player/system_instruction.prompt +0 -0
  319. package/data/packs/acts/prompts/acts_room_moderator/defaults_config.json +0 -9
  320. package/data/packs/acts/prompts/acts_room_moderator/moderate.json +0 -34
  321. package/data/packs/acts/prompts/acts_room_moderator/moderate.prompt +0 -70
  322. package/data/packs/acts/prompts/acts_room_moderator/system_instruction.prompt +0 -0
  323. package/data/packs/acts/prompts/character_guide/defaults_config.json +0 -18
  324. package/data/packs/acts/prompts/character_guide/perceive.json +0 -29
  325. package/data/packs/acts/prompts/character_guide/perceive.prompt +0 -140
  326. package/data/packs/acts/prompts/character_guide/system_instruction.prompt +0 -0
  327. package/data/packs/acts/prompts/discipleship_mentor/defaults_config.json +0 -23
  328. package/data/packs/acts/prompts/discipleship_mentor/perceive.json +0 -33
  329. package/data/packs/acts/prompts/discipleship_mentor/perceive.prompt +0 -245
  330. package/data/packs/acts/prompts/discipleship_mentor/system_instruction.prompt +0 -0
  331. package/data/packs/acts/prompts/mentor_coach/defaults_config.json +0 -13
  332. package/data/packs/acts/prompts/mentor_coach/perceive.json +0 -29
  333. package/data/packs/acts/prompts/mentor_coach/perceive.prompt +0 -87
  334. package/data/packs/acts/prompts/mentor_coach/system_instruction.prompt +0 -0
  335. package/data/packs/acts/rooms/session.json +0 -14
  336. package/data/packs/acts/rooms/training.json +0 -58
  337. package/dist-sdk/server/src/tools/packs/acts/data/cards.d.ts +0 -53
  338. package/dist-sdk/server/src/tools/packs/acts/data/cards.js +0 -54
  339. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.d.ts +0 -2
  340. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.js +0 -185
  341. package/dist-sdk/server/src/tools/packs/acts/data/encounters.d.ts +0 -12
  342. package/dist-sdk/server/src/tools/packs/acts/data/encounters.js +0 -102
  343. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.d.ts +0 -2
  344. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.js +0 -196
  345. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.d.ts +0 -2
  346. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.js +0 -1311
  347. package/dist-sdk/server/src/tools/packs/acts/engine/cards.d.ts +0 -5
  348. package/dist-sdk/server/src/tools/packs/acts/engine/cards.js +0 -27
  349. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.d.ts +0 -37
  350. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.js +0 -120
  351. package/dist-sdk/server/src/tools/packs/acts/engine/dice.d.ts +0 -20
  352. package/dist-sdk/server/src/tools/packs/acts/engine/dice.js +0 -41
  353. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.d.ts +0 -54
  354. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.js +0 -200
  355. package/dist-sdk/server/src/tools/packs/acts/index.d.ts +0 -2
  356. package/dist-sdk/server/src/tools/packs/acts/index.js +0 -24
  357. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.d.ts +0 -2
  358. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.js +0 -184
  359. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.d.ts +0 -2
  360. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.js +0 -107
  361. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.d.ts +0 -3
  362. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.js +0 -146
  363. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.d.ts +0 -4
  364. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.js +0 -241
  365. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.d.ts +0 -3
  366. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.js +0 -72
  367. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.d.ts +0 -2
  368. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.js +0 -75
  369. package/dist-sdk/server/src/tools/packs/acts/tools/shared.d.ts +0 -20
  370. package/dist-sdk/server/src/tools/packs/acts/tools/shared.js +0 -70
  371. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.d.ts +0 -4
  372. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.js +0 -215
  373. package/docs/.nojekyll +0 -1
  374. package/docs/assets/hierarchy.js +0 -1
  375. package/docs/assets/highlight.css +0 -113
  376. package/docs/assets/icons.js +0 -18
  377. package/docs/assets/icons.svg +0 -1
  378. package/docs/assets/main.js +0 -60
  379. package/docs/assets/navigation.js +0 -1
  380. package/docs/assets/search.js +0 -1
  381. package/docs/assets/style.css +0 -1648
  382. package/docs/classes/Agent.html +0 -801
  383. package/docs/classes/Briyah.html +0 -296
  384. package/docs/classes/BriyahConfigService.html +0 -119
  385. package/docs/classes/NativeToolRegistry.html +0 -166
  386. package/docs/classes/PackInstantiationService.html +0 -157
  387. package/docs/classes/PackService.html +0 -247
  388. package/docs/classes/Room.html +0 -1338
  389. package/docs/classes/RoomMessage.html +0 -290
  390. package/docs/enums/MessageAction.html +0 -136
  391. package/docs/functions/actsTools.html +0 -44
  392. package/docs/functions/availableToolPacks.html +0 -41
  393. package/docs/functions/buildMarkdown.html +0 -54
  394. package/docs/functions/dnd5eTools.html +0 -44
  395. package/docs/functions/installToolPacks.html +0 -48
  396. package/docs/functions/pageMarker.html +0 -45
  397. package/docs/functions/registerToolPacks.html +0 -54
  398. package/docs/functions/splitMarkdownIntoPages.html +0 -51
  399. package/docs/functions/stripWrappingFence.html +0 -52
  400. package/docs/hierarchy.html +0 -46
  401. package/docs/index.html +0 -595
  402. package/docs/interfaces/AgentCreationOptions.html +0 -125
  403. package/docs/interfaces/AgentInfo.html +0 -218
  404. package/docs/interfaces/AgentMessagesResponse.html +0 -74
  405. package/docs/interfaces/AppService.html +0 -3337
  406. package/docs/interfaces/Artifact.html +0 -95
  407. package/docs/interfaces/ArtifactMetadata.html +0 -112
  408. package/docs/interfaces/ArtifactWriteOptions.html +0 -90
  409. package/docs/interfaces/AttachDocumentResponse.html +0 -62
  410. package/docs/interfaces/BriyahConfigOptions.html +0 -124
  411. package/docs/interfaces/ChapterInfo.html +0 -62
  412. package/docs/interfaces/Character.html +0 -86
  413. package/docs/interfaces/ConversionAgent.html +0 -78
  414. package/docs/interfaces/CreateAgentResponse.html +0 -56
  415. package/docs/interfaces/CreateRoomResponse.html +0 -62
  416. package/docs/interfaces/CreateStoryResponse.html +0 -56
  417. package/docs/interfaces/FileList.html +0 -56
  418. package/docs/interfaces/FileMetadata.html +0 -89
  419. package/docs/interfaces/IConfigService.html +0 -79
  420. package/docs/interfaces/InstantiateModels.html +0 -64
  421. package/docs/interfaces/InstantiateRoomResult.html +0 -70
  422. package/docs/interfaces/LoadedPack.html +0 -131
  423. package/docs/interfaces/LoggingOptions.html +0 -92
  424. package/docs/interfaces/Message.html +0 -84
  425. package/docs/interfaces/ModelChoice.html +0 -73
  426. package/docs/interfaces/ModelInfo.html +0 -74
  427. package/docs/interfaces/NativeToolDefinition.html +0 -107
  428. package/docs/interfaces/PackAgentTemplate.html +0 -101
  429. package/docs/interfaces/PackRoomTemplate.html +0 -108
  430. package/docs/interfaces/PackView.html +0 -172
  431. package/docs/interfaces/PdfConversionOptions.html +0 -102
  432. package/docs/interfaces/PdfConversionResult.html +0 -97
  433. package/docs/interfaces/PdfMarkdownOptions.html +0 -198
  434. package/docs/interfaces/PdfMarkdownResult.html +0 -106
  435. package/docs/interfaces/PdfPageMarkdown.html +0 -94
  436. package/docs/interfaces/PreparedPromptResponse.html +0 -62
  437. package/docs/interfaces/ProcessTextResponse.html +0 -86
  438. package/docs/interfaces/PromptFile.html +0 -70
  439. package/docs/interfaces/PromptFileContent.html +0 -76
  440. package/docs/interfaces/PromptFilesResponse.html +0 -56
  441. package/docs/interfaces/PromptFolder.html +0 -80
  442. package/docs/interfaces/PromptFolderDefaults.html +0 -155
  443. package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
  444. package/docs/interfaces/PromptFoldersResponse.html +0 -56
  445. package/docs/interfaces/RoomDetails.html +0 -151
  446. package/docs/interfaces/RoomErrorUpdate.html +0 -82
  447. package/docs/interfaces/RoomInfo.html +0 -88
  448. package/docs/interfaces/RoomMessageUpdate.html +0 -113
  449. package/docs/interfaces/RoomMessagesResponse.html +0 -62
  450. package/docs/interfaces/SendMessageResult.html +0 -62
  451. package/docs/interfaces/StoryErrorEvent.html +0 -84
  452. package/docs/interfaces/StoryIdea.html +0 -74
  453. package/docs/interfaces/StoryInfo.html +0 -198
  454. package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
  455. package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
  456. package/docs/interfaces/StoryState.html +0 -108
  457. package/docs/interfaces/StoryStateEvent.html +0 -76
  458. package/docs/interfaces/ToolArtifact.html +0 -85
  459. package/docs/interfaces/ToolCaller.html +0 -77
  460. package/docs/interfaces/ToolDefinition.html +0 -80
  461. package/docs/interfaces/ToolHelpers.html +0 -105
  462. package/docs/interfaces/ToolPackDocuments.html +0 -100
  463. package/docs/interfaces/ToolParameter.html +0 -74
  464. package/docs/interfaces/ToolRoomAccess.html +0 -227
  465. package/docs/interfaces/ToolSummary.html +0 -74
  466. package/docs/interfaces/ToolsResponse.html +0 -68
  467. package/docs/interfaces/Transaction.html +0 -104
  468. package/docs/interfaces/TransactionHistoryResponse.html +0 -62
  469. package/docs/modules.html +0 -53
  470. package/docs/types/PackOrigin.html +0 -34
  471. package/docs/types/PromptScope.html +0 -34
  472. package/docs/types/RoomTurnMode.html +0 -42
  473. package/docs/types/RoomUpdate.html +0 -36
  474. package/docs/types/RosterOverrides.html +0 -42
  475. package/docs/types/ToolContext.html +0 -40
  476. package/docs/types/ToolRunResult.html +0 -34
  477. package/src/tools/packs/dnd5e/README.md +0 -867
@@ -29,29 +29,78 @@ import { AgentInfo, RoomInfo, RoomDetails, RoomTurnMode, CreateRoomResponse, Cre
29
29
  import { RoomMessage } from './room/message';
30
30
  import { ToolStoreService } from './tools/tool-store.service';
31
31
  import { ToolExecutionService } from './tools/tool-execution.service';
32
+ /**
33
+ * Agent settings that {@link AppService.createAgent} takes as an object rather
34
+ * than a positional parameter.
35
+ *
36
+ * The positional list is public SDK surface and stops at ten, so everything since
37
+ * lives here. Each of these is also settable through {@link AppService.updateAgent},
38
+ * which is the point: an agent that needs a tool grant should not have to be
39
+ * created and then edited.
40
+ */
32
41
  export interface AgentCreationOptions {
42
+ /** Enable the provider's web search, where it has one. */
33
43
  allowSearch?: boolean;
44
+ /** Names of tools this agent may run with EXECUTE. */
34
45
  toolNames?: string[];
46
+ /**
47
+ * This agent sends MODERATE messages, so its room needs a moderator. For a
48
+ * human-controlled agent it also removes the action and target pickers from
49
+ * the room's composer. See {@link Agent.useModerator}.
50
+ */
35
51
  useModerator?: boolean;
52
+ /** Notes only this agent sees. */
36
53
  privateContext?: string;
54
+ /** Minutes to keep the prompt cache alive; above 5 selects the 1-hour cache. */
37
55
  promptCacheTTL?: number;
56
+ /** Rolling history window: keep only the last N messages. */
38
57
  maxHistoryMessages?: number;
58
+ /** A cheaper same-service model for mechanical prompts. */
39
59
  smallModelName?: string;
60
+ /**
61
+ * The room this agent exists for. An owned agent is left out of
62
+ * {@link AppService.listAgents} and deleted with its room.
63
+ */
40
64
  ownerRoomId?: string;
41
65
  }
66
+ /**
67
+ * How {@link AppService.convertPdfToMarkdownPages} should run.
68
+ *
69
+ * The limits are inherited from {@link PdfConversionOptions}; everything added
70
+ * here is about *which* agent does the converting and what it is told.
71
+ */
42
72
  export interface PdfMarkdownOptions extends PdfConversionOptions {
73
+ /** Overrides `DOC_CONVERSION_AI_SERVICE`. */
43
74
  aiServiceName?: string;
75
+ /** Overrides `DOC_CONVERSION_AI_MODEL`. */
44
76
  aiModel?: string;
77
+ /**
78
+ * The prompt folder holding the conversion prompt. Defaults to `pdf_converter`.
79
+ *
80
+ * A host with its own transcription prompt points at its own folder — including
81
+ * a pack-qualified one — and keeps Briyah's concurrency, retry and assembly.
82
+ */
45
83
  promptFolder?: string;
84
+ /** The prompt file within that folder. Defaults to `convert_pdf_page`. */
46
85
  promptFile?: string;
86
+ /** Shown in logs and cost reports. Defaults to `PDF Converter`. */
47
87
  agentName?: string;
48
88
  reasoningEffort?: 'low' | 'medium' | 'high' | null;
89
+ /** Noun phrase completing "Convert this page from ___", e.g. `a fleet schedule`. */
49
90
  documentType?: string;
91
+ /** What must survive verbatim, e.g. `chapter and verse numbers`. */
50
92
  fidelityHints?: string;
93
+ /** Plural noun for the document's records, e.g. `vehicle rows`. Adds a don't-drop warning. */
51
94
  rowNoun?: string;
95
+ /** Further Handlebars variables for a caller's own prompt. */
52
96
  variables?: Record<string, unknown>;
97
+ /**
98
+ * Finish each page's agent once it has answered. Defaults to true. Pass false
99
+ * when the caller wants to read costs off the agents and dispose of them itself.
100
+ */
53
101
  finishAgents?: boolean;
54
102
  }
103
+ /** A finished conversion, with the agents typed as Briyah's own. */
55
104
  export interface PdfMarkdownResult extends Omit<PdfConversionResult, 'agents'> {
56
105
  agents: Agent[];
57
106
  }
@@ -79,23 +128,184 @@ export declare class AppService {
79
128
  private aiServices;
80
129
  private readonly userPreferencesFile;
81
130
  constructor(aiFactoryService: AiFactoryService, agentStore: AgentStoreService, agentMessageService: AgentMessageService, roomStore: RoomStoreService, roomMessageService: RoomMessageService, userPaths: UserPathsService, attachedFileService: AttachedFileService, artifactService: ArtifactService, storyStore: StoryStoreService, storyService: StoryService, publishedAgentsService: PublishedAgentsService, publishedRoomsService: PublishedRoomsService, balanceService: BalanceService, balanceMessageService: BalanceMessageService, transactionService: TransactionService, agentFactory: AgentFactory, roomFactory: RoomFactory, toolStore: ToolStoreService, toolExecution: ToolExecutionService, packService: PackService);
131
+ /** Packs, as this user sees them. */
82
132
  get packs(): PackService;
83
133
  private packInstantiationService?;
134
+ /**
135
+ * Supplies the service that builds agents and rooms from pack templates.
136
+ *
137
+ * Set after construction rather than injected: it drives this service, so it
138
+ * cannot also be one of its constructor arguments.
139
+ */
84
140
  setPackInstantiation(service: PackInstantiationService): void;
141
+ /** Builds agents and rooms from pack templates. */
85
142
  get packInstantiation(): PackInstantiationService;
86
143
  private rpgCampaignService?;
144
+ /**
145
+ * Supplies the service that builds and reads campaigns.
146
+ *
147
+ * Set after construction for the same reason pack instantiation is: it drives
148
+ * this service, so it cannot also be one of its constructor arguments.
149
+ */
87
150
  setRpg(service: RpgService): void;
151
+ /** Campaigns: the streamlined D&D surface, built on packs and published rooms. */
88
152
  get rpg(): RpgService;
153
+ /**
154
+ * The packs this user has enabled, as a thunk.
155
+ *
156
+ * Handed to the prompt resolver and to every agent this service creates. A
157
+ * thunk rather than an array because both outlive a toggle — see
158
+ * {@link Agent.enabledPacks}.
159
+ */
89
160
  readonly enabledPacks: () => readonly string[];
161
+ /**
162
+ * Returns the names of all available AI service providers.
163
+ *
164
+ * Only providers that have a configured API key are included.
165
+ *
166
+ * @returns Array of provider names (e.g. `'Anthropic'`, `'OpenAI'`, `'GoogleAI'`)
167
+ */
90
168
  getAiServiceNames(): string[];
169
+ /**
170
+ * Returns the AI service instance for the given provider name.
171
+ *
172
+ * @internal Returns a framework-level service; SDK consumers should use
173
+ * {@link listAiModels} or higher-level methods rather than handling
174
+ * `BaseAiService` directly.
175
+ * @param serviceName - Provider name as returned by {@link getAiServiceNames}
176
+ * @returns The corresponding AI service instance
177
+ * @throws {Error} If the service name is not recognized
178
+ */
91
179
  getAiServiceFromServiceName(serviceName: string): BaseAiService;
180
+ /**
181
+ * Fetches available models from the specified AI service provider.
182
+ *
183
+ * @param aiServiceName - Provider name as returned by {@link getAiServiceNames}
184
+ * @returns Array of model descriptors including name, description, and service
185
+ */
92
186
  listAiModels(aiServiceName: string): Promise<ModelInfo[]>;
187
+ /**
188
+ * Returns models available for image generation, as configured in
189
+ * `common/config/image_models.json`.
190
+ *
191
+ * @returns Array of model descriptors. Returns an empty array if the config file is missing.
192
+ */
93
193
  listImageModels(): Promise<ImageModelOption[]>;
194
+ /**
195
+ * Returns models available for story generation, as configured in
196
+ * `common/config/story_models.json`.
197
+ *
198
+ * @returns Array of model descriptors. Returns an empty array if the config file is missing.
199
+ */
94
200
  listStoryModels(): Promise<ModelInfo[]>;
201
+ /**
202
+ * Returns the available story genre names.
203
+ *
204
+ * Genres are read from `common/story_ideas/` - each `.json` file corresponds to a genre.
205
+ * Pass a genre name to {@link getRandomStoryIdeaByGenre} to get a story idea.
206
+ *
207
+ * @returns Array of genre names (e.g. `['fantasy', 'sci-fi', 'mystery']`)
208
+ */
95
209
  listStoryGenres(): string[];
210
+ /**
211
+ * Returns a random story idea from the specified genre.
212
+ *
213
+ * @param genreName - Genre name as returned by {@link listStoryGenres} (e.g. `'fantasy'`)
214
+ * @returns A random `StoryIdea` object, or `null` if the genre file is empty
215
+ * @throws {NotFoundError} If the genre does not exist
216
+ * @throws {OperationFailedError} If the genre file cannot be read
217
+ */
96
218
  getRandomStoryIdeaByGenre(genreName: string): StoryIdea | null;
219
+ /**
220
+ * Returns a random story idea from a randomly selected genre.
221
+ *
222
+ * @returns A random `StoryIdea` object, or `null` if no genres/ideas are available
223
+ */
97
224
  getRandomStoryIdea(): StoryIdea | null;
225
+ /**
226
+ * Creates a new AI agent and registers it in memory.
227
+ *
228
+ * The agent is immediately findable by ID but **not** persisted to disk.
229
+ * Call `agent.save()` when you want to write it to storage.
230
+ *
231
+ * @param aiServiceName - Provider name (e.g. `'Anthropic'`, `'OpenAI'`). Use {@link getAiServiceNames} for valid values.
232
+ * @param agentName - Full name of the agent (used in conversation logs and file storage)
233
+ * @param agentNickname - Short display name shown in the UI
234
+ * @param description - Brief description of the agent's role or personality
235
+ * @param aiModel - Model identifier (e.g. `'claude-haiku-4-5'`, `'gpt-4o'`)
236
+ * @param promptName - Prompt folder under `data/prompts/` that provides the agent's system instruction. Defaults to `'default'`.
237
+ * @param controlledByHuman - If `true`, the agent's responses are driven by a human rather than the AI. Defaults to `false`.
238
+ * @param reasoningEffort - Extended-thinking effort level for models that support it (e.g. Claude 3.7 Sonnet, o1/o3). Pass `null` to disable. Defaults to `undefined` (model default).
239
+ * @param maxOutputTokens - Override the model's default maximum output token limit
240
+ * @param beginInstruction - Optional prompt stored with the agent and sent when the host app triggers a "Begin" action (e.g. `'Begin by reading the attached documents and asking the user the first question.'`)
241
+ * @param options - Everything else an agent can be created with: tool grants, private context, prompt cache TTL, search, the history window and the small-model override. Add new settings here rather than as further positional parameters.
242
+ * @returns The newly created {@link Agent} instance
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const agent = appService.createAgent(
247
+ * 'Anthropic',
248
+ * 'AI Assistant',
249
+ * 'James',
250
+ * 'A helpful AI assistant',
251
+ * 'claude-haiku-4-5',
252
+ * );
253
+ * if (!agent.id) throw new Error('Agent creation failed');
254
+ * agent.save(); // persist to disk
255
+ * ```
256
+ */
98
257
  createAgent(aiServiceName: string, agentName: string, agentNickname: string, description: string, aiModel: string, promptName?: string, controlledByHuman?: boolean, reasoningEffort?: 'low' | 'medium' | 'high' | null, maxOutputTokens?: number, beginInstruction?: string, options?: AgentCreationOptions): Agent;
258
+ /**
259
+ * Creates an agent from a prompt folder, applying everything that folder declares.
260
+ *
261
+ * A folder's `defaults_config.json` names the role: what it is called, which tools
262
+ * it needs, which documents it carries. {@link createAgent} takes none of that —
263
+ * it takes eleven positional arguments and an options object, and leaves the
264
+ * mapping to the caller. Every caller then writes the same mapping: the web
265
+ * client's create-agent dialog, and every SDK host after it. Hard-coding the
266
+ * result instead is worse, because a pack's tool and document lists change and a
267
+ * transcribed copy does not.
268
+ *
269
+ * Differences from {@link createAgent}, each deliberate:
270
+ *
271
+ * - **It saves.** A convenience constructor that leaves the agent in memory only
272
+ * loses it on restart, which is not what a caller reaching for one expects.
273
+ * - **It attaches the folder's documents**, unless `attachDocuments` is false.
274
+ * {@link PromptFolderDefaults.documentIds} describes them as a pre-tick that
275
+ * stays the user's choice, which is right for a dialog where somebody can untick
276
+ * a box; headless there is nobody to untick, and a character creator without its
277
+ * class documents builds sheets with no spells and no class features.
278
+ * - **It is async**, only because attaching is.
279
+ *
280
+ * @param options.folder Prompt folder name, e.g. `'dungeon_master'`
281
+ * @param options.aiServiceName Provider name, e.g. `'Anthropic'`
282
+ * @param options.aiModel Model id for this agent
283
+ * @param options.overrides Fields to override the folder's declared defaults;
284
+ * the same shape, so `{agentNickname: 'Homer', controlledByHuman: true}` is all
285
+ * a human-controlled player needs
286
+ * @param options.attachDocuments Attach the folder's `documentIds` (default true)
287
+ * @returns The created, saved agent
288
+ * @throws {NotFoundError} If the folder does not exist. Unlike {@link createAgent},
289
+ * which warns and carries on, this refuses: the whole point of the call is the
290
+ * folder's recipe, and a folder that is not there has none — the agent would come
291
+ * out with no tools, no documents and the shared root prompts
292
+ * @throws {Error} If the agent could not be created
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * const dm = await appService.createAgentFromFolder({
297
+ * folder: 'dungeon_master',
298
+ * aiServiceName: 'Anthropic',
299
+ * aiModel: 'claude-sonnet-5',
300
+ * });
301
+ * const you = await appService.createAgentFromFolder({
302
+ * folder: 'dnd_player',
303
+ * aiServiceName: 'Anthropic',
304
+ * aiModel: 'claude-haiku-4-5',
305
+ * overrides: { agentNickname: 'Homer', controlledByHuman: true },
306
+ * });
307
+ * ```
308
+ */
99
309
  createAgentFromFolder(options: {
100
310
  folder: string;
101
311
  aiServiceName: string;
@@ -103,173 +313,1625 @@ export declare class AppService {
103
313
  overrides?: Partial<PromptFolderDefaults>;
104
314
  attachDocuments?: boolean;
105
315
  }): Promise<Agent>;
316
+ /**
317
+ * Sends a text prompt to an agent and returns its response.
318
+ *
319
+ * The exchange is added to the agent's conversation history and persisted to disk.
320
+ *
321
+ * @param agentId - The agent's ID (from {@link createAgent} or {@link listAgents})
322
+ * @param text - The prompt text to send
323
+ * @returns Object containing the agent's reply text (`result`), the latest formatted
324
+ * message, its index in the history, and cumulative token counts and cost
325
+ * @throws {NotFoundError} If no agent with the given ID exists
326
+ *
327
+ * @example
328
+ * ```typescript
329
+ * const result = await appService.processText(agent.id, 'What is the capital of France?');
330
+ * console.log(result.result); // 'Paris'
331
+ * console.log(result.totalCost); // e.g. 0.000023
332
+ * ```
333
+ */
106
334
  processText(agentId: string, text: string): Promise<ProcessTextResponse>;
335
+ /**
336
+ * Attaches a document to an agent so it can reference the file's contents in prompts.
337
+ *
338
+ * The file is stored on disk and uploaded to the AI provider if required
339
+ * (e.g. OpenAI file uploads, Grok file uploads). The agent state is persisted after attachment.
340
+ *
341
+ * @param agentId - The agent's ID
342
+ * @param fileName - File name including extension (e.g. `'report.pdf'`)
343
+ * @param fileData - Raw file bytes as a `Buffer`
344
+ * @returns Object containing a `documentId` that can be used with {@link deleteAttachedFileById}
345
+ * @throws {Error} If no agent with the given ID exists
346
+ */
107
347
  attachDocument(agentId: string, fileName: string, fileData: Buffer): Promise<AttachDocumentResponse>;
348
+ /**
349
+ * Returns every prompt folder name this user can reach.
350
+ *
351
+ * Covers the common and user prompt directories plus the folders of any pack
352
+ * the user has enabled, which appear pack-qualified (`dnd5e:dungeon_master`).
353
+ * A folder in more than one directory appears once.
354
+ *
355
+ * @returns Sorted array of folder names
356
+ */
108
357
  listPromptFolders(): string[];
358
+ /**
359
+ * Returns prompt folder names annotated with where they came from.
360
+ *
361
+ * When the same folder name exists in both the user and common directories the
362
+ * user copy wins and the entry reports `scope: 'user'`. A pack's folder is a
363
+ * separate entry under its qualified name, so a pack shipping a `witness`
364
+ * folder does not collide with a `witness` folder the user wrote.
365
+ *
366
+ * Pack folders are listed only for enabled packs. That is the difference
367
+ * between listing and resolving: a disabled pack's folder still resolves when
368
+ * an agent names it, it just stops being offered.
369
+ *
370
+ * @param scope - Optional filter: `'common'` returns only system-provided folders
371
+ * (including packs', which are read-only in the same way), `'user'` returns only
372
+ * the user's own folders and their pack overlays, omit to return all
373
+ * @returns Object with a `folders` array, sorted by name
374
+ */
109
375
  listPromptFoldersWithScope(scope?: PromptScope): PromptFoldersResponse;
376
+ /**
377
+ * Returns all prepared prompt template names available to a specific agent.
378
+ *
379
+ * Merges prompts from the agent's own prompt folder and the root prompts directory,
380
+ * deduplicating across both. These names can be passed to {@link runPreparedPrompt}.
381
+ *
382
+ * @param agentId - The agent's ID
383
+ * @returns Array of prompt template names (without file extension)
384
+ * @throws {NotFoundError} If no agent with the given ID exists
385
+ */
110
386
  listPrompts(agentId: string): Promise<string[]>;
387
+ /**
388
+ * Executes a named Handlebars prompt template against an agent.
389
+ *
390
+ * The template is loaded from the agent's prompt folder (with the standard 4-level
391
+ * fallback). `variables` are substituted into the template before sending.
392
+ *
393
+ * @param agentId - The agent's ID
394
+ * @param promptName - Template name returned by {@link listPrompts} (without extension)
395
+ * @param variables - Key-value pairs substituted into the template's `{{variable}}` placeholders
396
+ * @returns Object with a `result` string containing the agent's response
397
+ * @throws {NotFoundError} If no agent with the given ID exists
398
+ */
111
399
  runPreparedPrompt(agentId: string, promptName: string, variables?: any): Promise<PreparedPromptResponse>;
400
+ /**
401
+ * Lists all top-level agents belonging to this user.
402
+ *
403
+ * Agents that are owned by a room or story are excluded - use
404
+ * {@link getRoomDetails} or story methods to access those agents.
405
+ *
406
+ * @param includeRoomAgents - Also return the agents owned by a room or story.
407
+ * Only for offering an existing agent as something to copy; the agent list a
408
+ * user manages is the default, unowned one.
409
+ * @returns Array of agent metadata objects
410
+ */
112
411
  listAgents(includeRoomAgents?: boolean): Promise<AgentInfo[]>;
412
+ /**
413
+ * Returns detailed metadata for a specific agent.
414
+ *
415
+ * @param agentId - The agent's ID
416
+ * @returns Agent metadata object, or `null` if no agent with the given ID exists
417
+ */
113
418
  getAgentDetails(agentId: string): Promise<AgentInfo | null>;
419
+ /**
420
+ * Creates a new room and populates it with the specified agents.
421
+ *
422
+ * @param roomName - Display name for the room
423
+ * @param goal - Description of the room's purpose or objective, shared with all agents
424
+ * @param agentIds - IDs of the agents to add to the room. May be empty: a room
425
+ * is created before the agents that belong to it exist, and they are added
426
+ * afterwards with {@link createRoomAgent}.
427
+ * @param roomLeader - Nickname (or name) of the member agent to lead the room.
428
+ * Defaults to the first agent.
429
+ * @param turnMode - `'broadcast'` (default) prompts every agent for each message;
430
+ * `'directed'` prompts only the message's targets. See {@link RoomTurnMode}.
431
+ * @param moderator - Nickname of the agent that places messages the room cannot
432
+ * route mechanically. Only consulted in `'moderated'` mode.
433
+ * @returns Object containing the new `roomId`
434
+ * @throws {NotFoundError} If any agent ID does not exist
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * const { roomId } = await appService.createRoom(
439
+ * 'Research Session',
440
+ * 'Analyze the provided documents and produce a summary',
441
+ * [analystId, writerAgentId],
442
+ * );
443
+ * ```
444
+ */
445
+ /**
446
+ * Whether a prompt folder provides the `moderate.prompt` a moderator needs.
447
+ *
448
+ * The one definition of "could moderate", shared by the check that refuses a
449
+ * misconfigured room and the {@link AgentInfo.canModerate} the client picks a
450
+ * moderator with. Two definitions would eventually disagree, and the way they
451
+ * would show it is a room offering a moderator the server then rejects.
452
+ */
114
453
  private folderProvidesModeratePrompt;
454
+ /**
455
+ * Whether this agent could be a room's moderator.
456
+ *
457
+ * Both halves matter: moderating means answering a prompt, which a human agent
458
+ * never does, and it means having that prompt to answer.
459
+ */
115
460
  private canAgentModerate;
461
+ /**
462
+ * Why the room cannot moderate, or null when it can.
463
+ *
464
+ * "Can" is deliberately stronger than "a moderator is named". A moderator whose
465
+ * prompt folder has no `moderate.prompt` fails in the worst possible way: the
466
+ * prompt lookup throws, {@link Room} swallows the throw, and the message
467
+ * disappears leaving only a log line. Catching that here is the difference
468
+ * between an error the user can act on and a room that quietly eats messages.
469
+ *
470
+ * @param roster The membership to resolve the moderator against, which is not
471
+ * always the room's current one — an agent being added is checked before it
472
+ * arrives.
473
+ */
116
474
  private describeMissingModerator;
475
+ /**
476
+ * Refuses a configuration in which an agent that sends MODERATE messages has no
477
+ * moderator to route them.
478
+ *
479
+ * Checked when the combination can come into being — creating a room, adding an
480
+ * agent to one, changing a room's moderator, turning the flag on — and never on
481
+ * load, which would make an existing room unopenable rather than fixable.
482
+ *
483
+ * @param arriving An agent not yet in the room, checked as though it were.
484
+ */
117
485
  private assertModeratorAvailable;
118
486
  createRoom(roomName: string, goal: string, agentIds: string[], roomLeader?: string, turnMode?: RoomTurnMode, moderator?: string): Promise<CreateRoomResponse>;
487
+ /**
488
+ * Updates the name, goal, and/or agent membership of an existing room.
489
+ *
490
+ * Published room instances cannot be edited - edit the template instead.
491
+ *
492
+ * @param roomId - The room's ID
493
+ * @param roomName - New display name
494
+ * @param goal - New goal description
495
+ * @param baseRoomDir - Optional override for the room's base storage directory
496
+ * @param agentIds - Replacement list of agent IDs (replaces current membership
497
+ * entirely). Omit to leave membership unchanged, which is what the client
498
+ * does: membership is managed through {@link createRoomAgent} and
499
+ * {@link removeRoomAgent}, not by re-sending the roster with every rename.
500
+ * @param roomLeader - Nickname (or name) of the member agent to lead the room.
501
+ * Omit to leave the current leader unchanged.
502
+ * @param turnMode - How the room chooses who responds. Omit to leave unchanged.
503
+ * See {@link RoomTurnMode}.
504
+ * @param moderator - Nickname of the moderator agent. Omit to leave unchanged.
505
+ * @throws {NotFoundError} If the room does not exist
506
+ * @throws {OperationFailedError} If attempting to edit a published room instance
507
+ */
119
508
  editRoom(roomId: string, roomName: string, goal: string, baseRoomDir?: string, agentIds?: string[], roomLeader?: string, turnMode?: RoomTurnMode, moderator?: string, pack?: string): Promise<void>;
509
+ /**
510
+ * Separates a room's name from the bare name of an agent that belongs to it.
511
+ */
120
512
  private static readonly ROOM_AGENT_SEPARATOR;
513
+ /**
514
+ * The stored name of an agent that belongs to a room.
515
+ *
516
+ * Every agent lives inside exactly one room, so an unqualified "Narrator" says
517
+ * nothing about which table it sits at once there are three of them.
518
+ */
121
519
  private static prefixedAgentName;
520
+ /**
521
+ * Strips a room-name prefix from an agent name, leaving the bare name.
522
+ * An agent that does not carry the prefix is returned unchanged.
523
+ */
122
524
  private static bareAgentName;
525
+ /**
526
+ * Re-prefixes the agents a renamed room owns.
527
+ *
528
+ * Only the display name moves. The nickname is what every handoff, target and
529
+ * tool call addresses an agent by, so renaming the room must not touch it.
530
+ */
123
531
  private renameOwnedAgents;
532
+ /**
533
+ * Creates an agent that belongs to a room and adds it to that room.
534
+ *
535
+ * This is the only way an agent joins a room. The agent is owned by it: it is
536
+ * left out of {@link listAgents} and deleted with the room, so a room is a
537
+ * self-contained cast rather than a set of references to a shared pool.
538
+ *
539
+ * `request.agentName` is the bare name. It is stored prefixed with the room's
540
+ * name, while the nickname is derived from the bare name — otherwise every
541
+ * agent in the room would be addressed by the room's first word.
542
+ *
543
+ * @param roomId - The room the agent will belong to
544
+ * @param request - The same fields {@link createAgent} takes
545
+ * @returns Object containing the new `agentId`
546
+ * @throws {NotFoundError} If the room does not exist
547
+ * @throws {OperationFailedError} If the room is a published instance, or another
548
+ * agent in the room already answers to the same nickname
549
+ */
124
550
  createRoomAgent(roomId: string, request: CreateRoomAgentRequest): Promise<CreateAgentResponse>;
551
+ /**
552
+ * Adds an agent to a room, built from a prompt folder's declared defaults.
553
+ *
554
+ * The room-scoped counterpart to {@link createAgentFromFolder}, and the piece a
555
+ * pack's room template is instantiated through. Everything a folder already
556
+ * declares — name, nickname, description, tool grants, documents, cache TTL —
557
+ * comes from its `defaults_config.json`, so a template only has to say what
558
+ * differs.
559
+ *
560
+ * Routed through {@link createRoomAgent} rather than {@link createAgentFromFolder},
561
+ * which does none of what a room member needs: the stored name is prefixed with
562
+ * the room's, the nickname is derived from the bare name, `ownerRoomId` is set,
563
+ * the moderator requirement is checked, and an agent whose nickname collides is
564
+ * removed again instead of being left behind belonging to a room it never joined.
565
+ *
566
+ * @param roomId - The room to add to
567
+ * @param options - The folder to build from, the model to use, and any overrides
568
+ * @returns The new agent's id, its resolved nickname, and any document ids that
569
+ * resolved to nothing — returned rather than swallowed, because a document that
570
+ * silently fails to attach is a capability the agent appears to have and does not
571
+ * @throws {NotFoundError} If the room does not exist, or the folder does not.
572
+ * See {@link createAgentFromFolder} for why a missing folder is fatal here
573
+ * @throws {ValidationError} If the agent needs a moderator the room does not have
574
+ * @throws {OperationFailedError} If the nickname is already taken in the room
575
+ */
125
576
  createRoomAgentFromFolder(roomId: string, options: {
126
577
  folder: string;
127
578
  aiServiceName: string;
128
579
  aiModel: string;
129
580
  smallModelName?: string;
130
581
  overrides?: Partial<PromptFolderDefaults>;
582
+ /** Files the new agent under a pack, so it is listed and hidden with it. */
131
583
  pack?: string;
584
+ /** The pack template's key, when this agent came from one. */
132
585
  packAgentKey?: string;
133
586
  }): Promise<{
134
587
  agentId: string;
135
588
  nickname: string;
136
589
  unresolvedDocumentIds: string[];
137
590
  }>;
591
+ /**
592
+ * Removes an agent from a room, and deletes it if the room owns it.
593
+ *
594
+ * @param roomId - The room's ID
595
+ * @param agentId - The agent's ID
596
+ * @throws {NotFoundError} If the room does not exist, or the agent is not in it
597
+ * @throws {OperationFailedError} If the room is a published instance
598
+ * @throws {ValidationError} If removing the moderator would leave an agent that
599
+ * sends MODERATE messages with nothing to route them
600
+ */
138
601
  removeRoomAgent(roomId: string, agentId: string): Promise<void>;
602
+ /**
603
+ * Lists the rooms this user builds and owns.
604
+ *
605
+ * Published instances are excluded — use {@link getPublishedRoomInstances} for
606
+ * those, which is also how the client reaches them.
607
+ *
608
+ * @returns Array of room summary objects (id, name, goal, agent count)
609
+ */
139
610
  listRooms(): Promise<RoomInfo[]>;
611
+ /**
612
+ * Returns full details for a room, including the metadata of each member agent.
613
+ *
614
+ * @param roomId - The room's ID
615
+ * @returns Room details object, or `null` if no room with the given ID exists
616
+ */
140
617
  getRoomDetails(roomId: string): Promise<RoomDetails | null>;
618
+ /**
619
+ * Returns the raw `Room` object for a given ID.
620
+ *
621
+ * Use {@link getRoomDetails} for a plain metadata object. This method exposes
622
+ * the full `Room` instance, which is useful for advanced operations.
623
+ *
624
+ * @param roomId - The room's ID
625
+ * @returns The `Room` instance, or `null` if not found
626
+ */
141
627
  getRoomById(roomId: string): Promise<Room | null>;
628
+ /**
629
+ * Sets which agent leads the room's conversation and persists the change.
630
+ *
631
+ * The room leader is given conversational authority in the default room
632
+ * prompts (other agents defer to it) and is consulted on adjournment.
633
+ *
634
+ * @param roomId - The room's ID
635
+ * @param agentNickname - Nickname of the member agent to make leader
636
+ * @throws {NotFoundError} If the room does not exist
637
+ */
142
638
  setRoomLeader(roomId: string, agentNickname: string): Promise<void>;
639
+ /**
640
+ * Returns messages from a room's conversation log starting from a given index.
641
+ *
642
+ * Pass the index of the last message you received as `fromIndex` to poll for
643
+ * new messages only.
644
+ *
645
+ * @param roomId - The room's ID
646
+ * @param fromIndex - Zero-based index to start from (default `0` returns all messages)
647
+ * @param includeThoughts - If `true`, includes `'think'` action messages which are
648
+ * normally hidden (agents' internal reasoning). Default `false`.
649
+ * @returns Object with the messages array and total cost across all agents.
650
+ * Returns empty messages with zero cost if the room is not found.
651
+ */
143
652
  getRoomMessages(roomId: string, fromIndex?: number, includeThoughts?: boolean): Promise<RoomMessagesResponse>;
653
+ /**
654
+ * Returns an agent's conversation history starting from a given index.
655
+ *
656
+ * Pass the `messageIndex` from a previous response as `fromIndex` to
657
+ * retrieve only new messages since the last poll.
658
+ *
659
+ * @param agentId - The agent's ID
660
+ * @param fromIndex - Zero-based index to start from (default `0` returns all messages)
661
+ * @returns Object with the messages array and cumulative token/cost totals.
662
+ * Returns empty messages with zero counts if the agent is not found.
663
+ */
144
664
  getAgentMessages(agentId: string, fromIndex?: number): Promise<AgentMessagesResponse>;
665
+ /**
666
+ * Gets messages from a story's room starting from a specific index
667
+ * @param storyId The story ID
668
+ * @param fromIndex The index to start from (0-based)
669
+ * @returns Array of indexed messages and total story cost
670
+ */
145
671
  getStoryMessages(storyId: string, fromIndex: number): Promise<RoomMessagesResponse>;
672
+ /**
673
+ * Adds a message to a room's pending queue to be processed by the agents.
674
+ *
675
+ * **Action values:**
676
+ * - `'moderate'` *(default)* - routes the message through the room's moderator (story rooms only)
677
+ * - `'speak'` - all agents hear the message; `targets` (if provided) restricts which agents may respond
678
+ * - `'whisper'` - only agents listed in `targets` hear the message
679
+ * - `'think'` - inaudible; stays only in the sender's history, not shown to other agents
680
+ * - `'shout'` - overrides all other conversations; all agents hear and respond
681
+ * - `'adjourn'` - signals intent to halt the conversation; the room adjourns once every agent agrees
682
+ *
683
+ * Anything else is sent as `'speak'`. To create an artifact use {@link publishArtifact}
684
+ * rather than this method.
685
+ *
686
+ * @param roomId - The room's ID
687
+ * @param content - The message text (or artifact body when `action` is `'publish'`)
688
+ * @param sender - Display name of the sender (e.g. `'User'`, `'System'`)
689
+ * @param action - Message action type (default `'moderate'`)
690
+ * @param targets - Agent names to receive or respond to the message (behavior varies by action)
691
+ * @param clearQueue - If `true`, clears any pending messages before adding this one. Default `false`.
692
+ * @returns Whether the message was accepted. A human agent's message is rejected
693
+ * (`accepted: false` with a `reason`) when it is not the human's turn to speak.
694
+ * @throws {NotFoundError} If the room does not exist
695
+ *
696
+ * @example
697
+ * ```typescript
698
+ * // Broadcast a message that all agents can respond to
699
+ * await appService.sendRoomMessage(roomId, 'Hello everyone!', 'User', 'speak');
700
+ *
701
+ * // Whisper to a specific agent
702
+ * const result = await appService.sendRoomMessage(roomId, 'Just between us...', 'User', 'whisper', ['James']);
703
+ * if (!result.accepted) {
704
+ * console.log(result.reason); // e.g. "It is James's turn to speak"
705
+ * }
706
+ * ```
707
+ */
146
708
  sendRoomMessage(roomId: string, content: string, sender: string, action?: string, targets?: string[], clearQueue?: boolean, context?: unknown): Promise<SendMessageResult>;
709
+ /**
710
+ * Pauses message processing in a room.
711
+ *
712
+ * Pending messages remain in the queue. Call {@link resumeRoom} to continue processing.
713
+ *
714
+ * @param roomId - The room's ID
715
+ * @throws {NotFoundError} If the room does not exist
716
+ */
147
717
  pauseRoom(roomId: string): Promise<void>;
718
+ /**
719
+ * Resumes message processing in a room that was previously paused.
720
+ *
721
+ * @param roomId - The room's ID
722
+ * @throws {NotFoundError} If the room does not exist
723
+ */
148
724
  resumeRoom(roomId: string): Promise<void>;
725
+ /**
726
+ * Permanently deletes an agent and all its stored data.
727
+ *
728
+ * If the agent is a published instance, its entry is also removed from the
729
+ * published agents mapping.
730
+ *
731
+ * @param agentId - The agent's ID
732
+ * @throws {NotFoundError} If no agent with the given ID exists
733
+ */
149
734
  deleteAgent(agentId: string): Promise<void>;
735
+ /**
736
+ * Creates a publicly accessible clone of a template agent.
737
+ *
738
+ * The new instance is independent of the template's conversation history.
739
+ * Multiple instances can be created from a single template. Use
740
+ * {@link resetPublishedInstance} to restore an instance to the template's
741
+ * current state.
742
+ *
743
+ * @param templateId - ID of the template agent to clone
744
+ * @param instanceName - Display name for the new instance
745
+ * @returns Object with the new `instanceId` and the `publicUrl` path
746
+ * @throws {NotFoundError} If the template agent does not exist
747
+ * @see {@link getPublishedInstances}
748
+ * @see {@link resetPublishedInstance}
749
+ */
150
750
  publishAgentInstance(templateId: string, instanceName: string): Promise<{
151
751
  instanceId: string;
152
752
  publicUrl: string;
153
753
  }>;
754
+ /**
755
+ * Returns all published instances created from a template agent.
756
+ *
757
+ * @param templateId - ID of the template agent
758
+ * @returns Array of agent metadata objects for each published instance
759
+ * @see {@link publishAgentInstance}
760
+ */
154
761
  getPublishedInstances(templateId: string): Promise<AgentInfo[]>;
762
+ /**
763
+ * Resets a published agent instance to its template's current state.
764
+ *
765
+ * Clears the instance's conversation history and regenerates it from
766
+ * the template agent. Does not affect the template itself.
767
+ *
768
+ * @param instanceId - ID of the published instance to reset
769
+ * @throws {NotFoundError} If the instance does not exist
770
+ * @throws {OperationFailedError} If the agent is not a published instance
771
+ */
155
772
  resetPublishedInstance(instanceId: string): Promise<void>;
773
+ /**
774
+ * Lists all published agent instances belonging to this user.
775
+ *
776
+ * Published agents are clones of template agents that are accessible
777
+ * via the public API (e.g. for end-users to chat with). Agents owned
778
+ * by rooms are excluded from this list.
779
+ *
780
+ * @returns Array of agent metadata objects for all published instances
781
+ * @see {@link publishAgentInstance}
782
+ */
156
783
  listPublishedAgents(): Promise<AgentInfo[]>;
784
+ /**
785
+ * Permanently deletes a room and all its data.
786
+ *
787
+ * If the room is a template, all of its published instances are deleted first.
788
+ * The agents the room owns, its attached files and its published room mapping
789
+ * are also cleaned up.
790
+ *
791
+ * @param roomId - The room's ID
792
+ * @throws {NotFoundError} If the room does not exist
793
+ * @throws {OperationFailedError} If deletion fails
794
+ */
157
795
  deleteRoom(roomId: string): Promise<void>;
796
+ /**
797
+ * Creates a publicly accessible clone of a template room.
798
+ *
799
+ * The instance is a full copy of the template including all agents.
800
+ * Use {@link resetPublishedRoomInstance} to restore it to the template's state.
801
+ *
802
+ * @param templateId - ID of the template room to clone
803
+ * @param publishedName - Display name for the instance (defaults to the template's name)
804
+ * @param userId - The owning user's ID (used for public access mapping)
805
+ * @returns The new instance's room ID
806
+ * @throws {NotFoundError} If the template room does not exist
807
+ */
158
808
  publishRoom(templateId: string, publishedName: string | undefined, userId: string): Promise<string>;
809
+ /**
810
+ * Summarizes a room for a listing.
811
+ *
812
+ * The cost is summed from the room's agents rather than held on the room —
813
+ * the same sum {@link getRoomMessages} reports, so the two never disagree.
814
+ * @param room - The room to summarize
815
+ * @returns The room's summary
816
+ */
159
817
  private static toRoomInfo;
818
+ /**
819
+ * Returns all published instances created from a template room.
820
+ *
821
+ * @param templateId - ID of the template room
822
+ * @returns Array of room summary objects for each published instance
823
+ * @see {@link publishRoom}
824
+ */
160
825
  getPublishedRoomInstances(templateId: string): Promise<RoomInfo[]>;
826
+ /**
827
+ * Lists every published room instance this user owns.
828
+ *
829
+ * The room counterpart to {@link listPublishedAgents}, and the only view of
830
+ * them that is not filtered by which template they came from — a published
831
+ * room is a live public link, and the point of the list is seeing all of them
832
+ * and what they have cost.
833
+ *
834
+ * @returns Array of room summary objects, one per published instance
835
+ */
161
836
  listPublishedRooms(): Promise<RoomInfo[]>;
837
+ /**
838
+ * Resets a published room instance to a clean state.
839
+ *
840
+ * Clears the instance's messages and artifacts, and resets all of its
841
+ * cloned agents to their template state. Does not affect the template room.
842
+ *
843
+ * @param instanceId - ID of the published room instance to reset
844
+ * @throws {NotFoundError} If the instance does not exist
845
+ * @throws {OperationFailedError} If the room is not a published instance
846
+ */
162
847
  resetPublishedRoomInstance(instanceId: string): Promise<void>;
848
+ /**
849
+ * Returns the user's stored preferences object.
850
+ *
851
+ * Preferences are application-defined - Briyah stores and returns them as-is.
852
+ * Returns `{}` if no preferences have been saved yet.
853
+ *
854
+ * @returns The preferences object previously written by {@link saveUserPreferences},
855
+ * or an empty object if none exist
856
+ */
163
857
  getUserPreferences(): any;
858
+ /**
859
+ * Persists the user's preferences object to disk.
860
+ *
861
+ * The shape of `preferences` is application-defined. Pass any serializable object;
862
+ * it will be stored as JSON and returned verbatim by {@link getUserPreferences}.
863
+ *
864
+ * @param preferences - Serializable preferences object to store
865
+ */
164
866
  saveUserPreferences(preferences: any): void;
867
+ /**
868
+ * Returns the names of all prompt files in a folder, merged from both the common
869
+ * and user prompt directories.
870
+ *
871
+ * Pass `'shared'` as `folderName` to list files in the root prompts directory.
872
+ * Files that exist in both directories appear once in the result.
873
+ *
874
+ * @param folderName - Folder to list, or `'shared'` for the root prompts directory
875
+ * @returns Object with a `files` array of base names (no extension), sorted alphabetically
876
+ */
165
877
  listPromptFiles(folderName: string): FileList;
878
+ /**
879
+ * Returns prompt file names in a folder annotated with their origin scope.
880
+ *
881
+ * When the same file name exists in both the common and user directories,
882
+ * the user copy wins and the entry is reported as `scope: 'user'`.
883
+ * Pass `'shared'` as `folderName` to list files in the root prompts directory.
884
+ *
885
+ * @param folderName - Folder to list, or `'shared'` for the root prompts directory
886
+ * @returns Object with a `files` array of `{ name, scope }` entries, sorted alphabetically
887
+ */
166
888
  listPromptFilesWithScope(folderName: string): PromptFilesResponse;
889
+ /**
890
+ * Reads a prompt file, applying the shared lookup order (`prompt-resolver.ts`).
891
+ *
892
+ * For a bare folder that is the historical four levels — `user/{folder}`,
893
+ * `user/root`, `common/{folder}`, `common/root` — plus the folders of any pack
894
+ * this user has enabled. For a pack-qualified folder (`dnd5e:battle_master`) it
895
+ * is the pack's own tiers, then the shared roots.
896
+ *
897
+ * The returned `scope` collapses the four tiers onto the two the client knows:
898
+ * a pack overlay reports `'user'`, a pack's own file reports `'common'`. `pack`
899
+ * and `tier` carry the detail, and are populated even when the reference was
900
+ * bare. Returns `{ content: '' }` if the file does not exist in any location.
901
+ *
902
+ * @param folderName - Prompt folder name, `'shared'` for the root prompts directory,
903
+ * or a pack-qualified name like `dnd5e:dungeon_master`
904
+ * @param fileName - Base name of the prompt file (with or without `.prompt`/`.json` extension)
905
+ * @returns `{ content, scope, pack, tier }` where all but `content` are omitted when not found
906
+ */
167
907
  getPromptFile(folderName: string, fileName: string): PromptFileContent;
908
+ /**
909
+ * Reads a prompt folder's `defaults_config.json` — the agent settings the create-agent
910
+ * form pre-fills when that folder is chosen.
911
+ *
912
+ * Resolved through the same 4-level fallback as any other prompt file, so a user copy
913
+ * overrides the shipped one and a file at the prompts root supplies defaults for every
914
+ * folder that has none of its own.
915
+ *
916
+ * A missing file and an unparseable one both return `{ defaults: {} }`: defaults are a
917
+ * convenience, and a folder must stay usable when its config is broken. Unparseable is
918
+ * logged; missing is not, since most folders have no config at all.
919
+ *
920
+ * Every field is coerced to its declared type and unknown keys are dropped, so a typo
921
+ * in a hand-edited file cannot ride through to the create-agent request.
922
+ *
923
+ * @param folderName - Prompt folder name, or `'shared'` for the root prompts directory
924
+ * @returns The declared defaults, and the scope the file was read from
925
+ */
168
926
  getPromptFolderDefaults(folderName: string): PromptFolderDefaultsResponse;
927
+ /**
928
+ * Whether a prompt folder reference reaches a folder that exists.
929
+ *
930
+ * The check every "build an agent from a folder" path makes before it builds
931
+ * one: a reference that reaches nothing does not fail, it falls back to the
932
+ * shared root prompts and produces a generic conversational agent. A bare name
933
+ * for a pack this user has not enabled counts as not existing, because that is
934
+ * how it will behave.
935
+ *
936
+ * @param folderName - Prompt folder name, bare or `pack:folder`
937
+ * @returns True when the folder exists, or names the prompts root
938
+ */
169
939
  promptFolderExists(folderName: string): boolean;
940
+ /**
941
+ * Refuses a prompt folder that reaches nothing, naming the likely cause.
942
+ *
943
+ * @param folderName - The folder the caller asked for
944
+ * @throws {NotFoundError} If no tier has the folder
945
+ */
170
946
  private requirePromptFolder;
947
+ /**
948
+ * Writes content to a prompt file in the user prompt directory.
949
+ *
950
+ * Always saves to the user directory - common prompt files are never overwritten.
951
+ * If the target folder does not exist it is created automatically.
952
+ * Passing `'shared'` as `folderName` writes to the root user prompts directory.
953
+ *
954
+ * Special case: passing an empty `content` for a `'json'` file deletes the file
955
+ * rather than writing an empty document.
956
+ *
957
+ * @param folderName - Prompt folder name, or `'shared'` for the root user prompts directory
958
+ * @param fileName - Base name of the file (without extension)
959
+ * @param content - File content to write
960
+ * @param fileType - `'prompt'` (writes a `.prompt` file) or `'json'` (writes a `.json` file)
961
+ */
171
962
  savePromptFile(folderName: string, fileName: string, content: string, fileType: string): void;
963
+ /**
964
+ * Deletes a prompt file from the user prompts directory.
965
+ *
966
+ * Removes both the `.prompt` and `.json` variants if they exist.
967
+ * This is a no-op if neither file is present.
968
+ *
969
+ * @param folderName - Prompt folder name, or `'shared'` for the root prompts directory
970
+ * @param fileName - Base name of the file to delete (without extension)
971
+ */
172
972
  deletePromptFile(folderName: string, fileName: string): void;
973
+ /**
974
+ * Returns all artifacts published in a room.
975
+ *
976
+ * Artifacts are collaborative documents created by agents via the `'publish'` action.
977
+ *
978
+ * @param roomId - The room's ID
979
+ * @returns Object with an `artifacts` array. Returns `{ artifacts: [] }` if the room is not found.
980
+ * @see {@link publishArtifact}
981
+ */
173
982
  getRoomArtifacts(roomId: string): Promise<{
174
983
  artifacts: any[];
175
984
  }>;
985
+ /**
986
+ * Programmatically publishes an artifact to a room.
987
+ *
988
+ * This is the imperative equivalent of an agent sending a `'publish'` action message.
989
+ * Agents in the room can read and reference the artifact in subsequent prompts.
990
+ *
991
+ * @param roomId - The room's ID
992
+ * @param name - Artifact name (unique within the room)
993
+ * @param creator - Display name of the creator
994
+ * @param body - The artifact's text content
995
+ * @param viewers - Agent names that can view this artifact (empty array = all agents)
996
+ * @throws {NotFoundError} If the room does not exist
997
+ * @throws {OperationFailedError} If `name` is empty
998
+ */
176
999
  publishArtifact(roomId: string, name: string, creator: string, body: string, viewers?: string[]): Promise<void>;
1000
+ /**
1001
+ * Creates a new prompt folder in the user prompts directory.
1002
+ *
1003
+ * An empty `system_instruction.prompt` file is created inside the folder so that
1004
+ * it is immediately usable as a prompt source for agents.
1005
+ *
1006
+ * @param folderName - Name of the folder to create
1007
+ * @throws {OperationFailedError} If a folder with that name already exists
1008
+ */
177
1009
  createPromptFolder(folderName: string): void;
1010
+ /**
1011
+ * Deletes a prompt folder and all its contents from the user prompts directory.
1012
+ *
1013
+ * Only user-owned folders can be deleted; common folders are not affected.
1014
+ *
1015
+ * @param folderName - Name of the folder to delete
1016
+ * @throws {OperationFailedError} If `folderName` is `'shared'`
1017
+ * @throws {NotFoundError} If the folder does not exist in the user prompts directory
1018
+ */
178
1019
  deletePromptFolder(folderName: string): void;
1020
+ /**
1021
+ * Updates one or more properties of an existing agent and persists the changes.
1022
+ *
1023
+ * Only fields that are present in the `updates` object are changed;
1024
+ * omitted fields are left as-is.
1025
+ *
1026
+ * @param agentId - The agent's ID
1027
+ * @param updates - Fields to update:
1028
+ * - `agentNickname` - short display name
1029
+ * - `description` - role or personality description
1030
+ * - `modelName` - model identifier (e.g. `'claude-haiku-4-5'`)
1031
+ * - `reasoningEffort` - `'low' | 'medium' | 'high' | null`
1032
+ * - `isControlledByHuman` - whether a human drives this agent's responses
1033
+ * - `maxOutputTokens` - override the model's default output token limit
1034
+ * - `allowSearch` - enable web search capability (provider must support it)
1035
+ * - `beginInstruction` - prompt sent when the host app triggers a "Begin" action
1036
+ * @throws {NotFoundError} If no agent with the given ID exists
1037
+ */
179
1038
  updateAgent(agentId: string, updates: UpdateAgentRequest): Promise<void>;
1039
+ /**
1040
+ * Renames an agent, and repoints every room that named it.
1041
+ *
1042
+ * The manual counterpart to `ToolRoomAccess.renameAgent`. That one is
1043
+ * synchronous by contract and so fixes only the room it runs in, which is
1044
+ * complete for a room-owned agent; this path reaches an agent shared across
1045
+ * several rooms, where a rename would otherwise leave the other rooms pointing
1046
+ * at a nickname nobody answers to — including their leader, and the `viewers`
1047
+ * of every artifact the agent could read.
1048
+ *
1049
+ * Every room is checked before any is changed. A rename applied to two rooms
1050
+ * and refused by a third would leave the agent named one thing and half its
1051
+ * rooms naming another, which is worse than not renaming at all.
1052
+ *
1053
+ * @param agent The agent to rename
1054
+ * @param newName The new name; the routing nickname is its first word
1055
+ * @throws {ValidationError} If any room it sits in already has that name
1056
+ */
1057
+ private renameAgentEverywhere;
1058
+ /**
1059
+ * Whether this deployment permits users to author and run their own tools.
1060
+ * Native (host-registered) tools are always available regardless.
1061
+ */
180
1062
  get userAuthoredToolsEnabled(): boolean;
1063
+ /**
1064
+ * Lists user-authored tools (with code). Empty when authoring is disabled.
1065
+ *
1066
+ * @returns Array of user-authored tool definitions
1067
+ */
181
1068
  listTools(): Promise<ToolDefinition[]>;
1069
+ /**
1070
+ * Lists native (host-registered) tools as code-free summaries. These are
1071
+ * grantable to agents but not editable through the API.
1072
+ *
1073
+ * @returns Array of native tool summaries
1074
+ */
1075
+ /**
1076
+ * Keeps grants the client could not have seen when it built its list.
1077
+ *
1078
+ * The edit form sends the whole grant list, and it filters that list against the
1079
+ * tools it was offered. Those are only the tools of the packs this user has
1080
+ * enabled — so opening an agent whose pack is off and pressing Save would send a
1081
+ * list with every one of its grants missing, and the agent would lose them for
1082
+ * good with nothing said.
1083
+ *
1084
+ * The server cannot tell "the user removed it" from "the client never saw it" by
1085
+ * looking at the list, so it looks at the tool instead: a name the user could not
1086
+ * have been offered is kept, and a name they could have been offered is theirs to
1087
+ * remove. A grant for a tool nothing registers at all is also kept, since the
1088
+ * form drops those from its list too.
1089
+ *
1090
+ * @param current The agent's grants before the update
1091
+ * @param requested The grants the client sent
1092
+ * @returns The grants to store
1093
+ */
182
1094
  private preserveHiddenGrants;
1095
+ /**
1096
+ * Native tools this user may grant.
1097
+ *
1098
+ * Filtered to the packs they have enabled. Two kinds are always listed: a tool
1099
+ * with no `group`, registered by the host directly rather than by a pack, and a
1100
+ * **core** tool, which belongs to the engine rather than to a domain and so has
1101
+ * no pack to enable. Filtering core out would hide `rename_agent` from every
1102
+ * user permanently, since `core` never appears in anyone's enabled list.
1103
+ *
1104
+ * Listing only. {@link ToolExecutionService} and `Room.buildAvailableTools`
1105
+ * deliberately do not filter, so disabling a pack hides its tools from the
1106
+ * pickers without stopping an agent that already holds one from calling it.
1107
+ *
1108
+ * @returns Code-free summaries of the grantable native tools
1109
+ */
183
1110
  listNativeToolSummaries(): ToolSummary[];
1111
+ /**
1112
+ * Creates a new user-authored tool.
1113
+ *
1114
+ * @param tool - The tool definition to create
1115
+ * @returns The created tool definition
1116
+ * @throws {OperationFailedError} If authoring is disabled or the name already exists
1117
+ */
184
1118
  createTool(tool: ToolDefinition): Promise<ToolDefinition>;
1119
+ /**
1120
+ * Updates an existing user-authored tool.
1121
+ *
1122
+ * @param name - The tool's name
1123
+ * @param tool - The updated tool definition
1124
+ * @returns The saved tool definition
1125
+ * @throws {NotFoundError} If the tool does not exist
1126
+ * @throws {OperationFailedError} If authoring is disabled
1127
+ */
185
1128
  updateTool(name: string, tool: ToolDefinition): Promise<ToolDefinition>;
1129
+ /**
1130
+ * Deletes a user-authored tool. Agents granted the tool keep the (now dangling)
1131
+ * grant; the room silently drops missing tools from their prompts.
1132
+ *
1133
+ * @param name - The tool's name
1134
+ * @throws {NotFoundError} If the tool does not exist
1135
+ * @throws {OperationFailedError} If authoring is disabled
1136
+ */
186
1137
  deleteTool(name: string): Promise<void>;
187
1138
  private assertUserAuthoringAllowed;
1139
+ /**
1140
+ * Runs a tool with the given arguments for testing from the Tools page.
1141
+ * Failures are returned in-band as `{ ok: false, error }`.
1142
+ *
1143
+ * @param name - The tool's name
1144
+ * @param args - Named arguments for the tool
1145
+ * @returns The tool run result
1146
+ */
188
1147
  testTool(name: string, args: Record<string, any>): Promise<ToolRunResult>;
1148
+ /**
1149
+ * Lists the files currently attached to an agent.
1150
+ *
1151
+ * @param agentId - The agent's ID
1152
+ * @returns Object with a `files` array of file names. Returns `{ files: [] }` if the agent is not found.
1153
+ */
189
1154
  listAttachedFiles(agentId: string): Promise<FileList>;
1155
+ /**
1156
+ * Removes a file from an agent by its file name.
1157
+ *
1158
+ * Deletes the file from storage and updates the agent's metadata.
1159
+ * Use {@link deleteAttachedFileById} if you have the document ID instead.
1160
+ *
1161
+ * @param agentId - The agent's ID
1162
+ * @param fileName - Name of the file to remove (e.g. `'report.pdf'`)
1163
+ * @throws {NotFoundError} If the agent or file is not found
1164
+ */
190
1165
  deleteAttachedFile(agentId: string, fileName: string): Promise<void>;
1166
+ /**
1167
+ * Removes an attached file by its document ID (as returned by {@link attachDocument}).
1168
+ *
1169
+ * Searches all agents to locate the owner, removes the file from storage,
1170
+ * and updates the agent's metadata.
1171
+ *
1172
+ * @param documentId - The `documentId` returned by {@link attachDocument}
1173
+ * @throws {NotFoundError} If no file with the given ID exists
1174
+ * @throws {OperationFailedError} If deletion fails
1175
+ */
191
1176
  deleteAttachedFileById(documentId: string): Promise<void>;
1177
+ /**
1178
+ * Clears an agent's conversation history while preserving its configuration
1179
+ * and re-attaching any previously uploaded files.
1180
+ *
1181
+ * Useful for starting a fresh conversation without recreating the agent.
1182
+ * If the history begins with a summary block (from a prior compaction), only
1183
+ * messages after the summary are cleared.
1184
+ *
1185
+ * @param agentId - The agent's ID
1186
+ * @throws {NotFoundError} If no agent with the given ID exists
1187
+ */
192
1188
  reloadAgent(agentId: string): Promise<void>;
1189
+ /**
1190
+ * Compacts an agent's conversation history into a single summary message.
1191
+ * Uses the `compact_agent` prompt (role folder first, common-root as fallback).
1192
+ *
1193
+ * @param agentId - The agent's ID
1194
+ * @throws {NotFoundError} If no agent with the given ID exists
1195
+ */
193
1196
  compactAgentConversation(agentId: string): Promise<void>;
1197
+ /**
1198
+ * Clears a room's message history and artifacts, and resets all member agents.
1199
+ *
1200
+ * Agent configurations (model, prompt, files) are preserved; only conversation
1201
+ * history and artifacts are removed.
1202
+ *
1203
+ * @param roomId - The room's ID
1204
+ * @throws {NotFoundError} If the room does not exist
1205
+ */
194
1206
  resetRoom(roomId: string): Promise<void>;
1207
+ /**
1208
+ * Resets a story to the beginning while preserving artifacts and the opening scene.
1209
+ *
1210
+ * If a chapter 1 backup exists, agents are restored from it; otherwise their
1211
+ * conversation histories are cleared. The list of declined characters is also cleared.
1212
+ *
1213
+ * @param storyId - The story's ID
1214
+ * @throws {NotFoundError} If the story or its room does not exist
1215
+ */
195
1216
  resetStory(storyId: string): Promise<void>;
1217
+ /**
1218
+ * Reverts the most recent chapter progression for a story. Restores room
1219
+ * messages, artifacts, and agent histories from the previous chapter
1220
+ * backup, then deletes that backup. Only valid when the current chapter
1221
+ * has not been played past the opening scene.
1222
+ *
1223
+ * @param storyId - The story's ID
1224
+ * @throws {NotFoundError} If the story or its room does not exist
1225
+ * @throws {OperationFailedError} If revert is not currently valid
1226
+ */
196
1227
  revertStoryChapter(storyId: string): Promise<void>;
1228
+ /**
1229
+ * Creates a new interactive story with AI-driven characters.
1230
+ *
1231
+ * When this method returns, the story is **immediately playable**: brief character
1232
+ * backgrounds and the opening scene have already been generated. A background job
1233
+ * then generates the detailed plot plan and full character profiles; subscribe to
1234
+ * {@link getStoryProgressEmitter} to be notified when that finishes (`step === 'complete'`),
1235
+ * but there is no need to wait for it before letting the player interact.
1236
+ *
1237
+ * @param name - Display name for the story
1238
+ * @param idea - Brief premise or concept for the story
1239
+ * @param userCharacterDesc - Description of the character the human player will portray
1240
+ * @param otherCharactersDesc - Description of other prominent characters to generate
1241
+ * @param storyModel - Model identifier from `story_models.json` (e.g. `'claude-haiku-4-5'`). Defaults to the configured default.
1242
+ * @param isImport - Set `true` when reconstructing a story from exported data. Default `false`.
1243
+ * @param imageModelName - Optional image model name from image_models.json (supplies both the generation and editing models)
1244
+ * @param skipDetailedPlot - Set `true` to generate a simple plot scenario instead of a detailed plot plan with secrets, twists, and events. Default `false`.
1245
+ * @returns Story metadata including the new `id` - story is ready to play immediately
1246
+ *
1247
+ * @example
1248
+ * ```typescript
1249
+ * // Story is playable as soon as createStory returns
1250
+ * const story = await appService.createStory(
1251
+ * 'The Lost Kingdom',
1252
+ * 'A medieval fantasy adventure',
1253
+ * 'A young knight seeking redemption',
1254
+ * 'A wise wizard and a cunning rogue',
1255
+ * );
1256
+ *
1257
+ * // Optionally listen for background completion (plot plan + detailed profiles)
1258
+ * const emitter = appService.getStoryProgressEmitter(story.id);
1259
+ * emitter?.on('progress', ({ step, message }) => {
1260
+ * if (step === 'complete') console.log('Background setup finished');
1261
+ * });
1262
+ * ```
1263
+ */
197
1264
  createStory(name: string, idea: string, userCharacterDesc: string, otherCharactersDesc: string, illustrateStory: boolean, storyModel?: string, isImport?: boolean, imageModelName?: string, skipDetailedPlot?: boolean): Promise<StoryInfo>;
1265
+ /**
1266
+ * Reconstructs a story from a previously exported zip archive.
1267
+ *
1268
+ * @param zipBuffer - Raw bytes of the zip file produced by {@link exportStoryData}
1269
+ * @returns Story metadata for the newly imported story
1270
+ */
198
1271
  importStoryFromZip(zipBuffer: Buffer): Promise<StoryInfo>;
1272
+ /**
1273
+ * Returns the `EventEmitter` for tracking background story work.
1274
+ *
1275
+ * Subscribe to the `'progress'` event. Each event payload is
1276
+ * `{ step: string, message: string, timestamp: number }`.
1277
+ *
1278
+ * **`step` values emitted after {@link createStory} returns:**
1279
+ *
1280
+ * The story is already playable when `createStory` returns. There is no `'ready'`
1281
+ * step for story creation - the storyId does not exist until `createStory` returns,
1282
+ * so the client cannot subscribe to the progress emitter until after that point.
1283
+ * These steps describe the optional background job (plot plan + detailed profiles)
1284
+ * that continues after the method returns:
1285
+ * - `'start'` - background job has begun
1286
+ * - `'profiles'` - generating detailed character profiles
1287
+ * - `'portraits'` - generating character portrait images (only if an image model is configured)
1288
+ * - `'complete'` - background job finished; detailed profiles and plot plan are now available
1289
+ * - `'error'` - background job failed; `message` contains the error text
1290
+ *
1291
+ * **`step` values emitted during {@link progressStory}:**
1292
+ *
1293
+ * `'ready'` fires just before `progressStory` returns, so the story is playable
1294
+ * as soon as the Promise resolves - no need to separately listen for `'ready'`.
1295
+ * The event is emitted for the benefit of SSE clients that want to update their UI
1296
+ * in real time. After `'ready'`, a background job continues:
1297
+ * - `'opening-scene'` - writing the new chapter's opening scene
1298
+ * - `'chapter-backup'` - saving chapter checkpoint data
1299
+ * - `'ready'` - chapter ready; fired just before `progressStory` resolves
1300
+ * - `'profiles'` - (background) recreating plot plan and character profiles
1301
+ * - `'complete'` - (background) all chapter work done
1302
+ * - `'error'` - progression failed
1303
+ *
1304
+ * The emitter is removed after the terminal step (`'complete'`, `'ready'`, or `'error'`),
1305
+ * so this method returns `undefined` once a terminal step has fired.
1306
+ *
1307
+ * @param storyId - The story's ID
1308
+ * @returns `EventEmitter` emitting `'progress'` events, or `undefined` if already complete
1309
+ */
199
1310
  getStoryProgressEmitter(storyId: string): EventEmitter<[never]>;
1311
+ /**
1312
+ * Returns the `EventEmitter` for real-time story updates.
1313
+ *
1314
+ * The emitter fires four named events. Each payload includes a `timestamp` field.
1315
+ *
1316
+ * ---
1317
+ *
1318
+ * **`'story-state'`** - {@link StoryStateEvent}
1319
+ * Fires after every room turn with the complete updated game state.
1320
+ * ```typescript
1321
+ * emitter.on('story-state', (event: StoryStateEvent) => {
1322
+ * const myTurn = event.state.currentSpeaker === event.state.userAgentName;
1323
+ * });
1324
+ * ```
1325
+ * Use `state.currentSpeaker === state.userAgentName` to detect the player's turn.
1326
+ * Do **not** use `state.humanPrompt` for turn detection - it is a UI display string
1327
+ * (e.g. `"What does Elena do next?"`) present even when it is not the player's turn.
1328
+ *
1329
+ * ---
1330
+ *
1331
+ * **`'suggest-introduce-character'`** - {@link StoryIntroduceCharacterEvent}
1332
+ * Fires when the narrator wants to add a new character. The host app should surface
1333
+ * this to the player before acting.
1334
+ * - **Accept:** call {@link introduceCharacterToStory} with `fromNarratorSuggestion: true`
1335
+ * - **Reject:** call {@link declineCharacter}
1336
+ * ```typescript
1337
+ * emitter.on('suggest-introduce-character', (event: StoryIntroduceCharacterEvent) => {
1338
+ * // event.characterName is the narrator-chosen name
1339
+ * });
1340
+ * ```
1341
+ *
1342
+ * ---
1343
+ *
1344
+ * **`'suggest-progress-chapter'`** - {@link StoryProgressChapterEvent}
1345
+ * Fires when the narrator wants to advance to the next chapter. The host app should
1346
+ * surface this to the player before acting.
1347
+ * - **Accept:** call {@link progressStory}
1348
+ * - **Stay in current chapter:** ignore the event (no rejection call needed)
1349
+ *
1350
+ * ---
1351
+ *
1352
+ * **`'story-error'`** - {@link StoryErrorEvent}
1353
+ * Fires when the story engine encounters a fatal error during room processing.
1354
+ * Named `'story-error'` rather than `'error'` to avoid Node.js throwing an uncaught
1355
+ * exception when no listener is attached to `'error'`.
1356
+ * Check `event.errorType === 'InsufficientBalanceError'` for balance failures.
1357
+ *
1358
+ * ---
1359
+ *
1360
+ * @param storyId - The story's ID
1361
+ * @returns `EventEmitter` emitting `'story-state'`, `'suggest-introduce-character'`,
1362
+ * `'suggest-progress-chapter'`, and `'story-error'` events
1363
+ */
200
1364
  getStoryMessageEmitter(storyId: string): EventEmitter<[never]>;
1365
+ /**
1366
+ * Returns a Node.js `EventEmitter` that fires whenever this agent's state changes
1367
+ * (new message, token count update, etc.).
1368
+ *
1369
+ * Useful for building real-time UIs. Subscribe to the `'update'` event to receive
1370
+ * agent state payloads without polling.
1371
+ *
1372
+ * @param agentId - The agent's ID
1373
+ * @returns `EventEmitter` that emits `'update'` events with agent state payloads
1374
+ *
1375
+ * @example
1376
+ * ```typescript
1377
+ * const emitter = appService.getAgentMessageEmitter(agent.id);
1378
+ * emitter.on('update', (state) => {
1379
+ * console.log('New message:', state.latestMessage);
1380
+ * });
1381
+ * ```
1382
+ */
201
1383
  getAgentMessageEmitter(agentId: string): EventEmitter<[never]>;
1384
+ /**
1385
+ * Ensures the real-time state callback is registered for an agent.
1386
+ *
1387
+ * Normally called automatically by {@link processText} and {@link getAgentMessages}.
1388
+ * Call this explicitly when connecting a new SSE client to an agent that was
1389
+ * loaded from disk (not yet touched in this session).
1390
+ *
1391
+ * @param agentId - The agent's ID
1392
+ */
202
1393
  ensureAgentStateCallback(agentId: string): Promise<void>;
1394
+ /**
1395
+ * Sets up the state change callback for an agent to emit SSE updates
1396
+ * @param agent The agent to set up the callback for
1397
+ */
203
1398
  private setupAgentStateCallback;
1399
+ /**
1400
+ * Returns a Node.js `EventEmitter` that fires whenever a new message arrives in the room.
1401
+ *
1402
+ * Subscribe to the `'update'` event to receive room message payloads in real time
1403
+ * without polling.
1404
+ *
1405
+ * @param roomId - The room's ID
1406
+ * @returns `EventEmitter` that emits `'update'` events with room message payloads
1407
+ */
204
1408
  getRoomMessageEmitter(roomId: string): EventEmitter<[never]>;
1409
+ /**
1410
+ * Returns a Node.js `EventEmitter` that fires whenever the user's balance changes.
1411
+ *
1412
+ * Subscribe to the `'update'` event to push real-time balance updates to a connected
1413
+ * client (e.g. via SSE) without polling.
1414
+ *
1415
+ * @param userId - The user's ID (typically the same ID used with `getAppService`)
1416
+ * @returns `EventEmitter` that emits `'update'` events with the new balance value
1417
+ */
205
1418
  getBalanceMessageEmitter(userId: string): EventEmitter;
1419
+ /**
1420
+ * Ensures the real-time state callback is registered for a room.
1421
+ *
1422
+ * Normally called automatically. Call this explicitly when connecting a new
1423
+ * SSE client to a room that was loaded from disk (not yet touched in this session).
1424
+ *
1425
+ * @param roomId - The room's ID
1426
+ */
206
1427
  ensureRoomStateCallback(roomId: string): Promise<void>;
207
1428
  private setupRoomStateCallback;
1429
+ /**
1430
+ * Lists all stories belonging to this user.
1431
+ *
1432
+ * @returns Array of story metadata objects
1433
+ */
208
1434
  listStories(): StoryInfo[];
1435
+ /**
1436
+ * Resumes any stories that were paused due to insufficient balance.
1437
+ *
1438
+ * Call this after adding balance via {@link addBalance} to allow stories that
1439
+ * stalled mid-processing to continue from where they left off.
1440
+ *
1441
+ * @returns The number of stories that were resumed
1442
+ */
209
1443
  resumePausedStories(): Promise<number>;
1444
+ /**
1445
+ * Permanently deletes a story, its room, all characters, chapters, and artifacts.
1446
+ *
1447
+ * @param storyId - The story's ID
1448
+ */
210
1449
  deleteStory(storyId: string): Promise<void>;
1450
+ /**
1451
+ * Summarizes and compresses agent conversation histories to reduce token usage.
1452
+ *
1453
+ * Uses story-specific prompts: the narrator summarizes plot events,
1454
+ * characters summarize their relationships and experiences. The original
1455
+ * messages are replaced with a compact summary block.
1456
+ *
1457
+ * @param storyId - The story's ID
1458
+ * @returns Object with `success` flag, optional `message`, and compaction `details`
1459
+ */
211
1460
  compactStory(storyId: string): Promise<{
212
1461
  success: boolean;
213
1462
  message?: string;
214
1463
  details?: any;
215
1464
  }>;
1465
+ /**
1466
+ * Advances the story to the next chapter.
1467
+ *
1468
+ * Creates a checkpoint of the current chapter state and rebuilds the opening scene.
1469
+ * The story is **immediately playable when this Promise resolves** - the `'ready'`
1470
+ * progress event fires just before the function returns, so awaiting this call is
1471
+ * sufficient; there is no need to separately wait for the event.
1472
+ *
1473
+ * After the function returns, a background job recreates the plot plan and character
1474
+ * profiles for the new chapter (`'profiles'` --> `'complete'`). Agent
1475
+ * conversation histories are **not** compacted here - each agent compacts
1476
+ * independently on demand when it individually reaches the compaction threshold
1477
+ * (see {@link compactStory} for manual compaction).
1478
+ *
1479
+ * @param storyId - The story's ID
1480
+ * @returns Object with the new `chapterIndex`
1481
+ */
216
1482
  progressStory(storyId: string): Promise<{
217
1483
  chapterIndex: number;
218
1484
  }>;
1485
+ /**
1486
+ * Returns the current runtime state of a story.
1487
+ *
1488
+ * Includes messages, pending message count, processing status, and story metadata.
1489
+ * Useful for restoring UI state after reconnecting.
1490
+ *
1491
+ * @param storyId - The story's ID
1492
+ * @returns Full story state object
1493
+ */
219
1494
  getStoryState(storyId: string): Promise<StoryState>;
1495
+ /**
1496
+ * Returns metadata for a specific story.
1497
+ *
1498
+ * @param storyId - The story's ID
1499
+ * @returns Story metadata, or `undefined` if not found
1500
+ */
220
1501
  getStoryInfo(storyId: string): Promise<StoryInfo | undefined>;
1502
+ /**
1503
+ * Submits the human player's response to the story.
1504
+ *
1505
+ * Adds the content as a player message and triggers the AI characters
1506
+ * to continue the narrative.
1507
+ *
1508
+ * Pass the literal string `'PASS'` (case-insensitive) to skip the player's
1509
+ * turn and let the AI characters continue without player input.
1510
+ *
1511
+ * @param storyId - The story's ID
1512
+ * @param content - The player's message or action, or `'PASS'` to skip the turn
1513
+ */
221
1514
  respondToStory(storyId: string, content: string): Promise<void>;
1515
+ /**
1516
+ * Cancels any pending AI turns and forces the human's turn.
1517
+ *
1518
+ * Drops the room's pending message queue and pauses processing so the
1519
+ * human-controlled agent becomes the current speaker. Any in-flight LLM
1520
+ * calls (perceive or moderator) will discard their responses on return.
1521
+ *
1522
+ * @param storyId - The story's ID
1523
+ */
222
1524
  interruptStory(storyId: string): Promise<void>;
1525
+ /**
1526
+ * Adds a new AI character to an existing story.
1527
+ *
1528
+ * Creates a character agent and integrates it into the story's room.
1529
+ * The character profile is generated by the AI based on the provided description.
1530
+ *
1531
+ * When {@link getStoryMessageEmitter} fires a `'suggestion'` update with
1532
+ * `suggestion.type === 'introduce_character'`, pass `suggestion.characterName` as
1533
+ * `name` and set `fromNarratorSuggestion: true` to accept the suggestion.
1534
+ * To reject it instead, call {@link declineCharacter}.
1535
+ *
1536
+ * @param storyId - The story's ID
1537
+ * @param name - The character's name
1538
+ * @param description - Brief description of the character's personality and role
1539
+ * @param storyModel - Optional model override from `story_models.json`
1540
+ * @param fromNarratorSuggestion - Set `true` when accepting a narrator `'suggestion'` update. Default `false`.
1541
+ */
223
1542
  introduceCharacterToStory(storyId: string, name: string, description: string, storyModel?: string, fromNarratorSuggestion?: boolean): Promise<void>;
1543
+ /**
1544
+ * Records that the player declined a narrator-suggested character introduction.
1545
+ *
1546
+ * Prevents the narrator from suggesting the same character again in this story.
1547
+ *
1548
+ * @param storyId - The story's ID
1549
+ * @param characterName - The character name that was declined
1550
+ */
224
1551
  declineCharacter(storyId: string, characterName: string): Promise<void>;
1552
+ /**
1553
+ * Removes a character's agent from the story while preserving their profile file.
1554
+ *
1555
+ * The character can be reintroduced later via {@link introduceCharacterToStory}
1556
+ * and their profile will be available.
1557
+ *
1558
+ * @param storyId - The story's ID
1559
+ * @param characterName - The character's name
1560
+ */
225
1561
  deleteCharacterFromStory(storyId: string, characterName: string): Promise<void>;
1562
+ /**
1563
+ * Returns all chapter checkpoints for a story.
1564
+ *
1565
+ * Chapters are created by {@link progressStory} and can be read with {@link getChapter}.
1566
+ *
1567
+ * @param storyId - The story's ID
1568
+ * @returns Object with a `chapters` array of chapter info objects
1569
+ */
226
1570
  listChapters(storyId: string): {
227
1571
  chapters: ChapterInfo[];
228
1572
  };
1573
+ /**
1574
+ * Returns the messages from a specific chapter checkpoint.
1575
+ *
1576
+ * @param storyId - The story's ID
1577
+ * @param chapterIndex - The chapter number (1-based, as returned by {@link listChapters})
1578
+ * @returns Array of room messages from that chapter
1579
+ */
229
1580
  getChapter(storyId: string, chapterIndex: number): Promise<RoomMessage[]>;
1581
+ /**
1582
+ * Overwrites the content of a chapter checkpoint.
1583
+ *
1584
+ * @param storyId - The story's ID
1585
+ * @param chapterIndex - The chapter number to overwrite
1586
+ * @param content - The new chapter content
1587
+ * @throws {OperationFailedError} If the chapter cannot be saved
1588
+ */
230
1589
  saveChapter(storyId: string, chapterIndex: number, content: string): void;
1590
+ /**
1591
+ * Deletes a chapter checkpoint from a story.
1592
+ *
1593
+ * @param storyId - The story's ID
1594
+ * @param chapterIndex - The chapter number to delete
1595
+ * @throws {NotFoundError} If the chapter does not exist
1596
+ */
231
1597
  deleteChapter(storyId: string, chapterIndex: number): void;
1598
+ /**
1599
+ * Returns all current characters in a story.
1600
+ *
1601
+ * @param storyId - The story's ID
1602
+ * @returns Array of character objects (derived from the story's room agents)
1603
+ */
232
1604
  listCharacters(storyId: string): Promise<Character[]>;
1605
+ /**
1606
+ * Returns the profile for a specific character.
1607
+ *
1608
+ * @param storyId - The story's ID
1609
+ * @param characterName - The character's name
1610
+ * @returns Object with `content` containing the character profile markdown
1611
+ */
233
1612
  getCharacter(storyId: string, characterName: string): Promise<{
234
1613
  content: string;
235
1614
  }>;
1615
+ /**
1616
+ * Saves a character's profile markdown.
1617
+ *
1618
+ * @param storyId - The story's ID
1619
+ * @param characterName - The character's name
1620
+ * @param content - Markdown content for the character profile
1621
+ */
236
1622
  saveCharacter(storyId: string, characterName: string, content: string): void;
1623
+ /**
1624
+ * Returns the inventory for a specific character.
1625
+ *
1626
+ * @param storyId - The story's ID
1627
+ * @param characterName - The character's name
1628
+ * @returns Object with `content` containing the inventory markdown
1629
+ */
237
1630
  getCharacterInventory(storyId: string, characterName: string): Promise<{
238
1631
  content: string;
239
1632
  }>;
1633
+ /**
1634
+ * Saves a character's inventory markdown.
1635
+ *
1636
+ * @param storyId - The story's ID
1637
+ * @param characterName - The character's name
1638
+ * @param content - Markdown content for the character inventory
1639
+ */
240
1640
  saveCharacterInventory(storyId: string, characterName: string, content: string): Promise<void>;
1641
+ /**
1642
+ * Returns the story's plot plan.
1643
+ *
1644
+ * The plot plan is a room artifact generated by the narrator at story creation
1645
+ * and updated as the story progresses.
1646
+ *
1647
+ * @param storyId - The story's ID
1648
+ * @returns Object with `content` containing the plot plan markdown
1649
+ */
241
1650
  getPlotPlan(storyId: string): Promise<{
242
1651
  content: string;
243
1652
  }>;
1653
+ /**
1654
+ * Generates the full story as a single markdown document.
1655
+ *
1656
+ * Combines all chapters and room messages in narrative order.
1657
+ *
1658
+ * @param storyId - The story's ID
1659
+ * @returns The complete story formatted as markdown text
1660
+ */
244
1661
  downloadStoryMarkdown(storyId: string): Promise<string>;
1662
+ /**
1663
+ * Exports the complete story data as a downloadable zip archive.
1664
+ *
1665
+ * The archive can be re-imported via {@link importStoryFromZip}.
1666
+ *
1667
+ * @param storyId - The story's ID
1668
+ * @returns Object with a `stream` (readable zip stream) and `filename` for the download
1669
+ */
245
1670
  exportStoryData(storyId: string): Promise<{
246
1671
  stream: Readable;
247
1672
  filename: string;
248
1673
  }>;
1674
+ /**
1675
+ * Returns the formatted conversation history for a specific character in a story.
1676
+ *
1677
+ * @param storyId - The story's ID
1678
+ * @param agentId - The character agent's ID
1679
+ * @returns Object with `content` containing the formatted history text
1680
+ */
249
1681
  getAgentHistory(storyId: string, agentId: string): Promise<{
250
1682
  content: string;
251
1683
  }>;
1684
+ /**
1685
+ * Saves the story's plot plan.
1686
+ *
1687
+ * Persists the content as a room artifact via the publish mechanism.
1688
+ *
1689
+ * @param storyId - The story's ID
1690
+ * @param content - The plot plan markdown to save
1691
+ */
252
1692
  savePlotPlan(storyId: string, content: string): Promise<void>;
1693
+ /**
1694
+ * Returns the user's current credit balance in dollars.
1695
+ *
1696
+ * The balance is decremented automatically after each AI call based on token usage
1697
+ * and any configured markup. Calls that would exceed the balance throw
1698
+ * `InsufficientBalanceError` before the request is sent.
1699
+ *
1700
+ * @returns Current balance in dollars
1701
+ */
253
1702
  getBalance(): number;
1703
+ /**
1704
+ * Adds funds to the user's balance.
1705
+ *
1706
+ * Use this to credit a user after a payment is processed by your application.
1707
+ *
1708
+ * @param amount - Dollar amount to add (must be positive)
1709
+ */
254
1710
  addBalance(amount: number): void;
1711
+ /**
1712
+ * Records a new payment transaction.
1713
+ *
1714
+ * Call this when your payment provider confirms a payment has been initiated.
1715
+ * The `paymentId` should be the unique identifier issued by your payment provider
1716
+ * (e.g. a Stripe Payment Intent ID). Use {@link updateTransactionStatus} to update
1717
+ * the status once the provider confirms success or failure.
1718
+ *
1719
+ * @param amount - Dollar amount of the transaction
1720
+ * @param paymentId - Unique payment identifier from your payment provider
1721
+ * @param status - Initial status; defaults to `'pending'`
1722
+ * @returns The created `Transaction` record
1723
+ */
255
1724
  recordTransaction(amount: number, paymentId: string, status?: 'pending' | 'succeeded' | 'failed' | 'cancelled'): Promise<Transaction>;
1725
+ /**
1726
+ * Updates the status of an existing transaction.
1727
+ *
1728
+ * Call this when your payment provider webhook confirms the final outcome of a payment.
1729
+ *
1730
+ * @param paymentId - The payment provider ID used when the transaction was recorded
1731
+ * @param status - New status (`'succeeded'`, `'failed'`, or `'cancelled'`)
1732
+ */
256
1733
  updateTransactionStatus(paymentId: string, status: 'pending' | 'succeeded' | 'failed' | 'cancelled'): Promise<void>;
1734
+ /**
1735
+ * Retrieves a single transaction by its payment provider ID.
1736
+ *
1737
+ * @param paymentId - The payment provider ID used when the transaction was recorded
1738
+ * @returns The matching `Transaction`, or `null` if not found
1739
+ */
257
1740
  getTransactionByPaymentId(paymentId: string): Promise<Transaction | null>;
1741
+ /**
1742
+ * Returns paginated transaction history for this user, sorted newest-first.
1743
+ *
1744
+ * @param limit - Maximum number of records to return (default: 50)
1745
+ * @param offset - Number of records to skip for pagination (default: 0)
1746
+ * @returns Object with a `transactions` array and a `total` count
1747
+ */
258
1748
  getTransactions(limit?: number, offset?: number): Promise<TransactionHistoryResponse>;
1749
+ /**
1750
+ * Returns metadata for all artifacts owned by this user.
1751
+ *
1752
+ * Artifacts are persistent named documents that can be attached to agents
1753
+ * (see {@link attachArtifactToAgent}) or shared with rooms via the `'publish'` action.
1754
+ * Use {@link getUserArtifact} to retrieve the actual content.
1755
+ *
1756
+ * @returns Array of artifact metadata objects (ID, name, creation date, etc.)
1757
+ */
259
1758
  listUserArtifacts(): ArtifactMetadata[];
1759
+ /**
1760
+ * Returns the content of a user artifact.
1761
+ *
1762
+ * Text artifacts are returned as `string`; binary artifacts (e.g. converted PDFs
1763
+ * in intermediate state) may be returned as `Buffer`.
1764
+ *
1765
+ * @param artifactId - The artifact's ID (from {@link listUserArtifacts})
1766
+ * @returns The artifact content, or `null` if no artifact with that ID exists
1767
+ */
260
1768
  getUserArtifact(artifactId: string): string | Buffer | null;
1769
+ /**
1770
+ * Creates a new named artifact and returns its ID.
1771
+ *
1772
+ * The artifact is persisted immediately. Use the returned ID to attach it to
1773
+ * agents ({@link attachArtifactToAgent}) or reference it in room messages.
1774
+ *
1775
+ * @param name - Human-readable display name for the artifact
1776
+ * @param content - Initial text content (typically Markdown)
1777
+ * @returns The new artifact's ID
1778
+ */
261
1779
  createUserArtifact(name: string, content: string): string;
1780
+ /**
1781
+ * Replaces the content of an existing artifact.
1782
+ *
1783
+ * @param artifactId - The artifact's ID (from {@link listUserArtifacts})
1784
+ * @param content - New content to write
1785
+ * @returns `true` on success, `false` if no artifact with that ID exists
1786
+ */
262
1787
  updateUserArtifact(artifactId: string, content: string): boolean;
1788
+ /**
1789
+ * Creates an artifact from a PDF by converting it to Markdown, running the
1790
+ * conversion in the background.
1791
+ *
1792
+ * Returns the artifact ID immediately with placeholder content. The artifact
1793
+ * content is replaced with the converted Markdown when the background job
1794
+ * finishes. If conversion fails, the artifact content is replaced with an
1795
+ * error message.
1796
+ *
1797
+ * Requires the `DOC_CONVERSION_AI_SERVICE` and `DOC_CONVERSION_AI_MODEL`
1798
+ * environment variables to be set to an AI service that supports PDF documents.
1799
+ *
1800
+ * A PDF over ten pages is converted page by page, at most
1801
+ * `PDF_CONVERT_CONCURRENCY` at a time, with each page retried before it is
1802
+ * given up on. A page that is given up on does not fail the document: the
1803
+ * artifact still lands, naming the pages that are missing from it so they can
1804
+ * be re-run. Only a conversion that produces nothing at all replaces the
1805
+ * artifact with an error.
1806
+ *
1807
+ * @param name - Display name for the artifact
1808
+ * @param pdfBuffer - Buffer containing the raw PDF data
1809
+ * @returns The new artifact's ID (content is a placeholder until conversion completes)
1810
+ */
263
1811
  convertUserArtifact(name: string, pdfBuffer: Buffer): string;
1812
+ /**
1813
+ * Converts a PDF to Markdown a page at a time and returns the pages.
1814
+ *
1815
+ * The building block under {@link convertUserArtifact}, public because a host
1816
+ * embedding Briyah usually wants the pages and the cost rather than an
1817
+ * artifact — to extract records from each page, to cache the result under its
1818
+ * own key, or to show progress. Every page is converted by its own throwaway
1819
+ * agent, so nothing accumulates history and pages stay independent.
1820
+ *
1821
+ * Bounded, retried and non-fatal: at most {@link PdfMarkdownOptions.concurrency}
1822
+ * pages are in flight, each page is retried on an empty response, a thrown
1823
+ * error or a timeout, and a page that exhausts its attempts is reported in
1824
+ * `failedPages` rather than failing the document.
1825
+ *
1826
+ * @param pdfBuffer - The raw PDF
1827
+ * @param options - Models, prompt, hints and limits; every field has a default
1828
+ * @returns The pages, the assembled Markdown, what failed, and the cost
1829
+ * @throws {ValidationError} If no conversion service or model is configured
1830
+ *
1831
+ * @example
1832
+ * ```typescript
1833
+ * const result = await appService.convertPdfToMarkdownPages(buffer, {
1834
+ * concurrency: 8,
1835
+ * fidelityHints: 'chapter and verse numbers',
1836
+ * onProgress: (message) => console.log(message),
1837
+ * });
1838
+ * if (result.failedPages.length) console.warn('Re-run pages', result.failedPages);
1839
+ * ```
1840
+ */
264
1841
  convertPdfToMarkdownPages(pdfBuffer: Buffer | Uint8Array, options?: PdfMarkdownOptions): Promise<PdfMarkdownResult>;
1842
+ /**
1843
+ * Converts a whole PDF in one request, for a document short enough that page
1844
+ * continuity is worth more than page-level recovery.
1845
+ *
1846
+ * Retried on the same policy as a page, since an empty response here loses the
1847
+ * entire document rather than one page of it.
1848
+ */
265
1849
  private convertWholePdf;
1850
+ /**
1851
+ * Background conversion process - updates the artifact when complete.
1852
+ *
1853
+ * A document of more than ten pages is converted page-by-page, which is what
1854
+ * makes a partial failure survivable: the artifact still lands, carrying the
1855
+ * pages that converted and naming the ones that did not.
1856
+ *
1857
+ * @param artifactId The artifact ID to update
1858
+ * @param name The artifact name
1859
+ * @param pdfBuffer Buffer containing PDF data
1860
+ */
266
1861
  private convertPdfInBackground;
1862
+ /**
1863
+ * Changes the display name of an artifact.
1864
+ *
1865
+ * @param artifactId - The artifact's ID (from {@link listUserArtifacts})
1866
+ * @param newName - New display name for the artifact
1867
+ * @returns `true` on success, `false` if no artifact with that ID exists
1868
+ */
267
1869
  renameUserArtifact(artifactId: string, newName: string): boolean;
1870
+ /**
1871
+ * Permanently deletes a user artifact.
1872
+ *
1873
+ * Any agents that have the artifact attached will lose access to it after deletion.
1874
+ *
1875
+ * @param artifactId - The artifact's ID (from {@link listUserArtifacts})
1876
+ * @returns `true` on success, `false` if no artifact with that ID exists
1877
+ */
268
1878
  deleteUserArtifact(artifactId: string): boolean;
1879
+ /**
1880
+ * Gets the artifact service for a story
1881
+ * @param storyId The story ID
1882
+ * @returns The story-specific artifact service
1883
+ */
269
1884
  private getStoryArtifactService;
1885
+ /**
1886
+ * Returns all artifacts associated with a story.
1887
+ *
1888
+ * Story artifacts include the plot plan and any documents published by agents
1889
+ * during the narrative.
1890
+ *
1891
+ * @param storyId - The story's ID
1892
+ * @returns Array of artifact metadata objects
1893
+ */
270
1894
  listStoryArtifacts(storyId: string): ArtifactMetadata[];
1895
+ /**
1896
+ * Returns the content of a specific story artifact.
1897
+ *
1898
+ * @param storyId - The story's ID
1899
+ * @param artifactId - The artifact's ID (from {@link listStoryArtifacts})
1900
+ * @returns The artifact content as a string or Buffer, or `null` if not found
1901
+ */
271
1902
  getStoryArtifact(storyId: string, artifactId: string): string | Buffer | null;
1903
+ /**
1904
+ * Returns metadata for all artifacts currently attached to an agent.
1905
+ *
1906
+ * Attached artifacts are included in the agent's context on every prompt, allowing
1907
+ * the agent to reference their content. Use {@link attachArtifactToAgent} and
1908
+ * {@link detachArtifactFromAgent} to manage attachments.
1909
+ *
1910
+ * @param agentId - The agent's ID
1911
+ * @returns Array of artifact metadata objects for the agent's attached artifacts
1912
+ * @throws {NotFoundError} If no agent with the given ID exists
1913
+ */
272
1914
  listAgentArtifacts(agentId: string): Promise<ArtifactMetadata[]>;
1915
+ /**
1916
+ * Attaches a user artifact to an agent so the agent can read its content in prompts.
1917
+ *
1918
+ * The attachment is persisted immediately via `agent.save()`. The artifact content
1919
+ * is injected into the agent's context on each subsequent call.
1920
+ *
1921
+ * @param agentId - The agent's ID
1922
+ * @param artifactId - The artifact's ID (from {@link listUserArtifacts})
1923
+ * @throws {NotFoundError} If the agent or artifact does not exist
1924
+ */
273
1925
  attachArtifactToAgent(agentId: string, artifactId: string): Promise<void>;
1926
+ /**
1927
+ * Removes an artifact attachment from an agent.
1928
+ *
1929
+ * The artifact itself is not deleted - only the link between the agent and the artifact
1930
+ * is removed. Changes are persisted immediately via `agent.save()`.
1931
+ *
1932
+ * @param agentId - The agent's ID
1933
+ * @param artifactId - The artifact's ID to detach
1934
+ * @throws {NotFoundError} If no agent with the given ID exists
1935
+ */
274
1936
  detachArtifactFromAgent(agentId: string, artifactId: string): Promise<void>;
275
1937
  }