briyah 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -8
- package/data/common/config/LICENSE-model-prices.md +65 -0
- package/data/common/config/markup +1 -1
- package/data/common/config/model_prices.json +47443 -46295
- package/data/common/config/story_models.json +3 -3
- package/data/common/prompts/illustrator/describe_scene.prompt +4 -4
- package/data/common/prompts/narrator/create_story.prompt +2 -0
- package/data/common/prompts/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +795 -787
- package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +2 -1
- package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +1 -1
- package/data/packs/dnd5e/rooms/campaign.json +18 -15
- package/data/packs/dnd5e/rooms/table.json +17 -16
- package/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +103 -0
- package/dist-sdk/server/src/ai/LLM/anthropic.service.js +174 -3
- package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +194 -3
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +299 -19
- package/dist-sdk/server/src/ai/LLM/blank-image.d.ts +36 -0
- package/dist-sdk/server/src/ai/LLM/blank-image.js +80 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-client.d.ts +26 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-client.js +25 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-workflow.d.ts +54 -0
- package/dist-sdk/server/src/ai/LLM/comfyui-workflow.js +59 -1
- package/dist-sdk/server/src/ai/LLM/comfyui.service.d.ts +21 -1
- package/dist-sdk/server/src/ai/LLM/comfyui.service.js +25 -1
- package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +52 -0
- package/dist-sdk/server/src/ai/LLM/deepseek.service.js +103 -4
- package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +25 -0
- package/dist-sdk/server/src/ai/LLM/fal.service.js +56 -2
- package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +19 -0
- package/dist-sdk/server/src/ai/LLM/googleai.service.js +43 -2
- package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +22 -0
- package/dist-sdk/server/src/ai/LLM/grok.service.js +55 -3
- package/dist-sdk/server/src/ai/LLM/mock.service.js +31 -4
- package/dist-sdk/server/src/ai/LLM/openai.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/LLM/openai.service.js +81 -3
- package/dist-sdk/server/src/ai/LLM/self-hosted.service.d.ts +21 -0
- package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +45 -3
- package/dist-sdk/server/src/ai/LLM/together.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/LLM/together.service.js +61 -3
- package/dist-sdk/server/src/ai/agent-config.d.ts +15 -1
- package/dist-sdk/server/src/ai/agent-factory.d.ts +16 -0
- package/dist-sdk/server/src/ai/agent-factory.js +20 -0
- package/dist-sdk/server/src/ai/agent-message.service.d.ts +30 -0
- package/dist-sdk/server/src/ai/agent-message.service.js +30 -0
- package/dist-sdk/server/src/ai/agent-store.service.d.ts +80 -0
- package/dist-sdk/server/src/ai/agent-store.service.js +166 -7
- package/dist-sdk/server/src/ai/agent.d.ts +197 -2
- package/dist-sdk/server/src/ai/agent.js +225 -14
- package/dist-sdk/server/src/ai/ai-debug-logger.d.ts +18 -0
- package/dist-sdk/server/src/ai/ai-debug-logger.js +19 -0
- package/dist-sdk/server/src/ai/ai-factory.service.d.ts +9 -0
- package/dist-sdk/server/src/ai/ai-factory.service.js +9 -0
- package/dist-sdk/server/src/ai/artifact.service.d.ts +131 -0
- package/dist-sdk/server/src/ai/artifact.service.js +148 -3
- package/dist-sdk/server/src/ai/attached-file.service.d.ts +87 -0
- package/dist-sdk/server/src/ai/attached-file.service.js +105 -0
- package/dist-sdk/server/src/ai/model_prices.d.ts +30 -0
- package/dist-sdk/server/src/ai/model_prices.js +91 -5
- package/dist-sdk/server/src/ai/pack-artifacts.d.ts +84 -0
- package/dist-sdk/server/src/ai/pack-artifacts.js +168 -0
- package/dist-sdk/server/src/ai/published-agents.service.d.ts +25 -0
- package/dist-sdk/server/src/ai/published-agents.service.js +30 -3
- package/dist-sdk/server/src/app/balance-message.service.d.ts +24 -0
- package/dist-sdk/server/src/app/balance-message.service.js +24 -0
- package/dist-sdk/server/src/app/balance.module.d.ts +4 -0
- package/dist-sdk/server/src/app/balance.module.js +4 -0
- package/dist-sdk/server/src/app/balance.service.d.ts +37 -0
- package/dist-sdk/server/src/app/balance.service.js +54 -0
- package/dist-sdk/server/src/app/stripe.controller.d.ts +21 -0
- package/dist-sdk/server/src/app/stripe.controller.js +35 -0
- package/dist-sdk/server/src/app/stripe.service.d.ts +43 -0
- package/dist-sdk/server/src/app/stripe.service.js +62 -0
- package/dist-sdk/server/src/app/transaction.service.d.ts +27 -0
- package/dist-sdk/server/src/app/transaction.service.js +36 -0
- package/dist-sdk/server/src/app/user-service-factory.d.ts +8 -0
- package/dist-sdk/server/src/app/user-service-factory.js +46 -3
- package/dist-sdk/server/src/app/user-service-manager.d.ts +27 -0
- package/dist-sdk/server/src/app/user-service-manager.js +43 -0
- package/dist-sdk/server/src/app.controller.d.ts +120 -0
- package/dist-sdk/server/src/app.controller.js +365 -14
- package/dist-sdk/server/src/app.module.js +28 -6
- package/dist-sdk/server/src/app.service.d.ts +1710 -4
- package/dist-sdk/server/src/app.service.js +1938 -20
- package/dist-sdk/server/src/auth/agent-access.decorator.d.ts +17 -0
- package/dist-sdk/server/src/auth/agent-access.decorator.js +17 -0
- package/dist-sdk/server/src/auth/auth.controller.js +46 -0
- package/dist-sdk/server/src/auth/auth.module.js +3 -2
- package/dist-sdk/server/src/auth/auth.service.d.ts +33 -0
- package/dist-sdk/server/src/auth/auth.service.js +39 -3
- package/dist-sdk/server/src/auth/jwt-auth.guard.js +44 -0
- package/dist-sdk/server/src/auth/jwt.strategy.js +2 -2
- package/dist-sdk/server/src/auth/owner-only.decorator.d.ts +9 -0
- package/dist-sdk/server/src/auth/owner-only.decorator.js +9 -0
- package/dist-sdk/server/src/auth/phone-validation.service.d.ts +25 -0
- package/dist-sdk/server/src/auth/phone-validation.service.js +30 -0
- package/dist-sdk/server/src/auth/rate-limit.service.d.ts +19 -0
- package/dist-sdk/server/src/auth/rate-limit.service.js +24 -0
- package/dist-sdk/server/src/auth/room-access.decorator.d.ts +8 -0
- package/dist-sdk/server/src/auth/room-access.decorator.js +8 -0
- package/dist-sdk/server/src/auth/scopes.decorator.d.ts +7 -0
- package/dist-sdk/server/src/auth/scopes.decorator.js +7 -0
- package/dist-sdk/server/src/auth/scopes.guard.d.ts +16 -0
- package/dist-sdk/server/src/auth/scopes.guard.js +30 -0
- package/dist-sdk/server/src/auth/session.guard.d.ts +4 -0
- package/dist-sdk/server/src/auth/session.guard.js +8 -0
- package/dist-sdk/server/src/auth/twilio.service.d.ts +27 -0
- package/dist-sdk/server/src/auth/twilio.service.js +30 -4
- package/dist-sdk/server/src/auth/users.service.d.ts +30 -0
- package/dist-sdk/server/src/auth/users.service.js +42 -0
- package/dist-sdk/server/src/common/errors.d.ts +20 -0
- package/dist-sdk/server/src/common/errors.js +21 -0
- package/dist-sdk/server/src/config/env-config.d.ts +7 -0
- package/dist-sdk/server/src/config/prompt-resolver.d.ts +180 -0
- package/dist-sdk/server/src/config/prompt-resolver.js +182 -0
- package/dist-sdk/server/src/config/user-config.service.d.ts +59 -0
- package/dist-sdk/server/src/config/user-config.service.js +57 -0
- package/dist-sdk/server/src/config/user-paths.service.d.ts +61 -0
- package/dist-sdk/server/src/config/user-paths.service.js +67 -0
- package/dist-sdk/server/src/documents/pdf-conversion.d.ts +121 -1
- package/dist-sdk/server/src/documents/pdf-conversion.js +94 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +98 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.js +104 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +114 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +69 -0
- package/dist-sdk/server/src/packs/pack.service.d.ts +99 -1
- package/dist-sdk/server/src/packs/pack.service.js +98 -1
- package/dist-sdk/server/src/room/artifact-store.service.d.ts +27 -0
- package/dist-sdk/server/src/room/artifact-store.service.js +49 -3
- package/dist-sdk/server/src/room/artifact.d.ts +18 -0
- package/dist-sdk/server/src/room/illustration/illustration.service.d.ts +211 -0
- package/dist-sdk/server/src/room/illustration/illustration.service.js +771 -0
- package/dist-sdk/server/src/room/illustration/illustration.types.d.ts +101 -0
- package/dist-sdk/server/src/room/illustration/illustration.types.js +2 -0
- package/dist-sdk/server/src/room/message.d.ts +64 -0
- package/dist-sdk/server/src/room/message.js +77 -2
- package/dist-sdk/server/src/room/nickname.d.ts +26 -0
- package/dist-sdk/server/src/room/nickname.js +26 -0
- package/dist-sdk/server/src/room/published-rooms.service.js +2 -0
- package/dist-sdk/server/src/room/room-config.d.ts +84 -1
- package/dist-sdk/server/src/room/room-config.js +19 -0
- package/dist-sdk/server/src/room/room-factory.d.ts +20 -0
- package/dist-sdk/server/src/room/room-factory.js +25 -0
- package/dist-sdk/server/src/room/room-message.service.d.ts +28 -0
- package/dist-sdk/server/src/room/room-message.service.js +28 -0
- package/dist-sdk/server/src/room/room-store.service.d.ts +184 -0
- package/dist-sdk/server/src/room/room-store.service.js +280 -6
- package/dist-sdk/server/src/room/room.d.ts +981 -1
- package/dist-sdk/server/src/room/room.js +1531 -27
- package/dist-sdk/server/src/rpg/rpg-models.d.ts +50 -0
- package/dist-sdk/server/src/rpg/rpg-models.js +53 -0
- package/dist-sdk/server/src/rpg/rpg-roster.d.ts +37 -0
- package/dist-sdk/server/src/rpg/rpg-roster.js +37 -0
- package/dist-sdk/server/src/rpg/rpg.service.d.ts +87 -0
- package/dist-sdk/server/src/rpg/rpg.service.js +108 -1
- package/dist-sdk/server/src/sdk/briyah-config.d.ts +57 -0
- package/dist-sdk/server/src/sdk/briyah-config.js +17 -0
- package/dist-sdk/server/src/sdk/briyah.d.ts +228 -0
- package/dist-sdk/server/src/sdk/briyah.js +285 -7
- package/dist-sdk/server/src/sdk/index.js +23 -0
- package/dist-sdk/server/src/shared/shared.module.d.ts +8 -0
- package/dist-sdk/server/src/shared/shared.module.js +13 -5
- package/dist-sdk/server/src/story/story-message.service.d.ts +43 -0
- package/dist-sdk/server/src/story/story-message.service.js +43 -0
- package/dist-sdk/server/src/story/story-progress.service.d.ts +23 -0
- package/dist-sdk/server/src/story/story-progress.service.js +23 -0
- package/dist-sdk/server/src/story/story-store.service.d.ts +92 -0
- package/dist-sdk/server/src/story/story-store.service.js +136 -1
- package/dist-sdk/server/src/story/story.service.d.ts +366 -9
- package/dist-sdk/server/src/story/story.service.js +825 -374
- package/dist-sdk/server/src/tools/core/illustrate.tool.d.ts +14 -0
- package/dist-sdk/server/src/tools/core/illustrate.tool.js +80 -0
- package/dist-sdk/server/src/tools/core/index.d.ts +22 -0
- package/dist-sdk/server/src/tools/core/index.js +24 -1
- package/dist-sdk/server/src/tools/core/rename.tool.d.ts +8 -0
- package/dist-sdk/server/src/tools/core/rename.tool.js +11 -0
- package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +22 -0
- package/dist-sdk/server/src/tools/native-tool-registry.service.js +22 -0
- package/dist-sdk/server/src/tools/native-tool.types.d.ts +266 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.d.ts +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/backgrounds.js +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.d.ts +46 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/cantrips.js +40 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.d.ts +33 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/feats.js +19 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.d.ts +37 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.d.ts +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.generated.js +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/gear.js +27 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +36 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +32 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.d.ts +32 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.generated.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/magic-items.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.d.ts +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.generated.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/monsters.js +20 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +36 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.d.ts +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.generated.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/spells.js +21 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +95 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +66 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.d.ts +50 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/weapons.js +28 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.d.ts +92 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/bestiary.js +152 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.d.ts +28 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/campaign-items.js +29 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.d.ts +31 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/cantrips.js +36 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +261 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +401 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.d.ts +11 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/coerce.js +11 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.d.ts +65 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/dice.js +67 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +73 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +63 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.d.ts +66 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encumbrance.js +59 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.d.ts +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/feats.js +49 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +42 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +59 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.d.ts +72 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/guides.js +63 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.d.ts +57 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/items.js +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +81 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +85 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +60 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +64 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +169 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +203 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +201 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +149 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.d.ts +56 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/spells.js +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.d.ts +65 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/weapons.js +73 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/index.d.ts +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/index.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.d.ts +4 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +116 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.d.ts +14 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/class.tool.js +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +35 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +6 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +25 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.d.ts +7 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/item.tool.js +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.d.ts +8 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +55 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +194 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +263 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +127 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.d.ts +13 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/spell.tool.js +18 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/state.tools.js +23 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.d.ts +1 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +35 -0
- package/dist-sdk/server/src/tools/packs/index.d.ts +49 -0
- package/dist-sdk/server/src/tools/packs/index.js +66 -0
- package/dist-sdk/server/src/tools/shared/coerce.d.ts +95 -0
- package/dist-sdk/server/src/tools/shared/coerce.js +98 -0
- package/dist-sdk/server/src/tools/tool-execution.service.d.ts +107 -3
- package/dist-sdk/server/src/tools/tool-execution.service.js +163 -19
- package/dist-sdk/server/src/tools/tool-store.service.d.ts +11 -0
- package/dist-sdk/server/src/tools/tool-store.service.js +13 -1
- package/dist-sdk/shared/types/app.types.d.ts +328 -13
- package/dist-sdk/shared/types/app.types.js +18 -1
- package/package.json +167 -168
- package/data/common/config/random_words.txt +0 -2241
- package/data/common/story_ideas/biblical.json +0 -122
- package/data/common/story_ideas/fantasy.json +0 -82
- package/data/common/story_ideas/historical_fiction.json +0 -82
- package/data/common/story_ideas/science_fiction.json +0 -82
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -113
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1648
- package/docs/classes/Agent.html +0 -801
- package/docs/classes/Briyah.html +0 -296
- package/docs/classes/BriyahConfigService.html +0 -119
- package/docs/classes/NativeToolRegistry.html +0 -166
- package/docs/classes/PackInstantiationService.html +0 -157
- package/docs/classes/PackService.html +0 -247
- package/docs/classes/Room.html +0 -1434
- package/docs/classes/RoomMessage.html +0 -290
- package/docs/enums/MessageAction.html +0 -136
- package/docs/functions/availableToolPacks.html +0 -41
- package/docs/functions/buildMarkdown.html +0 -54
- package/docs/functions/dnd5eTools.html +0 -44
- package/docs/functions/installToolPacks.html +0 -51
- package/docs/functions/pageMarker.html +0 -45
- package/docs/functions/registerToolPacks.html +0 -54
- package/docs/functions/splitMarkdownIntoPages.html +0 -51
- package/docs/functions/stripWrappingFence.html +0 -52
- package/docs/hierarchy.html +0 -46
- package/docs/index.html +0 -595
- package/docs/interfaces/AgentCreationOptions.html +0 -125
- package/docs/interfaces/AgentInfo.html +0 -218
- package/docs/interfaces/AgentMessagesResponse.html +0 -74
- package/docs/interfaces/AppService.html +0 -3340
- package/docs/interfaces/Artifact.html +0 -95
- package/docs/interfaces/ArtifactMetadata.html +0 -112
- package/docs/interfaces/ArtifactWriteOptions.html +0 -90
- package/docs/interfaces/AttachDocumentResponse.html +0 -62
- package/docs/interfaces/BriyahConfigOptions.html +0 -124
- package/docs/interfaces/ChapterInfo.html +0 -62
- package/docs/interfaces/Character.html +0 -86
- package/docs/interfaces/ConversionAgent.html +0 -78
- package/docs/interfaces/CreateAgentResponse.html +0 -56
- package/docs/interfaces/CreateRoomResponse.html +0 -62
- package/docs/interfaces/CreateStoryResponse.html +0 -56
- package/docs/interfaces/FileList.html +0 -56
- package/docs/interfaces/FileMetadata.html +0 -89
- package/docs/interfaces/IConfigService.html +0 -79
- package/docs/interfaces/InstantiateModels.html +0 -64
- package/docs/interfaces/InstantiateRoomResult.html +0 -70
- package/docs/interfaces/LoadedPack.html +0 -131
- package/docs/interfaces/LoggingOptions.html +0 -92
- package/docs/interfaces/Message.html +0 -84
- package/docs/interfaces/ModelChoice.html +0 -73
- package/docs/interfaces/ModelInfo.html +0 -74
- package/docs/interfaces/NativeToolDefinition.html +0 -107
- package/docs/interfaces/PackAgentTemplate.html +0 -101
- package/docs/interfaces/PackRoomTemplate.html +0 -108
- package/docs/interfaces/PackView.html +0 -172
- package/docs/interfaces/PdfConversionOptions.html +0 -102
- package/docs/interfaces/PdfConversionResult.html +0 -97
- package/docs/interfaces/PdfMarkdownOptions.html +0 -198
- package/docs/interfaces/PdfMarkdownResult.html +0 -106
- package/docs/interfaces/PdfPageMarkdown.html +0 -94
- package/docs/interfaces/PreparedPromptResponse.html +0 -62
- package/docs/interfaces/ProcessTextResponse.html +0 -86
- package/docs/interfaces/PromptFile.html +0 -70
- package/docs/interfaces/PromptFileContent.html +0 -76
- package/docs/interfaces/PromptFilesResponse.html +0 -56
- package/docs/interfaces/PromptFolder.html +0 -80
- package/docs/interfaces/PromptFolderDefaults.html +0 -155
- package/docs/interfaces/PromptFolderDefaultsResponse.html +0 -79
- package/docs/interfaces/PromptFoldersResponse.html +0 -56
- package/docs/interfaces/RoomDetails.html +0 -151
- package/docs/interfaces/RoomErrorUpdate.html +0 -82
- package/docs/interfaces/RoomInfo.html +0 -88
- package/docs/interfaces/RoomMessageUpdate.html +0 -113
- package/docs/interfaces/RoomMessagesResponse.html +0 -62
- package/docs/interfaces/SendMessageResult.html +0 -62
- package/docs/interfaces/StoryErrorEvent.html +0 -84
- package/docs/interfaces/StoryIdea.html +0 -74
- package/docs/interfaces/StoryInfo.html +0 -198
- package/docs/interfaces/StoryIntroduceCharacterEvent.html +0 -79
- package/docs/interfaces/StoryProgressChapterEvent.html +0 -72
- package/docs/interfaces/StoryState.html +0 -108
- package/docs/interfaces/StoryStateEvent.html +0 -76
- package/docs/interfaces/ToolArtifact.html +0 -85
- package/docs/interfaces/ToolCaller.html +0 -77
- package/docs/interfaces/ToolDefinition.html +0 -80
- package/docs/interfaces/ToolHelpers.html +0 -105
- package/docs/interfaces/ToolPackDocuments.html +0 -100
- package/docs/interfaces/ToolParameter.html +0 -74
- package/docs/interfaces/ToolRoomAccess.html +0 -260
- package/docs/interfaces/ToolSummary.html +0 -74
- package/docs/interfaces/ToolsResponse.html +0 -68
- package/docs/interfaces/Transaction.html +0 -104
- package/docs/interfaces/TransactionHistoryResponse.html +0 -62
- package/docs/modules.html +0 -53
- package/docs/types/PackOrigin.html +0 -34
- package/docs/types/PromptScope.html +0 -34
- package/docs/types/RoomTurnMode.html +0 -42
- package/docs/types/RoomUpdate.html +0 -36
- package/docs/types/RosterOverrides.html +0 -42
- package/docs/types/ToolContext.html +0 -40
- package/docs/types/ToolRunResult.html +0 -34
- package/src/tools/packs/dnd5e/README.md +0 -867
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes per-call debug files for AI requests, thinking output, and responses.
|
|
3
|
+
*
|
|
4
|
+
* Enabled when process.env.AI_DEBUG === 'true' (or when aiDebug is set in
|
|
5
|
+
* LoggingOptions, which maps to the same env var via BriyahConfigService).
|
|
6
|
+
*
|
|
7
|
+
* Files are written to:
|
|
8
|
+
* {BRIYAH_DATA_PATH}/logs/ai-debug/YYYY-MM-DD_HH-mm-ss-SSS_<agentName>_REQUEST.txt
|
|
9
|
+
* {BRIYAH_DATA_PATH}/logs/ai-debug/YYYY-MM-DD_HH-mm-ss-SSS_<agentName>_THINKING.txt
|
|
10
|
+
* {BRIYAH_DATA_PATH}/logs/ai-debug/YYYY-MM-DD_HH-mm-ss-SSS_<agentName>_RESPONSE.txt
|
|
11
|
+
*
|
|
12
|
+
* The millisecond-resolution timestamp prefix keeps files sortable chronologically and
|
|
13
|
+
* distinguishes concurrent calls from different agents.
|
|
14
|
+
*
|
|
15
|
+
* Logging errors are swallowed so they never interrupt the main request flow.
|
|
16
|
+
*/
|
|
1
17
|
export declare class AiDebugLogger {
|
|
2
18
|
static isEnabled(): boolean;
|
|
3
19
|
private static getLogDir;
|
|
4
20
|
private static timestamp;
|
|
21
|
+
/** Replace filesystem-unsafe characters and cap length so filenames stay readable. */
|
|
5
22
|
private static sanitize;
|
|
6
23
|
private static write;
|
|
7
24
|
static writeRequest(agentName: string, content: unknown): void;
|
|
25
|
+
/** No-op when content is empty — avoids creating zero-byte THINKING files on non-reasoning models. */
|
|
8
26
|
static writeThinking(agentName: string, content: string): void;
|
|
9
27
|
static writeResponse(agentName: string, content: string): void;
|
|
10
28
|
}
|
|
@@ -36,6 +36,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.AiDebugLogger = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Writes per-call debug files for AI requests, thinking output, and responses.
|
|
41
|
+
*
|
|
42
|
+
* Enabled when process.env.AI_DEBUG === 'true' (or when aiDebug is set in
|
|
43
|
+
* LoggingOptions, which maps to the same env var via BriyahConfigService).
|
|
44
|
+
*
|
|
45
|
+
* Files are written to:
|
|
46
|
+
* {BRIYAH_DATA_PATH}/logs/ai-debug/YYYY-MM-DD_HH-mm-ss-SSS_<agentName>_REQUEST.txt
|
|
47
|
+
* {BRIYAH_DATA_PATH}/logs/ai-debug/YYYY-MM-DD_HH-mm-ss-SSS_<agentName>_THINKING.txt
|
|
48
|
+
* {BRIYAH_DATA_PATH}/logs/ai-debug/YYYY-MM-DD_HH-mm-ss-SSS_<agentName>_RESPONSE.txt
|
|
49
|
+
*
|
|
50
|
+
* The millisecond-resolution timestamp prefix keeps files sortable chronologically and
|
|
51
|
+
* distinguishes concurrent calls from different agents.
|
|
52
|
+
*
|
|
53
|
+
* Logging errors are swallowed so they never interrupt the main request flow.
|
|
54
|
+
*/
|
|
39
55
|
class AiDebugLogger {
|
|
40
56
|
static isEnabled() {
|
|
41
57
|
return process.env.AI_DEBUG === 'true';
|
|
@@ -53,6 +69,7 @@ class AiDebugLogger {
|
|
|
53
69
|
`_${pad(now.getHours())}-${pad(now.getMinutes())}-${pad(now.getSeconds())}` +
|
|
54
70
|
`-${pad(now.getMilliseconds(), 3)}`);
|
|
55
71
|
}
|
|
72
|
+
/** Replace filesystem-unsafe characters and cap length so filenames stay readable. */
|
|
56
73
|
static sanitize(name) {
|
|
57
74
|
return name.replace(/[<>:"/\\|?*\s]+/g, '_').substring(0, 80);
|
|
58
75
|
}
|
|
@@ -64,12 +81,14 @@ class AiDebugLogger {
|
|
|
64
81
|
fs.writeFileSync(path.join(this.getLogDir(), filename), content, 'utf8');
|
|
65
82
|
}
|
|
66
83
|
catch {
|
|
84
|
+
// Never let debug logging break the main flow.
|
|
67
85
|
}
|
|
68
86
|
}
|
|
69
87
|
static writeRequest(agentName, content) {
|
|
70
88
|
const text = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
|
|
71
89
|
this.write(agentName, 'REQUEST', text);
|
|
72
90
|
}
|
|
91
|
+
/** No-op when content is empty — avoids creating zero-byte THINKING files on non-reasoning models. */
|
|
73
92
|
static writeThinking(agentName, content) {
|
|
74
93
|
if (!content)
|
|
75
94
|
return;
|
|
@@ -21,6 +21,15 @@ export declare class AiFactoryService {
|
|
|
21
21
|
private readonly comfyUiAiService;
|
|
22
22
|
private readonly selfHostedAiService;
|
|
23
23
|
constructor(openAiService: OpenAiService, grokAiService: GrokAiService, anthropicAiService: AnthropicAiService, deepSeekAiService: DeepSeekAiService, togetherAiService: TogetherAiService, mockAiService: MockAiService, googleAiService: GoogleAiService, falAiService: FalAiService, comfyUiAiService: ComfyUiAiService, selfHostedAiService: SelfHostedAiService);
|
|
24
|
+
/**
|
|
25
|
+
* Creates an AI service instance based on the service name
|
|
26
|
+
* @param serviceName The name of the service to create (must match getServiceName())
|
|
27
|
+
* @returns The appropriate AI service instance
|
|
28
|
+
*/
|
|
24
29
|
createAiService(serviceName: string): BaseAiService;
|
|
30
|
+
/**
|
|
31
|
+
* Gets all available AI services
|
|
32
|
+
* @returns Array of all AI service instances
|
|
33
|
+
*/
|
|
25
34
|
getAllAiServices(): BaseAiService[];
|
|
26
35
|
}
|
|
@@ -44,6 +44,11 @@ let AiFactoryService = class AiFactoryService {
|
|
|
44
44
|
this.comfyUiAiService = comfyUiAiService;
|
|
45
45
|
this.selfHostedAiService = selfHostedAiService;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates an AI service instance based on the service name
|
|
49
|
+
* @param serviceName The name of the service to create (must match getServiceName())
|
|
50
|
+
* @returns The appropriate AI service instance
|
|
51
|
+
*/
|
|
47
52
|
createAiService(serviceName) {
|
|
48
53
|
switch (serviceName) {
|
|
49
54
|
case this.openAiService.getServiceName():
|
|
@@ -70,6 +75,10 @@ let AiFactoryService = class AiFactoryService {
|
|
|
70
75
|
throw new Error(`Unknown AI service: ${serviceName}`);
|
|
71
76
|
}
|
|
72
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets all available AI services
|
|
80
|
+
* @returns Array of all AI service instances
|
|
81
|
+
*/
|
|
73
82
|
getAllAiServices() {
|
|
74
83
|
return [
|
|
75
84
|
this.openAiService,
|
|
@@ -1,27 +1,158 @@
|
|
|
1
1
|
import { UserPathsService } from '../config/user-paths.service';
|
|
2
2
|
import { ArtifactMetadata } from '../../../shared/types/app.types';
|
|
3
|
+
/**
|
|
4
|
+
* Service for managing user artifacts (reusable markdown documents)
|
|
5
|
+
* Separate from AttachedFileService which handles agent-specific file uploads
|
|
6
|
+
* and separate from Room artifacts which are agent-generated conversation outputs
|
|
7
|
+
*
|
|
8
|
+
* Reads span two tiers: the user's own artifacts, and the read-only documents
|
|
9
|
+
* shipped by enabled tool packs (see `pack-artifacts.ts`). Writes only ever touch
|
|
10
|
+
* the user's, and a `pack:` id is refused rather than silently ignored.
|
|
11
|
+
*/
|
|
3
12
|
export declare class ArtifactService {
|
|
4
13
|
private readonly userPaths;
|
|
5
14
|
private readonly artifactsDir;
|
|
15
|
+
/**
|
|
16
|
+
* Where packs live, highest precedence first: the user's own packs, then the
|
|
17
|
+
* host's. A pack name exists in only one of them, so the order settles a
|
|
18
|
+
* collision rather than layering.
|
|
19
|
+
*/
|
|
6
20
|
private readonly packRoots;
|
|
21
|
+
/**
|
|
22
|
+
* The packs whose documents this user should be offered.
|
|
23
|
+
*
|
|
24
|
+
* A thunk, and defaulting to none, so the many places that build an
|
|
25
|
+
* `ArtifactService` without a pack service keep working — they simply see no
|
|
26
|
+
* pack documents in a listing, which is what an unconfigured user sees anyway.
|
|
27
|
+
* Resolution never consults it.
|
|
28
|
+
*/
|
|
7
29
|
private enabledPacks;
|
|
8
30
|
constructor(userPaths: UserPathsService, storageDir?: string);
|
|
31
|
+
/**
|
|
32
|
+
* Tells this service which packs the user has enabled.
|
|
33
|
+
*
|
|
34
|
+
* Set after construction because `PackService` and `ArtifactService` are both
|
|
35
|
+
* built per user and neither can be the other's constructor argument.
|
|
36
|
+
*
|
|
37
|
+
* @param enabledPacks A thunk over the user's enabled packs
|
|
38
|
+
*/
|
|
9
39
|
setEnabledPacks(enabledPacks: () => readonly string[]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Guards every write path against a pack document.
|
|
42
|
+
*
|
|
43
|
+
* There is one copy of a shipped document and it is the same for every user,
|
|
44
|
+
* so editing, renaming or deleting one is not a thing a single user may do.
|
|
45
|
+
* Returning rather than throwing keeps the existing "false means it did not
|
|
46
|
+
* happen" contract of the write methods.
|
|
47
|
+
*
|
|
48
|
+
* @returns True when the caller should stop
|
|
49
|
+
*/
|
|
10
50
|
private refuseWriteToPackDocument;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the path to the metadata file
|
|
53
|
+
*/
|
|
11
54
|
private getMetadataPath;
|
|
55
|
+
/**
|
|
56
|
+
* Loads metadata from disk
|
|
57
|
+
*/
|
|
12
58
|
private loadMetadata;
|
|
59
|
+
/**
|
|
60
|
+
* Saves metadata to disk
|
|
61
|
+
*/
|
|
13
62
|
private saveMetadata;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the file path for an artifact
|
|
65
|
+
* @deprecated Use getArtifactFilePath instead for MIME-aware path resolution
|
|
66
|
+
*/
|
|
14
67
|
private getArtifactPath;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the file path for an artifact based on its MIME type
|
|
70
|
+
*/
|
|
15
71
|
private getArtifactFilePath;
|
|
72
|
+
/**
|
|
73
|
+
* Stores a new artifact
|
|
74
|
+
* @param name User-friendly name for the artifact
|
|
75
|
+
* @param content Markdown content
|
|
76
|
+
* @param description Optional description for the artifact
|
|
77
|
+
* @returns The artifactId
|
|
78
|
+
*/
|
|
16
79
|
storeArtifact(name: string, content: string, description?: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Gets artifact content
|
|
82
|
+
* @param artifactId The artifact ID
|
|
83
|
+
* @returns The content (string for text, Buffer for images), or null if not found
|
|
84
|
+
*/
|
|
17
85
|
getArtifact(artifactId: string): string | Buffer | null;
|
|
86
|
+
/**
|
|
87
|
+
* Lists a pack's document files by name, for a tool that enumerates its own
|
|
88
|
+
* documents rather than being handed them.
|
|
89
|
+
*
|
|
90
|
+
* Reads the pack's `artifacts/` directory rather than its manifest, so an
|
|
91
|
+
* operator can add a document by dropping a file in — see
|
|
92
|
+
* {@link listPackDocumentFiles}. Nothing in the client uses this; it exists for
|
|
93
|
+
* `helpers.packDocuments`.
|
|
94
|
+
* @param pack The pack name
|
|
95
|
+
* @param prefix Keep only file names starting with this
|
|
96
|
+
* @returns Bare `.md` file names, sorted
|
|
97
|
+
*/
|
|
18
98
|
listPackDocumentFiles(pack: string, prefix?: string): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Reads one of a pack's document files by name.
|
|
101
|
+
* @param pack The pack name
|
|
102
|
+
* @param fileName A bare file name from {@link listPackDocumentFiles}
|
|
103
|
+
* @returns The document's text, or null if there is no such file
|
|
104
|
+
*/
|
|
19
105
|
readPackDocumentFile(pack: string, fileName: string): string | null;
|
|
106
|
+
/**
|
|
107
|
+
* Lists all artifacts: the documents shipped by enabled tool packs first, then
|
|
108
|
+
* the user's own.
|
|
109
|
+
*
|
|
110
|
+
* Pack documents lead because they are the same for everyone and the user did
|
|
111
|
+
* not put them there — burying them among their own uploads is how they get
|
|
112
|
+
* missed.
|
|
113
|
+
* @returns Array of artifact metadata
|
|
114
|
+
*/
|
|
20
115
|
listArtifacts(): ArtifactMetadata[];
|
|
116
|
+
/**
|
|
117
|
+
* Gets metadata for a specific artifact
|
|
118
|
+
* @param artifactId The artifact ID
|
|
119
|
+
* @returns The metadata, or null if not found
|
|
120
|
+
*/
|
|
21
121
|
getArtifactMetadata(artifactId: string): ArtifactMetadata | null;
|
|
122
|
+
/**
|
|
123
|
+
* Updates artifact content
|
|
124
|
+
* @param artifactId The artifact ID
|
|
125
|
+
* @param content New content
|
|
126
|
+
* @returns True if successful, false otherwise
|
|
127
|
+
*/
|
|
22
128
|
updateArtifact(artifactId: string, content: string): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Renames an artifact
|
|
131
|
+
* @param artifactId The artifact ID
|
|
132
|
+
* @param newName New name
|
|
133
|
+
* @returns True if successful, false otherwise
|
|
134
|
+
*/
|
|
23
135
|
renameArtifact(artifactId: string, newName: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Updates an artifact's description in metadata
|
|
138
|
+
* @param artifactId The artifact ID
|
|
139
|
+
* @param description New description
|
|
140
|
+
* @returns True if successful, false otherwise
|
|
141
|
+
*/
|
|
24
142
|
updateArtifactDescription(artifactId: string, description: string): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Deletes an artifact
|
|
145
|
+
* @param artifactId The artifact ID
|
|
146
|
+
* @returns True if successful, false otherwise
|
|
147
|
+
*/
|
|
25
148
|
deleteArtifact(artifactId: string): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Stores a new image artifact
|
|
151
|
+
* @param name User-friendly name for the artifact
|
|
152
|
+
* @param imageData Binary image data
|
|
153
|
+
* @param mimeType MIME type of the image (e.g., 'image/png')
|
|
154
|
+
* @param description Optional description for the artifact
|
|
155
|
+
* @returns The artifactId
|
|
156
|
+
*/
|
|
26
157
|
storeImageArtifact(name: string, imageData: Buffer, mimeType: string, description?: string): string;
|
|
27
158
|
}
|
|
@@ -50,14 +50,37 @@ const crypto_1 = require("crypto");
|
|
|
50
50
|
const user_paths_service_1 = require("../config/user-paths.service");
|
|
51
51
|
const pack_artifacts_1 = require("./pack-artifacts");
|
|
52
52
|
const logger_1 = require("../common/logger");
|
|
53
|
+
/**
|
|
54
|
+
* Service for managing user artifacts (reusable markdown documents)
|
|
55
|
+
* Separate from AttachedFileService which handles agent-specific file uploads
|
|
56
|
+
* and separate from Room artifacts which are agent-generated conversation outputs
|
|
57
|
+
*
|
|
58
|
+
* Reads span two tiers: the user's own artifacts, and the read-only documents
|
|
59
|
+
* shipped by enabled tool packs (see `pack-artifacts.ts`). Writes only ever touch
|
|
60
|
+
* the user's, and a `pack:` id is refused rather than silently ignored.
|
|
61
|
+
*/
|
|
53
62
|
let ArtifactService = class ArtifactService {
|
|
54
63
|
userPaths;
|
|
55
64
|
artifactsDir;
|
|
65
|
+
/**
|
|
66
|
+
* Where packs live, highest precedence first: the user's own packs, then the
|
|
67
|
+
* host's. A pack name exists in only one of them, so the order settles a
|
|
68
|
+
* collision rather than layering.
|
|
69
|
+
*/
|
|
56
70
|
packRoots;
|
|
71
|
+
/**
|
|
72
|
+
* The packs whose documents this user should be offered.
|
|
73
|
+
*
|
|
74
|
+
* A thunk, and defaulting to none, so the many places that build an
|
|
75
|
+
* `ArtifactService` without a pack service keep working — they simply see no
|
|
76
|
+
* pack documents in a listing, which is what an unconfigured user sees anyway.
|
|
77
|
+
* Resolution never consults it.
|
|
78
|
+
*/
|
|
57
79
|
enabledPacks = () => [];
|
|
58
80
|
constructor(userPaths, storageDir) {
|
|
59
81
|
this.userPaths = userPaths;
|
|
60
82
|
this.packRoots = [this.userPaths.getUserPacksDir(), this.userPaths.getPacksDir()];
|
|
83
|
+
// Use provided storageDir or default to user-specific artifacts directory
|
|
61
84
|
if (storageDir) {
|
|
62
85
|
this.artifactsDir = storageDir;
|
|
63
86
|
}
|
|
@@ -65,13 +88,32 @@ let ArtifactService = class ArtifactService {
|
|
|
65
88
|
const userDataDir = this.userPaths.getUserDataDir();
|
|
66
89
|
this.artifactsDir = path.join(userDataDir, 'artifacts');
|
|
67
90
|
}
|
|
91
|
+
// Create artifacts directory if it doesn't exist
|
|
68
92
|
if (!fs.existsSync(this.artifactsDir)) {
|
|
69
93
|
fs.mkdirSync(this.artifactsDir, { recursive: true });
|
|
70
94
|
}
|
|
71
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Tells this service which packs the user has enabled.
|
|
98
|
+
*
|
|
99
|
+
* Set after construction because `PackService` and `ArtifactService` are both
|
|
100
|
+
* built per user and neither can be the other's constructor argument.
|
|
101
|
+
*
|
|
102
|
+
* @param enabledPacks A thunk over the user's enabled packs
|
|
103
|
+
*/
|
|
72
104
|
setEnabledPacks(enabledPacks) {
|
|
73
105
|
this.enabledPacks = enabledPacks;
|
|
74
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Guards every write path against a pack document.
|
|
109
|
+
*
|
|
110
|
+
* There is one copy of a shipped document and it is the same for every user,
|
|
111
|
+
* so editing, renaming or deleting one is not a thing a single user may do.
|
|
112
|
+
* Returning rather than throwing keeps the existing "false means it did not
|
|
113
|
+
* happen" contract of the write methods.
|
|
114
|
+
*
|
|
115
|
+
* @returns True when the caller should stop
|
|
116
|
+
*/
|
|
75
117
|
refuseWriteToPackDocument(artifactId, operation) {
|
|
76
118
|
if (!(0, pack_artifacts_1.isPackArtifactId)(artifactId)) {
|
|
77
119
|
return false;
|
|
@@ -79,9 +121,15 @@ let ArtifactService = class ArtifactService {
|
|
|
79
121
|
logger_1.logger.warn(`Refusing to ${operation} pack document ${artifactId}: shipped documents are read-only`);
|
|
80
122
|
return true;
|
|
81
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets the path to the metadata file
|
|
126
|
+
*/
|
|
82
127
|
getMetadataPath() {
|
|
83
128
|
return path.join(this.artifactsDir, 'metadata.json');
|
|
84
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Loads metadata from disk
|
|
132
|
+
*/
|
|
85
133
|
loadMetadata() {
|
|
86
134
|
const metadataPath = this.getMetadataPath();
|
|
87
135
|
if (!fs.existsSync(metadataPath)) {
|
|
@@ -96,13 +144,23 @@ let ArtifactService = class ArtifactService {
|
|
|
96
144
|
return {};
|
|
97
145
|
}
|
|
98
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Saves metadata to disk
|
|
149
|
+
*/
|
|
99
150
|
saveMetadata(metadata) {
|
|
100
151
|
const metadataPath = this.getMetadataPath();
|
|
101
152
|
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), 'utf8');
|
|
102
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Gets the file path for an artifact
|
|
156
|
+
* @deprecated Use getArtifactFilePath instead for MIME-aware path resolution
|
|
157
|
+
*/
|
|
103
158
|
getArtifactPath(artifactId) {
|
|
104
159
|
return path.join(this.artifactsDir, `${artifactId}.md`);
|
|
105
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Gets the file path for an artifact based on its MIME type
|
|
163
|
+
*/
|
|
106
164
|
getArtifactFilePath(artifactId, metadata) {
|
|
107
165
|
if (metadata.mimeType?.startsWith('image/')) {
|
|
108
166
|
const extension = metadata.mimeType.split('/').pop();
|
|
@@ -110,10 +168,19 @@ let ArtifactService = class ArtifactService {
|
|
|
110
168
|
}
|
|
111
169
|
return path.join(this.artifactsDir, `${artifactId}.md`);
|
|
112
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Stores a new artifact
|
|
173
|
+
* @param name User-friendly name for the artifact
|
|
174
|
+
* @param content Markdown content
|
|
175
|
+
* @param description Optional description for the artifact
|
|
176
|
+
* @returns The artifactId
|
|
177
|
+
*/
|
|
113
178
|
storeArtifact(name, content, description) {
|
|
114
179
|
const artifactId = (0, crypto_1.randomUUID)();
|
|
115
180
|
const filePath = this.getArtifactPath(artifactId);
|
|
181
|
+
// Write content to file
|
|
116
182
|
fs.writeFileSync(filePath, content, 'utf8');
|
|
183
|
+
// Update metadata
|
|
117
184
|
const metadata = this.loadMetadata();
|
|
118
185
|
metadata[artifactId] = {
|
|
119
186
|
artifactId,
|
|
@@ -127,7 +194,15 @@ let ArtifactService = class ArtifactService {
|
|
|
127
194
|
this.saveMetadata(metadata);
|
|
128
195
|
return artifactId;
|
|
129
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Gets artifact content
|
|
199
|
+
* @param artifactId The artifact ID
|
|
200
|
+
* @returns The content (string for text, Buffer for images), or null if not found
|
|
201
|
+
*/
|
|
130
202
|
getArtifact(artifactId) {
|
|
203
|
+
// Deliberately not gated on the pack being enabled: an agent resolves its
|
|
204
|
+
// attached ids on every request, and turning a pack off should not quietly
|
|
205
|
+
// strip a document out of an agent that already carries it.
|
|
131
206
|
if ((0, pack_artifacts_1.isPackArtifactId)(artifactId)) {
|
|
132
207
|
return (0, pack_artifacts_1.getPackArtifact)(this.packRoots, artifactId);
|
|
133
208
|
}
|
|
@@ -140,11 +215,12 @@ let ArtifactService = class ArtifactService {
|
|
|
140
215
|
return null;
|
|
141
216
|
}
|
|
142
217
|
try {
|
|
218
|
+
// Check if binary based on MIME type
|
|
143
219
|
if (metadata.mimeType?.startsWith('image/')) {
|
|
144
|
-
return fs.readFileSync(filePath);
|
|
220
|
+
return fs.readFileSync(filePath); // Return Buffer for images
|
|
145
221
|
}
|
|
146
222
|
else {
|
|
147
|
-
return fs.readFileSync(filePath, 'utf8');
|
|
223
|
+
return fs.readFileSync(filePath, 'utf8'); // Return string for text
|
|
148
224
|
}
|
|
149
225
|
}
|
|
150
226
|
catch (error) {
|
|
@@ -152,12 +228,39 @@ let ArtifactService = class ArtifactService {
|
|
|
152
228
|
return null;
|
|
153
229
|
}
|
|
154
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Lists a pack's document files by name, for a tool that enumerates its own
|
|
233
|
+
* documents rather than being handed them.
|
|
234
|
+
*
|
|
235
|
+
* Reads the pack's `artifacts/` directory rather than its manifest, so an
|
|
236
|
+
* operator can add a document by dropping a file in — see
|
|
237
|
+
* {@link listPackDocumentFiles}. Nothing in the client uses this; it exists for
|
|
238
|
+
* `helpers.packDocuments`.
|
|
239
|
+
* @param pack The pack name
|
|
240
|
+
* @param prefix Keep only file names starting with this
|
|
241
|
+
* @returns Bare `.md` file names, sorted
|
|
242
|
+
*/
|
|
155
243
|
listPackDocumentFiles(pack, prefix) {
|
|
156
244
|
return (0, pack_artifacts_1.listPackDocumentFiles)(this.packRoots, pack, prefix);
|
|
157
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Reads one of a pack's document files by name.
|
|
248
|
+
* @param pack The pack name
|
|
249
|
+
* @param fileName A bare file name from {@link listPackDocumentFiles}
|
|
250
|
+
* @returns The document's text, or null if there is no such file
|
|
251
|
+
*/
|
|
158
252
|
readPackDocumentFile(pack, fileName) {
|
|
159
253
|
return (0, pack_artifacts_1.readPackDocumentFile)(this.packRoots, pack, fileName);
|
|
160
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Lists all artifacts: the documents shipped by enabled tool packs first, then
|
|
257
|
+
* the user's own.
|
|
258
|
+
*
|
|
259
|
+
* Pack documents lead because they are the same for everyone and the user did
|
|
260
|
+
* not put them there — burying them among their own uploads is how they get
|
|
261
|
+
* missed.
|
|
262
|
+
* @returns Array of artifact metadata
|
|
263
|
+
*/
|
|
161
264
|
listArtifacts() {
|
|
162
265
|
const metadata = this.loadMetadata();
|
|
163
266
|
return [
|
|
@@ -165,6 +268,11 @@ let ArtifactService = class ArtifactService {
|
|
|
165
268
|
...Object.values(metadata),
|
|
166
269
|
];
|
|
167
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Gets metadata for a specific artifact
|
|
273
|
+
* @param artifactId The artifact ID
|
|
274
|
+
* @returns The metadata, or null if not found
|
|
275
|
+
*/
|
|
168
276
|
getArtifactMetadata(artifactId) {
|
|
169
277
|
if ((0, pack_artifacts_1.isPackArtifactId)(artifactId)) {
|
|
170
278
|
return (0, pack_artifacts_1.getPackArtifactMetadata)(this.packRoots, artifactId);
|
|
@@ -172,6 +280,12 @@ let ArtifactService = class ArtifactService {
|
|
|
172
280
|
const metadata = this.loadMetadata();
|
|
173
281
|
return metadata[artifactId] || null;
|
|
174
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Updates artifact content
|
|
285
|
+
* @param artifactId The artifact ID
|
|
286
|
+
* @param content New content
|
|
287
|
+
* @returns True if successful, false otherwise
|
|
288
|
+
*/
|
|
175
289
|
updateArtifact(artifactId, content) {
|
|
176
290
|
if (this.refuseWriteToPackDocument(artifactId, 'update')) {
|
|
177
291
|
return false;
|
|
@@ -181,7 +295,9 @@ let ArtifactService = class ArtifactService {
|
|
|
181
295
|
return false;
|
|
182
296
|
}
|
|
183
297
|
try {
|
|
298
|
+
// Write new content
|
|
184
299
|
fs.writeFileSync(filePath, content, 'utf8');
|
|
300
|
+
// Update size in metadata
|
|
185
301
|
const metadata = this.loadMetadata();
|
|
186
302
|
if (metadata[artifactId]) {
|
|
187
303
|
metadata[artifactId].size = Buffer.byteLength(content, 'utf8');
|
|
@@ -194,6 +310,12 @@ let ArtifactService = class ArtifactService {
|
|
|
194
310
|
return false;
|
|
195
311
|
}
|
|
196
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Renames an artifact
|
|
315
|
+
* @param artifactId The artifact ID
|
|
316
|
+
* @param newName New name
|
|
317
|
+
* @returns True if successful, false otherwise
|
|
318
|
+
*/
|
|
197
319
|
renameArtifact(artifactId, newName) {
|
|
198
320
|
if (this.refuseWriteToPackDocument(artifactId, 'rename')) {
|
|
199
321
|
return false;
|
|
@@ -212,6 +334,12 @@ let ArtifactService = class ArtifactService {
|
|
|
212
334
|
return false;
|
|
213
335
|
}
|
|
214
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Updates an artifact's description in metadata
|
|
339
|
+
* @param artifactId The artifact ID
|
|
340
|
+
* @param description New description
|
|
341
|
+
* @returns True if successful, false otherwise
|
|
342
|
+
*/
|
|
215
343
|
updateArtifactDescription(artifactId, description) {
|
|
216
344
|
if (this.refuseWriteToPackDocument(artifactId, 'describe')) {
|
|
217
345
|
return false;
|
|
@@ -230,6 +358,11 @@ let ArtifactService = class ArtifactService {
|
|
|
230
358
|
return false;
|
|
231
359
|
}
|
|
232
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Deletes an artifact
|
|
363
|
+
* @param artifactId The artifact ID
|
|
364
|
+
* @returns True if successful, false otherwise
|
|
365
|
+
*/
|
|
233
366
|
deleteArtifact(artifactId) {
|
|
234
367
|
if (this.refuseWriteToPackDocument(artifactId, 'delete')) {
|
|
235
368
|
return false;
|
|
@@ -243,7 +376,9 @@ let ArtifactService = class ArtifactService {
|
|
|
243
376
|
return false;
|
|
244
377
|
}
|
|
245
378
|
try {
|
|
379
|
+
// Delete file
|
|
246
380
|
fs.unlinkSync(filePath);
|
|
381
|
+
// Update metadata
|
|
247
382
|
const allMetadata = this.loadMetadata();
|
|
248
383
|
delete allMetadata[artifactId];
|
|
249
384
|
this.saveMetadata(allMetadata);
|
|
@@ -254,12 +389,22 @@ let ArtifactService = class ArtifactService {
|
|
|
254
389
|
return false;
|
|
255
390
|
}
|
|
256
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Stores a new image artifact
|
|
394
|
+
* @param name User-friendly name for the artifact
|
|
395
|
+
* @param imageData Binary image data
|
|
396
|
+
* @param mimeType MIME type of the image (e.g., 'image/png')
|
|
397
|
+
* @param description Optional description for the artifact
|
|
398
|
+
* @returns The artifactId
|
|
399
|
+
*/
|
|
257
400
|
storeImageArtifact(name, imageData, mimeType, description) {
|
|
258
401
|
const artifactId = (0, crypto_1.randomUUID)();
|
|
259
|
-
const extension = mimeType.split('/')[1];
|
|
402
|
+
const extension = mimeType.split('/')[1]; // e.g., 'png' from 'image/png'
|
|
260
403
|
const fileName = `${artifactId}.${extension}`;
|
|
261
404
|
const filePath = path.join(this.artifactsDir, fileName);
|
|
405
|
+
// Write binary data
|
|
262
406
|
fs.writeFileSync(filePath, imageData);
|
|
407
|
+
// Update metadata
|
|
263
408
|
const metadata = this.loadMetadata();
|
|
264
409
|
metadata[artifactId] = {
|
|
265
410
|
artifactId,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { UserPathsService } from '../config/user-paths.service';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for file metadata
|
|
4
|
+
*/
|
|
2
5
|
export interface FileMetadata {
|
|
3
6
|
fileName: string;
|
|
4
7
|
fileId: string;
|
|
@@ -13,23 +16,107 @@ export interface FileMetadata {
|
|
|
13
16
|
[key: string]: any;
|
|
14
17
|
};
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Service for managing files attached to agents
|
|
21
|
+
*/
|
|
16
22
|
export declare class AttachedFileService {
|
|
17
23
|
private readonly userPaths;
|
|
18
24
|
private readonly attachedFilesDir;
|
|
19
25
|
constructor(userPaths: UserPathsService);
|
|
20
26
|
private getMetadataPath;
|
|
27
|
+
/**
|
|
28
|
+
* Stores a file for an owner (agent or room)
|
|
29
|
+
* @param ownerId The ID of the owner
|
|
30
|
+
* @param fileName The name of the file
|
|
31
|
+
* @param fileData The file data as a Uint8Array
|
|
32
|
+
* @param additionalMetadata Additional metadata to store with the file
|
|
33
|
+
* @returns The ID of the stored file
|
|
34
|
+
*/
|
|
21
35
|
storeFile(ownerId: string, fileName: string, fileData: Uint8Array, additionalMetadata?: Partial<FileMetadata>): string;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a file for an owner
|
|
38
|
+
* @param ownerId The ID of the owner
|
|
39
|
+
* @param fileId The ID of the file
|
|
40
|
+
* @returns The file data as a Uint8Array, or null if not found
|
|
41
|
+
*/
|
|
22
42
|
getFile(ownerId: string, fileId: string): Uint8Array | null;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves a file by name for an owner
|
|
45
|
+
* @param ownerId The ID of the owner
|
|
46
|
+
* @param fileName The name of the file
|
|
47
|
+
* @returns The file data as a Uint8Array, or null if not found
|
|
48
|
+
*/
|
|
23
49
|
getFileByName(ownerId: string, fileName: string): Uint8Array | null;
|
|
50
|
+
/**
|
|
51
|
+
* Updates metadata for an existing file
|
|
52
|
+
* @param ownerId The ID of the owner
|
|
53
|
+
* @param fileId The ID of the file
|
|
54
|
+
* @param metadataUpdates The metadata updates to apply
|
|
55
|
+
* @returns True if the update was successful, false otherwise
|
|
56
|
+
*/
|
|
24
57
|
updateFileMetadata(ownerId: string, fileId: string, metadataUpdates: Partial<FileMetadata>): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Gets metadata for a file
|
|
60
|
+
* @param ownerId The ID of the owner
|
|
61
|
+
* @param fileId The ID of the file
|
|
62
|
+
* @returns The file metadata, or null if not found
|
|
63
|
+
*/
|
|
25
64
|
getFileMetadata(ownerId: string, fileId: string): FileMetadata | null;
|
|
65
|
+
/**
|
|
66
|
+
* Gets metadata for a file by its name
|
|
67
|
+
* @param ownerId The ID of the owner
|
|
68
|
+
* @param fileName The name of the file
|
|
69
|
+
* @returns The file metadata, or null if not found
|
|
70
|
+
*/
|
|
26
71
|
getFileMetadataByName(ownerId: string, fileName: string): FileMetadata | null;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the ID of a file by its name
|
|
74
|
+
* @param ownerId The ID of the owner
|
|
75
|
+
* @param fileName The name of the file
|
|
76
|
+
* @returns The file ID, or null if not found
|
|
77
|
+
*/
|
|
27
78
|
getFileIdByName(ownerId: string, fileName: string): string | null;
|
|
79
|
+
/**
|
|
80
|
+
* Lists all file metadata for an owner
|
|
81
|
+
* @param ownerId The ID of the owner
|
|
82
|
+
* @returns Array of file metadata objects
|
|
83
|
+
*/
|
|
28
84
|
listFileMetadata(ownerId: string): FileMetadata[];
|
|
85
|
+
/**
|
|
86
|
+
* Lists all files for an owner
|
|
87
|
+
* @param ownerId The ID of the owner
|
|
88
|
+
* @returns Array of file names
|
|
89
|
+
*/
|
|
29
90
|
listFiles(ownerId: string): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Deletes a file for an owner
|
|
93
|
+
* @param ownerId The ID of the owner
|
|
94
|
+
* @param fileId The ID of the file
|
|
95
|
+
* @returns True if the file was deleted, false otherwise
|
|
96
|
+
*/
|
|
30
97
|
deleteFile(ownerId: string, fileId: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Deletes a file by name for an owner
|
|
100
|
+
* @param ownerId The ID of the owner
|
|
101
|
+
* @param fileName The name of the file
|
|
102
|
+
* @returns True if the file was deleted, false otherwise
|
|
103
|
+
*/
|
|
31
104
|
deleteFileByName(ownerId: string, fileName: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Deletes all files for an owner
|
|
107
|
+
* @param ownerId The ID of the owner
|
|
108
|
+
* @returns True if the owner's directory was deleted, false otherwise
|
|
109
|
+
*/
|
|
32
110
|
deleteAllFiles(ownerId: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Gets the path to an owner's directory
|
|
113
|
+
* @param ownerId The ID of the owner
|
|
114
|
+
* @returns The path to the owner's directory
|
|
115
|
+
*/
|
|
33
116
|
private getOwnerDirectory;
|
|
117
|
+
/**
|
|
118
|
+
* Recursively deletes a directory
|
|
119
|
+
* @param dirPath The path to the directory
|
|
120
|
+
*/
|
|
34
121
|
private deleteDirectory;
|
|
35
122
|
}
|