briyah 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -7
- package/data/common/config/LICENSE-model-prices.md +65 -0
- package/data/common/config/model_prices.json +47443 -46295
- package/data/common/prompts/narrator/create_story.prompt +2 -0
- package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
- package/dist-sdk/server/src/ai/LLM/anthropic.service.js +173 -2
- package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +172 -3
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +241 -5
- 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 +102 -3
- package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
- package/dist-sdk/server/src/ai/LLM/fal.service.js +55 -1
- package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
- package/dist-sdk/server/src/ai/LLM/googleai.service.js +42 -1
- package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
- package/dist-sdk/server/src/ai/LLM/grok.service.js +54 -2
- 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 +80 -2
- 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 +44 -2
- package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/LLM/together.service.js +60 -2
- package/dist-sdk/server/src/ai/agent-config.d.ts +15 -0
- 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 -5
- package/dist-sdk/server/src/ai/agent.d.ts +196 -0
- package/dist-sdk/server/src/ai/agent.js +224 -11
- 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 +38 -1
- 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 +87 -0
- package/dist-sdk/server/src/app.controller.js +272 -12
- package/dist-sdk/server/src/app.module.js +28 -6
- package/dist-sdk/server/src/app.service.d.ts +1661 -0
- package/dist-sdk/server/src/app.service.js +1837 -4
- 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 +18 -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 +99 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +100 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +58 -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/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 +26 -0
- package/dist-sdk/server/src/room/room-factory.d.ts +12 -0
- package/dist-sdk/server/src/room/room-factory.js +14 -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 +176 -0
- package/dist-sdk/server/src/room/room-store.service.js +238 -5
- package/dist-sdk/server/src/room/room.d.ts +878 -0
- package/dist-sdk/server/src/room/room.js +1291 -23
- 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 +103 -0
- 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 +398 -0
- package/dist-sdk/server/src/story/story.service.js +829 -25
- package/dist-sdk/server/src/tools/core/index.d.ts +22 -0
- package/dist-sdk/server/src/tools/core/index.js +22 -0
- 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 +176 -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 +192 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +144 -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 +164 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +188 -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 +116 -0
- 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 +73 -0
- package/dist-sdk/server/src/tools/tool-execution.service.js +74 -0
- 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 +285 -13
- package/dist-sdk/shared/types/app.types.js +3 -0
- 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,61 +1,146 @@
|
|
|
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;
|
|
@@ -64,13 +149,29 @@ export interface SheetState {
|
|
|
64
149
|
saveProf: AbilityKey[];
|
|
65
150
|
skillProf: string[];
|
|
66
151
|
skillExp: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Tools the character is proficient with, in the SRD table's spelling where it
|
|
154
|
+
* carries one. Stored rather than derived from the class and race, unlike weapon
|
|
155
|
+
* proficiency, because most of it is *chosen*: a bard's three instruments and a
|
|
156
|
+
* dwarf's one artisan's tool cannot be read back off anything.
|
|
157
|
+
*
|
|
158
|
+
* Held as written rather than lowercased, since these are display names —
|
|
159
|
+
* comparison goes through `nameKey` instead.
|
|
160
|
+
*/
|
|
67
161
|
toolProf: string[];
|
|
162
|
+
/**
|
|
163
|
+
* Tools the proficiency bonus is doubled for. Separate from `skillExp` because a
|
|
164
|
+
* rogue's Expertise may be spent on thieves' tools instead of a second skill, and
|
|
165
|
+
* folding a tool into the skill list would have `skillModifier` looking it up in
|
|
166
|
+
* the skill-to-ability map and finding nothing.
|
|
167
|
+
*/
|
|
68
168
|
toolExp: string[];
|
|
69
169
|
hp: {
|
|
70
170
|
max: number;
|
|
71
171
|
cur: number;
|
|
72
172
|
temp: number;
|
|
73
173
|
};
|
|
174
|
+
/** Hit dice pools keyed by die, e.g. { d10: { max: 3, cur: 3 } }. */
|
|
74
175
|
hd: Record<string, {
|
|
75
176
|
max: number;
|
|
76
177
|
cur: number;
|
|
@@ -78,21 +179,43 @@ export interface SheetState {
|
|
|
78
179
|
ac: number;
|
|
79
180
|
speed: number;
|
|
80
181
|
initBonus: number;
|
|
182
|
+
/** Spell slots keyed by spell level as a string. */
|
|
81
183
|
slots: Record<string, ResourcePool>;
|
|
184
|
+
/** Named feature and item uses, keyed by an internal snake_case key. */
|
|
82
185
|
uses: Record<string, ResourcePool>;
|
|
83
186
|
attacks: AttackEntry[];
|
|
187
|
+
/** Dice given by other characters, waiting to be spent on a roll. */
|
|
84
188
|
boons?: BoonEntry[];
|
|
189
|
+
/** The roll a held die would be added to. Only kept while {@link boons} has one. */
|
|
85
190
|
pendingRoll?: PendingRoll;
|
|
191
|
+
/**
|
|
192
|
+
* A stat block's Multiattack text, when it has one.
|
|
193
|
+
*
|
|
194
|
+
* Stored as the prose the block prints, because that is what it is — no count
|
|
195
|
+
* can be parsed out of "two with its scimitar and one with its dagger" reliably
|
|
196
|
+
* enough to enforce. Presence is what matters: it is the difference between a
|
|
197
|
+
* creature allowed more than one attack in a round and one that is not, which is
|
|
198
|
+
* the distinction the rules actually turn on.
|
|
199
|
+
*/
|
|
86
200
|
multiattack?: string;
|
|
87
201
|
spells?: string[];
|
|
202
|
+
/** Feats taken, by name, in the order taken. */
|
|
88
203
|
feats?: string[];
|
|
204
|
+
/**
|
|
205
|
+
* True when this character plays with the optional encumbrance variant.
|
|
206
|
+
*
|
|
207
|
+
* A table-wide rule living on a per-character sheet, because the pack has no
|
|
208
|
+
* room-level configuration. Set it for everyone or for nobody.
|
|
209
|
+
*/
|
|
89
210
|
encumbrance?: boolean;
|
|
90
211
|
cond: ConditionEntry[];
|
|
212
|
+
/** Exhaustion level, 0 to 6. */
|
|
91
213
|
exh: number;
|
|
92
214
|
deathSaves: {
|
|
93
215
|
s: number;
|
|
94
216
|
f: number;
|
|
95
217
|
};
|
|
218
|
+
/** True when the character is at 0 hit points but stable rather than dying. */
|
|
96
219
|
stable: boolean;
|
|
97
220
|
resist: string[];
|
|
98
221
|
immune: string[];
|
|
@@ -100,26 +223,95 @@ export interface SheetState {
|
|
|
100
223
|
inv: InventoryItem[];
|
|
101
224
|
coin: Record<string, number>;
|
|
102
225
|
xp: number;
|
|
226
|
+
/**
|
|
227
|
+
* True when this is a monster in the current fight rather than a character.
|
|
228
|
+
*
|
|
229
|
+
* Same shape as a character on purpose: every tool resolves its target by name
|
|
230
|
+
* through `loadSheet`, so one shape means they all work on a monster.
|
|
231
|
+
*
|
|
232
|
+
* Three rules differ. A foe dies outright at 0 rather than falling unconscious,
|
|
233
|
+
* its saves come from {@link saveBonus} rather than class proficiency, and
|
|
234
|
+
* `recomputeDerived` leaves it alone because it has no class to rebuild from.
|
|
235
|
+
*/
|
|
103
236
|
foe?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Saving throw bonuses as printed on a stat block, which are flat numbers
|
|
239
|
+
* rather than an ability modifier plus proficiency. Consulted by
|
|
240
|
+
* {@link saveModifier} ahead of the class calculation; an ability absent here
|
|
241
|
+
* falls back to its own modifier, which is what a stat block means by
|
|
242
|
+
* listing only some of them.
|
|
243
|
+
*/
|
|
104
244
|
saveBonus?: Partial<Record<AbilityKey, number>>;
|
|
245
|
+
/** Anything a future pack version or a human added; round-tripped untouched. */
|
|
105
246
|
[key: string]: any;
|
|
106
247
|
}
|
|
107
248
|
export declare class SheetError extends Error {
|
|
249
|
+
/** A machine-readable reason so callers can branch without parsing the message. */
|
|
108
250
|
readonly violation: string;
|
|
109
251
|
constructor(violation: string, message: string);
|
|
110
252
|
}
|
|
253
|
+
/** The artifact name a character's sheet lives under. */
|
|
111
254
|
export declare function sheetArtifactName(characterName: string): string;
|
|
255
|
+
/** Extracts the character name from a sheet artifact name. */
|
|
112
256
|
export declare function characterNameFromArtifact(artifactName: string): string;
|
|
257
|
+
/** True when the artifact name is a character sheet. */
|
|
113
258
|
export declare function isSheetArtifact(artifactName: string): boolean;
|
|
259
|
+
/** The artifact name a monster combatant lives under while a fight is running. */
|
|
114
260
|
export declare function foeArtifactName(foeName: string): string;
|
|
261
|
+
/** Extracts the creature's name from a foe artifact name. */
|
|
115
262
|
export declare function foeNameFromArtifact(artifactName: string): string;
|
|
263
|
+
/**
|
|
264
|
+
* True when the artifact name is a monster in the current fight.
|
|
265
|
+
*
|
|
266
|
+
* The separate prefix is a privacy boundary, not tidiness. `Party Status` is rebuilt
|
|
267
|
+
* from every `Sheet:` artifact and read by every player, so a monster filed there
|
|
268
|
+
* would publish its remaining hit points to the table — which the Dungeon Master's
|
|
269
|
+
* prompt forbids saying out loud.
|
|
270
|
+
*/
|
|
116
271
|
export declare function isFoeArtifact(artifactName: string): boolean;
|
|
272
|
+
/** Where a combatant's sheet belongs, party member or monster. */
|
|
117
273
|
export declare function combatantArtifactName(state: SheetState): string;
|
|
274
|
+
/**
|
|
275
|
+
* Reads the canonical state out of a sheet artifact body.
|
|
276
|
+
* @param body The artifact body
|
|
277
|
+
* @returns The parsed state
|
|
278
|
+
* @throws {SheetError} With violation 'sheet_corrupt' when the state block is
|
|
279
|
+
* missing or unparseable, so the caller can refuse to write rather than
|
|
280
|
+
* overwriting whatever data survives.
|
|
281
|
+
*/
|
|
118
282
|
export declare function parseSheet(body: string): SheetState;
|
|
283
|
+
/** Extracts the free-prose region, or '' when there is none. */
|
|
119
284
|
export declare function extractNotes(body: string): string;
|
|
285
|
+
/**
|
|
286
|
+
* Every field a sheet actually has, derived from {@link normalizeState} rather than
|
|
287
|
+
* listed by hand so the two cannot drift apart.
|
|
288
|
+
*
|
|
289
|
+
* `SheetState` ends in `[key: string]: any`, which lets a future version add a field
|
|
290
|
+
* without old sheets failing to load — but it also means TypeScript cannot enumerate
|
|
291
|
+
* the real fields, so `patch_sheet` needs this to tell `abil` from a typo of it.
|
|
292
|
+
*
|
|
293
|
+
* `normalizeState({})` sets every key explicitly, including the ones it leaves
|
|
294
|
+
* `undefined`, so its own output is the authoritative list.
|
|
295
|
+
* @returns The field names, sorted
|
|
296
|
+
*/
|
|
120
297
|
export declare function sheetFieldNames(): string[];
|
|
298
|
+
/**
|
|
299
|
+
* Reports the values that had to be corrected when reading a sheet, so the DM
|
|
300
|
+
* hears about it rather than the fix happening silently.
|
|
301
|
+
* @param raw The state as it was on disk
|
|
302
|
+
* @param normalized The state after normalization
|
|
303
|
+
* @returns Human-readable warnings, empty when the sheet was consistent
|
|
304
|
+
*/
|
|
121
305
|
export declare function collectWarnings(raw: any, normalized: SheetState): string[];
|
|
122
306
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
307
|
+
/**
|
|
308
|
+
* Renders a complete sheet artifact body from state, splicing the previous free
|
|
309
|
+
* prose back in verbatim.
|
|
310
|
+
* @param state The canonical state; its `rev` is incremented by the caller
|
|
311
|
+
* @param notes The prose region to preserve, from {@link extractNotes}
|
|
312
|
+
* @returns The artifact body
|
|
313
|
+
*/
|
|
123
314
|
export declare function renderSheet(state: SheetState, notes: string): string;
|
|
315
|
+
/** Formats a modifier with an explicit sign, e.g. '+3' or '-1'. */
|
|
124
316
|
export declare function signed(value: number): string;
|
|
125
317
|
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) {
|
|
@@ -167,6 +227,7 @@ function normalizeState(raw) {
|
|
|
167
227
|
saveProf: toStringArray(raw.saveProf),
|
|
168
228
|
skillProf: toStringArray(raw.skillProf).map((s) => s.toLowerCase()),
|
|
169
229
|
skillExp: toStringArray(raw.skillExp).map((s) => s.toLowerCase()),
|
|
230
|
+
// Not lowercased, unlike the skills: a tool is a display name.
|
|
170
231
|
toolProf: toStringArray(raw.toolProf),
|
|
171
232
|
toolExp: toStringArray(raw.toolExp),
|
|
172
233
|
hp: {
|
|
@@ -203,9 +264,17 @@ function normalizeState(raw) {
|
|
|
203
264
|
foe: raw.foe === true ? true : undefined,
|
|
204
265
|
saveBonus: normalizeSaveBonus(raw.saveBonus),
|
|
205
266
|
};
|
|
267
|
+
// Current hit points can never exceed the maximum or fall below zero.
|
|
206
268
|
state.hp.cur = clamp(state.hp.cur, 0, state.hp.max);
|
|
207
269
|
return state;
|
|
208
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Reads a stat block's flat saving throw bonuses, keeping only the abilities it
|
|
273
|
+
* actually lists. An absent one falls back to the ability modifier, which is what a
|
|
274
|
+
* stat block means by printing some saves and not others.
|
|
275
|
+
* @param raw The field as stored
|
|
276
|
+
* @returns The bonuses, or undefined when there are none
|
|
277
|
+
*/
|
|
209
278
|
function normalizeBoons(raw) {
|
|
210
279
|
if (!Array.isArray(raw))
|
|
211
280
|
return undefined;
|
|
@@ -248,9 +317,28 @@ function normalizeSaveBonus(raw) {
|
|
|
248
317
|
}
|
|
249
318
|
return Object.keys(out).length > 0 ? out : undefined;
|
|
250
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Every field a sheet actually has, derived from {@link normalizeState} rather than
|
|
322
|
+
* listed by hand so the two cannot drift apart.
|
|
323
|
+
*
|
|
324
|
+
* `SheetState` ends in `[key: string]: any`, which lets a future version add a field
|
|
325
|
+
* without old sheets failing to load — but it also means TypeScript cannot enumerate
|
|
326
|
+
* the real fields, so `patch_sheet` needs this to tell `abil` from a typo of it.
|
|
327
|
+
*
|
|
328
|
+
* `normalizeState({})` sets every key explicitly, including the ones it leaves
|
|
329
|
+
* `undefined`, so its own output is the authoritative list.
|
|
330
|
+
* @returns The field names, sorted
|
|
331
|
+
*/
|
|
251
332
|
function sheetFieldNames() {
|
|
252
333
|
return Object.keys(normalizeState({})).sort();
|
|
253
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Reports the values that had to be corrected when reading a sheet, so the DM
|
|
337
|
+
* hears about it rather than the fix happening silently.
|
|
338
|
+
* @param raw The state as it was on disk
|
|
339
|
+
* @param normalized The state after normalization
|
|
340
|
+
* @returns Human-readable warnings, empty when the sheet was consistent
|
|
341
|
+
*/
|
|
254
342
|
function collectWarnings(raw, normalized) {
|
|
255
343
|
const warnings = [];
|
|
256
344
|
const rawCur = Number(raw?.hp?.cur);
|
|
@@ -326,6 +414,10 @@ function normalizeInventory(value) {
|
|
|
326
414
|
if (typeof entry === 'string')
|
|
327
415
|
return { n: entry, q: 1 };
|
|
328
416
|
if (entry && typeof entry === 'object' && entry.n) {
|
|
417
|
+
// Rebuilt field by field rather than spread, so a hand-edited sheet
|
|
418
|
+
// cannot smuggle arbitrary keys into an inventory entry. Every flag
|
|
419
|
+
// an item can carry has to be listed here — one that is missing is
|
|
420
|
+
// silently discarded on the next read.
|
|
329
421
|
const item = { n: String(entry.n), q: Math.max(Number(entry.q) || 1, 0) };
|
|
330
422
|
if (entry.eq)
|
|
331
423
|
item.eq = true;
|
|
@@ -353,6 +445,16 @@ function normalizeCoin(value) {
|
|
|
353
445
|
function clamp(value, min, max) {
|
|
354
446
|
return Math.min(Math.max(value, min), max);
|
|
355
447
|
}
|
|
448
|
+
// ---------------------------------------------------------------------------
|
|
449
|
+
// Rendering
|
|
450
|
+
// ---------------------------------------------------------------------------
|
|
451
|
+
/**
|
|
452
|
+
* Renders a complete sheet artifact body from state, splicing the previous free
|
|
453
|
+
* prose back in verbatim.
|
|
454
|
+
* @param state The canonical state; its `rev` is incremented by the caller
|
|
455
|
+
* @param notes The prose region to preserve, from {@link extractNotes}
|
|
456
|
+
* @returns The artifact body
|
|
457
|
+
*/
|
|
356
458
|
function renderSheet(state, notes) {
|
|
357
459
|
const summary = renderSummary(state);
|
|
358
460
|
const prose = trimNotes(notes);
|
|
@@ -362,11 +464,14 @@ function renderSheet(state, notes) {
|
|
|
362
464
|
sections.push([NOTES_OPEN, prose, NOTES_CLOSE].join('\n'));
|
|
363
465
|
}
|
|
364
466
|
else {
|
|
467
|
+
// Keep the markers even when empty so the next writer has an anchor and a
|
|
468
|
+
// human can see where their own notes are meant to go.
|
|
365
469
|
sections.push([NOTES_OPEN, NOTES_CLOSE].join('\n'));
|
|
366
470
|
}
|
|
367
471
|
sections.push(stateBlock);
|
|
368
472
|
return sections.join('\n\n') + '\n';
|
|
369
473
|
}
|
|
474
|
+
/** Caps the prose region, dropping the oldest lines rather than the newest. */
|
|
370
475
|
function trimNotes(notes) {
|
|
371
476
|
const text = (notes || '').trim();
|
|
372
477
|
if (text.length <= MAX_NOTES_CHARS)
|
|
@@ -382,9 +487,20 @@ function trimNotes(notes) {
|
|
|
382
487
|
}
|
|
383
488
|
return ['*(older notes trimmed)*', ...kept].join('\n');
|
|
384
489
|
}
|
|
490
|
+
/** Formats a modifier with an explicit sign, e.g. '+3' or '-1'. */
|
|
385
491
|
function signed(value) {
|
|
386
492
|
return value >= 0 ? `+${value}` : `${value}`;
|
|
387
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* The readable half of a monster's sheet.
|
|
496
|
+
*
|
|
497
|
+
* Not the character render: a foe has no class, level, proficiency bonus, hit dice
|
|
498
|
+
* or spell slots, and printing "Level 1" against a wight is worse than printing
|
|
499
|
+
* nothing. A fight needs its hit points, armour class, what it can do, and what is
|
|
500
|
+
* currently wrong with it.
|
|
501
|
+
* @param state The monster
|
|
502
|
+
* @returns The summary block
|
|
503
|
+
*/
|
|
388
504
|
function renderFoeSummary(state) {
|
|
389
505
|
const lines = [`# ${state.name}`];
|
|
390
506
|
const dead = state.deathSaves.f >= 3 || state.hp.cur <= 0;
|
|
@@ -421,6 +537,7 @@ function renderFoeSummary(state) {
|
|
|
421
537
|
}
|
|
422
538
|
return lines.join('\n');
|
|
423
539
|
}
|
|
540
|
+
/** The human-readable half of the sheet, regenerated on every write. */
|
|
424
541
|
function renderSummary(state) {
|
|
425
542
|
if (state.foe)
|
|
426
543
|
return renderFoeSummary(state);
|
|
@@ -444,6 +561,8 @@ function renderSummary(state) {
|
|
|
444
561
|
lines.push(`*${descriptors.join(' — ')}*`);
|
|
445
562
|
lines.push('');
|
|
446
563
|
const tempNote = state.hp.temp > 0 ? ` (temp ${state.hp.temp})` : '';
|
|
564
|
+
// Exhaustion and heavy armour change the effective maximum and speed without
|
|
565
|
+
// touching the stored values, so the line shows what is actually in play.
|
|
447
566
|
const maxHp = rules.effectiveMaxHp(state);
|
|
448
567
|
const maxNote = maxHp === state.hp.max ? '' : ` of ${state.hp.max}, halved by exhaustion`;
|
|
449
568
|
const movement = rules.effectiveSpeed(state);
|
|
@@ -464,6 +583,10 @@ function renderSummary(state) {
|
|
|
464
583
|
.map((skill) => `${titleCase(skill)} ${signed(rules.skillModifier(state, skill))}`)
|
|
465
584
|
.join(' · '));
|
|
466
585
|
}
|
|
586
|
+
// Named on the sheet rather than left to a lookup: the DM asks for a thieves'
|
|
587
|
+
// tools check mid-scene, and the answer has to be in front of the player.
|
|
588
|
+
// No modifier is printed because the ability a tool check uses is the DM's call,
|
|
589
|
+
// so the only thing to show is the expertise marker the saves line also uses.
|
|
467
590
|
const tools = [...new Set([...(state.toolProf || []), ...(state.toolExp || [])])];
|
|
468
591
|
if (tools.length > 0) {
|
|
469
592
|
lines.push('**Tools (proficient):** ' +
|
|
@@ -483,6 +606,8 @@ function renderSummary(state) {
|
|
|
483
606
|
lines.push(...renderAttackRiders(state));
|
|
484
607
|
}
|
|
485
608
|
if (state.boons?.length) {
|
|
609
|
+
// The pending roll rides on this line rather than its own, because it only
|
|
610
|
+
// means anything while a die is held and it is why the die is still there.
|
|
486
611
|
const pending = state.pendingRoll;
|
|
487
612
|
const against = pending && pending.dc !== undefined
|
|
488
613
|
? ` — ${pending.subject || pending.kind} ${pending.total} vs ${pending.dc}, ${pending.dc - pending.total} short`
|
|
@@ -505,8 +630,15 @@ function renderSummary(state) {
|
|
|
505
630
|
}
|
|
506
631
|
const traits = (0, races_1.racialTraits)(state);
|
|
507
632
|
if (traits.length > 0) {
|
|
633
|
+
// Names only. The full text is in the race table and comes back through
|
|
634
|
+
// `read_sheet` with section "race", so the sheet stays short — it is
|
|
635
|
+
// rendered into its owner's prompt on every single turn.
|
|
508
636
|
lines.push(`**Racial traits:** ${traits.map((trait) => trait.n).join(', ')}`);
|
|
509
637
|
}
|
|
638
|
+
// The name only. What the background *does* is in the `Background: <name>` document
|
|
639
|
+
// its player already reads, and anything recorded for this character is in the notes
|
|
640
|
+
// below — so repeating a paragraph of it in a block rendered on every turn would be
|
|
641
|
+
// paying twice for the same prose.
|
|
510
642
|
if (state.bg)
|
|
511
643
|
lines.push(`**Background:** ${state.bg}`);
|
|
512
644
|
if (state.darkvision)
|
|
@@ -525,6 +657,9 @@ function renderSummary(state) {
|
|
|
525
657
|
});
|
|
526
658
|
if (gear.length > 0)
|
|
527
659
|
lines.push(`**Gear:** ${gear.join(', ')}`);
|
|
660
|
+
// Shown only when it can actually matter. Without the variant, capacity is
|
|
661
|
+
// "high enough that most characters don't usually have to worry about it", and
|
|
662
|
+
// a line saying so every turn would be noise in the owner's prompt.
|
|
528
663
|
const load = (0, encumbrance_1.encumbrance)(state);
|
|
529
664
|
if (load.variant || load.tier !== 'unencumbered') {
|
|
530
665
|
lines.push(`**Carrying:** ${(0, encumbrance_1.describeEncumbrance)(state)}`);
|
|
@@ -543,6 +678,15 @@ function renderSummary(state) {
|
|
|
543
678
|
lines.push(`**Vulnerable to:** ${state.vuln.join(', ')}`);
|
|
544
679
|
return lines.join('\n');
|
|
545
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* The riders printed under the attack line, one per attack that has one.
|
|
683
|
+
*
|
|
684
|
+
* Their own lines rather than appended to the attack summary, because the summary is
|
|
685
|
+
* a single dense row and a rider is a sentence — inlined, the one thing on the line
|
|
686
|
+
* that needs acting on is the easiest to skim past.
|
|
687
|
+
* @param state The combatant
|
|
688
|
+
* @returns Zero or more lines
|
|
689
|
+
*/
|
|
546
690
|
function renderAttackRiders(state) {
|
|
547
691
|
return state.attacks
|
|
548
692
|
.filter((attack) => attack.note)
|