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,76 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The character sheet artifact: its canonical state, how it is parsed out of a
|
|
3
|
+
* Markdown artifact, and how the artifact is rendered back from state.
|
|
4
|
+
*
|
|
5
|
+
* A sheet artifact has three regions with different owners:
|
|
6
|
+
*
|
|
7
|
+
* 1. A rendered summary, regenerated from state on every write. Never
|
|
8
|
+
* authoritative — a human editing it in the Artifacts tab loses nothing,
|
|
9
|
+
* because the next tool call overwrites it.
|
|
10
|
+
* 2. A free-prose region between `<!-- briyah:notes -->` markers, preserved
|
|
11
|
+
* byte-for-byte across writes. This is where backstory and table notes live.
|
|
12
|
+
* 3. A fenced ```briyah-state block holding the canonical JSON. Located by its
|
|
13
|
+
* info string rather than by position, and tagged `briyah-state` rather than
|
|
14
|
+
* `json` both to make it unambiguous to find and to signal to the model that
|
|
15
|
+
* it must not be hand-edited.
|
|
16
|
+
*
|
|
17
|
+
* Keys in the state are abbreviated because the whole block is rendered into the
|
|
18
|
+
* prompt of every agent that can view the sheet, on every turn.
|
|
19
|
+
*/
|
|
1
20
|
import { AbilityKey } from '../data/srd';
|
|
21
|
+
/** The schema version, bumped when a migration becomes necessary. */
|
|
2
22
|
export declare const SHEET_STATE_VERSION = 1;
|
|
3
23
|
export declare const SHEET_NAME_PREFIX = "Sheet: ";
|
|
24
|
+
/**
|
|
25
|
+
* Monster combatants are filed apart from characters so that everything which
|
|
26
|
+
* walks the party — `Party Status`, `read_sheet character: "party"` — keeps
|
|
27
|
+
* walking the party only. See {@link isFoeArtifact}.
|
|
28
|
+
*/
|
|
4
29
|
export declare const FOE_NAME_PREFIX = "Foe: ";
|
|
5
30
|
export declare const PARTY_STATUS_ARTIFACT = "Party Status";
|
|
6
31
|
export declare const ENCOUNTER_ARTIFACT = "Encounter";
|
|
7
32
|
export interface ClassEntry {
|
|
33
|
+
/** Class key, e.g. 'ranger'. */
|
|
8
34
|
c: string;
|
|
35
|
+
/** Subclass name, free text. */
|
|
9
36
|
sub?: string;
|
|
10
37
|
lvl: number;
|
|
38
|
+
/** Hit die, e.g. 'd10'. */
|
|
11
39
|
hd: string;
|
|
12
40
|
}
|
|
13
41
|
export interface ResourcePool {
|
|
14
42
|
max: number;
|
|
15
43
|
cur: number;
|
|
44
|
+
/** When the pool refills: 'short', 'long', or 'other' for manual only. */
|
|
16
45
|
reset?: 'short' | 'long' | 'other';
|
|
17
46
|
}
|
|
18
47
|
export interface InventoryItem {
|
|
48
|
+
/** Item name. */
|
|
19
49
|
n: string;
|
|
50
|
+
/** Quantity. */
|
|
20
51
|
q: number;
|
|
52
|
+
/** True when worn or wielded. */
|
|
21
53
|
eq?: boolean;
|
|
54
|
+
/** Remaining charges or uses, for things like a healer's kit. */
|
|
22
55
|
chg?: number;
|
|
56
|
+
/**
|
|
57
|
+
* True when the character is attuned to this item.
|
|
58
|
+
*
|
|
59
|
+
* Kept on the inventory entry rather than in a list of its own, so it travels
|
|
60
|
+
* with the item: giving away an attuned ring cannot leave the attunement
|
|
61
|
+
* behind, and the three-item limit is a count over the inventory.
|
|
62
|
+
*/
|
|
23
63
|
att?: boolean;
|
|
24
64
|
}
|
|
25
65
|
export interface AttackEntry {
|
|
26
66
|
n: string;
|
|
67
|
+
/** Attack bonus. */
|
|
27
68
|
atk: number;
|
|
69
|
+
/** Damage dice expression, e.g. '1d8+3'. */
|
|
28
70
|
dmg: string;
|
|
71
|
+
/** Damage type, e.g. 'piercing'. */
|
|
29
72
|
type?: string;
|
|
30
73
|
range?: string;
|
|
31
74
|
props?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* The rider a stat block prints after the damage, e.g. a wolf's "DC 11 Strength
|
|
77
|
+
* saving throw or be knocked prone". Carried onto the creature because it is the
|
|
78
|
+
* half of the attack the tools cannot roll for you, and an attack that reaches
|
|
79
|
+
* the table without it is adjudicated as though it did not exist.
|
|
80
|
+
*/
|
|
32
81
|
note?: string;
|
|
33
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* A die another character has handed this one to spend on a future roll.
|
|
85
|
+
*
|
|
86
|
+
* Bardic Inspiration, Bless, Guidance: a resource whose whole effect happens on
|
|
87
|
+
* somebody else's sheet. Spending it used only to decrement the giver's counter,
|
|
88
|
+
* which meant the die existed nowhere — a bard gave Inspiration to a fighter, the
|
|
89
|
+
* fighter missed by three, and nothing surfaced the d6 that would have hit. The
|
|
90
|
+
* player had to say so afterwards, twice, and it still was not offered.
|
|
91
|
+
*/
|
|
34
92
|
export interface BoonEntry {
|
|
35
93
|
n: string;
|
|
94
|
+
/** The die rolled when it is spent, e.g. 'd6'. */
|
|
36
95
|
die: string;
|
|
96
|
+
/** Who gave it, so the table can see whose resource is riding on the roll. */
|
|
37
97
|
from?: string;
|
|
38
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The d20 this character most recently rolled, so a held die can be added to *that*
|
|
101
|
+
* roll rather than to whatever the agent running the fight remembers of it.
|
|
102
|
+
*
|
|
103
|
+
* Kept only while the character is holding a boon — nobody else can use it, and
|
|
104
|
+
* recording one on every check in the game would cost a sheet write per roll.
|
|
105
|
+
*
|
|
106
|
+
* It exists because the arithmetic went missing without it. A ranger declared she
|
|
107
|
+
* was spending her Bardic Inspiration, the die was rolled *before* the attack, and
|
|
108
|
+
* the +1 was then never added: 12 against a DC of 13 was reported as a miss when
|
|
109
|
+
* 12 + 1 would have hit. She lost the die and the hit in the same breath.
|
|
110
|
+
*/
|
|
39
111
|
export interface PendingRoll {
|
|
112
|
+
/** attack, save, skill, ability or tool. */
|
|
40
113
|
kind: string;
|
|
114
|
+
/** What was rolled — the attack, skill or ability — for the report. */
|
|
41
115
|
subject?: string;
|
|
116
|
+
/** The total as rolled, modifiers included. */
|
|
42
117
|
total: number;
|
|
118
|
+
/** The target number, when the caller gave one. */
|
|
43
119
|
dc?: number;
|
|
120
|
+
/** The round it was rolled in, so a die cannot be added to a stale roll. */
|
|
44
121
|
round?: number;
|
|
122
|
+
/** A natural 1 misses whatever is added to it, and no die can turn that. */
|
|
45
123
|
natural1?: boolean;
|
|
46
124
|
}
|
|
47
125
|
export interface ConditionEntry {
|
|
48
126
|
n: string;
|
|
127
|
+
/** Free-text duration, e.g. '2 rounds'. */
|
|
49
128
|
dur?: string;
|
|
50
129
|
}
|
|
51
130
|
export interface SheetState {
|
|
131
|
+
/** Schema version. */
|
|
52
132
|
v: number;
|
|
133
|
+
/** Revision counter, incremented on every write. */
|
|
53
134
|
rev: number;
|
|
54
135
|
name: string;
|
|
136
|
+
/** Nickname of the agent who plays this character. */
|
|
55
137
|
owner?: string;
|
|
56
138
|
race?: string;
|
|
139
|
+
/** 'Small' or 'Medium', from the race. */
|
|
57
140
|
size?: string;
|
|
141
|
+
/** Darkvision range in feet, from the race. */
|
|
58
142
|
darkvision?: number;
|
|
143
|
+
/** Languages known, seeded by the race. */
|
|
59
144
|
languages?: string[];
|
|
60
145
|
bg?: string;
|
|
61
146
|
align?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Url of the character's portrait, rendered into the summary as an image.
|
|
149
|
+
*
|
|
150
|
+
* Written well after the sheet is: `create_sheet` asks for the picture and the
|
|
151
|
+
* drawing takes minutes, so it lands in a later write. Stored rather than
|
|
152
|
+
* resolved on read — which is how a story finds a character's portrait — because
|
|
153
|
+
* nothing reads a room artifact on the way out. A sheet is what it says it is.
|
|
154
|
+
*/
|
|
155
|
+
img?: string;
|
|
62
156
|
class: ClassEntry[];
|
|
63
157
|
abil: Record<AbilityKey, number>;
|
|
64
158
|
saveProf: AbilityKey[];
|
|
65
159
|
skillProf: string[];
|
|
66
160
|
skillExp: string[];
|
|
161
|
+
/**
|
|
162
|
+
* Tools the character is proficient with, in the SRD table's spelling where it
|
|
163
|
+
* carries one. Stored rather than derived from the class and race, unlike weapon
|
|
164
|
+
* proficiency, because most of it is *chosen*: a bard's three instruments and a
|
|
165
|
+
* dwarf's one artisan's tool cannot be read back off anything.
|
|
166
|
+
*
|
|
167
|
+
* Held as written rather than lowercased, since these are display names —
|
|
168
|
+
* comparison goes through `nameKey` instead.
|
|
169
|
+
*/
|
|
67
170
|
toolProf: string[];
|
|
171
|
+
/**
|
|
172
|
+
* Tools the proficiency bonus is doubled for. Separate from `skillExp` because a
|
|
173
|
+
* rogue's Expertise may be spent on thieves' tools instead of a second skill, and
|
|
174
|
+
* folding a tool into the skill list would have `skillModifier` looking it up in
|
|
175
|
+
* the skill-to-ability map and finding nothing.
|
|
176
|
+
*/
|
|
68
177
|
toolExp: string[];
|
|
69
178
|
hp: {
|
|
70
179
|
max: number;
|
|
71
180
|
cur: number;
|
|
72
181
|
temp: number;
|
|
73
182
|
};
|
|
183
|
+
/** Hit dice pools keyed by die, e.g. { d10: { max: 3, cur: 3 } }. */
|
|
74
184
|
hd: Record<string, {
|
|
75
185
|
max: number;
|
|
76
186
|
cur: number;
|
|
@@ -78,21 +188,43 @@ export interface SheetState {
|
|
|
78
188
|
ac: number;
|
|
79
189
|
speed: number;
|
|
80
190
|
initBonus: number;
|
|
191
|
+
/** Spell slots keyed by spell level as a string. */
|
|
81
192
|
slots: Record<string, ResourcePool>;
|
|
193
|
+
/** Named feature and item uses, keyed by an internal snake_case key. */
|
|
82
194
|
uses: Record<string, ResourcePool>;
|
|
83
195
|
attacks: AttackEntry[];
|
|
196
|
+
/** Dice given by other characters, waiting to be spent on a roll. */
|
|
84
197
|
boons?: BoonEntry[];
|
|
198
|
+
/** The roll a held die would be added to. Only kept while {@link boons} has one. */
|
|
85
199
|
pendingRoll?: PendingRoll;
|
|
200
|
+
/**
|
|
201
|
+
* A stat block's Multiattack text, when it has one.
|
|
202
|
+
*
|
|
203
|
+
* Stored as the prose the block prints, because that is what it is — no count
|
|
204
|
+
* can be parsed out of "two with its scimitar and one with its dagger" reliably
|
|
205
|
+
* enough to enforce. Presence is what matters: it is the difference between a
|
|
206
|
+
* creature allowed more than one attack in a round and one that is not, which is
|
|
207
|
+
* the distinction the rules actually turn on.
|
|
208
|
+
*/
|
|
86
209
|
multiattack?: string;
|
|
87
210
|
spells?: string[];
|
|
211
|
+
/** Feats taken, by name, in the order taken. */
|
|
88
212
|
feats?: string[];
|
|
213
|
+
/**
|
|
214
|
+
* True when this character plays with the optional encumbrance variant.
|
|
215
|
+
*
|
|
216
|
+
* A table-wide rule living on a per-character sheet, because the pack has no
|
|
217
|
+
* room-level configuration. Set it for everyone or for nobody.
|
|
218
|
+
*/
|
|
89
219
|
encumbrance?: boolean;
|
|
90
220
|
cond: ConditionEntry[];
|
|
221
|
+
/** Exhaustion level, 0 to 6. */
|
|
91
222
|
exh: number;
|
|
92
223
|
deathSaves: {
|
|
93
224
|
s: number;
|
|
94
225
|
f: number;
|
|
95
226
|
};
|
|
227
|
+
/** True when the character is at 0 hit points but stable rather than dying. */
|
|
96
228
|
stable: boolean;
|
|
97
229
|
resist: string[];
|
|
98
230
|
immune: string[];
|
|
@@ -100,26 +232,95 @@ export interface SheetState {
|
|
|
100
232
|
inv: InventoryItem[];
|
|
101
233
|
coin: Record<string, number>;
|
|
102
234
|
xp: number;
|
|
235
|
+
/**
|
|
236
|
+
* True when this is a monster in the current fight rather than a character.
|
|
237
|
+
*
|
|
238
|
+
* Same shape as a character on purpose: every tool resolves its target by name
|
|
239
|
+
* through `loadSheet`, so one shape means they all work on a monster.
|
|
240
|
+
*
|
|
241
|
+
* Three rules differ. A foe dies outright at 0 rather than falling unconscious,
|
|
242
|
+
* its saves come from {@link saveBonus} rather than class proficiency, and
|
|
243
|
+
* `recomputeDerived` leaves it alone because it has no class to rebuild from.
|
|
244
|
+
*/
|
|
103
245
|
foe?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Saving throw bonuses as printed on a stat block, which are flat numbers
|
|
248
|
+
* rather than an ability modifier plus proficiency. Consulted by
|
|
249
|
+
* {@link saveModifier} ahead of the class calculation; an ability absent here
|
|
250
|
+
* falls back to its own modifier, which is what a stat block means by
|
|
251
|
+
* listing only some of them.
|
|
252
|
+
*/
|
|
104
253
|
saveBonus?: Partial<Record<AbilityKey, number>>;
|
|
254
|
+
/** Anything a future pack version or a human added; round-tripped untouched. */
|
|
105
255
|
[key: string]: any;
|
|
106
256
|
}
|
|
107
257
|
export declare class SheetError extends Error {
|
|
258
|
+
/** A machine-readable reason so callers can branch without parsing the message. */
|
|
108
259
|
readonly violation: string;
|
|
109
260
|
constructor(violation: string, message: string);
|
|
110
261
|
}
|
|
262
|
+
/** The artifact name a character's sheet lives under. */
|
|
111
263
|
export declare function sheetArtifactName(characterName: string): string;
|
|
264
|
+
/** Extracts the character name from a sheet artifact name. */
|
|
112
265
|
export declare function characterNameFromArtifact(artifactName: string): string;
|
|
266
|
+
/** True when the artifact name is a character sheet. */
|
|
113
267
|
export declare function isSheetArtifact(artifactName: string): boolean;
|
|
268
|
+
/** The artifact name a monster combatant lives under while a fight is running. */
|
|
114
269
|
export declare function foeArtifactName(foeName: string): string;
|
|
270
|
+
/** Extracts the creature's name from a foe artifact name. */
|
|
115
271
|
export declare function foeNameFromArtifact(artifactName: string): string;
|
|
272
|
+
/**
|
|
273
|
+
* True when the artifact name is a monster in the current fight.
|
|
274
|
+
*
|
|
275
|
+
* The separate prefix is a privacy boundary, not tidiness. `Party Status` is rebuilt
|
|
276
|
+
* from every `Sheet:` artifact and read by every player, so a monster filed there
|
|
277
|
+
* would publish its remaining hit points to the table — which the Dungeon Master's
|
|
278
|
+
* prompt forbids saying out loud.
|
|
279
|
+
*/
|
|
116
280
|
export declare function isFoeArtifact(artifactName: string): boolean;
|
|
281
|
+
/** Where a combatant's sheet belongs, party member or monster. */
|
|
117
282
|
export declare function combatantArtifactName(state: SheetState): string;
|
|
283
|
+
/**
|
|
284
|
+
* Reads the canonical state out of a sheet artifact body.
|
|
285
|
+
* @param body The artifact body
|
|
286
|
+
* @returns The parsed state
|
|
287
|
+
* @throws {SheetError} With violation 'sheet_corrupt' when the state block is
|
|
288
|
+
* missing or unparseable, so the caller can refuse to write rather than
|
|
289
|
+
* overwriting whatever data survives.
|
|
290
|
+
*/
|
|
118
291
|
export declare function parseSheet(body: string): SheetState;
|
|
292
|
+
/** Extracts the free-prose region, or '' when there is none. */
|
|
119
293
|
export declare function extractNotes(body: string): string;
|
|
294
|
+
/**
|
|
295
|
+
* Every field a sheet actually has, derived from {@link normalizeState} rather than
|
|
296
|
+
* listed by hand so the two cannot drift apart.
|
|
297
|
+
*
|
|
298
|
+
* `SheetState` ends in `[key: string]: any`, which lets a future version add a field
|
|
299
|
+
* without old sheets failing to load — but it also means TypeScript cannot enumerate
|
|
300
|
+
* the real fields, so `patch_sheet` needs this to tell `abil` from a typo of it.
|
|
301
|
+
*
|
|
302
|
+
* `normalizeState({})` sets every key explicitly, including the ones it leaves
|
|
303
|
+
* `undefined`, so its own output is the authoritative list.
|
|
304
|
+
* @returns The field names, sorted
|
|
305
|
+
*/
|
|
120
306
|
export declare function sheetFieldNames(): string[];
|
|
307
|
+
/**
|
|
308
|
+
* Reports the values that had to be corrected when reading a sheet, so the DM
|
|
309
|
+
* hears about it rather than the fix happening silently.
|
|
310
|
+
* @param raw The state as it was on disk
|
|
311
|
+
* @param normalized The state after normalization
|
|
312
|
+
* @returns Human-readable warnings, empty when the sheet was consistent
|
|
313
|
+
*/
|
|
121
314
|
export declare function collectWarnings(raw: any, normalized: SheetState): string[];
|
|
122
315
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
316
|
+
/**
|
|
317
|
+
* Renders a complete sheet artifact body from state, splicing the previous free
|
|
318
|
+
* prose back in verbatim.
|
|
319
|
+
* @param state The canonical state; its `rev` is incremented by the caller
|
|
320
|
+
* @param notes The prose region to preserve, from {@link extractNotes}
|
|
321
|
+
* @returns The artifact body
|
|
322
|
+
*/
|
|
123
323
|
export declare function renderSheet(state: SheetState, notes: string): string;
|
|
324
|
+
/** Formats a modifier with an explicit sign, e.g. '+3' or '-1'. */
|
|
124
325
|
export declare function signed(value: number): string;
|
|
125
326
|
export declare function titleCase(text: string): string;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The character sheet artifact: its canonical state, how it is parsed out of a
|
|
4
|
+
* Markdown artifact, and how the artifact is rendered back from state.
|
|
5
|
+
*
|
|
6
|
+
* A sheet artifact has three regions with different owners:
|
|
7
|
+
*
|
|
8
|
+
* 1. A rendered summary, regenerated from state on every write. Never
|
|
9
|
+
* authoritative — a human editing it in the Artifacts tab loses nothing,
|
|
10
|
+
* because the next tool call overwrites it.
|
|
11
|
+
* 2. A free-prose region between `<!-- briyah:notes -->` markers, preserved
|
|
12
|
+
* byte-for-byte across writes. This is where backstory and table notes live.
|
|
13
|
+
* 3. A fenced ```briyah-state block holding the canonical JSON. Located by its
|
|
14
|
+
* info string rather than by position, and tagged `briyah-state` rather than
|
|
15
|
+
* `json` both to make it unambiguous to find and to signal to the model that
|
|
16
|
+
* it must not be hand-edited.
|
|
17
|
+
*
|
|
18
|
+
* Keys in the state are abbreviated because the whole block is rendered into the
|
|
19
|
+
* prompt of every agent that can view the sheet, on every turn.
|
|
20
|
+
*/
|
|
2
21
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
22
|
if (k2 === undefined) k2 = k;
|
|
4
23
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -50,12 +69,19 @@ exports.renderSheet = renderSheet;
|
|
|
50
69
|
exports.signed = signed;
|
|
51
70
|
exports.titleCase = titleCase;
|
|
52
71
|
const srd_1 = require("../data/srd");
|
|
72
|
+
// rules.ts imports only types from this module, so this direction is safe.
|
|
53
73
|
const rules = __importStar(require("./rules"));
|
|
54
74
|
const races_1 = require("./races");
|
|
55
75
|
const kits_1 = require("./kits");
|
|
56
76
|
const encumbrance_1 = require("./encumbrance");
|
|
77
|
+
/** The schema version, bumped when a migration becomes necessary. */
|
|
57
78
|
exports.SHEET_STATE_VERSION = 1;
|
|
58
79
|
exports.SHEET_NAME_PREFIX = 'Sheet: ';
|
|
80
|
+
/**
|
|
81
|
+
* Monster combatants are filed apart from characters so that everything which
|
|
82
|
+
* walks the party — `Party Status`, `read_sheet character: "party"` — keeps
|
|
83
|
+
* walking the party only. See {@link isFoeArtifact}.
|
|
84
|
+
*/
|
|
59
85
|
exports.FOE_NAME_PREFIX = 'Foe: ';
|
|
60
86
|
exports.PARTY_STATUS_ARTIFACT = 'Party Status';
|
|
61
87
|
exports.ENCOUNTER_ARTIFACT = 'Encounter';
|
|
@@ -64,6 +90,7 @@ const NOTES_OPEN = '<!-- briyah:notes -->';
|
|
|
64
90
|
const NOTES_CLOSE = '<!-- /briyah:notes -->';
|
|
65
91
|
const MAX_NOTES_CHARS = 1500;
|
|
66
92
|
class SheetError extends Error {
|
|
93
|
+
/** A machine-readable reason so callers can branch without parsing the message. */
|
|
67
94
|
violation;
|
|
68
95
|
constructor(violation, message) {
|
|
69
96
|
super(message);
|
|
@@ -72,31 +99,53 @@ class SheetError extends Error {
|
|
|
72
99
|
}
|
|
73
100
|
}
|
|
74
101
|
exports.SheetError = SheetError;
|
|
102
|
+
/** The artifact name a character's sheet lives under. */
|
|
75
103
|
function sheetArtifactName(characterName) {
|
|
76
104
|
return `${exports.SHEET_NAME_PREFIX}${characterName}`;
|
|
77
105
|
}
|
|
106
|
+
/** Extracts the character name from a sheet artifact name. */
|
|
78
107
|
function characterNameFromArtifact(artifactName) {
|
|
79
108
|
return artifactName.startsWith(exports.SHEET_NAME_PREFIX)
|
|
80
109
|
? artifactName.slice(exports.SHEET_NAME_PREFIX.length)
|
|
81
110
|
: artifactName;
|
|
82
111
|
}
|
|
112
|
+
/** True when the artifact name is a character sheet. */
|
|
83
113
|
function isSheetArtifact(artifactName) {
|
|
84
114
|
return artifactName.startsWith(exports.SHEET_NAME_PREFIX);
|
|
85
115
|
}
|
|
116
|
+
/** The artifact name a monster combatant lives under while a fight is running. */
|
|
86
117
|
function foeArtifactName(foeName) {
|
|
87
118
|
return `${exports.FOE_NAME_PREFIX}${foeName}`;
|
|
88
119
|
}
|
|
120
|
+
/** Extracts the creature's name from a foe artifact name. */
|
|
89
121
|
function foeNameFromArtifact(artifactName) {
|
|
90
122
|
return artifactName.startsWith(exports.FOE_NAME_PREFIX)
|
|
91
123
|
? artifactName.slice(exports.FOE_NAME_PREFIX.length)
|
|
92
124
|
: artifactName;
|
|
93
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* True when the artifact name is a monster in the current fight.
|
|
128
|
+
*
|
|
129
|
+
* The separate prefix is a privacy boundary, not tidiness. `Party Status` is rebuilt
|
|
130
|
+
* from every `Sheet:` artifact and read by every player, so a monster filed there
|
|
131
|
+
* would publish its remaining hit points to the table — which the Dungeon Master's
|
|
132
|
+
* prompt forbids saying out loud.
|
|
133
|
+
*/
|
|
94
134
|
function isFoeArtifact(artifactName) {
|
|
95
135
|
return artifactName.startsWith(exports.FOE_NAME_PREFIX);
|
|
96
136
|
}
|
|
137
|
+
/** Where a combatant's sheet belongs, party member or monster. */
|
|
97
138
|
function combatantArtifactName(state) {
|
|
98
139
|
return state.foe ? foeArtifactName(state.name) : sheetArtifactName(state.name);
|
|
99
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Reads the canonical state out of a sheet artifact body.
|
|
143
|
+
* @param body The artifact body
|
|
144
|
+
* @returns The parsed state
|
|
145
|
+
* @throws {SheetError} With violation 'sheet_corrupt' when the state block is
|
|
146
|
+
* missing or unparseable, so the caller can refuse to write rather than
|
|
147
|
+
* overwriting whatever data survives.
|
|
148
|
+
*/
|
|
100
149
|
function parseSheet(body) {
|
|
101
150
|
const block = extractStateBlock(body);
|
|
102
151
|
if (block === null) {
|
|
@@ -117,6 +166,7 @@ function parseSheet(body) {
|
|
|
117
166
|
}
|
|
118
167
|
return normalizeState(parsed);
|
|
119
168
|
}
|
|
169
|
+
/** Extracts the raw text inside the state fence, or null when absent. */
|
|
120
170
|
function extractStateBlock(body) {
|
|
121
171
|
if (!body)
|
|
122
172
|
return null;
|
|
@@ -129,6 +179,7 @@ function extractStateBlock(body) {
|
|
|
129
179
|
return null;
|
|
130
180
|
return lines.slice(openIndex + 1, openIndex + 1 + closeOffset).join('\n');
|
|
131
181
|
}
|
|
182
|
+
/** Extracts the free-prose region, or '' when there is none. */
|
|
132
183
|
function extractNotes(body) {
|
|
133
184
|
if (!body)
|
|
134
185
|
return '';
|
|
@@ -137,6 +188,8 @@ function extractNotes(body) {
|
|
|
137
188
|
if (open !== -1 && close > open) {
|
|
138
189
|
return body.slice(open + NOTES_OPEN.length, close).trim();
|
|
139
190
|
}
|
|
191
|
+
// No markers: treat everything between the summary and the state fence as
|
|
192
|
+
// prose, so a human who deleted the markers loses nothing.
|
|
140
193
|
const fenceIndex = body.indexOf('```' + STATE_FENCE_TAG);
|
|
141
194
|
if (fenceIndex === -1)
|
|
142
195
|
return '';
|
|
@@ -144,6 +197,13 @@ function extractNotes(body) {
|
|
|
144
197
|
const headingIndex = beforeFence.search(/^##\s/m);
|
|
145
198
|
return headingIndex === -1 ? '' : beforeFence.slice(headingIndex).trim();
|
|
146
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Fills in defaults and clamps values that cannot be legal, so a hand-edited
|
|
202
|
+
* sheet keeps the game running instead of failing mid-combat. Anything clamped
|
|
203
|
+
* is reported through {@link collectWarnings} rather than silently fixed.
|
|
204
|
+
* @param raw The parsed JSON
|
|
205
|
+
* @returns A state object with every field present
|
|
206
|
+
*/
|
|
147
207
|
function normalizeState(raw) {
|
|
148
208
|
const abil = {};
|
|
149
209
|
for (const ability of srd_1.ABILITIES) {
|
|
@@ -162,11 +222,13 @@ function normalizeState(raw) {
|
|
|
162
222
|
languages: raw.languages ? toStringArray(raw.languages) : undefined,
|
|
163
223
|
bg: raw.bg ? String(raw.bg) : undefined,
|
|
164
224
|
align: raw.align ? String(raw.align) : undefined,
|
|
225
|
+
img: raw.img ? String(raw.img).trim() || undefined : undefined,
|
|
165
226
|
class: Array.isArray(raw.class) && raw.class.length > 0 ? raw.class : [],
|
|
166
227
|
abil: abil,
|
|
167
228
|
saveProf: toStringArray(raw.saveProf),
|
|
168
229
|
skillProf: toStringArray(raw.skillProf).map((s) => s.toLowerCase()),
|
|
169
230
|
skillExp: toStringArray(raw.skillExp).map((s) => s.toLowerCase()),
|
|
231
|
+
// Not lowercased, unlike the skills: a tool is a display name.
|
|
170
232
|
toolProf: toStringArray(raw.toolProf),
|
|
171
233
|
toolExp: toStringArray(raw.toolExp),
|
|
172
234
|
hp: {
|
|
@@ -203,9 +265,17 @@ function normalizeState(raw) {
|
|
|
203
265
|
foe: raw.foe === true ? true : undefined,
|
|
204
266
|
saveBonus: normalizeSaveBonus(raw.saveBonus),
|
|
205
267
|
};
|
|
268
|
+
// Current hit points can never exceed the maximum or fall below zero.
|
|
206
269
|
state.hp.cur = clamp(state.hp.cur, 0, state.hp.max);
|
|
207
270
|
return state;
|
|
208
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Reads a stat block's flat saving throw bonuses, keeping only the abilities it
|
|
274
|
+
* actually lists. An absent one falls back to the ability modifier, which is what a
|
|
275
|
+
* stat block means by printing some saves and not others.
|
|
276
|
+
* @param raw The field as stored
|
|
277
|
+
* @returns The bonuses, or undefined when there are none
|
|
278
|
+
*/
|
|
209
279
|
function normalizeBoons(raw) {
|
|
210
280
|
if (!Array.isArray(raw))
|
|
211
281
|
return undefined;
|
|
@@ -248,9 +318,28 @@ function normalizeSaveBonus(raw) {
|
|
|
248
318
|
}
|
|
249
319
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
250
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Every field a sheet actually has, derived from {@link normalizeState} rather than
|
|
323
|
+
* listed by hand so the two cannot drift apart.
|
|
324
|
+
*
|
|
325
|
+
* `SheetState` ends in `[key: string]: any`, which lets a future version add a field
|
|
326
|
+
* without old sheets failing to load — but it also means TypeScript cannot enumerate
|
|
327
|
+
* the real fields, so `patch_sheet` needs this to tell `abil` from a typo of it.
|
|
328
|
+
*
|
|
329
|
+
* `normalizeState({})` sets every key explicitly, including the ones it leaves
|
|
330
|
+
* `undefined`, so its own output is the authoritative list.
|
|
331
|
+
* @returns The field names, sorted
|
|
332
|
+
*/
|
|
251
333
|
function sheetFieldNames() {
|
|
252
334
|
return Object.keys(normalizeState({})).sort();
|
|
253
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Reports the values that had to be corrected when reading a sheet, so the DM
|
|
338
|
+
* hears about it rather than the fix happening silently.
|
|
339
|
+
* @param raw The state as it was on disk
|
|
340
|
+
* @param normalized The state after normalization
|
|
341
|
+
* @returns Human-readable warnings, empty when the sheet was consistent
|
|
342
|
+
*/
|
|
254
343
|
function collectWarnings(raw, normalized) {
|
|
255
344
|
const warnings = [];
|
|
256
345
|
const rawCur = Number(raw?.hp?.cur);
|
|
@@ -326,6 +415,10 @@ function normalizeInventory(value) {
|
|
|
326
415
|
if (typeof entry === 'string')
|
|
327
416
|
return { n: entry, q: 1 };
|
|
328
417
|
if (entry && typeof entry === 'object' && entry.n) {
|
|
418
|
+
// Rebuilt field by field rather than spread, so a hand-edited sheet
|
|
419
|
+
// cannot smuggle arbitrary keys into an inventory entry. Every flag
|
|
420
|
+
// an item can carry has to be listed here — one that is missing is
|
|
421
|
+
// silently discarded on the next read.
|
|
329
422
|
const item = { n: String(entry.n), q: Math.max(Number(entry.q) || 1, 0) };
|
|
330
423
|
if (entry.eq)
|
|
331
424
|
item.eq = true;
|
|
@@ -353,6 +446,16 @@ function normalizeCoin(value) {
|
|
|
353
446
|
function clamp(value, min, max) {
|
|
354
447
|
return Math.min(Math.max(value, min), max);
|
|
355
448
|
}
|
|
449
|
+
// ---------------------------------------------------------------------------
|
|
450
|
+
// Rendering
|
|
451
|
+
// ---------------------------------------------------------------------------
|
|
452
|
+
/**
|
|
453
|
+
* Renders a complete sheet artifact body from state, splicing the previous free
|
|
454
|
+
* prose back in verbatim.
|
|
455
|
+
* @param state The canonical state; its `rev` is incremented by the caller
|
|
456
|
+
* @param notes The prose region to preserve, from {@link extractNotes}
|
|
457
|
+
* @returns The artifact body
|
|
458
|
+
*/
|
|
356
459
|
function renderSheet(state, notes) {
|
|
357
460
|
const summary = renderSummary(state);
|
|
358
461
|
const prose = trimNotes(notes);
|
|
@@ -362,11 +465,14 @@ function renderSheet(state, notes) {
|
|
|
362
465
|
sections.push([NOTES_OPEN, prose, NOTES_CLOSE].join('\n'));
|
|
363
466
|
}
|
|
364
467
|
else {
|
|
468
|
+
// Keep the markers even when empty so the next writer has an anchor and a
|
|
469
|
+
// human can see where their own notes are meant to go.
|
|
365
470
|
sections.push([NOTES_OPEN, NOTES_CLOSE].join('\n'));
|
|
366
471
|
}
|
|
367
472
|
sections.push(stateBlock);
|
|
368
473
|
return sections.join('\n\n') + '\n';
|
|
369
474
|
}
|
|
475
|
+
/** Caps the prose region, dropping the oldest lines rather than the newest. */
|
|
370
476
|
function trimNotes(notes) {
|
|
371
477
|
const text = (notes || '').trim();
|
|
372
478
|
if (text.length <= MAX_NOTES_CHARS)
|
|
@@ -382,9 +488,20 @@ function trimNotes(notes) {
|
|
|
382
488
|
}
|
|
383
489
|
return ['*(older notes trimmed)*', ...kept].join('\n');
|
|
384
490
|
}
|
|
491
|
+
/** Formats a modifier with an explicit sign, e.g. '+3' or '-1'. */
|
|
385
492
|
function signed(value) {
|
|
386
493
|
return value >= 0 ? `+${value}` : `${value}`;
|
|
387
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* The readable half of a monster's sheet.
|
|
497
|
+
*
|
|
498
|
+
* Not the character render: a foe has no class, level, proficiency bonus, hit dice
|
|
499
|
+
* or spell slots, and printing "Level 1" against a wight is worse than printing
|
|
500
|
+
* nothing. A fight needs its hit points, armour class, what it can do, and what is
|
|
501
|
+
* currently wrong with it.
|
|
502
|
+
* @param state The monster
|
|
503
|
+
* @returns The summary block
|
|
504
|
+
*/
|
|
388
505
|
function renderFoeSummary(state) {
|
|
389
506
|
const lines = [`# ${state.name}`];
|
|
390
507
|
const dead = state.deathSaves.f >= 3 || state.hp.cur <= 0;
|
|
@@ -421,6 +538,7 @@ function renderFoeSummary(state) {
|
|
|
421
538
|
}
|
|
422
539
|
return lines.join('\n');
|
|
423
540
|
}
|
|
541
|
+
/** The human-readable half of the sheet, regenerated on every write. */
|
|
424
542
|
function renderSummary(state) {
|
|
425
543
|
if (state.foe)
|
|
426
544
|
return renderFoeSummary(state);
|
|
@@ -443,7 +561,13 @@ function renderSummary(state) {
|
|
|
443
561
|
].filter(Boolean);
|
|
444
562
|
lines.push(`*${descriptors.join(' — ')}*`);
|
|
445
563
|
lines.push('');
|
|
564
|
+
if (state.img) {
|
|
565
|
+
lines.push(``);
|
|
566
|
+
lines.push('');
|
|
567
|
+
}
|
|
446
568
|
const tempNote = state.hp.temp > 0 ? ` (temp ${state.hp.temp})` : '';
|
|
569
|
+
// Exhaustion and heavy armour change the effective maximum and speed without
|
|
570
|
+
// touching the stored values, so the line shows what is actually in play.
|
|
447
571
|
const maxHp = rules.effectiveMaxHp(state);
|
|
448
572
|
const maxNote = maxHp === state.hp.max ? '' : ` of ${state.hp.max}, halved by exhaustion`;
|
|
449
573
|
const movement = rules.effectiveSpeed(state);
|
|
@@ -464,6 +588,10 @@ function renderSummary(state) {
|
|
|
464
588
|
.map((skill) => `${titleCase(skill)} ${signed(rules.skillModifier(state, skill))}`)
|
|
465
589
|
.join(' · '));
|
|
466
590
|
}
|
|
591
|
+
// Named on the sheet rather than left to a lookup: the DM asks for a thieves'
|
|
592
|
+
// tools check mid-scene, and the answer has to be in front of the player.
|
|
593
|
+
// No modifier is printed because the ability a tool check uses is the DM's call,
|
|
594
|
+
// so the only thing to show is the expertise marker the saves line also uses.
|
|
467
595
|
const tools = [...new Set([...(state.toolProf || []), ...(state.toolExp || [])])];
|
|
468
596
|
if (tools.length > 0) {
|
|
469
597
|
lines.push('**Tools (proficient):** ' +
|
|
@@ -483,6 +611,8 @@ function renderSummary(state) {
|
|
|
483
611
|
lines.push(...renderAttackRiders(state));
|
|
484
612
|
}
|
|
485
613
|
if (state.boons?.length) {
|
|
614
|
+
// The pending roll rides on this line rather than its own, because it only
|
|
615
|
+
// means anything while a die is held and it is why the die is still there.
|
|
486
616
|
const pending = state.pendingRoll;
|
|
487
617
|
const against = pending && pending.dc !== undefined
|
|
488
618
|
? ` — ${pending.subject || pending.kind} ${pending.total} vs ${pending.dc}, ${pending.dc - pending.total} short`
|
|
@@ -505,8 +635,15 @@ function renderSummary(state) {
|
|
|
505
635
|
}
|
|
506
636
|
const traits = (0, races_1.racialTraits)(state);
|
|
507
637
|
if (traits.length > 0) {
|
|
638
|
+
// Names only. The full text is in the race table and comes back through
|
|
639
|
+
// `read_sheet` with section "race", so the sheet stays short — it is
|
|
640
|
+
// rendered into its owner's prompt on every single turn.
|
|
508
641
|
lines.push(`**Racial traits:** ${traits.map((trait) => trait.n).join(', ')}`);
|
|
509
642
|
}
|
|
643
|
+
// The name only. What the background *does* is in the `Background: <name>` document
|
|
644
|
+
// its player already reads, and anything recorded for this character is in the notes
|
|
645
|
+
// below — so repeating a paragraph of it in a block rendered on every turn would be
|
|
646
|
+
// paying twice for the same prose.
|
|
510
647
|
if (state.bg)
|
|
511
648
|
lines.push(`**Background:** ${state.bg}`);
|
|
512
649
|
if (state.darkvision)
|
|
@@ -525,6 +662,9 @@ function renderSummary(state) {
|
|
|
525
662
|
});
|
|
526
663
|
if (gear.length > 0)
|
|
527
664
|
lines.push(`**Gear:** ${gear.join(', ')}`);
|
|
665
|
+
// Shown only when it can actually matter. Without the variant, capacity is
|
|
666
|
+
// "high enough that most characters don't usually have to worry about it", and
|
|
667
|
+
// a line saying so every turn would be noise in the owner's prompt.
|
|
528
668
|
const load = (0, encumbrance_1.encumbrance)(state);
|
|
529
669
|
if (load.variant || load.tier !== 'unencumbered') {
|
|
530
670
|
lines.push(`**Carrying:** ${(0, encumbrance_1.describeEncumbrance)(state)}`);
|
|
@@ -543,6 +683,15 @@ function renderSummary(state) {
|
|
|
543
683
|
lines.push(`**Vulnerable to:** ${state.vuln.join(', ')}`);
|
|
544
684
|
return lines.join('\n');
|
|
545
685
|
}
|
|
686
|
+
/**
|
|
687
|
+
* The riders printed under the attack line, one per attack that has one.
|
|
688
|
+
*
|
|
689
|
+
* Their own lines rather than appended to the attack summary, because the summary is
|
|
690
|
+
* a single dense row and a rider is a sentence — inlined, the one thing on the line
|
|
691
|
+
* that needs acting on is the easiest to skim past.
|
|
692
|
+
* @param state The combatant
|
|
693
|
+
* @returns Zero or more lines
|
|
694
|
+
*/
|
|
546
695
|
function renderAttackRiders(state) {
|
|
547
696
|
return state.attacks
|
|
548
697
|
.filter((attack) => attack.note)
|