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
|
@@ -10,6 +10,11 @@ import { StoryInfo, StoryState, Character } from '../../../shared/types/app.type
|
|
|
10
10
|
import { UserPathsService } from '../config/user-paths.service';
|
|
11
11
|
import { ArtifactService } from '../ai/artifact.service';
|
|
12
12
|
import { Readable } from 'stream';
|
|
13
|
+
import { IllustrationService } from '../room/illustration/illustration.service';
|
|
14
|
+
/**
|
|
15
|
+
* Service handling business logic for stories
|
|
16
|
+
* Works alongside StoryStoreService which handles persistence
|
|
17
|
+
*/
|
|
13
18
|
export declare class StoryService {
|
|
14
19
|
private readonly storyStore;
|
|
15
20
|
private readonly agentStore;
|
|
@@ -19,88 +24,440 @@ export declare class StoryService {
|
|
|
19
24
|
private readonly userPaths;
|
|
20
25
|
private readonly agentFactory;
|
|
21
26
|
private readonly roomFactory;
|
|
27
|
+
private readonly illustration;
|
|
22
28
|
private readonly storyArtifactServices;
|
|
23
29
|
private readonly chaptersInProgress;
|
|
24
|
-
constructor(storyStore: StoryStoreService, agentStore: AgentStoreService, roomStore: RoomStoreService, progressService: StoryProgressService, messageService: StoryMessageService, userPaths: UserPathsService, agentFactory: AgentFactory, roomFactory: RoomFactory);
|
|
30
|
+
constructor(storyStore: StoryStoreService, agentStore: AgentStoreService, roomStore: RoomStoreService, progressService: StoryProgressService, messageService: StoryMessageService, userPaths: UserPathsService, agentFactory: AgentFactory, roomFactory: RoomFactory, illustration: IllustrationService);
|
|
31
|
+
/**
|
|
32
|
+
* Describes a story to the illustration pipeline.
|
|
33
|
+
*
|
|
34
|
+
* The indirection is what keeps existing stories untouched by the extraction:
|
|
35
|
+
* this reports the artifacts directory a story's images are already in and the
|
|
36
|
+
* `/api/stories/...` URL already baked into its saved message bodies, so
|
|
37
|
+
* nothing moves and no stored transcript goes stale.
|
|
38
|
+
*/
|
|
39
|
+
private illustrationTarget;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the progress emitter for a story
|
|
42
|
+
* @param storyId The story ID
|
|
43
|
+
* @returns The event emitter or undefined
|
|
44
|
+
*/
|
|
25
45
|
getProgressEmitter(storyId: string): import("events")<[never]>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets or creates the message emitter for a story
|
|
48
|
+
* @param storyId The story ID
|
|
49
|
+
* @returns The event emitter
|
|
50
|
+
*/
|
|
26
51
|
getMessageEmitter(storyId: string): import("events")<[never]>;
|
|
52
|
+
/**
|
|
53
|
+
* Cleans up the progress emitter for a story
|
|
54
|
+
* @param storyId The story ID
|
|
55
|
+
*/
|
|
27
56
|
cleanupProgressEmitter(storyId: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Cleans up the message emitter for a story
|
|
59
|
+
* @param storyId The story ID
|
|
60
|
+
*/
|
|
28
61
|
cleanupMessageEmitter(storyId: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Gets or creates the artifact service for a story
|
|
64
|
+
* @param storyId The story ID
|
|
65
|
+
* @returns The story-specific artifact service
|
|
66
|
+
*/
|
|
29
67
|
getStoryArtifactService(storyId: string): ArtifactService;
|
|
68
|
+
/**
|
|
69
|
+
* Emits a story state update to connected SSE clients
|
|
70
|
+
* Called by room's onStateChange callback
|
|
71
|
+
* @param storyId The story ID
|
|
72
|
+
*/
|
|
30
73
|
private emitStoryStateUpdate;
|
|
31
74
|
getHumanPrompt(room: Room): string;
|
|
75
|
+
/**
|
|
76
|
+
* Handles errors from room operations and emits them through SSE
|
|
77
|
+
* @param storyId The story ID
|
|
78
|
+
* @param error The error that occurred
|
|
79
|
+
*/
|
|
32
80
|
private handleRoomError;
|
|
81
|
+
/**
|
|
82
|
+
* Picks a random word from the random words file, if there is one.
|
|
83
|
+
*
|
|
84
|
+
* The list is optional and is not published with the package, so an SDK host
|
|
85
|
+
* has no file to read. `create_story.prompt` offers the word as an aid rather
|
|
86
|
+
* than requiring it — "if you need random numbers or words, use these" — so a
|
|
87
|
+
* story created without one is a story the narrator had one fewer prompt from.
|
|
88
|
+
*
|
|
89
|
+
* Absent has to be handled here rather than left to throw: this runs inside
|
|
90
|
+
* {@link createStory}, so a missing file would fail every story creation
|
|
91
|
+
* outright rather than costing the narrator an idea.
|
|
92
|
+
* @returns A random word, or '' when no list is installed
|
|
93
|
+
*/
|
|
33
94
|
private getRandomWord;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the storage directories for a story
|
|
97
|
+
* @param storyId The story ID
|
|
98
|
+
* @returns Object with agentsDir, roomsDir, and artifactsDir paths
|
|
99
|
+
*/
|
|
34
100
|
private getStoryStorageDirs;
|
|
101
|
+
/**
|
|
102
|
+
* Looks up AI service and model from story_models.json using the model identifier
|
|
103
|
+
* @param storyModel The model identifier (e.g., "claude-sonnet-4-5")
|
|
104
|
+
* @returns Object with service and model, or null if not found
|
|
105
|
+
*/
|
|
35
106
|
private getStoryModelConfig;
|
|
36
107
|
private getStoryRoom;
|
|
108
|
+
/**
|
|
109
|
+
* Ensures a story's room and agents are loaded into memory
|
|
110
|
+
* Sets up the state change callback for event-driven updates
|
|
111
|
+
* @param storyId The story ID
|
|
112
|
+
*/
|
|
37
113
|
private ensureStoryLoaded;
|
|
38
114
|
getStoryInfo(storyId: string): Promise<StoryInfo | null>;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new story with business logic
|
|
117
|
+
* @param name The story name
|
|
118
|
+
* @param idea The story idea or existing story text (if isImport is true)
|
|
119
|
+
* @param userCharacterDesc Description of the character the user will play
|
|
120
|
+
* @param otherCharactersDesc Description of other prominent characters
|
|
121
|
+
* @param illustrateStory True if the story will be illustrated
|
|
122
|
+
* @param storyModel The model identifier (e.g., "claude-sonnet-4-5") from story_models.json
|
|
123
|
+
* @param isImport Flag indicating this is an imported existing story
|
|
124
|
+
* @param imageModelName Name of the image model in data/common/config/image_models.json. Each entry supplies both a generation model (portraits/scene references) and an editing model (story images with reference images).
|
|
125
|
+
* @param skipDetailedPlot When true, generate a simple plot scenario instead of a detailed plot plan with secrets, twists, and events
|
|
126
|
+
* @returns The story information including the generated ID
|
|
127
|
+
*/
|
|
39
128
|
createStory(name: string, idea: string, userCharacterDesc: string, otherCharactersDesc: string, illustrateStory: boolean, storyModel?: string, isImport?: boolean, imageModelName?: string, skipDetailedPlot?: boolean): Promise<StoryInfo>;
|
|
129
|
+
/**
|
|
130
|
+
* Performs the actual story creation work asynchronously
|
|
131
|
+
* This runs in the background after returning the storyId to the client
|
|
132
|
+
*/
|
|
40
133
|
private createStoryAsync;
|
|
41
134
|
generateCharacterPortraits(storyInfo: StoryInfo, room: Room): Promise<void>[];
|
|
42
135
|
generateOpeningSceneImage(storyInfo: StoryInfo, room: Room): Promise<{
|
|
43
136
|
type: string;
|
|
44
137
|
success: boolean;
|
|
45
138
|
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Validates the structure of an imported story directory
|
|
141
|
+
* @param importDir The directory containing the extracted story files
|
|
142
|
+
* @returns Validation result with errors and metadata if valid
|
|
143
|
+
*/
|
|
46
144
|
private validateImportStructure;
|
|
145
|
+
/**
|
|
146
|
+
* Extracts a zip file to a target directory with security checks
|
|
147
|
+
* @param zipBuffer The zip file buffer
|
|
148
|
+
* @param targetDir The directory to extract to
|
|
149
|
+
*/
|
|
47
150
|
private extractZip;
|
|
151
|
+
/**
|
|
152
|
+
* Imports a story from a zip file buffer
|
|
153
|
+
* @param zipBuffer The zip file buffer to import
|
|
154
|
+
* @returns The imported story metadata
|
|
155
|
+
*/
|
|
48
156
|
importStoryFromZip(zipBuffer: Buffer): Promise<StoryInfo>;
|
|
157
|
+
/**
|
|
158
|
+
* Populates agent conversation histories and room messages with imported story text
|
|
159
|
+
*
|
|
160
|
+
* @param room The story room
|
|
161
|
+
* @param storyText The imported story text
|
|
162
|
+
* @param audience Nicknames of the characters present for `storyText`. Characters
|
|
163
|
+
* outside it do not hear it, which is how a chapter can open on a scene only some
|
|
164
|
+
* of the cast are in. Non-character agents (narrator, moderator, illustrator,
|
|
165
|
+
* artist) are always seeded - they work on the whole story, not a scene of it -
|
|
166
|
+
* as is the player's own character, who is reading the text on screen either way.
|
|
167
|
+
* Omit to seed everyone, which is right when the text opens the story and the
|
|
168
|
+
* whole cast is new to it.
|
|
169
|
+
*/
|
|
49
170
|
populateStoryHistory(room: Room, storyText: string, audience?: string[]): void;
|
|
171
|
+
/**
|
|
172
|
+
* Sends a message to the story dialog and gets an AI response
|
|
173
|
+
* @param storyId The story ID
|
|
174
|
+
* @param message The user's message
|
|
175
|
+
* @param action The action type ('say' or 'do')
|
|
176
|
+
* @returns The AI assistant's response
|
|
177
|
+
*/
|
|
178
|
+
/**
|
|
179
|
+
* Gets the current state of a story including room messages and pending status
|
|
180
|
+
* @param storyId The story ID
|
|
181
|
+
* @returns Story state with room messages and pending status
|
|
182
|
+
*/
|
|
50
183
|
getStoryState(storyId: string): Promise<StoryState>;
|
|
184
|
+
/**
|
|
185
|
+
* Lists all characters in the story (excluding narrator)
|
|
186
|
+
* @param storyId The story ID
|
|
187
|
+
* @returns Array of character info
|
|
188
|
+
*/
|
|
51
189
|
listCharacters(storyId: string): Promise<Character[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Gets a character profile artifact content
|
|
192
|
+
* @param storyId The story ID
|
|
193
|
+
* @param characterName The character name
|
|
194
|
+
* @returns The character profile markdown content
|
|
195
|
+
*/
|
|
52
196
|
getCharacter(storyId: string, characterName: string): Promise<string | null>;
|
|
197
|
+
/**
|
|
198
|
+
* Saves a character profile (convenience wrapper for PUBLISH action)
|
|
199
|
+
* @param storyId The story ID
|
|
200
|
+
* @param characterName The character name
|
|
201
|
+
* @param content The updated character profile markdown
|
|
202
|
+
* @returns Success status
|
|
203
|
+
*/
|
|
53
204
|
saveCharacter(storyId: string, characterName: string, content: string): void;
|
|
205
|
+
/**
|
|
206
|
+
* Gets a character's inventory, stored in the owning agent's private context.
|
|
207
|
+
* @param storyId The story ID
|
|
208
|
+
* @param characterName The character name
|
|
209
|
+
* @returns The inventory markdown content, or null if no inventory exists yet
|
|
210
|
+
*/
|
|
54
211
|
getCharacterInventory(storyId: string, characterName: string): Promise<string | null>;
|
|
212
|
+
/**
|
|
213
|
+
* Saves a character's inventory to the owning agent's private context. The
|
|
214
|
+
* inventory stays visible only to the owning character and the Moderator.
|
|
215
|
+
* @param storyId The story ID
|
|
216
|
+
* @param characterName The character name
|
|
217
|
+
* @param content The updated inventory markdown
|
|
218
|
+
*/
|
|
55
219
|
saveCharacterInventory(storyId: string, characterName: string, content: string): Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* Gets the plot plan artifact content
|
|
222
|
+
* @param storyId The story ID
|
|
223
|
+
* @returns The plot plan markdown content
|
|
224
|
+
*/
|
|
56
225
|
getPlotPlan(storyId: string): Promise<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Gets the formatted conversation history for an agent in the story
|
|
228
|
+
* @param storyId The story ID
|
|
229
|
+
* @param agentId The agent ID
|
|
230
|
+
* @returns JSON string of the agent's conversation history
|
|
231
|
+
*/
|
|
57
232
|
getAgentHistory(storyId: string, agentId: string): Promise<string>;
|
|
233
|
+
/**
|
|
234
|
+
* Saves the plot plan (convenience wrapper for PUBLISH action)
|
|
235
|
+
* @param storyId The story ID
|
|
236
|
+
* @param content The updated plot plan markdown
|
|
237
|
+
* @returns Success status
|
|
238
|
+
*/
|
|
58
239
|
savePlotPlan(storyId: string, content: string): Promise<void>;
|
|
59
240
|
publishArtifact(storyId: string, name: string, creator: string, body: string, viewers: string[]): Promise<void>;
|
|
60
241
|
respondToStory(storyId: string, content: string): Promise<void>;
|
|
61
242
|
interruptStory(storyId: string): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Introduces a new character into an existing story
|
|
245
|
+
* Creates character agent, updates profile, and notifies narrator
|
|
246
|
+
* @param latestNarration When introduced by the narrator, the narration
|
|
247
|
+
* prose that introduced this character. It isn't logged to the room yet,
|
|
248
|
+
* so it's threaded in to seed the new character's first profile.
|
|
249
|
+
*/
|
|
62
250
|
introduceCharacter(storyId: string, characterName: string, characterDescription: string, storyModel?: string, fromNarratorSuggestion?: boolean, latestNarration?: string): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Records that user declined to introduce a character
|
|
253
|
+
* @param storyId The story ID
|
|
254
|
+
* @param characterName The character name that was declined
|
|
255
|
+
*/
|
|
63
256
|
declineCharacter(storyId: string, characterName: string): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Deletes a character agent from a story but preserves the character profile artifact
|
|
259
|
+
* @param storyId The story ID
|
|
260
|
+
* @param characterName The character name to delete
|
|
261
|
+
* @returns Success status and message
|
|
262
|
+
*/
|
|
64
263
|
deleteCharacter(storyId: string, characterName: string): Promise<void>;
|
|
65
264
|
deleteStory(storyId: string): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Helper function to disable markup and balance checks for story agents
|
|
267
|
+
* Used during story creation, chapter progression, and compaction
|
|
268
|
+
* @param agents Array of agents to disable flags for
|
|
269
|
+
* @param reason Optional reason for logging (e.g., "story creation", "chapter progression")
|
|
270
|
+
*/
|
|
66
271
|
private disableStoryAgentFlags;
|
|
272
|
+
/**
|
|
273
|
+
* Helper function to re-enable markup and balance checks for story agents
|
|
274
|
+
* Used after story creation, chapter progression, and compaction complete
|
|
275
|
+
* @param agents Array of agents to re-enable flags for
|
|
276
|
+
* @param reason Optional reason for logging (e.g., "story creation", "chapter progression")
|
|
277
|
+
*/
|
|
67
278
|
private enableStoryAgentFlags;
|
|
279
|
+
/**
|
|
280
|
+
* Compacts the conversation history for all agents in a story
|
|
281
|
+
* Uses story-specific prompts tailored for narrator (plot events) and characters (relationships)
|
|
282
|
+
* Processes all agents in parallel for better performance
|
|
283
|
+
* @param storyId The story ID
|
|
284
|
+
* @returns Success status, message, and details about compaction
|
|
285
|
+
*/
|
|
68
286
|
compactStory(storyId: string): Promise<{
|
|
69
287
|
success: boolean;
|
|
70
288
|
message?: string;
|
|
71
289
|
details?: any;
|
|
72
290
|
}>;
|
|
291
|
+
/**
|
|
292
|
+
* Progresses a story to the next chapter by:
|
|
293
|
+
* 1. Updating the Plot Plan artifact based on recent story events
|
|
294
|
+
* 2. Updating all Character Profile artifacts based on character development
|
|
295
|
+
* 3. Creating a new chapter folder with the next chapter index
|
|
296
|
+
* 4. Backing up the current room messages to the new chapter folder
|
|
297
|
+
* 5. Compacting the story conversation history in place
|
|
298
|
+
* 6. Clearing all room messages to start fresh for the next chapter
|
|
299
|
+
* @param storyId The story ID
|
|
300
|
+
* @returns Result with success status, chapter index, and compaction details
|
|
301
|
+
*/
|
|
73
302
|
progressStoryToNextChapter(storyId: string): Promise<{
|
|
74
303
|
chapterIndex: number;
|
|
75
304
|
}>;
|
|
305
|
+
/**
|
|
306
|
+
* Reverts the most recent chapter progression. Restores the previous
|
|
307
|
+
* chapter's room messages, artifacts, and agent histories from the
|
|
308
|
+
* `chapters/chapter_N/` backup, then deletes that backup so the story
|
|
309
|
+
* is back to exactly the state it was in before the player clicked
|
|
310
|
+
* Next Chapter.
|
|
311
|
+
*
|
|
312
|
+
* Only valid when the current chapter has not been played yet - i.e.
|
|
313
|
+
* the only room message is the Opening Scene. The endpoint also requires
|
|
314
|
+
* at least one chapter backup to exist.
|
|
315
|
+
*
|
|
316
|
+
* Token counts and cost totals are not rolled back (those tokens were
|
|
317
|
+
* actually consumed), matching `resetStory` semantics.
|
|
318
|
+
*
|
|
319
|
+
* @throws {NotFoundError} If the story or its room does not exist
|
|
320
|
+
* @throws {OperationFailedError} If no previous chapter exists, or the
|
|
321
|
+
* chapter has already been played past the opening scene.
|
|
322
|
+
*/
|
|
76
323
|
revertStoryChapter(storyId: string): Promise<void>;
|
|
324
|
+
/**
|
|
325
|
+
* Performs the actual chapter progression work asynchronously
|
|
326
|
+
* Phase 1: Quick opening scene generation (user-visible, 5-10s)
|
|
327
|
+
* Phase 2: Background processing (plot, profiles, compaction, 20-50s)
|
|
328
|
+
*/
|
|
77
329
|
private progressStoryToNextChapterAsync;
|
|
330
|
+
/**
|
|
331
|
+
* Generates the opening scene for a new chapter and a title for the previous chapter
|
|
332
|
+
* Uses create_chapter prompt which returns the title on the first line (with a #
|
|
333
|
+
* prefix), then the same `<time>`/`<situation>` preamble a narration carries, then
|
|
334
|
+
* the opening scene.
|
|
335
|
+
*/
|
|
78
336
|
private generateOpeningScene;
|
|
337
|
+
/**
|
|
338
|
+
* Asks the moderator which characters are present for the opening scene of a
|
|
339
|
+
* new chapter.
|
|
340
|
+
*
|
|
341
|
+
* A chapter opening does not go through the room's message loop - it is written
|
|
342
|
+
* before the chapter exists and seeded straight into history - so nothing has
|
|
343
|
+
* decided its audience. Without this every character hears it, including the ones
|
|
344
|
+
* the narrator left several days' travel away.
|
|
345
|
+
*
|
|
346
|
+
* Requires the room's situation to already be the new chapter's, since that is
|
|
347
|
+
* what the moderator treats as authoritative about who is present.
|
|
348
|
+
*
|
|
349
|
+
* @returns The nicknames who may hear the opening scene, or null if the moderator
|
|
350
|
+
* could not be reached or named nobody - in which case the caller should seed
|
|
351
|
+
* every agent rather than silently narrate to an empty room.
|
|
352
|
+
*/
|
|
79
353
|
private moderateOpeningSceneAudience;
|
|
354
|
+
/**
|
|
355
|
+
* Compacts every agent whose history has outgrown the threshold, in parallel.
|
|
356
|
+
* The threshold and the exemption for windowed agents live on `Agent`, so a
|
|
357
|
+
* story and a room agree on when a history has grown too long.
|
|
358
|
+
* @param agents The agents to consider
|
|
359
|
+
*/
|
|
80
360
|
private compactAgentHistories;
|
|
81
361
|
private extractMarkdownContent;
|
|
82
362
|
private updatePlotPlan;
|
|
363
|
+
/**
|
|
364
|
+
* Stores a character's inventory in the owning agent's private context. The
|
|
365
|
+
* inventory is therefore visible only to that character (injected into its own
|
|
366
|
+
* transient prompt) and, in aggregate, to the Moderator — never to other
|
|
367
|
+
* characters. Storing it on the agent rather than in a room artifact keeps the
|
|
368
|
+
* frequently-changing inventory out of the cached system instructions.
|
|
369
|
+
*
|
|
370
|
+
* @param room The story room
|
|
371
|
+
* @param characterNickname The owning character's nickname
|
|
372
|
+
* @param body Markdown body of the inventory (typically '## Items' and optional '## Conditions' sections)
|
|
373
|
+
*/
|
|
83
374
|
private storeCharacterInventory;
|
|
375
|
+
/**
|
|
376
|
+
* Reads changes.update_inventory off a moderator response and rewrites each
|
|
377
|
+
* named character's stored inventory. Silently no-ops if no updates.
|
|
378
|
+
*
|
|
379
|
+
* @param room The story room
|
|
380
|
+
* @param moderatorMessage The moderator's RoomMessage (with .changes populated)
|
|
381
|
+
*/
|
|
84
382
|
private applyInventoryUpdates;
|
|
383
|
+
/**
|
|
384
|
+
* Helper method to update all character profiles based on story progression
|
|
385
|
+
* Processes all characters in parallel for better performance
|
|
386
|
+
* @param room The story room
|
|
387
|
+
* @param characterAgents Array of character agents (excluding narrator)
|
|
388
|
+
* @returns Update result with details for each character
|
|
389
|
+
*/
|
|
85
390
|
private updateCharacterProfiles;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
391
|
+
/**
|
|
392
|
+
* Generates portrait image for a character
|
|
393
|
+
* @param room The story room
|
|
394
|
+
* @param characterAgent The character agent
|
|
395
|
+
* @param storyId The story ID
|
|
396
|
+
* @returns Promise resolving to the artifact ID of the generated image, or null on failure
|
|
397
|
+
*/
|
|
89
398
|
private generateCharacterPortrait;
|
|
90
|
-
private generatePortraitForName;
|
|
91
399
|
private updateCharacterPortrait;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Parses the narrator's preamble into structured fields. Extracts each
|
|
402
|
+
* tag's inner text (first occurrence, case-insensitive); missing tags
|
|
403
|
+
* are simply omitted from the result.
|
|
404
|
+
*/
|
|
96
405
|
private parseNarratorPreamble;
|
|
406
|
+
/**
|
|
407
|
+
* Updates the story's situation in metadata. Invoked from the Room's
|
|
408
|
+
* situation-update callback with the raw preamble text emitted by the
|
|
409
|
+
* narrator. The Room itself stays story-agnostic and does not interpret
|
|
410
|
+
* the preamble contents - all parsing happens here.
|
|
411
|
+
*
|
|
412
|
+
* @param storyId The story ID
|
|
413
|
+
* @param preamble The raw preamble text captured by the Room
|
|
414
|
+
*/
|
|
97
415
|
private updateStorySituation;
|
|
416
|
+
/**
|
|
417
|
+
* Asks the shared illustration pipeline for a picture of the story's current
|
|
418
|
+
* scene. The situation is passed in rather than read off the room: the room's
|
|
419
|
+
* copy holds the narrator's raw four-tag preamble, while the story's is the
|
|
420
|
+
* parsed inner text, and the illustrator wants the latter.
|
|
421
|
+
*/
|
|
422
|
+
private illustrateStorySituation;
|
|
423
|
+
/**
|
|
424
|
+
* Generates a complete markdown document of the story
|
|
425
|
+
* Includes metadata, all completed chapters, and current chapter in progress
|
|
426
|
+
* @param storyId The story ID
|
|
427
|
+
* @returns The complete story as markdown text
|
|
428
|
+
*/
|
|
98
429
|
generateStoryMarkdown(storyId: string): Promise<string>;
|
|
430
|
+
/**
|
|
431
|
+
* Creates a zip archive of the entire story folder
|
|
432
|
+
* @param storyId The story ID
|
|
433
|
+
* @returns Promise resolving to a readable stream of the zip file
|
|
434
|
+
*/
|
|
99
435
|
exportStoryData(storyId: string): Promise<{
|
|
100
436
|
stream: Readable;
|
|
101
437
|
filename: string;
|
|
102
438
|
}>;
|
|
439
|
+
/**
|
|
440
|
+
* Formats room messages as markdown text
|
|
441
|
+
*
|
|
442
|
+
* A message's situation is not printed. It restates where the scene stands,
|
|
443
|
+
* which is useful live and merely repetitive on the page — the narrator sets one
|
|
444
|
+
* often enough that the document filled up with headings.
|
|
445
|
+
*
|
|
446
|
+
* @param messages Array of room messages
|
|
447
|
+
* @returns Formatted markdown string
|
|
448
|
+
*/
|
|
103
449
|
private formatMessagesToMarkdown;
|
|
450
|
+
/**
|
|
451
|
+
* Process markdown to add sizing to images for better display
|
|
452
|
+
* Converts  to <img> tags with width constraints
|
|
453
|
+
* @param markdown The markdown string to process
|
|
454
|
+
* @param maxWidth Maximum width for images (default: 600px)
|
|
455
|
+
* @returns Processed markdown with HTML img tags
|
|
456
|
+
*/
|
|
104
457
|
private processImageMarkdown;
|
|
458
|
+
/**
|
|
459
|
+
* Updates the story's total cost by aggregating costs from all agents in the story's room
|
|
460
|
+
* @param storyId The story ID
|
|
461
|
+
*/
|
|
105
462
|
private updateStoryCost;
|
|
106
463
|
}
|