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,20 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a pack's templates into real agents and rooms.
|
|
3
|
+
*
|
|
4
|
+
* A pack ships a room the way a recipe ships a method: `rooms/table.json` names
|
|
5
|
+
* the agents it wants **by template key**, and every one of those keys is resolved
|
|
6
|
+
* to a created agent before anything is written. That indirection is the whole
|
|
7
|
+
* point — a template cannot name a nickname, because a nickname is derived at
|
|
8
|
+
* creation from the bare name's first word, the user may rename afterwards, and
|
|
9
|
+
* two agents in one room may not share one.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the room is created first
|
|
12
|
+
*
|
|
13
|
+
* An agent carries `ownerRoomId`, and `AppService.listAgents` skips any agent that
|
|
14
|
+
* has one. So an agent written for a room that then failed to save is invisible
|
|
15
|
+
* and unreachable for good. Creating the room first means its id exists before any
|
|
16
|
+
* agent claims it, and the rollback deletes the room, which takes its agents with
|
|
17
|
+
* it.
|
|
18
|
+
*
|
|
19
|
+
* ## Why models come from the request
|
|
20
|
+
*
|
|
21
|
+
* A template says `modelRole: 'economy'`, never a model id. A pack that named
|
|
22
|
+
* `claude-sonnet-5` would go stale and would assume the host's keys — but the
|
|
23
|
+
* split still matters, since the dnd5e pack exists partly so combat runs on a
|
|
24
|
+
* cheap agent. The caller supplies one model per role.
|
|
25
|
+
*/
|
|
1
26
|
import { PromptFolderDefaults } from '../../../shared/types/app.types';
|
|
2
27
|
import { AppService } from '../app.service';
|
|
3
28
|
import { RoomStoreService } from '../room/room-store.service';
|
|
4
29
|
import { PackService } from './pack.service';
|
|
30
|
+
/** Which model an instantiated agent should use, per the role its template asks for. */
|
|
5
31
|
export interface ModelChoice {
|
|
6
32
|
aiServiceName: string;
|
|
7
33
|
aiModel: string;
|
|
34
|
+
/** Same-service smaller model, for mechanical prompts. Optional. */
|
|
8
35
|
smallModelName?: string;
|
|
9
36
|
}
|
|
10
37
|
export interface InstantiateModels {
|
|
11
38
|
primary: ModelChoice;
|
|
39
|
+
/** Falls back to {@link primary} when the caller offers only one. */
|
|
12
40
|
economy?: ModelChoice;
|
|
13
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Per-agent changes to a room template's roster, keyed by the key the template
|
|
44
|
+
* addresses that agent by — its `as` when it has one, its template key otherwise.
|
|
45
|
+
*
|
|
46
|
+
* The reason this exists: a template ships a cast with fixed names, and the one
|
|
47
|
+
* thing an app almost always has to change is what the person at the keyboard is
|
|
48
|
+
* called. Without it, naming the player means either building the room by hand —
|
|
49
|
+
* giving up the ordering and the rollback this service exists for — or renaming
|
|
50
|
+
* the agent afterwards, once it has already introduced itself.
|
|
51
|
+
*/
|
|
14
52
|
export type RosterOverrides = Record<string, Partial<PromptFolderDefaults>>;
|
|
15
53
|
export interface InstantiateRoomResult {
|
|
16
54
|
roomId: string;
|
|
17
55
|
agentIds: string[];
|
|
56
|
+
/** Things that did not go as the template asked, but did not stop the room. */
|
|
18
57
|
warnings: string[];
|
|
19
58
|
}
|
|
20
59
|
export declare class PackInstantiationService {
|
|
@@ -22,15 +61,74 @@ export declare class PackInstantiationService {
|
|
|
22
61
|
private readonly packs;
|
|
23
62
|
private readonly roomStore;
|
|
24
63
|
constructor(app: AppService, packs: PackService, roomStore: RoomStoreService);
|
|
64
|
+
/**
|
|
65
|
+
* Builds a room from a pack's room template, with its whole cast.
|
|
66
|
+
*
|
|
67
|
+
* @param packName The pack holding the template
|
|
68
|
+
* @param roomKey The room template's key
|
|
69
|
+
* @param models One model per role the templates ask for
|
|
70
|
+
* @param name Overrides the template's room name
|
|
71
|
+
* @param overrides Per-agent changes, keyed by roster key — most usefully
|
|
72
|
+
* `{ player: { agentNickname: 'Homer' } }`. Applied over the template's own
|
|
73
|
+
* overrides, which are applied over the prompt folder's defaults
|
|
74
|
+
* @returns The room, its agents, and anything that did not go to plan
|
|
75
|
+
* @throws {NotFoundError} If the pack or the template does not exist
|
|
76
|
+
* @throws {ValidationError} If the pack is off, the template is inconsistent, or
|
|
77
|
+
* an override names a key that is not on the roster
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const { roomId } = await packInstantiation.instantiateRoom(
|
|
82
|
+
* 'dnd5e', 'table',
|
|
83
|
+
* { primary: { aiServiceName: 'Anthropic', aiModel: 'claude-sonnet-5' } },
|
|
84
|
+
* 'Tuesday Night Game',
|
|
85
|
+
* { player: { agentName: 'Homer', agentNickname: 'Homer' } },
|
|
86
|
+
* );
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
25
89
|
instantiateRoom(packName: string, roomKey: string, models: InstantiateModels, name?: string, overrides?: RosterOverrides): Promise<InstantiateRoomResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Builds a single free-standing agent from a pack's agent template.
|
|
92
|
+
*
|
|
93
|
+
* Free-standing rather than room-owned: this is the "preconfigured witness with
|
|
94
|
+
* the right statements attached" case, which has to be usable before any
|
|
95
|
+
* courtroom exists.
|
|
96
|
+
*
|
|
97
|
+
* @param packName The pack holding the template
|
|
98
|
+
* @param agentKey The agent template's key
|
|
99
|
+
* @param models One model per role
|
|
100
|
+
* @param overrides Anything the caller wants to change, e.g. the agent's name
|
|
101
|
+
* @returns The agent's id and anything that did not go to plan
|
|
102
|
+
* @throws {NotFoundError} If the pack or the template does not exist
|
|
103
|
+
* @throws {ValidationError} If the pack is off
|
|
104
|
+
*/
|
|
26
105
|
instantiateAgent(packName: string, agentKey: string, models: InstantiateModels, overrides?: Partial<PromptFolderDefaults>): Promise<{
|
|
27
106
|
agentId: string;
|
|
28
107
|
warnings: string[];
|
|
29
108
|
}>;
|
|
109
|
+
/** The pack, or a refusal that says which of the two things is wrong. */
|
|
30
110
|
private requireEnabledPack;
|
|
111
|
+
/**
|
|
112
|
+
* A template's prompt folder, qualified with its own pack when it is bare.
|
|
113
|
+
*
|
|
114
|
+
* A template may name another pack's folder outright — that is how a
|
|
115
|
+
* case-specific pack reuses a generic one's `witness` folder — so an
|
|
116
|
+
* already-qualified reference is left alone.
|
|
117
|
+
*/
|
|
31
118
|
private qualify;
|
|
119
|
+
/** Resolves every roster entry to its template, refusing an unknown key. */
|
|
32
120
|
private resolveRoster;
|
|
121
|
+
/** Checks a leader/moderator key names someone on the roster. */
|
|
33
122
|
private requireRosterKey;
|
|
123
|
+
/** The model for a template's declared role, falling back to the primary. */
|
|
34
124
|
private modelFor;
|
|
125
|
+
/**
|
|
126
|
+
* The template's name, suffixed if the user already has a room by it.
|
|
127
|
+
*
|
|
128
|
+
* Nothing enforces unique room names and rooms key on a UUID, so a second
|
|
129
|
+
* instantiation already worked — it just produced two indistinguishable entries
|
|
130
|
+
* in the sidebar. The suffix also reaches the agents, whose stored names carry
|
|
131
|
+
* the room's as a prefix.
|
|
132
|
+
*/
|
|
35
133
|
private uniqueRoomName;
|
|
36
134
|
}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Turning a pack's templates into real agents and rooms.
|
|
4
|
+
*
|
|
5
|
+
* A pack ships a room the way a recipe ships a method: `rooms/table.json` names
|
|
6
|
+
* the agents it wants **by template key**, and every one of those keys is resolved
|
|
7
|
+
* to a created agent before anything is written. That indirection is the whole
|
|
8
|
+
* point — a template cannot name a nickname, because a nickname is derived at
|
|
9
|
+
* creation from the bare name's first word, the user may rename afterwards, and
|
|
10
|
+
* two agents in one room may not share one.
|
|
11
|
+
*
|
|
12
|
+
* ## Why the room is created first
|
|
13
|
+
*
|
|
14
|
+
* An agent carries `ownerRoomId`, and `AppService.listAgents` skips any agent that
|
|
15
|
+
* has one. So an agent written for a room that then failed to save is invisible
|
|
16
|
+
* and unreachable for good. Creating the room first means its id exists before any
|
|
17
|
+
* agent claims it, and the rollback deletes the room, which takes its agents with
|
|
18
|
+
* it.
|
|
19
|
+
*
|
|
20
|
+
* ## Why models come from the request
|
|
21
|
+
*
|
|
22
|
+
* A template says `modelRole: 'economy'`, never a model id. A pack that named
|
|
23
|
+
* `claude-sonnet-5` would go stale and would assume the host's keys — but the
|
|
24
|
+
* split still matters, since the dnd5e pack exists partly so combat runs on a
|
|
25
|
+
* cheap agent. The caller supplies one model per role.
|
|
26
|
+
*/
|
|
2
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
28
|
exports.PackInstantiationService = void 0;
|
|
4
29
|
const room_store_service_1 = require("../room/room-store.service");
|
|
@@ -15,12 +40,38 @@ class PackInstantiationService {
|
|
|
15
40
|
this.packs = packs;
|
|
16
41
|
this.roomStore = roomStore;
|
|
17
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds a room from a pack's room template, with its whole cast.
|
|
45
|
+
*
|
|
46
|
+
* @param packName The pack holding the template
|
|
47
|
+
* @param roomKey The room template's key
|
|
48
|
+
* @param models One model per role the templates ask for
|
|
49
|
+
* @param name Overrides the template's room name
|
|
50
|
+
* @param overrides Per-agent changes, keyed by roster key — most usefully
|
|
51
|
+
* `{ player: { agentNickname: 'Homer' } }`. Applied over the template's own
|
|
52
|
+
* overrides, which are applied over the prompt folder's defaults
|
|
53
|
+
* @returns The room, its agents, and anything that did not go to plan
|
|
54
|
+
* @throws {NotFoundError} If the pack or the template does not exist
|
|
55
|
+
* @throws {ValidationError} If the pack is off, the template is inconsistent, or
|
|
56
|
+
* an override names a key that is not on the roster
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const { roomId } = await packInstantiation.instantiateRoom(
|
|
61
|
+
* 'dnd5e', 'table',
|
|
62
|
+
* { primary: { aiServiceName: 'Anthropic', aiModel: 'claude-sonnet-5' } },
|
|
63
|
+
* 'Tuesday Night Game',
|
|
64
|
+
* { player: { agentName: 'Homer', agentNickname: 'Homer' } },
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
18
68
|
async instantiateRoom(packName, roomKey, models, name, overrides) {
|
|
19
69
|
const pack = this.requireEnabledPack(packName);
|
|
20
70
|
const template = pack.rooms.find((room) => room.key === roomKey);
|
|
21
71
|
if (!template) {
|
|
22
72
|
throw new errors_1.NotFoundError(`Pack "${packName}" has no room template "${roomKey}"`);
|
|
23
73
|
}
|
|
74
|
+
// Everything that can be known before a side effect is checked before one.
|
|
24
75
|
const roster = this.resolveRoster(pack, template, overrides);
|
|
25
76
|
const leaderKey = this.requireRosterKey(template, roster, template.roomLeader, 'roomLeader');
|
|
26
77
|
const moderatorKey = this.requireRosterKey(template, roster, template.moderator, 'moderator');
|
|
@@ -29,6 +80,10 @@ class PackInstantiationService {
|
|
|
29
80
|
const agentIds = [];
|
|
30
81
|
const warnings = [];
|
|
31
82
|
try {
|
|
83
|
+
// The moderator first, whatever order the template lists it in.
|
|
84
|
+
// createRoomAgent refuses an agent that wants a moderator before the room
|
|
85
|
+
// names one, so a template that happened to list a player first would
|
|
86
|
+
// fail on a room that is otherwise perfectly well formed.
|
|
32
87
|
const ordered = [...roster].sort((a, b) => Number(b.key === moderatorKey) - Number(a.key === moderatorKey));
|
|
33
88
|
const nicknames = new Map();
|
|
34
89
|
for (const entry of ordered) {
|
|
@@ -44,6 +99,8 @@ class PackInstantiationService {
|
|
|
44
99
|
for (const id of created.unresolvedDocumentIds) {
|
|
45
100
|
warnings.push(`"${created.nickname}" could not attach the document ${id}`);
|
|
46
101
|
}
|
|
102
|
+
// Named as soon as it exists, so the next agent that wants a
|
|
103
|
+
// moderator finds one.
|
|
47
104
|
if (entry.key === moderatorKey) {
|
|
48
105
|
const room = await this.roomStore.getRoom(roomId);
|
|
49
106
|
room?.setModerator(created.nickname);
|
|
@@ -58,6 +115,8 @@ class PackInstantiationService {
|
|
|
58
115
|
name: roomName,
|
|
59
116
|
goal: template.goal,
|
|
60
117
|
turnMode: template.turnMode ?? 'broadcast',
|
|
118
|
+
// Resolved to the nicknames the created agents actually ended up
|
|
119
|
+
// with, never the template's keys.
|
|
61
120
|
roomLeader: leaderKey ? (nicknames.get(leaderKey) ?? '') : '',
|
|
62
121
|
moderator: moderatorKey ? (nicknames.get(moderatorKey) ?? '') : '',
|
|
63
122
|
pack: packName,
|
|
@@ -67,6 +126,9 @@ class PackInstantiationService {
|
|
|
67
126
|
return { roomId, agentIds, warnings };
|
|
68
127
|
}
|
|
69
128
|
catch (error) {
|
|
129
|
+
// A half-built room is worse than none: one that cannot route its
|
|
130
|
+
// members' messages eats them, and removeRoom deletes the agents it owns,
|
|
131
|
+
// which would otherwise be invisible to listAgents forever.
|
|
70
132
|
logger_1.logger.warn(`Rolling back room ${roomId} after a failed instantiation: ${error.message}`);
|
|
71
133
|
await this.app.deleteRoom(roomId).catch((cleanupError) => {
|
|
72
134
|
logger_1.logger.error(`Could not roll back room ${roomId}:`, cleanupError);
|
|
@@ -74,6 +136,21 @@ class PackInstantiationService {
|
|
|
74
136
|
throw error;
|
|
75
137
|
}
|
|
76
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Builds a single free-standing agent from a pack's agent template.
|
|
141
|
+
*
|
|
142
|
+
* Free-standing rather than room-owned: this is the "preconfigured witness with
|
|
143
|
+
* the right statements attached" case, which has to be usable before any
|
|
144
|
+
* courtroom exists.
|
|
145
|
+
*
|
|
146
|
+
* @param packName The pack holding the template
|
|
147
|
+
* @param agentKey The agent template's key
|
|
148
|
+
* @param models One model per role
|
|
149
|
+
* @param overrides Anything the caller wants to change, e.g. the agent's name
|
|
150
|
+
* @returns The agent's id and anything that did not go to plan
|
|
151
|
+
* @throws {NotFoundError} If the pack or the template does not exist
|
|
152
|
+
* @throws {ValidationError} If the pack is off
|
|
153
|
+
*/
|
|
77
154
|
async instantiateAgent(packName, agentKey, models, overrides) {
|
|
78
155
|
const pack = this.requireEnabledPack(packName);
|
|
79
156
|
const template = pack.agents.find((agent) => agent.key === agentKey);
|
|
@@ -90,6 +167,7 @@ class PackInstantiationService {
|
|
|
90
167
|
agent.save();
|
|
91
168
|
return { agentId: agent.id, warnings: [] };
|
|
92
169
|
}
|
|
170
|
+
/** The pack, or a refusal that says which of the two things is wrong. */
|
|
93
171
|
requireEnabledPack(packName) {
|
|
94
172
|
const pack = this.packs.getPack(packName);
|
|
95
173
|
if (!pack.enabled) {
|
|
@@ -97,11 +175,19 @@ class PackInstantiationService {
|
|
|
97
175
|
}
|
|
98
176
|
return pack;
|
|
99
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* A template's prompt folder, qualified with its own pack when it is bare.
|
|
180
|
+
*
|
|
181
|
+
* A template may name another pack's folder outright — that is how a
|
|
182
|
+
* case-specific pack reuses a generic one's `witness` folder — so an
|
|
183
|
+
* already-qualified reference is left alone.
|
|
184
|
+
*/
|
|
100
185
|
qualify(pack, promptFolder) {
|
|
101
186
|
return (0, prompt_resolver_1.isPackFolder)(promptFolder)
|
|
102
187
|
? promptFolder
|
|
103
188
|
: (0, prompt_resolver_1.formatPromptFolder)({ pack: pack.name, folder: promptFolder });
|
|
104
189
|
}
|
|
190
|
+
/** Resolves every roster entry to its template, refusing an unknown key. */
|
|
105
191
|
resolveRoster(pack, template, callerOverrides) {
|
|
106
192
|
const byKey = new Map(pack.agents.map((agent) => [agent.key, agent]));
|
|
107
193
|
const seen = new Set();
|
|
@@ -126,6 +212,9 @@ class PackInstantiationService {
|
|
|
126
212
|
},
|
|
127
213
|
};
|
|
128
214
|
});
|
|
215
|
+
// A key with no seat is a typo, and a typo that silently does nothing is
|
|
216
|
+
// the failure this whole argument exists to prevent — the caller would get
|
|
217
|
+
// a room whose player is still called PlayerOne and no reason why.
|
|
129
218
|
for (const key of Object.keys(callerOverrides ?? {})) {
|
|
130
219
|
if (!resolved.some((entry) => entry.key === key)) {
|
|
131
220
|
throw new errors_1.ValidationError(`Room template "${template.key}" has no agent "${key}" to override. ` +
|
|
@@ -134,6 +223,7 @@ class PackInstantiationService {
|
|
|
134
223
|
}
|
|
135
224
|
return resolved;
|
|
136
225
|
}
|
|
226
|
+
/** Checks a leader/moderator key names someone on the roster. */
|
|
137
227
|
requireRosterKey(template, roster, key, field) {
|
|
138
228
|
if (!key)
|
|
139
229
|
return undefined;
|
|
@@ -142,6 +232,7 @@ class PackInstantiationService {
|
|
|
142
232
|
}
|
|
143
233
|
return key;
|
|
144
234
|
}
|
|
235
|
+
/** The model for a template's declared role, falling back to the primary. */
|
|
145
236
|
modelFor(template, models) {
|
|
146
237
|
const choice = template.modelRole === 'economy' ? (models.economy ?? models.primary) : models.primary;
|
|
147
238
|
return {
|
|
@@ -150,6 +241,14 @@ class PackInstantiationService {
|
|
|
150
241
|
smallModelName: choice.smallModelName,
|
|
151
242
|
};
|
|
152
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* The template's name, suffixed if the user already has a room by it.
|
|
246
|
+
*
|
|
247
|
+
* Nothing enforces unique room names and rooms key on a UUID, so a second
|
|
248
|
+
* instantiation already worked — it just produced two indistinguishable entries
|
|
249
|
+
* in the sidebar. The suffix also reaches the agents, whose stored names carry
|
|
250
|
+
* the room's as a prefix.
|
|
251
|
+
*/
|
|
153
252
|
async uniqueRoomName(preferred) {
|
|
154
253
|
const taken = new Set((await this.roomStore.getTemplateRooms()).map((room) => room.name.trim().toLowerCase()));
|
|
155
254
|
if (!taken.has(preferred.toLowerCase()))
|
|
@@ -1,52 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a pack directory is, and how to read one.
|
|
3
|
+
*
|
|
4
|
+
* A pack gathers everything one domain needs — prompt folders, documents, agent
|
|
5
|
+
* and room templates, and the names of the native tools it expects — into a
|
|
6
|
+
* directory a host can drop in or a user can create.
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* packs/dnd5e/
|
|
10
|
+
* pack.json metadata; optional
|
|
11
|
+
* prompts/<folder>/ prompt folders, referenced as dnd5e:<folder>
|
|
12
|
+
* artifacts/ manifest.json + .md, read by pack-artifacts.ts
|
|
13
|
+
* agents/*.json agent templates
|
|
14
|
+
* rooms/*.json room templates
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Almost nothing is declared. The prompt folders, documents, templates and
|
|
18
|
+
* required tools are all discovered by reading the directory, because a declared
|
|
19
|
+
* copy of a directory listing drifts from it — which is the mistake
|
|
20
|
+
* `prompt-folders.spec.ts` exists to catch in the D&D prompts.
|
|
21
|
+
*
|
|
22
|
+
* `pack.json` is optional. A directory holding only `artifacts/manifest.json` is
|
|
23
|
+
* still a pack, titled after itself.
|
|
24
|
+
*/
|
|
1
25
|
import { PromptFolderDefaults } from '../../../shared/types/app.types';
|
|
26
|
+
/** Subdirectories of a pack, by what they hold. */
|
|
2
27
|
export declare const PACK_SUBDIR: {
|
|
3
28
|
readonly prompts: "prompts";
|
|
4
29
|
readonly artifacts: "artifacts";
|
|
5
30
|
readonly agents: "agents";
|
|
6
31
|
readonly rooms: "rooms";
|
|
7
32
|
};
|
|
33
|
+
/** The optional `pack.json`. */
|
|
8
34
|
export interface PackManifest {
|
|
35
|
+
/** Must equal the directory name. */
|
|
9
36
|
pack: string;
|
|
37
|
+
/** Display name; falls back to the pack name. */
|
|
10
38
|
title?: string;
|
|
11
39
|
description?: string;
|
|
12
40
|
version?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tool names the pack needs that nothing else in it declares.
|
|
43
|
+
*
|
|
44
|
+
* Rarely needed: the requirement is normally derived from the `toolNames` its
|
|
45
|
+
* prompt folders and agent templates already grant. This is for a tool a pack
|
|
46
|
+
* expects to call but has not wired into a grant yet.
|
|
47
|
+
*/
|
|
13
48
|
requiresTools?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Other packs this one expects. A warning on the Packs page and nothing more —
|
|
51
|
+
* never an auto-enable, never a block.
|
|
52
|
+
*/
|
|
14
53
|
requiresPacks?: string[];
|
|
15
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* One agent a pack ships, as a reference to a prompt folder plus overrides.
|
|
57
|
+
*
|
|
58
|
+
* Not a trimmed `AgentConfig`. `createAgentFromFolder` already exists so callers
|
|
59
|
+
* stop transcribing a folder's recipe, and `defaults_config.json` is the list
|
|
60
|
+
* `prompt-folders.spec.ts` treats as authoritative — a template with its own copy
|
|
61
|
+
* of `toolNames` would be a second list that drifts from it.
|
|
62
|
+
*/
|
|
16
63
|
export interface PackAgentTemplate {
|
|
64
|
+
/** Stable within the pack. Room templates reference agents by this. */
|
|
17
65
|
key: string;
|
|
66
|
+
/** A folder in this pack, or a `<pack>:<folder>` reference to another. */
|
|
18
67
|
promptFolder: string;
|
|
68
|
+
/** Shown in the pack listing and the pickers. Falls back to the key. */
|
|
19
69
|
label?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Which model tier this agent wants.
|
|
72
|
+
*
|
|
73
|
+
* A pack cannot name a model: the id goes stale and assumes the host's keys.
|
|
74
|
+
* But the split matters — the dnd5e pack exists partly so combat runs on a
|
|
75
|
+
* cheap agent — so the template says which tier it wants and instantiation
|
|
76
|
+
* supplies the models.
|
|
77
|
+
*/
|
|
20
78
|
modelRole?: 'primary' | 'economy';
|
|
79
|
+
/** Anything the folder's own defaults should not decide, e.g. a witness's name. */
|
|
21
80
|
overrides?: Partial<PromptFolderDefaults>;
|
|
22
81
|
}
|
|
82
|
+
/** One entry in a room template's roster. */
|
|
23
83
|
export interface PackRoomAgentEntry {
|
|
84
|
+
/** An agent template key in this pack. */
|
|
24
85
|
key: string;
|
|
86
|
+
/**
|
|
87
|
+
* A distinct key for this instance, when one template is used more than once.
|
|
88
|
+
* Lets `roomLeader` and `moderator` stay unambiguous with four players at a table.
|
|
89
|
+
*/
|
|
25
90
|
as?: string;
|
|
26
91
|
overrides?: Partial<PromptFolderDefaults>;
|
|
27
92
|
}
|
|
93
|
+
/** A room a pack ships, ready to instantiate with its whole cast. */
|
|
28
94
|
export interface PackRoomTemplate {
|
|
29
95
|
key: string;
|
|
30
96
|
name: string;
|
|
31
97
|
goal: string;
|
|
32
98
|
turnMode?: 'broadcast' | 'directed';
|
|
99
|
+
/**
|
|
100
|
+
* The roster, as loaded.
|
|
101
|
+
*
|
|
102
|
+
* In the JSON a bare string is accepted as sugar for `{ key }`;
|
|
103
|
+
* {@link readPack} normalizes it, so by the time anything else sees a template
|
|
104
|
+
* every entry is an object.
|
|
105
|
+
*/
|
|
33
106
|
agents: PackRoomAgentEntry[];
|
|
107
|
+
/**
|
|
108
|
+
* The leader, named by **agent key** rather than by nickname.
|
|
109
|
+
*
|
|
110
|
+
* A template cannot carry a nickname: the nickname is derived at creation from
|
|
111
|
+
* the bare name's first word, the user may rename, and two agents in a room may
|
|
112
|
+
* not share one. Instantiation resolves the key to whatever nickname the
|
|
113
|
+
* created agent ended up with.
|
|
114
|
+
*/
|
|
34
115
|
roomLeader?: string;
|
|
116
|
+
/** The moderator, also named by agent key. */
|
|
35
117
|
moderator?: string;
|
|
36
118
|
}
|
|
119
|
+
/** A pack directory, read. */
|
|
37
120
|
export interface LoadedPack {
|
|
38
121
|
name: string;
|
|
39
122
|
title: string;
|
|
40
123
|
description?: string;
|
|
41
124
|
version?: string;
|
|
125
|
+
/** Where it lives. */
|
|
42
126
|
dir: string;
|
|
127
|
+
/** Installed by the host, or created by this user. */
|
|
43
128
|
origin: PackOrigin;
|
|
44
129
|
promptFolders: string[];
|
|
45
130
|
agents: PackAgentTemplate[];
|
|
46
131
|
rooms: PackRoomTemplate[];
|
|
132
|
+
/** Tool names the pack's grants and manifest between them ask for. */
|
|
47
133
|
requiresTools: string[];
|
|
48
134
|
requiresPacks: string[];
|
|
49
135
|
}
|
|
50
136
|
export type PackOrigin = 'host' | 'user';
|
|
137
|
+
/**
|
|
138
|
+
* Reads a pack directory.
|
|
139
|
+
*
|
|
140
|
+
* Nothing here throws on bad content. A malformed template is dropped with a
|
|
141
|
+
* warning and the rest of the pack loads, for the same reason
|
|
142
|
+
* `pack-artifacts.ts` skips a bad manifest entry: one broken file a host dropped
|
|
143
|
+
* in must not take out the page that lists everything else.
|
|
144
|
+
*
|
|
145
|
+
* @param dir The pack directory
|
|
146
|
+
* @param name The directory name, which the manifest must agree with
|
|
147
|
+
* @param origin Where the directory came from
|
|
148
|
+
* @returns The pack, or null if the name is invalid or the directory is missing
|
|
149
|
+
*/
|
|
51
150
|
export declare function readPack(dir: string, name: string, origin: PackOrigin): LoadedPack | null;
|
|
151
|
+
/** The key an entry is addressed by, which is `as` when it has one. */
|
|
52
152
|
export declare function roomAgentKey(entry: PackRoomAgentEntry): string;
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What a pack directory is, and how to read one.
|
|
4
|
+
*
|
|
5
|
+
* A pack gathers everything one domain needs — prompt folders, documents, agent
|
|
6
|
+
* and room templates, and the names of the native tools it expects — into a
|
|
7
|
+
* directory a host can drop in or a user can create.
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* packs/dnd5e/
|
|
11
|
+
* pack.json metadata; optional
|
|
12
|
+
* prompts/<folder>/ prompt folders, referenced as dnd5e:<folder>
|
|
13
|
+
* artifacts/ manifest.json + .md, read by pack-artifacts.ts
|
|
14
|
+
* agents/*.json agent templates
|
|
15
|
+
* rooms/*.json room templates
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Almost nothing is declared. The prompt folders, documents, templates and
|
|
19
|
+
* required tools are all discovered by reading the directory, because a declared
|
|
20
|
+
* copy of a directory listing drifts from it — which is the mistake
|
|
21
|
+
* `prompt-folders.spec.ts` exists to catch in the D&D prompts.
|
|
22
|
+
*
|
|
23
|
+
* `pack.json` is optional. A directory holding only `artifacts/manifest.json` is
|
|
24
|
+
* still a pack, titled after itself.
|
|
25
|
+
*/
|
|
2
26
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
27
|
if (k2 === undefined) k2 = k;
|
|
4
28
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -40,12 +64,26 @@ const fs = __importStar(require("fs"));
|
|
|
40
64
|
const path = __importStar(require("path"));
|
|
41
65
|
const prompt_resolver_1 = require("../config/prompt-resolver");
|
|
42
66
|
const logger_1 = require("../common/logger");
|
|
67
|
+
/** Subdirectories of a pack, by what they hold. */
|
|
43
68
|
exports.PACK_SUBDIR = {
|
|
44
69
|
prompts: 'prompts',
|
|
45
70
|
artifacts: 'artifacts',
|
|
46
71
|
agents: 'agents',
|
|
47
72
|
rooms: 'rooms',
|
|
48
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Reads a pack directory.
|
|
76
|
+
*
|
|
77
|
+
* Nothing here throws on bad content. A malformed template is dropped with a
|
|
78
|
+
* warning and the rest of the pack loads, for the same reason
|
|
79
|
+
* `pack-artifacts.ts` skips a bad manifest entry: one broken file a host dropped
|
|
80
|
+
* in must not take out the page that lists everything else.
|
|
81
|
+
*
|
|
82
|
+
* @param dir The pack directory
|
|
83
|
+
* @param name The directory name, which the manifest must agree with
|
|
84
|
+
* @param origin Where the directory came from
|
|
85
|
+
* @returns The pack, or null if the name is invalid or the directory is missing
|
|
86
|
+
*/
|
|
49
87
|
function readPack(dir, name, origin) {
|
|
50
88
|
if (!(0, prompt_resolver_1.isValidPackName)(name)) {
|
|
51
89
|
logger_1.logger.warn(`Ignoring pack directory "${name}": a pack name must be lowercase letters, digits, "_" or "-"`);
|
|
@@ -72,6 +110,14 @@ function readPack(dir, name, origin) {
|
|
|
72
110
|
requiresPacks: (manifest?.requiresPacks ?? []).filter(prompt_resolver_1.isValidPackName),
|
|
73
111
|
};
|
|
74
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Every tool name the pack asks for, derived rather than declared.
|
|
115
|
+
*
|
|
116
|
+
* The union of what its prompt folders grant, what its agent templates add, and
|
|
117
|
+
* whatever `requiresTools` names. Derived because a hand-kept list disagrees with
|
|
118
|
+
* the grants sooner or later, and then the "missing tools" warning is wrong in
|
|
119
|
+
* whichever direction is least helpful.
|
|
120
|
+
*/
|
|
75
121
|
function deriveRequiredTools(dir, promptFolders, agents, manifest) {
|
|
76
122
|
const names = new Set(manifest?.requiresTools ?? []);
|
|
77
123
|
for (const folder of promptFolders) {
|
|
@@ -95,6 +141,7 @@ function readManifest(dir, name) {
|
|
|
95
141
|
}
|
|
96
142
|
return manifest;
|
|
97
143
|
}
|
|
144
|
+
/** Reads every `.json` in a subdirectory, dropping the ones that do not validate. */
|
|
98
145
|
function readTemplates(dir, subdir, validate) {
|
|
99
146
|
const templateDir = path.join(dir, subdir);
|
|
100
147
|
if (!fs.existsSync(templateDir))
|
|
@@ -118,6 +165,7 @@ function readTemplates(dir, subdir, validate) {
|
|
|
118
165
|
}
|
|
119
166
|
return templates;
|
|
120
167
|
}
|
|
168
|
+
/** A key has to be usable in a filename and a JSON reference, so borrow the pack rule. */
|
|
121
169
|
function isValidKey(key) {
|
|
122
170
|
return typeof key === 'string' && /^[a-z0-9][a-z0-9_-]*$/.test(key);
|
|
123
171
|
}
|
|
@@ -146,6 +194,15 @@ function validateAgentTemplate(value, file) {
|
|
|
146
194
|
: {}),
|
|
147
195
|
};
|
|
148
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Fields a template may never set.
|
|
199
|
+
*
|
|
200
|
+
* The billing three are the reason this is a list and not a comment: a pack that
|
|
201
|
+
* could set `disableBalanceCheck` is a pack that spends the host's money. The
|
|
202
|
+
* rest either resurrect state that belongs to some other agent (`history`,
|
|
203
|
+
* `attachedFiles`, the totals) or change which list the agent appears in
|
|
204
|
+
* (`isPublished`, `ownerRoomId`, the template ids).
|
|
205
|
+
*/
|
|
149
206
|
const FORBIDDEN_OVERRIDE_KEYS = new Set([
|
|
150
207
|
'id',
|
|
151
208
|
'createdAt',
|
|
@@ -231,6 +288,7 @@ function normalizeRoomAgentEntry(entry, file) {
|
|
|
231
288
|
: {}),
|
|
232
289
|
};
|
|
233
290
|
}
|
|
291
|
+
/** The key an entry is addressed by, which is `as` when it has one. */
|
|
234
292
|
function roomAgentKey(entry) {
|
|
235
293
|
return entry.as ?? entry.key;
|
|
236
294
|
}
|