briyah 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -8
- package/data/common/config/LICENSE-model-prices.md +65 -0
- package/data/common/config/markup +1 -1
- package/data/common/config/model_prices.json +47443 -46295
- package/data/common/config/story_models.json +3 -3
- package/data/common/prompts/illustrator/describe_scene.prompt +4 -4
- package/data/common/prompts/narrator/create_story.prompt +2 -0
- package/data/common/prompts/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +795 -787
- package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +2 -1
- package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +1 -1
- package/data/packs/dnd5e/rooms/campaign.json +18 -15
- package/data/packs/dnd5e/rooms/table.json +17 -16
- package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
- package/dist-sdk/server/src/ai/LLM/anthropic.service.js +174 -3
- package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +194 -3
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +299 -19
- package/dist-sdk/server/src/ai/LLM/blank-image.d.ts +36 -0
- package/dist-sdk/server/src/ai/LLM/blank-image.js +80 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
- package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
- package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
- package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
- package/dist-sdk/server/src/ai/LLM/deepseek.service.js +103 -4
- package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
- package/dist-sdk/server/src/ai/LLM/fal.service.js +56 -2
- package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
- package/dist-sdk/server/src/ai/LLM/googleai.service.js +43 -2
- package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
- package/dist-sdk/server/src/ai/LLM/grok.service.js +55 -3
- package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
- package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/LLM/openai.service.js +81 -3
- package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
- package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +45 -3
- package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/LLM/together.service.js +61 -3
- package/dist-sdk/server/src/ai/agent-config.d.ts +15 -1
- package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
- package/dist-sdk/server/src/ai/agent-factory.js +20 -0
- package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
- package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
- package/dist-sdk/server/src/ai/agent-store.service.js +166 -7
- package/dist-sdk/server/src/ai/agent.d.ts +197 -2
- package/dist-sdk/server/src/ai/agent.js +225 -14
- package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
- package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
- package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
- package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
- package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
- package/dist-sdk/server/src/ai/artifact.service.js +148 -3
- package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
- package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
- package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
- package/dist-sdk/server/src/ai/model_prices.js +91 -5
- package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
- package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
- package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
- package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
- package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
- package/dist-sdk/server/src/app/balance-message.service.js +24 -0
- package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
- package/dist-sdk/server/src/app/balance.module.js +4 -0
- package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
- package/dist-sdk/server/src/app/balance.service.js +54 -0
- package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
- package/dist-sdk/server/src/app/stripe.controller.js +35 -0
- package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
- package/dist-sdk/server/src/app/stripe.service.js +62 -0
- package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
- package/dist-sdk/server/src/app/transaction.service.js +36 -0
- package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
- package/dist-sdk/server/src/app/user-service-factory.js +46 -3
- package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
- package/dist-sdk/server/src/app/user-service-manager.js +43 -0
- package/dist-sdk/server/src/app.controller.d.ts +120 -0
- package/dist-sdk/server/src/app.controller.js +365 -14
- package/dist-sdk/server/src/app.module.js +28 -6
- package/dist-sdk/server/src/app.service.d.ts +1710 -4
- package/dist-sdk/server/src/app.service.js +1938 -20
- package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
- package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
- package/dist-sdk/server/src/auth/auth.controller.js +46 -0
- package/dist-sdk/server/src/auth/auth.module.js +3 -2
- package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
- package/dist-sdk/server/src/auth/auth.service.js +39 -3
- package/dist-sdk/server/src/auth/jwt-auth.guard.js +44 -0
- package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
- package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
- package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
- package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
- package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
- package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
- package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
- package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
- package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
- package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
- package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
- package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
- package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
- package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
- package/dist-sdk/server/src/auth/session.guard.js +8 -0
- package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
- package/dist-sdk/server/src/auth/twilio.service.js +30 -4
- package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
- package/dist-sdk/server/src/auth/users.service.js +42 -0
- package/dist-sdk/server/src/common/errors.d.ts +20 -0
- package/dist-sdk/server/src/common/errors.js +21 -0
- package/dist-sdk/server/src/config/env-config.d.ts +7 -0
- package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
- package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
- package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
- package/dist-sdk/server/src/config/user-config.service.js +57 -0
- package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
- package/dist-sdk/server/src/config/user-paths.service.js +67 -0
- package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
- package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.js +104 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +114 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +69 -0
- package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
- package/dist-sdk/server/src/packs/pack.service.js +98 -1
- package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
- package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
- package/dist-sdk/server/src/room/artifact.d.ts +18 -0
- package/dist-sdk/server/src/room/illustration/illustration.service.d.ts +211 -0
- package/dist-sdk/server/src/room/illustration/illustration.service.js +771 -0
- package/dist-sdk/server/src/room/illustration/illustration.types.d.ts +101 -0
- package/dist-sdk/server/src/room/illustration/illustration.types.js +2 -0
- package/dist-sdk/server/src/room/message.d.ts +64 -0
- package/dist-sdk/server/src/room/message.js +77 -2
- package/dist-sdk/server/src/room/nickname.d.ts +26 -0
- package/dist-sdk/server/src/room/nickname.js +26 -0
- package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
- package/dist-sdk/server/src/room/room-config.d.ts +84 -1
- package/dist-sdk/server/src/room/room-config.js +19 -0
- package/dist-sdk/server/src/room/room-factory.d.ts +20 -0
- package/dist-sdk/server/src/room/room-factory.js +25 -0
- package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
- package/dist-sdk/server/src/room/room-message.service.js +28 -0
- package/dist-sdk/server/src/room/room-store.service.d.ts +184 -0
- package/dist-sdk/server/src/room/room-store.service.js +280 -6
- package/dist-sdk/server/src/room/room.d.ts +981 -1
- package/dist-sdk/server/src/room/room.js +1531 -27
- package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
- package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
- package/dist-sdk/server/src/rpg/rpg-roster.d.ts +37 -0
- package/dist-sdk/server/src/rpg/rpg-roster.js +37 -0
- package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
- package/dist-sdk/server/src/rpg/rpg.service.js +108 -1
- package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
- package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
- package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
- package/dist-sdk/server/src/sdk/briyah.js +285 -7
- package/dist-sdk/server/src/sdk/index.js +23 -0
- package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
- package/dist-sdk/server/src/shared/shared.module.js +13 -5
- package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
- package/dist-sdk/server/src/story/story-message.service.js +43 -0
- package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
- package/dist-sdk/server/src/story/story-progress.service.js +23 -0
- package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
- package/dist-sdk/server/src/story/story-store.service.js +136 -1
- package/dist-sdk/server/src/story/story.service.d.ts +366 -9
- package/dist-sdk/server/src/story/story.service.js +825 -374
- package/dist-sdk/server/src/tools/core/illustrate.tool.d.ts +14 -0
- package/dist-sdk/server/src/tools/core/illustrate.tool.js +80 -0
- package/dist-sdk/server/src/tools/core/index.d.ts +22 -0
- package/dist-sdk/server/src/tools/core/index.js +24 -1
- package/dist-sdk/server/src/tools/core/rename.tool.d.ts +8 -0
- package/dist-sdk/server/src/tools/core/rename.tool.js +11 -0
- package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
- package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
- package/dist-sdk/server/src/tools/native-tool.types.d.ts +266 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +201 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +149 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +194 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +263 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +127 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
- package/dist-sdk/server/src/tools/packs/index.d.ts +49 -0
- package/dist-sdk/server/src/tools/packs/index.js +66 -0
- package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
- package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
- package/dist-sdk/server/src/tools/tool-execution.service.d.ts +107 -3
- package/dist-sdk/server/src/tools/tool-execution.service.js +163 -19
- package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
- package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
- package/dist-sdk/shared/types/app.types.d.ts +328 -13
- package/dist-sdk/shared/types/app.types.js +18 -1
- package/package.json +167 -168
- package/data/common/config/random_words.txt +0 -2241
- package/data/common/story_ideas/biblical.json +0 -122
- package/data/common/story_ideas/fantasy.json +0 -82
- package/data/common/story_ideas/historical_fiction.json +0 -82
- package/data/common/story_ideas/science_fiction.json +0 -82
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -113
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1648
- package/docs/classes/Agent.html +0 -801
- package/docs/classes/Briyah.html +0 -296
- package/docs/classes/BriyahConfigService.html +0 -119
- package/docs/classes/NativeToolRegistry.html +0 -166
- package/docs/classes/PackInstantiationService.html +0 -157
- package/docs/classes/PackService.html +0 -247
- package/docs/classes/Room.html +0 -1434
- package/docs/classes/RoomMessage.html +0 -290
- package/docs/enums/MessageAction.html +0 -136
- package/docs/functions/availableToolPacks.html +0 -41
- package/docs/functions/buildMarkdown.html +0 -54
- package/docs/functions/dnd5eTools.html +0 -44
- package/docs/functions/installToolPacks.html +0 -51
- package/docs/functions/pageMarker.html +0 -45
- package/docs/functions/registerToolPacks.html +0 -54
- package/docs/functions/splitMarkdownIntoPages.html +0 -51
- package/docs/functions/stripWrappingFence.html +0 -52
- package/docs/hierarchy.html +0 -46
- package/docs/index.html +0 -595
- package/docs/interfaces/AgentCreationOptions.html +0 -125
- package/docs/interfaces/AgentInfo.html +0 -218
- package/docs/interfaces/AgentMessagesResponse.html +0 -74
- package/docs/interfaces/AppService.html +0 -3340
- package/docs/interfaces/Artifact.html +0 -95
- package/docs/interfaces/ArtifactMetadata.html +0 -112
- package/docs/interfaces/ArtifactWriteOptions.html +0 -90
- package/docs/interfaces/AttachDocumentResponse.html +0 -62
- package/docs/interfaces/BriyahConfigOptions.html +0 -124
- package/docs/interfaces/ChapterInfo.html +0 -62
- package/docs/interfaces/Character.html +0 -86
- package/docs/interfaces/ConversionAgent.html +0 -78
- package/docs/interfaces/CreateAgentResponse.html +0 -56
- package/docs/interfaces/CreateRoomResponse.html +0 -62
- package/docs/interfaces/CreateStoryResponse.html +0 -56
- package/docs/interfaces/FileList.html +0 -56
- package/docs/interfaces/FileMetadata.html +0 -89
- package/docs/interfaces/IConfigService.html +0 -79
- package/docs/interfaces/InstantiateModels.html +0 -64
- package/docs/interfaces/InstantiateRoomResult.html +0 -70
- package/docs/interfaces/LoadedPack.html +0 -131
- package/docs/interfaces/LoggingOptions.html +0 -92
- package/docs/interfaces/Message.html +0 -84
- package/docs/interfaces/ModelChoice.html +0 -73
- package/docs/interfaces/ModelInfo.html +0 -74
- package/docs/interfaces/NativeToolDefinition.html +0 -107
- package/docs/interfaces/PackAgentTemplate.html +0 -101
- package/docs/interfaces/PackRoomTemplate.html +0 -108
- package/docs/interfaces/PackView.html +0 -172
- package/docs/interfaces/PdfConversionOptions.html +0 -102
- package/docs/interfaces/PdfConversionResult.html +0 -97
- package/docs/interfaces/PdfMarkdownOptions.html +0 -198
- package/docs/interfaces/PdfMarkdownResult.html +0 -106
- package/docs/interfaces/PdfPageMarkdown.html +0 -94
- package/docs/interfaces/PreparedPromptResponse.html +0 -62
- package/docs/interfaces/ProcessTextResponse.html +0 -86
- package/docs/interfaces/PromptFile.html +0 -70
- package/docs/interfaces/PromptFileContent.html +0 -76
- package/docs/interfaces/PromptFilesResponse.html +0 -56
- package/docs/interfaces/PromptFolder.html +0 -80
- package/docs/interfaces/PromptFolderDefaults.html +0 -155
- package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
- package/docs/interfaces/PromptFoldersResponse.html +0 -56
- package/docs/interfaces/RoomDetails.html +0 -151
- package/docs/interfaces/RoomErrorUpdate.html +0 -82
- package/docs/interfaces/RoomInfo.html +0 -88
- package/docs/interfaces/RoomMessageUpdate.html +0 -113
- package/docs/interfaces/RoomMessagesResponse.html +0 -62
- package/docs/interfaces/SendMessageResult.html +0 -62
- package/docs/interfaces/StoryErrorEvent.html +0 -84
- package/docs/interfaces/StoryIdea.html +0 -74
- package/docs/interfaces/StoryInfo.html +0 -198
- package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
- package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
- package/docs/interfaces/StoryState.html +0 -108
- package/docs/interfaces/StoryStateEvent.html +0 -76
- package/docs/interfaces/ToolArtifact.html +0 -85
- package/docs/interfaces/ToolCaller.html +0 -77
- package/docs/interfaces/ToolDefinition.html +0 -80
- package/docs/interfaces/ToolHelpers.html +0 -105
- package/docs/interfaces/ToolPackDocuments.html +0 -100
- package/docs/interfaces/ToolParameter.html +0 -74
- package/docs/interfaces/ToolRoomAccess.html +0 -260
- package/docs/interfaces/ToolSummary.html +0 -74
- package/docs/interfaces/ToolsResponse.html +0 -68
- package/docs/interfaces/Transaction.html +0 -104
- package/docs/interfaces/TransactionHistoryResponse.html +0 -62
- package/docs/modules.html +0 -53
- package/docs/types/PackOrigin.html +0 -34
- package/docs/types/PromptScope.html +0 -34
- package/docs/types/RoomTurnMode.html +0 -42
- package/docs/types/RoomUpdate.html +0 -36
- package/docs/types/RosterOverrides.html +0 -42
- package/docs/types/ToolContext.html +0 -40
- package/docs/types/ToolRunResult.html +0 -34
- package/src/tools/packs/dnd5e/README.md +0 -867
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The `check` tool: every d20 test a character makes, with the modifiers read off
|
|
4
|
+
* their sheet so no agent has to remember or invent a number.
|
|
5
|
+
*/
|
|
2
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
7
|
if (k2 === undefined) k2 = k;
|
|
4
8
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -44,6 +48,14 @@ const encounter_1 = require("../engine/encounter");
|
|
|
44
48
|
const shared_1 = require("./shared");
|
|
45
49
|
const BATCH_EXAMPLE = '[{"character":"Thalia","kind":"save","subject":"dex","dc":15},{"character":"Dorn","kind":"save","subject":"dex","dc":15}]';
|
|
46
50
|
const MAX_BATCH = 12;
|
|
51
|
+
/**
|
|
52
|
+
* The ability a tool check falls back to.
|
|
53
|
+
*
|
|
54
|
+
* Dexterity because the commonest tool check in play by a wide margin is picking a
|
|
55
|
+
* lock or disarming a trap with thieves' tools, which the SRD's own trap rules call
|
|
56
|
+
* a Dexterity check. Every result names the ability it used, so a check that should
|
|
57
|
+
* have been Intelligence is visible rather than silently wrong.
|
|
58
|
+
*/
|
|
47
59
|
const DEFAULT_TOOL_ABILITY = 'dex';
|
|
48
60
|
exports.checkTool = {
|
|
49
61
|
name: 'check',
|
|
@@ -102,6 +114,10 @@ exports.checkTool = {
|
|
|
102
114
|
if (requests.length > MAX_BATCH) {
|
|
103
115
|
throw new Error(`At most ${MAX_BATCH} rolls per call; ${requests.length} were given. Split them across turns.`);
|
|
104
116
|
}
|
|
117
|
+
// Read once and written once, however many rolls the batch holds. Each roll
|
|
118
|
+
// has to see what the ones before it spent — a batch of two bites from the
|
|
119
|
+
// same wolf is the thing being caught — but a whole group's attacks is one
|
|
120
|
+
// artifact write rather than one per roll.
|
|
105
121
|
const encounter = requests.some((r) => r.kind === 'attack') ? (0, shared_1.readEncounter)(room) : null;
|
|
106
122
|
const outcomes = [];
|
|
107
123
|
for (const request of requests) {
|
|
@@ -119,6 +135,7 @@ exports.checkTool = {
|
|
|
119
135
|
};
|
|
120
136
|
},
|
|
121
137
|
};
|
|
138
|
+
/** Reads either the single-roll parameters or the batch array. */
|
|
122
139
|
function collectRequests(args) {
|
|
123
140
|
const batch = (0, coerce_1.jsonArray)(args.batch, 'batch', BATCH_EXAMPLE);
|
|
124
141
|
const entries = batch.length > 0 ? batch : [args];
|
|
@@ -178,6 +195,12 @@ function resolveCheck(room, request, encounter) {
|
|
|
178
195
|
}
|
|
179
196
|
const sheet = (0, shared_1.loadSheet)(room, request.character);
|
|
180
197
|
const state = sheet.state;
|
|
198
|
+
// Before anything is rolled: a fight in progress governs who may attack and how
|
|
199
|
+
// often, and a roll that should not have happened cannot be taken back once the
|
|
200
|
+
// damage is in the result.
|
|
201
|
+
// A reaction happens on someone else's turn by definition — an opportunity
|
|
202
|
+
// attack is the common one — so the order cannot govern it. Declared rather than
|
|
203
|
+
// inferred, so the bypass is visible in the log instead of silent.
|
|
181
204
|
const governs = request.kind === 'attack' && !request.reaction ? encounter : null;
|
|
182
205
|
if (governs) {
|
|
183
206
|
const refusal = refuseIllegalAttack(governs, state);
|
|
@@ -192,12 +215,18 @@ function resolveCheck(room, request, encounter) {
|
|
|
192
215
|
const resolved = resolveModifier(state, request);
|
|
193
216
|
const asked = normalizeMode(request.mode);
|
|
194
217
|
const kind = request.kind === 'attack' ? 'attack' : request.kind === 'save' ? 'save' : 'check';
|
|
218
|
+
// A save is subject to the ability rolled, a check to the skill; both narrow
|
|
219
|
+
// which conditions apply. A tool check is subject to the ability it was made
|
|
220
|
+
// with, since the tool's own name tells `conditionEffects` nothing — and being
|
|
221
|
+
// heavily encumbered has to still hamper a Dexterity check with thieves' tools.
|
|
195
222
|
const subject = kind === 'save'
|
|
196
223
|
? rules.resolveAbility(request.subject || '')
|
|
197
224
|
: request.kind === 'tool'
|
|
198
225
|
? toolAbility(request)
|
|
199
226
|
: (request.subject || '').trim().toLowerCase();
|
|
200
227
|
const effects = rules.conditionEffects(state, kind, subject);
|
|
228
|
+
// Some conditions do not hamper the roll, they remove it: a paralyzed
|
|
229
|
+
// creature fails Strength and Dexterity saves without rolling.
|
|
201
230
|
if (effects.autoFail) {
|
|
202
231
|
const outcome = {
|
|
203
232
|
character: state.name,
|
|
@@ -214,6 +243,8 @@ function resolveCheck(room, request, encounter) {
|
|
|
214
243
|
};
|
|
215
244
|
return outcome;
|
|
216
245
|
}
|
|
246
|
+
// Advantage and disadvantage cancel rather than stack, so a condition that
|
|
247
|
+
// imposes disadvantage undoes advantage instead of adding to it.
|
|
217
248
|
let mode = asked;
|
|
218
249
|
let modeReason;
|
|
219
250
|
if (effects.disadvantage) {
|
|
@@ -239,6 +270,7 @@ function resolveCheck(room, request, encounter) {
|
|
|
239
270
|
detail: '',
|
|
240
271
|
};
|
|
241
272
|
if (request.kind === 'attack') {
|
|
273
|
+
// Spent whether it hits or misses: a miss is still the attack.
|
|
242
274
|
if (governs)
|
|
243
275
|
(0, encounter_1.recordAttack)(governs, state.name);
|
|
244
276
|
if (request.reaction && encounter)
|
|
@@ -248,11 +280,15 @@ function resolveCheck(room, request, encounter) {
|
|
|
248
280
|
if (roll.natural1)
|
|
249
281
|
outcome.critical = 'miss';
|
|
250
282
|
if (request.dc !== undefined) {
|
|
283
|
+
// A natural 20 always hits and a natural 1 always misses, whatever the AC.
|
|
251
284
|
outcome.dc = request.dc;
|
|
252
285
|
outcome.passed = roll.natural20 ? true : roll.natural1 ? false : roll.total >= request.dc;
|
|
253
286
|
}
|
|
254
287
|
if (resolved.attack && outcome.passed !== false) {
|
|
255
288
|
outcome.damage = (0, dice_1.rollDamage)(resolved.attack.dmg, resolved.attack.type, outcome.critical === 'hit');
|
|
289
|
+
// The rider, on the hit it applies to. Returned here rather than left on
|
|
290
|
+
// the stat block because this is the moment it has to be adjudicated, and
|
|
291
|
+
// a rider that has to be remembered from setup is one that is not.
|
|
256
292
|
if (resolved.attack.note)
|
|
257
293
|
outcome.rider = resolved.attack.note;
|
|
258
294
|
}
|
|
@@ -263,6 +299,10 @@ function resolveCheck(room, request, encounter) {
|
|
|
263
299
|
}
|
|
264
300
|
outcome.detail = describeOutcome(outcome, roll.kept[0]);
|
|
265
301
|
outcome.boon = offerHeldDie(state, outcome);
|
|
302
|
+
// Record the roll so a held die can be added to *this* one rather than to what
|
|
303
|
+
// the agent running the fight remembers of it. Only while a die is held: nobody
|
|
304
|
+
// else can use the record, and writing one on every check in the game would cost
|
|
305
|
+
// a sheet write and a client notification per roll.
|
|
266
306
|
if ((state.boons || []).length > 0) {
|
|
267
307
|
recordPendingRoll(room, state, request, outcome, encounter);
|
|
268
308
|
}
|
|
@@ -280,10 +320,41 @@ function resolveCheck(room, request, encounter) {
|
|
|
280
320
|
}
|
|
281
321
|
return outcome;
|
|
282
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Refuses an attack the initiative order does not allow.
|
|
325
|
+
*
|
|
326
|
+
* Two rules, and between them they close what a played fight actually did. A wolf
|
|
327
|
+
* with one Bite and no Multiattack rolled an attack during the wolf *before* it in
|
|
328
|
+
* the order, then rolled a second one when its own turn came up; the second killed a
|
|
329
|
+
* level-1 ranger. Nothing at the time could tell either roll from a legal one.
|
|
330
|
+
*
|
|
331
|
+
* - **A combatant whose turn has passed does not act again this round.** Rolling
|
|
332
|
+
* ahead of the pointer stays legal, because several monsters acting at once is one
|
|
333
|
+
* batched call by design and batching them must not become an error.
|
|
334
|
+
* - **One attack per round without Multiattack**, which is what makes rolling ahead
|
|
335
|
+
* safe: a creature that attacks early has spent the same budget it would have spent
|
|
336
|
+
* on its turn, so it cannot do both.
|
|
337
|
+
*
|
|
338
|
+
* **Monsters only.** A monster's action economy is exactly this rule — one attack
|
|
339
|
+
* unless the block prints Multiattack — and the agent running the fight is the only
|
|
340
|
+
* party to it, which is why nothing caught the extra bite. A character's is not:
|
|
341
|
+
* two-weapon fighting gives a second attack roll at *level 1*, and the ranger this
|
|
342
|
+
* guard exists to protect was carrying two shortswords when she died. Extra Attack,
|
|
343
|
+
* Action Surge, haste and a multi-beam eldritch blast all follow. Applying the budget
|
|
344
|
+
* to characters would refuse legal play, and a wrong refusal is worse than an absent
|
|
345
|
+
* guard — a character's attacks are declared by their own agent and resolved by
|
|
346
|
+
* another, so two parties have to agree before one happens.
|
|
347
|
+
*
|
|
348
|
+
* @param encounter The fight in progress
|
|
349
|
+
* @param state The would-be attacker
|
|
350
|
+
* @returns A refusal, or undefined when the attack is allowed
|
|
351
|
+
*/
|
|
283
352
|
function refuseIllegalAttack(encounter, state) {
|
|
284
353
|
if (!state.foe)
|
|
285
354
|
return undefined;
|
|
286
355
|
const standing = (0, encounter_1.turnStanding)(encounter, state.name);
|
|
356
|
+
// Not in the initiative order at all: a creature outside the fight is not
|
|
357
|
+
// governed by it. A trap, a bystander, something the DM is resolving alongside.
|
|
287
358
|
if (standing === 'absent')
|
|
288
359
|
return undefined;
|
|
289
360
|
const up = (0, encounter_1.currentCombatant)(encounter)?.name;
|
|
@@ -315,6 +386,17 @@ function refuseIllegalAttack(encounter, state) {
|
|
|
315
386
|
}
|
|
316
387
|
return undefined;
|
|
317
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Stores the roll a held die would be added to.
|
|
391
|
+
*
|
|
392
|
+
* Written through `mutateSheet` like any other sheet change, so it lands in the same
|
|
393
|
+
* artifact the die itself lives on and cannot drift from it.
|
|
394
|
+
* @param room The room access
|
|
395
|
+
* @param state The character who rolled
|
|
396
|
+
* @param request What was rolled
|
|
397
|
+
* @param outcome The result
|
|
398
|
+
* @param encounter The fight in progress, for the round a stale roll is judged against
|
|
399
|
+
*/
|
|
318
400
|
function recordPendingRoll(room, state, request, outcome, encounter) {
|
|
319
401
|
const pending = { kind: request.kind, total: outcome.total };
|
|
320
402
|
if (outcome.what)
|
|
@@ -330,11 +412,23 @@ function recordPendingRoll(room, state, request, outcome, encounter) {
|
|
|
330
412
|
return { ok: true, state: sheet.state, summary: 'roll recorded' };
|
|
331
413
|
});
|
|
332
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Offers back a die this character is holding, when it could still turn the roll.
|
|
417
|
+
*
|
|
418
|
+
* Only on a miss, and only when the die's maximum could actually reach the target
|
|
419
|
+
* number — a die that cannot save the roll is noise, and a die that could is the
|
|
420
|
+
* whole point. A bard gave Inspiration to a fighter who then missed by three, and
|
|
421
|
+
* nothing anywhere surfaced the d6; the player had to say so afterwards, twice, and
|
|
422
|
+
* it was still never offered.
|
|
423
|
+
* @param state The character who rolled
|
|
424
|
+
* @param outcome The roll, already resolved
|
|
425
|
+
* @returns The offer, or undefined when there is nothing worth saying
|
|
426
|
+
*/
|
|
333
427
|
function offerHeldDie(state, outcome) {
|
|
334
428
|
if (outcome.passed !== false || outcome.dc === undefined)
|
|
335
429
|
return undefined;
|
|
336
430
|
if (outcome.critical === 'miss')
|
|
337
|
-
return undefined;
|
|
431
|
+
return undefined; // A natural 1 misses whatever is added.
|
|
338
432
|
const held = state.boons || [];
|
|
339
433
|
if (held.length === 0)
|
|
340
434
|
return undefined;
|
|
@@ -344,9 +438,20 @@ function offerHeldDie(state, outcome) {
|
|
|
344
438
|
return undefined;
|
|
345
439
|
return { name: usable.n, die: usable.die, from: usable.from, short };
|
|
346
440
|
}
|
|
441
|
+
/** How a combatant's reaction is keyed in the round's budget, apart from its action. */
|
|
347
442
|
function reactionKey(name) {
|
|
348
443
|
return `${name} (reaction)`;
|
|
349
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* Refuses a second reaction in the same round.
|
|
447
|
+
*
|
|
448
|
+
* A reaction is deliberately outside the turn order, which is what makes it the one
|
|
449
|
+
* way past {@link refuseIllegalAttack} — so it needs its own limit, or declaring
|
|
450
|
+
* `reaction` becomes a way to attack as often as you like.
|
|
451
|
+
* @param encounter The fight in progress
|
|
452
|
+
* @param state The would-be reactor
|
|
453
|
+
* @returns A refusal, or undefined when the reaction is available
|
|
454
|
+
*/
|
|
350
455
|
function refuseSpentReaction(encounter, state) {
|
|
351
456
|
if (!state.foe)
|
|
352
457
|
return undefined;
|
|
@@ -360,6 +465,12 @@ function refuseSpentReaction(encounter, state) {
|
|
|
360
465
|
options: [`Wait until round ${encounter.round + 1}`, "Roll a different creature's attack"],
|
|
361
466
|
};
|
|
362
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* The ability a tool check is made with.
|
|
470
|
+
* @param request The roll being made
|
|
471
|
+
* @returns The ability key, defaulting to Dexterity
|
|
472
|
+
* @throws When an ability was named but is not one of the six
|
|
473
|
+
*/
|
|
363
474
|
function toolAbility(request) {
|
|
364
475
|
const named = (request.ability || '').trim();
|
|
365
476
|
if (!named)
|
|
@@ -370,6 +481,7 @@ function toolAbility(request) {
|
|
|
370
481
|
}
|
|
371
482
|
return ability;
|
|
372
483
|
}
|
|
484
|
+
/** Works out which modifier on the sheet a request is asking for. */
|
|
373
485
|
function resolveModifier(state, request) {
|
|
374
486
|
const subject = (request.subject || '').trim();
|
|
375
487
|
if (request.kind === 'initiative') {
|
|
@@ -399,6 +511,8 @@ function resolveModifier(state, request) {
|
|
|
399
511
|
const resolved = rules.toolCheckModifier(state, tool, ability);
|
|
400
512
|
return {
|
|
401
513
|
modifier: resolved.modifier,
|
|
514
|
+
// The ability is named because it was the caller's choice or our default,
|
|
515
|
+
// and a wrong one is only correctable if it is visible.
|
|
402
516
|
label: `${tool} (${ability.toUpperCase()})`,
|
|
403
517
|
note: resolved.proficient
|
|
404
518
|
? resolved.expertise
|
|
@@ -448,6 +562,7 @@ function describeOutcome(outcome, naturalRoll) {
|
|
|
448
562
|
}
|
|
449
563
|
return parts.join(' ');
|
|
450
564
|
}
|
|
565
|
+
/** A death saving throw is rolled and recorded on the sheet in one step. */
|
|
451
566
|
function resolveDeathSave(room, request) {
|
|
452
567
|
const roll = (0, dice_1.rollD20)(0, normalizeMode(request.mode), dice_1.defaultRng);
|
|
453
568
|
const face = roll.kept[0];
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `class_guide` tool: which classes this table allows, and handing a class's
|
|
3
|
+
* document to whoever is playing it.
|
|
4
|
+
*
|
|
5
|
+
* Exists because a class document cannot be attached to an agent in advance. A
|
|
6
|
+
* player's class is chosen *after* their agent is created, and the creator is handed
|
|
7
|
+
* players one at a time, so at every moment before this tool runs there is either
|
|
8
|
+
* nothing to attach or no way to know which of the twelve to pick.
|
|
9
|
+
*
|
|
10
|
+
* So the classes come from the files — `class-*.md` in the pack's `artifacts/`
|
|
11
|
+
* directory, listed at the moment the question is asked — and the document a player
|
|
12
|
+
* picks becomes a room artifact the creator and that player can read. Adding a class
|
|
13
|
+
* to a table is a file drop.
|
|
14
|
+
*/
|
|
1
15
|
import { NativeToolDefinition } from '../../../native-tool.types';
|
|
2
16
|
export declare const classGuideTool: NativeToolDefinition;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The `class_guide` tool: which classes this table allows, and handing a class's
|
|
4
|
+
* document to whoever is playing it.
|
|
5
|
+
*
|
|
6
|
+
* Exists because a class document cannot be attached to an agent in advance. A
|
|
7
|
+
* player's class is chosen *after* their agent is created, and the creator is handed
|
|
8
|
+
* players one at a time, so at every moment before this tool runs there is either
|
|
9
|
+
* nothing to attach or no way to know which of the twelve to pick.
|
|
10
|
+
*
|
|
11
|
+
* So the classes come from the files — `class-*.md` in the pack's `artifacts/`
|
|
12
|
+
* directory, listed at the moment the question is asked — and the document a player
|
|
13
|
+
* picks becomes a room artifact the creator and that player can read. Adding a class
|
|
14
|
+
* to a table is a file drop.
|
|
15
|
+
*/
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.classGuideTool = void 0;
|
|
4
18
|
const coerce_1 = require("../engine/coerce");
|
|
@@ -22,6 +36,9 @@ exports.classGuideTool = {
|
|
|
22
36
|
},
|
|
23
37
|
],
|
|
24
38
|
async handler(args, helpers) {
|
|
39
|
+
// A room is needed to *share* a document, not to read one, so the requirement
|
|
40
|
+
// is asserted in the sharing branch — which keeps listing and reading usable
|
|
41
|
+
// from the Tools test panel, where there is no room.
|
|
25
42
|
const documents = (0, shared_1.requirePackDocuments)(helpers);
|
|
26
43
|
const wanted = (0, coerce_1.str)(args.class, 'class');
|
|
27
44
|
if (!wanted)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** The dice tools: raw expression rolling, and initiative for a whole encounter. */
|
|
1
2
|
import { NativeToolDefinition } from '../../../native-tool.types';
|
|
2
3
|
export declare const rollDiceTool: NativeToolDefinition;
|
|
3
4
|
export declare const rollInitiativeTool: NativeToolDefinition;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/** The dice tools: raw expression rolling, and initiative for a whole encounter. */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.rollInitiativeTool = exports.rollDiceTool = void 0;
|
|
4
5
|
const coerce_1 = require("../engine/coerce");
|
|
@@ -48,6 +49,25 @@ exports.rollDiceTool = {
|
|
|
48
49
|
};
|
|
49
50
|
},
|
|
50
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Refuses a freehand roll that is really a combatant's attack.
|
|
54
|
+
*
|
|
55
|
+
* `check` is the only path that compares a roll to armour class. Rolling the damage
|
|
56
|
+
* here instead skips the attack roll entirely, and in a played fight that is exactly
|
|
57
|
+
* what happened: `roll_dice({"expressions": "critical_bite=4d4+2", "reason": "Wolf B
|
|
58
|
+
* critical bite against unconscious Artemis"})`, applied as a critical, killed a
|
|
59
|
+
* character who was never rolled against. A melee hit on an unconscious target is an
|
|
60
|
+
* automatic critical; it is not an automatic hit, and she had an armour class.
|
|
61
|
+
*
|
|
62
|
+
* The test is deliberately narrow — the text has to name both a combatant in the
|
|
63
|
+
* order *and* one of that same combatant's own attacks. "Wolf B's Dexterity save"
|
|
64
|
+
* names a combatant and no attack, so it rolls; a breath weapon or a trap names
|
|
65
|
+
* neither. Anything outside a fight is not examined at all.
|
|
66
|
+
*
|
|
67
|
+
* @param room The room access
|
|
68
|
+
* @param text The expressions and the stated reason, together
|
|
69
|
+
* @returns A refusal, or undefined when the roll is not an attack in disguise
|
|
70
|
+
*/
|
|
51
71
|
function refuseCombatantAttack(room, text) {
|
|
52
72
|
const encounter = (0, shared_1.readEncounter)(room);
|
|
53
73
|
if (!encounter)
|
|
@@ -61,7 +81,7 @@ function refuseCombatantAttack(room, text) {
|
|
|
61
81
|
attacks = (0, shared_1.loadSheet)(room, combatant.name).state.attacks.map((a) => a.n);
|
|
62
82
|
}
|
|
63
83
|
catch {
|
|
64
|
-
continue;
|
|
84
|
+
continue; // No sheet to contradict: nothing to be sure about, so allow it.
|
|
65
85
|
}
|
|
66
86
|
const named = attacks.find((attack) => haystack.includes(attack.toLowerCase()));
|
|
67
87
|
if (!named)
|
|
@@ -114,6 +134,8 @@ exports.rollInitiativeTool = {
|
|
|
114
134
|
source = 'sheet';
|
|
115
135
|
}
|
|
116
136
|
else {
|
|
137
|
+
// A monster the DM did not give a modifier for rolls flat rather
|
|
138
|
+
// than blocking the whole encounter on one missing number.
|
|
117
139
|
modifier = 0;
|
|
118
140
|
source = 'assumed 0';
|
|
119
141
|
}
|
|
@@ -129,8 +151,18 @@ exports.rollInitiativeTool = {
|
|
|
129
151
|
roll: entry.roll.kept[0],
|
|
130
152
|
modifier: entry.modifier,
|
|
131
153
|
}));
|
|
154
|
+
// A new fight starting is the reliable moment to clear the last one; the end
|
|
155
|
+
// of a fight is a message rather than a tool call and may never come. A
|
|
156
|
+
// leftover then costs one unused artifact rather than a monster with stale
|
|
157
|
+
// hit points joining the next encounter.
|
|
158
|
+
//
|
|
159
|
+
// Only the ones *not* in this fight: a fight is set up `stat_block place`
|
|
160
|
+
// then `roll_initiative`, so anything named here was just placed for it.
|
|
132
161
|
const cleared = (0, shared_1.clearFoes)(room, order.map((entry) => entry.name));
|
|
133
162
|
const encounterName = args.encounter_name ? (0, coerce_1.str)(args.encounter_name, 'encounter_name') : 'Encounter';
|
|
163
|
+
// State the `encounter` tool walks and advances, not a snapshot. Transient
|
|
164
|
+
// for the same reason as the sheets: it changes every turn, and cached it
|
|
165
|
+
// would throw away every viewer's prompt prefix that often.
|
|
134
166
|
const tracked = (0, shared_1.listFoeNames)(room);
|
|
135
167
|
const isFoe = new Set(tracked.map((name) => (0, coerce_2.nameKey)(name)));
|
|
136
168
|
const encounter = (0, encounter_1.newEncounter)(encounterName, order.map((entry) => ({
|
|
@@ -155,7 +187,9 @@ exports.rollInitiativeTool = {
|
|
|
155
187
|
};
|
|
156
188
|
},
|
|
157
189
|
};
|
|
190
|
+
/** Splits `Goblin A+2` into a name and a modifier, or a bare name. */
|
|
158
191
|
function parseCombatant(entry) {
|
|
192
|
+
// Accept a unicode minus as well, since models emit it.
|
|
159
193
|
const match = /^(.*?)\s*([+\-−]\s*\d+)$/.exec(entry.trim());
|
|
160
194
|
if (!match)
|
|
161
195
|
return { name: entry.trim(), modifier: null };
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `encounter` tool: whose turn it is, what round it is, and ending the fight.
|
|
3
|
+
*
|
|
4
|
+
* `roll_initiative` starts an encounter; this walks it. One call per turn, against a
|
|
5
|
+
* stored order that cannot drift the way one restated from memory does.
|
|
6
|
+
*/
|
|
1
7
|
import { NativeToolDefinition } from '../../../native-tool.types';
|
|
2
8
|
export declare const encounterTool: NativeToolDefinition;
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The `encounter` tool: whose turn it is, what round it is, and ending the fight.
|
|
4
|
+
*
|
|
5
|
+
* `roll_initiative` starts an encounter; this walks it. One call per turn, against a
|
|
6
|
+
* stored order that cannot drift the way one restated from memory does.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.encounterTool = void 0;
|
|
4
10
|
const coerce_1 = require("../engine/coerce");
|
|
5
11
|
const encounter_1 = require("../engine/encounter");
|
|
6
12
|
const sheet_1 = require("../engine/sheet");
|
|
7
13
|
const shared_1 = require("./shared");
|
|
14
|
+
/**
|
|
15
|
+
* Reads how every combatant actually ended, for the hand-back.
|
|
16
|
+
*
|
|
17
|
+
* The point of this is that it is *read*, not recalled. A fight ends with a written
|
|
18
|
+
* report, and a report written from memory once declared a total party kill in a
|
|
19
|
+
* fight where two of the four characters were still making death saving throws —
|
|
20
|
+
* one at two failures, one at one. Both were alive and neither came back, because
|
|
21
|
+
* nothing ever contradicted the sentence that said otherwise.
|
|
22
|
+
* @param room The room access
|
|
23
|
+
* @param state The encounter, read before its monsters are cleared
|
|
24
|
+
* @returns One entry per combatant, in initiative order
|
|
25
|
+
*/
|
|
8
26
|
function readOutcome(room, state) {
|
|
9
27
|
return state.order.map((combatant) => {
|
|
10
28
|
let sheet;
|
|
@@ -12,6 +30,7 @@ function readOutcome(room, state) {
|
|
|
12
30
|
sheet = (0, shared_1.loadSheet)(room, combatant.name).state;
|
|
13
31
|
}
|
|
14
32
|
catch {
|
|
33
|
+
// Cleared already, or never placed. Reported rather than guessed at.
|
|
15
34
|
return { name: combatant.name, hitPoints: '—', status: 'unknown' };
|
|
16
35
|
}
|
|
17
36
|
const outcome = {
|
|
@@ -27,13 +46,17 @@ function readOutcome(room, state) {
|
|
|
27
46
|
return outcome;
|
|
28
47
|
});
|
|
29
48
|
}
|
|
49
|
+
/** Standing or dying or dead, decided by the sheet and nothing else. */
|
|
30
50
|
function describeStanding(sheet) {
|
|
31
51
|
if (sheet.hp.cur > 0)
|
|
32
52
|
return 'standing';
|
|
53
|
+
// A monster dies at 0 and makes no saves; a character at 0 is dying until three
|
|
54
|
+
// failures say otherwise, whatever anyone narrated.
|
|
33
55
|
if (sheet.foe || sheet.deathSaves.f >= 3)
|
|
34
56
|
return 'dead';
|
|
35
57
|
return sheet.stable ? 'stable' : 'dying';
|
|
36
58
|
}
|
|
59
|
+
/** A compact description of where the fight has got to. */
|
|
37
60
|
function describe(room, state) {
|
|
38
61
|
const up = (0, encounter_1.currentCombatant)(state);
|
|
39
62
|
return {
|
|
@@ -86,6 +109,8 @@ exports.encounterTool = {
|
|
|
86
109
|
throw e;
|
|
87
110
|
}
|
|
88
111
|
if (action === 'end') {
|
|
112
|
+
// Read before clearing: the monsters' sheets are about to be deleted, and
|
|
113
|
+
// the outcome is the last moment anything can say what they were.
|
|
89
114
|
const outcome = state ? readOutcome(room, state) : undefined;
|
|
90
115
|
const cleared = (0, shared_1.clearFoes)(room);
|
|
91
116
|
room.remove(sheet_1.ENCOUNTER_ARTIFACT);
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `magic_item` tool: look an item up, or define one for this campaign.
|
|
3
|
+
*
|
|
4
|
+
* Same shape and same reasoning as `stat_block`. The Dungeon Master should never
|
|
5
|
+
* have to invent what an item does, and the common case — the party found a cloak
|
|
6
|
+
* of elvenkind, what is it? — is one cheap call rather than a handoff.
|
|
7
|
+
*/
|
|
1
8
|
import { NativeToolDefinition } from '../../../native-tool.types';
|
|
2
9
|
export declare const magicItemTool: NativeToolDefinition;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The `magic_item` tool: look an item up, or define one for this campaign.
|
|
4
|
+
*
|
|
5
|
+
* Same shape and same reasoning as `stat_block`. The Dungeon Master should never
|
|
6
|
+
* have to invent what an item does, and the common case — the party found a cloak
|
|
7
|
+
* of elvenkind, what is it? — is one cheap call rather than a handoff.
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.magicItemTool = void 0;
|
|
4
11
|
const coerce_1 = require("../engine/coerce");
|
|
@@ -87,15 +94,20 @@ exports.magicItemTool = {
|
|
|
87
94
|
source: resolved.source,
|
|
88
95
|
details: compact(resolved.item),
|
|
89
96
|
entry: (0, items_1.describeItem)(resolved.item),
|
|
97
|
+
// Only the shipped table is SRD text; a campaign item belongs to the
|
|
98
|
+
// table that wrote it. Same reasoning as `stat_block`.
|
|
90
99
|
attribution: resolved.source === 'srd' ? srd_1.SRD_ATTRIBUTION : undefined,
|
|
91
100
|
};
|
|
92
101
|
},
|
|
93
102
|
};
|
|
103
|
+
/** Adds or replaces a campaign item. */
|
|
94
104
|
function define(room, wanted, raw, campaign) {
|
|
95
105
|
const supplied = (0, coerce_1.jsonObject)(raw, 'define', DEFINE_EXAMPLE);
|
|
96
106
|
const item = (0, campaign_items_1.normalizeItem)(wanted, supplied);
|
|
97
107
|
const key = (0, coerce_1.nameKey)(item.name || wanted);
|
|
98
108
|
const replaced = campaign[key] !== undefined;
|
|
109
|
+
// Read-modify-write inside one update() so two concurrent definitions cannot
|
|
110
|
+
// lose each other. Viewers stay narrow: everything reads this through the tool.
|
|
99
111
|
room.update(campaign_items_1.ITEMS_ARTIFACT, (current) => {
|
|
100
112
|
const entries = (0, campaign_items_1.parseCampaignItems)(current?.body);
|
|
101
113
|
entries[key] = item;
|
|
@@ -108,6 +120,7 @@ function define(room, wanted, raw, campaign) {
|
|
|
108
120
|
note: `Stored in the "${campaign_items_1.ITEMS_ARTIFACT}" artifact. Look it up with magic_item from now on; it overrides any built-in item of the same name.`,
|
|
109
121
|
};
|
|
110
122
|
}
|
|
123
|
+
/** The machine-readable half: what the other tools and the sheet need. */
|
|
111
124
|
function compact(item) {
|
|
112
125
|
return {
|
|
113
126
|
type: item.subtype ? `${item.type} (${item.subtype})` : item.type,
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `stat_block` tool: look a creature up, or define one for this campaign.
|
|
3
|
+
*
|
|
4
|
+
* Exists so the Dungeon Master never has to invent a creature's numbers and never
|
|
5
|
+
* has to stall mid-scene to ask another agent for them. Ordinary creatures resolve
|
|
6
|
+
* from the shipped SRD table in one cheap call; anything bespoke is written into
|
|
7
|
+
* the room's `Bestiary` once and resolves the same way afterwards.
|
|
8
|
+
*/
|
|
1
9
|
import { NativeToolDefinition } from '../../../native-tool.types';
|
|
2
10
|
export declare const statBlockTool: NativeToolDefinition;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The `stat_block` tool: look a creature up, or define one for this campaign.
|
|
4
|
+
*
|
|
5
|
+
* Exists so the Dungeon Master never has to invent a creature's numbers and never
|
|
6
|
+
* has to stall mid-scene to ask another agent for them. Ordinary creatures resolve
|
|
7
|
+
* from the shipped SRD table in one cheap call; anything bespoke is written into
|
|
8
|
+
* the room's `Bestiary` once and resolves the same way afterwards.
|
|
9
|
+
*/
|
|
2
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
11
|
exports.statBlockTool = void 0;
|
|
4
12
|
const coerce_1 = require("../engine/coerce");
|
|
@@ -7,6 +15,16 @@ const bestiary_1 = require("../engine/bestiary");
|
|
|
7
15
|
const srd_1 = require("../data/srd");
|
|
8
16
|
const coerce_2 = require("../engine/coerce");
|
|
9
17
|
const shared_1 = require("./shared");
|
|
18
|
+
/**
|
|
19
|
+
* The whole schema, as far as the model is concerned — it is the only shape
|
|
20
|
+
* guidance the tool gives, in both the tool description and the `define`
|
|
21
|
+
* parameter. It therefore has to show the fields that are easy to get wrong:
|
|
22
|
+
* `traits` (and `actions`, `reactions`, `legendary.options`, which share its
|
|
23
|
+
* shape) is a *list of named paragraphs*, and `resist` is a *list*. Left out of
|
|
24
|
+
* the example, a real campaign wrote `traits` as one prose string and named its
|
|
25
|
+
* resistances `resistances`, so the creature rendered as hundreds of lines of
|
|
26
|
+
* `undefined` and its resistances were dropped without a word.
|
|
27
|
+
*/
|
|
10
28
|
const DEFINE_EXAMPLE = '{"name":"Kesh\'s enforcer","ac":15,"hp":58,"hpDice":"9d8+18","speed":"30 ft.","abil":{"str":17,"dex":14,"con":15,"int":10,"wis":12,"cha":11},"resist":["cold","bludgeoning from nonmagical attacks"],"traits":[{"n":"Brutal Reprisal","text":"When first bloodied, it makes one maul attack as a reaction."}],"multiattack":"Two maul attacks.","attacks":[{"n":"Maul","atk":6,"dmg":"2d6+4","type":"bludgeoning","reach":"5 ft","note":"On a hit the target makes a DC 14 Strength save or is knocked prone."}]}';
|
|
11
29
|
const MAX_INSTANCES = 12;
|
|
12
30
|
exports.statBlockTool = {
|
|
@@ -51,6 +69,8 @@ exports.statBlockTool = {
|
|
|
51
69
|
if (!creature)
|
|
52
70
|
throw new Error('Name a creature, or "list" to see what is available.');
|
|
53
71
|
const existing = room.get(bestiary_1.BESTIARY_ARTIFACT);
|
|
72
|
+
// A corrupt bestiary throws rather than being silently replaced, the same
|
|
73
|
+
// way a corrupt character sheet does.
|
|
54
74
|
const campaign = (0, bestiary_1.parseBestiary)(existing?.body);
|
|
55
75
|
if (args.define !== undefined && args.define !== '' && args.define !== null) {
|
|
56
76
|
return define(room, creature, args.define, campaign);
|
|
@@ -73,6 +93,8 @@ exports.statBlockTool = {
|
|
|
73
93
|
};
|
|
74
94
|
}
|
|
75
95
|
const resolved = (0, bestiary_1.resolveMonster)(creature, campaign);
|
|
96
|
+
// Several creatures match a partial name. Returning one of them at random
|
|
97
|
+
// would put a wrong monster into a real fight, so ask instead.
|
|
76
98
|
if (resolved.ambiguous) {
|
|
77
99
|
return {
|
|
78
100
|
found: false,
|
|
@@ -104,16 +126,23 @@ exports.statBlockTool = {
|
|
|
104
126
|
source: resolved.source,
|
|
105
127
|
block: compact(resolved.block),
|
|
106
128
|
statBlock: (0, bestiary_1.describeMonster)(resolved.block),
|
|
129
|
+
// Only the shipped table is SRD text. A campaign creature is the
|
|
130
|
+
// table's own invention, and stamping someone else's licence on it
|
|
131
|
+
// would be a false claim about where it came from.
|
|
107
132
|
attribution: resolved.source === 'srd' ? srd_1.SRD_ATTRIBUTION : undefined,
|
|
108
133
|
...instanceHitPoints(helpers.room, resolved.block, args.count, (0, coerce_1.bool)(args.place)),
|
|
109
134
|
};
|
|
110
135
|
},
|
|
111
136
|
};
|
|
137
|
+
/** Adds or replaces a campaign creature. */
|
|
112
138
|
function define(room, creature, raw, campaign) {
|
|
113
139
|
const supplied = (0, coerce_1.jsonObject)(raw, 'define', DEFINE_EXAMPLE);
|
|
114
140
|
const block = (0, bestiary_1.normalizeMonster)(creature, supplied);
|
|
115
141
|
const key = (0, coerce_2.nameKey)(block.name || creature);
|
|
116
142
|
const replaced = campaign[key] !== undefined;
|
|
143
|
+
// Read-modify-write inside one update() so two concurrent definitions cannot
|
|
144
|
+
// lose each other. Viewers stay narrow: everything reads this through the
|
|
145
|
+
// tool, so nobody needs it in their cached prompt.
|
|
117
146
|
room.update(bestiary_1.BESTIARY_ARTIFACT, (current) => {
|
|
118
147
|
const entries = (0, bestiary_1.parseBestiary)(current?.body);
|
|
119
148
|
entries[key] = block;
|
|
@@ -126,8 +155,24 @@ function define(room, creature, raw, campaign) {
|
|
|
126
155
|
note: `Stored in the "${bestiary_1.BESTIARY_ARTIFACT}" artifact. Look it up with stat_block from now on; it overrides any built-in creature of the same name.`,
|
|
127
156
|
};
|
|
128
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Rolls a hit point total per creature in a group, so a fight has distinct
|
|
160
|
+
* targets rather than identical ones.
|
|
161
|
+
*
|
|
162
|
+
* With `place`, each one is also written as a combatant the other tools can operate
|
|
163
|
+
* on by name — `check`, `apply_hp` and `conditions` all resolve their target through
|
|
164
|
+
* `loadSheet`, so a placed monster works like a character. Without it the totals are
|
|
165
|
+
* only reported, and whoever runs the fight has to hold them in prose.
|
|
166
|
+
*
|
|
167
|
+
* @param room The room, when the caller can place combatants
|
|
168
|
+
* @param block The creature
|
|
169
|
+
* @param count The raw count argument
|
|
170
|
+
* @param place Whether to write the combatants into the fight
|
|
171
|
+
* @returns An `instances` field, or nothing when no count was asked for
|
|
172
|
+
*/
|
|
129
173
|
function instanceHitPoints(room, block, count, place) {
|
|
130
174
|
if (count === undefined || count === null || count === '') {
|
|
175
|
+
// `place` on its own means one of them.
|
|
131
176
|
if (!place)
|
|
132
177
|
return {};
|
|
133
178
|
count = 1;
|
|
@@ -160,6 +205,16 @@ function instanceHitPoints(room, block, count, place) {
|
|
|
160
205
|
'it compares against the armour class for you. Apply damage to them with apply_hp, and set conditions with conditions. Their hit points are tracked for you; do not carry them in your situation line.',
|
|
161
206
|
};
|
|
162
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* The machine-readable half of a result: what the other tools need.
|
|
210
|
+
*
|
|
211
|
+
* Traits, actions, reactions and legendary actions are deliberately absent. They
|
|
212
|
+
* are prose, they reach the model through `statBlock` already, and a result
|
|
213
|
+
* carrying both halves of a vampire twice would approach the 16 KB cap that
|
|
214
|
+
* replaces an oversized result with a mangled string. `saves` is here because it
|
|
215
|
+
* is a number the Dungeon Master adds to a d20 and cannot derive: a proficient
|
|
216
|
+
* save is not the ability modifier.
|
|
217
|
+
*/
|
|
163
218
|
function compact(block) {
|
|
164
219
|
return {
|
|
165
220
|
ac: block.ac,
|