briyah 1.0.0
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/.prettierrc +7 -0
- package/dist/ai/LLM/anthropic.module.d.ts +2 -0
- package/dist/ai/LLM/anthropic.module.js +21 -0
- package/dist/ai/LLM/anthropic.service.d.ts +27 -0
- package/dist/ai/LLM/anthropic.service.js +329 -0
- package/dist/ai/LLM/base-ai.service.d.ts +45 -0
- package/dist/ai/LLM/base-ai.service.js +409 -0
- package/dist/ai/LLM/deepseek.module.d.ts +2 -0
- package/dist/ai/LLM/deepseek.module.js +21 -0
- package/dist/ai/LLM/deepseek.service.d.ts +15 -0
- package/dist/ai/LLM/deepseek.service.js +279 -0
- package/dist/ai/LLM/fal.module.d.ts +2 -0
- package/dist/ai/LLM/fal.module.js +21 -0
- package/dist/ai/LLM/fal.service.d.ts +17 -0
- package/dist/ai/LLM/fal.service.js +314 -0
- package/dist/ai/LLM/googleai.module.d.ts +2 -0
- package/dist/ai/LLM/googleai.module.js +21 -0
- package/dist/ai/LLM/googleai.service.d.ts +20 -0
- package/dist/ai/LLM/googleai.service.js +271 -0
- package/dist/ai/LLM/grok.module.d.ts +2 -0
- package/dist/ai/LLM/grok.module.js +21 -0
- package/dist/ai/LLM/grok.service.d.ts +14 -0
- package/dist/ai/LLM/grok.service.js +263 -0
- package/dist/ai/LLM/mock.module.d.ts +2 -0
- package/dist/ai/LLM/mock.module.js +21 -0
- package/dist/ai/LLM/mock.service.d.ts +13 -0
- package/dist/ai/LLM/mock.service.js +194 -0
- package/dist/ai/LLM/openai.module.d.ts +2 -0
- package/dist/ai/LLM/openai.module.js +21 -0
- package/dist/ai/LLM/openai.service.d.ts +21 -0
- package/dist/ai/LLM/openai.service.js +421 -0
- package/dist/ai/LLM/together.module.d.ts +2 -0
- package/dist/ai/LLM/together.module.js +21 -0
- package/dist/ai/LLM/together.service.d.ts +18 -0
- package/dist/ai/LLM/together.service.js +285 -0
- package/dist/ai/LLM/vertexai.module.d.ts +2 -0
- package/dist/ai/LLM/vertexai.module.js +21 -0
- package/dist/ai/LLM/vertexai.service.d.ts +17 -0
- package/dist/ai/LLM/vertexai.service.js +323 -0
- package/dist/ai/agent-config.d.ts +32 -0
- package/dist/ai/agent-config.js +2 -0
- package/dist/ai/agent-factory.d.ts +15 -0
- package/dist/ai/agent-factory.js +24 -0
- package/dist/ai/agent-message.service.d.ts +9 -0
- package/dist/ai/agent-message.service.js +56 -0
- package/dist/ai/agent-store.module.d.ts +2 -0
- package/dist/ai/agent-store.module.js +21 -0
- package/dist/ai/agent-store.service.d.ts +31 -0
- package/dist/ai/agent-store.service.js +352 -0
- package/dist/ai/agent.d.ts +75 -0
- package/dist/ai/agent.js +174 -0
- package/dist/ai/ai-factory.module.d.ts +2 -0
- package/dist/ai/ai-factory.module.js +40 -0
- package/dist/ai/ai-factory.service.d.ts +24 -0
- package/dist/ai/ai-factory.service.js +94 -0
- package/dist/ai/artifact.module.d.ts +2 -0
- package/dist/ai/artifact.module.js +22 -0
- package/dist/ai/artifact.service.d.ts +21 -0
- package/dist/ai/artifact.service.js +239 -0
- package/dist/ai/attached-file.module.d.ts +2 -0
- package/dist/ai/attached-file.module.js +22 -0
- package/dist/ai/attached-file.service.d.ts +35 -0
- package/dist/ai/attached-file.service.js +253 -0
- package/dist/ai/model_prices.d.ts +2 -0
- package/dist/ai/model_prices.js +54 -0
- package/dist/ai/published-agents.service.d.ts +13 -0
- package/dist/ai/published-agents.service.js +118 -0
- package/dist/app/balance-message.service.d.ts +8 -0
- package/dist/app/balance-message.service.js +45 -0
- package/dist/app/balance.module.d.ts +2 -0
- package/dist/app/balance.module.js +20 -0
- package/dist/app/balance.service.d.ts +18 -0
- package/dist/app/balance.service.js +158 -0
- package/dist/app/stripe.controller.d.ts +31 -0
- package/dist/app/stripe.controller.js +150 -0
- package/dist/app/stripe.module.d.ts +2 -0
- package/dist/app/stripe.module.js +22 -0
- package/dist/app/stripe.service.d.ts +28 -0
- package/dist/app/stripe.service.js +198 -0
- package/dist/app/transaction.service.d.ts +15 -0
- package/dist/app/transaction.service.js +139 -0
- package/dist/app/user-service-factory.d.ts +21 -0
- package/dist/app/user-service-factory.js +81 -0
- package/dist/app/user-service-manager.d.ts +28 -0
- package/dist/app/user-service-manager.js +102 -0
- package/dist/app.controller.d.ts +232 -0
- package/dist/app.controller.js +2536 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +45 -0
- package/dist/app.service.d.ts +186 -0
- package/dist/app.service.js +1334 -0
- package/dist/auth/agent-access.decorator.d.ts +2 -0
- package/dist/auth/agent-access.decorator.js +10 -0
- package/dist/auth/auth.controller.d.ts +38 -0
- package/dist/auth/auth.controller.js +356 -0
- package/dist/auth/auth.module.d.ts +2 -0
- package/dist/auth/auth.module.js +55 -0
- package/dist/auth/auth.service.d.ts +14 -0
- package/dist/auth/auth.service.js +84 -0
- package/dist/auth/dto/bot-login.dto.d.ts +4 -0
- package/dist/auth/dto/bot-login.dto.js +2 -0
- package/dist/auth/dto/password-reset.dto.d.ts +11 -0
- package/dist/auth/dto/password-reset.dto.js +2 -0
- package/dist/auth/dto/phone-login.dto.d.ts +8 -0
- package/dist/auth/dto/phone-login.dto.js +2 -0
- package/dist/auth/dto/phone-verification.dto.d.ts +9 -0
- package/dist/auth/dto/phone-verification.dto.js +2 -0
- package/dist/auth/jwt-auth.guard.d.ts +13 -0
- package/dist/auth/jwt-auth.guard.js +143 -0
- package/dist/auth/jwt.strategy.d.ts +17 -0
- package/dist/auth/jwt.strategy.js +45 -0
- package/dist/auth/phone-validation.service.d.ts +7 -0
- package/dist/auth/phone-validation.service.js +50 -0
- package/dist/auth/public.decorator.d.ts +2 -0
- package/dist/auth/public.decorator.js +7 -0
- package/dist/auth/rate-limit.service.d.ts +16 -0
- package/dist/auth/rate-limit.service.js +84 -0
- package/dist/auth/room-access.decorator.d.ts +2 -0
- package/dist/auth/room-access.decorator.js +10 -0
- package/dist/auth/scopes.decorator.d.ts +2 -0
- package/dist/auth/scopes.decorator.js +7 -0
- package/dist/auth/scopes.guard.d.ts +9 -0
- package/dist/auth/scopes.guard.js +82 -0
- package/dist/auth/session.guard.d.ts +7 -0
- package/dist/auth/session.guard.js +55 -0
- package/dist/auth/twilio.service.d.ts +15 -0
- package/dist/auth/twilio.service.js +139 -0
- package/dist/auth/users.service.d.ts +24 -0
- package/dist/auth/users.service.js +149 -0
- package/dist/common/errors.d.ts +12 -0
- package/dist/common/errors.js +43 -0
- package/dist/config/configuration.module.d.ts +2 -0
- package/dist/config/configuration.module.js +20 -0
- package/dist/config/configuration.service.d.ts +26 -0
- package/dist/config/configuration.service.js +131 -0
- package/dist/main.js +15749 -0
- package/dist/room/artifact-store.service.d.ts +15 -0
- package/dist/room/artifact-store.service.js +226 -0
- package/dist/room/artifact.d.ts +6 -0
- package/dist/room/artifact.js +2 -0
- package/dist/room/message.d.ts +19 -0
- package/dist/room/message.js +70 -0
- package/dist/room/published-rooms.service.d.ts +12 -0
- package/dist/room/published-rooms.service.js +108 -0
- package/dist/room/room-config.d.ts +12 -0
- package/dist/room/room-config.js +2 -0
- package/dist/room/room-factory.d.ts +7 -0
- package/dist/room/room-factory.js +16 -0
- package/dist/room/room-message.module.d.ts +2 -0
- package/dist/room/room-message.module.js +21 -0
- package/dist/room/room-message.service.d.ts +8 -0
- package/dist/room/room-message.service.js +44 -0
- package/dist/room/room-store.module.d.ts +2 -0
- package/dist/room/room-store.module.js +25 -0
- package/dist/room/room-store.service.d.ts +38 -0
- package/dist/room/room-store.service.js +353 -0
- package/dist/room/room.d.ts +107 -0
- package/dist/room/room.js +833 -0
- package/dist/sdk/briyah-config.d.ts +13 -0
- package/dist/sdk/briyah-config.js +32 -0
- package/dist/sdk/briyah.d.ts +36 -0
- package/dist/sdk/briyah.js +122 -0
- package/dist/sdk/index.d.ts +6 -0
- package/dist/sdk/index.js +11 -0
- package/dist/server/src/ai/LLM/anthropic.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/anthropic.module.js +21 -0
- package/dist/server/src/ai/LLM/anthropic.service.d.ts +27 -0
- package/dist/server/src/ai/LLM/anthropic.service.js +329 -0
- package/dist/server/src/ai/LLM/base-ai.service.d.ts +45 -0
- package/dist/server/src/ai/LLM/base-ai.service.js +409 -0
- package/dist/server/src/ai/LLM/deepseek.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/deepseek.module.js +21 -0
- package/dist/server/src/ai/LLM/deepseek.service.d.ts +15 -0
- package/dist/server/src/ai/LLM/deepseek.service.js +279 -0
- package/dist/server/src/ai/LLM/fal.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/fal.module.js +21 -0
- package/dist/server/src/ai/LLM/fal.service.d.ts +17 -0
- package/dist/server/src/ai/LLM/fal.service.js +314 -0
- package/dist/server/src/ai/LLM/googleai.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/googleai.module.js +21 -0
- package/dist/server/src/ai/LLM/googleai.service.d.ts +20 -0
- package/dist/server/src/ai/LLM/googleai.service.js +271 -0
- package/dist/server/src/ai/LLM/grok.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/grok.module.js +21 -0
- package/dist/server/src/ai/LLM/grok.service.d.ts +14 -0
- package/dist/server/src/ai/LLM/grok.service.js +263 -0
- package/dist/server/src/ai/LLM/mock.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/mock.module.js +21 -0
- package/dist/server/src/ai/LLM/mock.service.d.ts +13 -0
- package/dist/server/src/ai/LLM/mock.service.js +194 -0
- package/dist/server/src/ai/LLM/openai.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/openai.module.js +21 -0
- package/dist/server/src/ai/LLM/openai.service.d.ts +21 -0
- package/dist/server/src/ai/LLM/openai.service.js +421 -0
- package/dist/server/src/ai/LLM/together.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/together.module.js +21 -0
- package/dist/server/src/ai/LLM/together.service.d.ts +18 -0
- package/dist/server/src/ai/LLM/together.service.js +285 -0
- package/dist/server/src/ai/LLM/vertexai.module.d.ts +2 -0
- package/dist/server/src/ai/LLM/vertexai.module.js +21 -0
- package/dist/server/src/ai/LLM/vertexai.service.d.ts +17 -0
- package/dist/server/src/ai/LLM/vertexai.service.js +323 -0
- package/dist/server/src/ai/agent-config.d.ts +32 -0
- package/dist/server/src/ai/agent-config.js +2 -0
- package/dist/server/src/ai/agent-factory.d.ts +15 -0
- package/dist/server/src/ai/agent-factory.js +24 -0
- package/dist/server/src/ai/agent-message.service.d.ts +9 -0
- package/dist/server/src/ai/agent-message.service.js +56 -0
- package/dist/server/src/ai/agent-store.module.d.ts +2 -0
- package/dist/server/src/ai/agent-store.module.js +21 -0
- package/dist/server/src/ai/agent-store.service.d.ts +31 -0
- package/dist/server/src/ai/agent-store.service.js +352 -0
- package/dist/server/src/ai/agent.d.ts +75 -0
- package/dist/server/src/ai/agent.js +174 -0
- package/dist/server/src/ai/ai-factory.module.d.ts +2 -0
- package/dist/server/src/ai/ai-factory.module.js +40 -0
- package/dist/server/src/ai/ai-factory.service.d.ts +24 -0
- package/dist/server/src/ai/ai-factory.service.js +94 -0
- package/dist/server/src/ai/artifact.module.d.ts +2 -0
- package/dist/server/src/ai/artifact.module.js +22 -0
- package/dist/server/src/ai/artifact.service.d.ts +21 -0
- package/dist/server/src/ai/artifact.service.js +239 -0
- package/dist/server/src/ai/attached-file.module.d.ts +2 -0
- package/dist/server/src/ai/attached-file.module.js +22 -0
- package/dist/server/src/ai/attached-file.service.d.ts +35 -0
- package/dist/server/src/ai/attached-file.service.js +253 -0
- package/dist/server/src/ai/model_prices.d.ts +2 -0
- package/dist/server/src/ai/model_prices.js +54 -0
- package/dist/server/src/ai/published-agents.service.d.ts +13 -0
- package/dist/server/src/ai/published-agents.service.js +118 -0
- package/dist/server/src/app/balance-message.service.d.ts +8 -0
- package/dist/server/src/app/balance-message.service.js +45 -0
- package/dist/server/src/app/balance.module.d.ts +2 -0
- package/dist/server/src/app/balance.module.js +20 -0
- package/dist/server/src/app/balance.service.d.ts +18 -0
- package/dist/server/src/app/balance.service.js +158 -0
- package/dist/server/src/app/stripe.controller.d.ts +31 -0
- package/dist/server/src/app/stripe.controller.js +148 -0
- package/dist/server/src/app/stripe.module.d.ts +2 -0
- package/dist/server/src/app/stripe.module.js +22 -0
- package/dist/server/src/app/stripe.service.d.ts +28 -0
- package/dist/server/src/app/stripe.service.js +198 -0
- package/dist/server/src/app/transaction.service.d.ts +15 -0
- package/dist/server/src/app/transaction.service.js +139 -0
- package/dist/server/src/app/user-service-factory.d.ts +21 -0
- package/dist/server/src/app/user-service-factory.js +81 -0
- package/dist/server/src/app/user-service-manager.d.ts +28 -0
- package/dist/server/src/app/user-service-manager.js +102 -0
- package/dist/server/src/app.controller.d.ts +232 -0
- package/dist/server/src/app.controller.js +2534 -0
- package/dist/server/src/app.module.d.ts +2 -0
- package/dist/server/src/app.module.js +45 -0
- package/dist/server/src/app.service.d.ts +186 -0
- package/dist/server/src/app.service.js +1334 -0
- package/dist/server/src/auth/agent-access.decorator.d.ts +2 -0
- package/dist/server/src/auth/agent-access.decorator.js +10 -0
- package/dist/server/src/auth/auth.controller.d.ts +38 -0
- package/dist/server/src/auth/auth.controller.js +356 -0
- package/dist/server/src/auth/auth.module.d.ts +2 -0
- package/dist/server/src/auth/auth.module.js +55 -0
- package/dist/server/src/auth/auth.service.d.ts +14 -0
- package/dist/server/src/auth/auth.service.js +84 -0
- package/dist/server/src/auth/dto/bot-login.dto.d.ts +4 -0
- package/dist/server/src/auth/dto/bot-login.dto.js +2 -0
- package/dist/server/src/auth/dto/password-reset.dto.d.ts +11 -0
- package/dist/server/src/auth/dto/password-reset.dto.js +2 -0
- package/dist/server/src/auth/dto/phone-login.dto.d.ts +8 -0
- package/dist/server/src/auth/dto/phone-login.dto.js +2 -0
- package/dist/server/src/auth/dto/phone-verification.dto.d.ts +9 -0
- package/dist/server/src/auth/dto/phone-verification.dto.js +2 -0
- package/dist/server/src/auth/jwt-auth.guard.d.ts +13 -0
- package/dist/server/src/auth/jwt-auth.guard.js +143 -0
- package/dist/server/src/auth/jwt.strategy.d.ts +17 -0
- package/dist/server/src/auth/jwt.strategy.js +45 -0
- package/dist/server/src/auth/phone-validation.service.d.ts +7 -0
- package/dist/server/src/auth/phone-validation.service.js +50 -0
- package/dist/server/src/auth/public.decorator.d.ts +2 -0
- package/dist/server/src/auth/public.decorator.js +7 -0
- package/dist/server/src/auth/rate-limit.service.d.ts +16 -0
- package/dist/server/src/auth/rate-limit.service.js +84 -0
- package/dist/server/src/auth/room-access.decorator.d.ts +2 -0
- package/dist/server/src/auth/room-access.decorator.js +10 -0
- package/dist/server/src/auth/scopes.decorator.d.ts +2 -0
- package/dist/server/src/auth/scopes.decorator.js +7 -0
- package/dist/server/src/auth/scopes.guard.d.ts +9 -0
- package/dist/server/src/auth/scopes.guard.js +82 -0
- package/dist/server/src/auth/session.guard.d.ts +7 -0
- package/dist/server/src/auth/session.guard.js +55 -0
- package/dist/server/src/auth/twilio.service.d.ts +15 -0
- package/dist/server/src/auth/twilio.service.js +139 -0
- package/dist/server/src/auth/users.service.d.ts +24 -0
- package/dist/server/src/auth/users.service.js +149 -0
- package/dist/server/src/common/errors.d.ts +12 -0
- package/dist/server/src/common/errors.js +43 -0
- package/dist/server/src/config/configuration.module.d.ts +2 -0
- package/dist/server/src/config/configuration.module.js +20 -0
- package/dist/server/src/config/configuration.service.d.ts +26 -0
- package/dist/server/src/config/configuration.service.js +131 -0
- package/dist/server/src/room/artifact-store.service.d.ts +15 -0
- package/dist/server/src/room/artifact-store.service.js +226 -0
- package/dist/server/src/room/artifact.d.ts +6 -0
- package/dist/server/src/room/artifact.js +2 -0
- package/dist/server/src/room/message.d.ts +19 -0
- package/dist/server/src/room/message.js +70 -0
- package/dist/server/src/room/published-rooms.service.d.ts +12 -0
- package/dist/server/src/room/published-rooms.service.js +108 -0
- package/dist/server/src/room/room-config.d.ts +12 -0
- package/dist/server/src/room/room-config.js +2 -0
- package/dist/server/src/room/room-factory.d.ts +7 -0
- package/dist/server/src/room/room-factory.js +16 -0
- package/dist/server/src/room/room-message.module.d.ts +2 -0
- package/dist/server/src/room/room-message.module.js +21 -0
- package/dist/server/src/room/room-message.service.d.ts +8 -0
- package/dist/server/src/room/room-message.service.js +44 -0
- package/dist/server/src/room/room-store.module.d.ts +2 -0
- package/dist/server/src/room/room-store.module.js +25 -0
- package/dist/server/src/room/room-store.service.d.ts +38 -0
- package/dist/server/src/room/room-store.service.js +353 -0
- package/dist/server/src/room/room.d.ts +107 -0
- package/dist/server/src/room/room.js +833 -0
- package/dist/server/src/sdk/briyah-config.d.ts +13 -0
- package/dist/server/src/sdk/briyah-config.js +32 -0
- package/dist/server/src/sdk/briyah.d.ts +36 -0
- package/dist/server/src/sdk/briyah.js +122 -0
- package/dist/server/src/sdk/index.d.ts +6 -0
- package/dist/server/src/sdk/index.js +11 -0
- package/dist/server/src/shared/shared.module.d.ts +2 -0
- package/dist/server/src/shared/shared.module.js +46 -0
- package/dist/server/src/story/story-message.service.d.ts +10 -0
- package/dist/server/src/story/story-message.service.js +57 -0
- package/dist/server/src/story/story-progress.service.d.ts +8 -0
- package/dist/server/src/story/story-progress.service.js +44 -0
- package/dist/server/src/story/story-store.module.d.ts +2 -0
- package/dist/server/src/story/story-store.module.js +22 -0
- package/dist/server/src/story/story-store.service.d.ts +23 -0
- package/dist/server/src/story/story-store.service.js +392 -0
- package/dist/server/src/story/story.service.d.ts +94 -0
- package/dist/server/src/story/story.service.js +1797 -0
- package/dist/shared/shared.module.d.ts +2 -0
- package/dist/shared/shared.module.js +46 -0
- package/dist/shared/types/app.types.d.ts +296 -0
- package/dist/shared/types/app.types.js +17 -0
- package/dist/story/story-message.service.d.ts +10 -0
- package/dist/story/story-message.service.js +57 -0
- package/dist/story/story-progress.service.d.ts +8 -0
- package/dist/story/story-progress.service.js +44 -0
- package/dist/story/story-store.module.d.ts +2 -0
- package/dist/story/story-store.module.js +22 -0
- package/dist/story/story-store.service.d.ts +23 -0
- package/dist/story/story-store.service.js +392 -0
- package/dist/story/story.service.d.ts +94 -0
- package/dist/story/story.service.js +1797 -0
- package/eslint.config.js +29 -0
- package/package.json +125 -0
|
@@ -0,0 +1,2536 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.AppController = void 0;
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const platform_express_1 = require("@nestjs/platform-express");
|
|
52
|
+
const rxjs_1 = require("rxjs");
|
|
53
|
+
const jwt_auth_guard_1 = require("./auth/jwt-auth.guard");
|
|
54
|
+
const agent_access_decorator_1 = require("./auth/agent-access.decorator");
|
|
55
|
+
const room_access_decorator_1 = require("./auth/room-access.decorator");
|
|
56
|
+
const user_service_manager_1 = require("./app/user-service-manager");
|
|
57
|
+
const published_agents_service_1 = require("./ai/published-agents.service");
|
|
58
|
+
const published_rooms_service_1 = require("./room/published-rooms.service");
|
|
59
|
+
const errors_1 = require("./common/errors");
|
|
60
|
+
const app_types_1 = require("@shared/types/app.types");
|
|
61
|
+
const path = __importStar(require("path"));
|
|
62
|
+
let AppController = class AppController {
|
|
63
|
+
userServiceManager;
|
|
64
|
+
publishedAgentsService;
|
|
65
|
+
publishedRoomsService;
|
|
66
|
+
constructor(userServiceManager, publishedAgentsService, publishedRoomsService) {
|
|
67
|
+
this.userServiceManager = userServiceManager;
|
|
68
|
+
this.publishedAgentsService = publishedAgentsService;
|
|
69
|
+
this.publishedRoomsService = publishedRoomsService;
|
|
70
|
+
}
|
|
71
|
+
getAppService(req, agentId, roomId) {
|
|
72
|
+
let userId;
|
|
73
|
+
const authSource = req.user?.authSource;
|
|
74
|
+
if (req.user && req.user.sub) {
|
|
75
|
+
userId = req.user.sub;
|
|
76
|
+
}
|
|
77
|
+
else if (agentId) {
|
|
78
|
+
userId = this.publishedAgentsService.getUserId(agentId);
|
|
79
|
+
if (!userId) {
|
|
80
|
+
throw new common_1.NotFoundException(`Agent ${agentId} is not published or does not exist`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (roomId) {
|
|
84
|
+
userId = this.publishedRoomsService.getUserId(roomId);
|
|
85
|
+
if (!userId) {
|
|
86
|
+
throw new common_1.NotFoundException(`Room ${roomId} is not published or does not exist`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (req.user && req.user.username) {
|
|
90
|
+
userId = req.user.username;
|
|
91
|
+
}
|
|
92
|
+
return this.userServiceManager.getAppService(userId);
|
|
93
|
+
}
|
|
94
|
+
listServices(req) {
|
|
95
|
+
const appService = this.getAppService(req);
|
|
96
|
+
return appService.getAiServiceNames();
|
|
97
|
+
}
|
|
98
|
+
async listModels(req, aiServiceName) {
|
|
99
|
+
try {
|
|
100
|
+
const appService = this.getAppService(req);
|
|
101
|
+
return await appService.listAiModels(aiServiceName);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.error(`[${req.user?.sub}] Error listing models for ${aiServiceName}:`, error);
|
|
105
|
+
throw new common_1.HttpException('Failed to list models', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
listImageModels(req) {
|
|
109
|
+
try {
|
|
110
|
+
const appService = this.getAppService(req);
|
|
111
|
+
return appService.listImageModels();
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.error('Error reading image models:', error);
|
|
115
|
+
throw new common_1.HttpException('Failed to list image models', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
listStoryModels(req) {
|
|
119
|
+
try {
|
|
120
|
+
const appService = this.getAppService(req);
|
|
121
|
+
return appService.listStoryModels();
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('Error reading story models:', error);
|
|
125
|
+
throw new common_1.HttpException('Failed to list story models', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
listStoryModelDefaults(_req) {
|
|
129
|
+
return {
|
|
130
|
+
selectedStoryModel: process.env.DEFAULT_STORY_MODEL,
|
|
131
|
+
selectedImageModel: process.env.DEFAULT_IMAGE_MODEL,
|
|
132
|
+
enforceDefaultModels: process.env.ENFORCE_DEFAULT_MODELS === 'true',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
async createAgent(req, body) {
|
|
136
|
+
if (!body.aiServiceName || !body.aiModel || !body.agentName) {
|
|
137
|
+
throw new common_1.BadRequestException('AI service name, AI Model, and agent name are required');
|
|
138
|
+
}
|
|
139
|
+
if (!body.agentName?.trim()) {
|
|
140
|
+
throw new common_1.BadRequestException('Agent name cannot be empty');
|
|
141
|
+
}
|
|
142
|
+
if (body.agentName.length > 200) {
|
|
143
|
+
throw new common_1.BadRequestException('Agent name too long');
|
|
144
|
+
}
|
|
145
|
+
const appService = this.getAppService(req);
|
|
146
|
+
const agent = appService.createAgent(body.aiServiceName, body.agentName, body.agentNickname, body.description, body.aiModel, body.promptName, body.controlledByHuman, body.reasoningEffort, body.maxOutputTokens, body.beginInstruction);
|
|
147
|
+
if (!agent) {
|
|
148
|
+
throw new common_1.HttpException('Failed to create agent', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
149
|
+
}
|
|
150
|
+
agent.save();
|
|
151
|
+
return { agentId: agent.id };
|
|
152
|
+
}
|
|
153
|
+
async processText(req, agentId, body) {
|
|
154
|
+
if (!agentId) {
|
|
155
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
156
|
+
}
|
|
157
|
+
if (!body.text) {
|
|
158
|
+
throw new common_1.BadRequestException('Text is required');
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const appService = this.getAppService(req, agentId);
|
|
162
|
+
if (req.user.type === 'agent-access') {
|
|
163
|
+
const agentDetails = await appService.getAgentDetails(agentId);
|
|
164
|
+
if (!agentDetails || !agentDetails.isPublished) {
|
|
165
|
+
throw new common_1.ForbiddenException('Agent is not published');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return await appService.processText(agentId, body.text);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (error instanceof common_1.ForbiddenException || error instanceof common_1.BadRequestException) {
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
console.error(`[${req.user?.sub}] Error processing text for agent ${agentId}:`, error);
|
|
175
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
176
|
+
return {
|
|
177
|
+
result: `Error: ${error.message}`,
|
|
178
|
+
latestMessage: undefined,
|
|
179
|
+
messageIndex: undefined,
|
|
180
|
+
totalInputTokens: 0,
|
|
181
|
+
totalOutputTokens: 0,
|
|
182
|
+
totalCost: 0,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
throw new common_1.HttpException(`Failed to process text: ${error.message}`, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async attachDocument(req, agentId, body, file) {
|
|
189
|
+
if (!agentId) {
|
|
190
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
191
|
+
}
|
|
192
|
+
const MAX_FILE_SIZE = 50 * 1024 * 1024;
|
|
193
|
+
if (file && file.size > MAX_FILE_SIZE) {
|
|
194
|
+
throw new common_1.HttpException('File too large', common_1.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
195
|
+
}
|
|
196
|
+
const appService = this.getAppService(req);
|
|
197
|
+
let fileName = file?.originalname || 'attach_file';
|
|
198
|
+
if (body.fileName && body.fileName !== '') {
|
|
199
|
+
fileName = body.fileName;
|
|
200
|
+
}
|
|
201
|
+
fileName = path.basename(fileName).replace(/[^a-zA-Z0-9._-]/g, '_');
|
|
202
|
+
try {
|
|
203
|
+
const result = await appService.attachDocument(agentId, fileName, file.buffer);
|
|
204
|
+
return {
|
|
205
|
+
...result,
|
|
206
|
+
filename: fileName,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
console.error(`[${req.user?.sub}] Error attaching document to agent ${agentId}:`, error);
|
|
211
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
212
|
+
throw new common_1.NotFoundException(error.message);
|
|
213
|
+
}
|
|
214
|
+
if (error.message?.includes('not found')) {
|
|
215
|
+
throw new common_1.NotFoundException(error.message);
|
|
216
|
+
}
|
|
217
|
+
throw new common_1.HttpException('Failed to attach document', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async listAttachedFiles(req, agentId) {
|
|
221
|
+
try {
|
|
222
|
+
const appService = this.getAppService(req);
|
|
223
|
+
return appService.listAttachedFiles(agentId);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
console.error(`[${req.user?.sub}] Error listing attached files for agent ${agentId}:`, error);
|
|
227
|
+
return { files: [] };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
getPrompts(req, scope) {
|
|
231
|
+
try {
|
|
232
|
+
const appService = this.getAppService(req);
|
|
233
|
+
return appService.listPromptFoldersWithScope(scope);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
console.error(`[${req.user?.sub}] Error listing prompt folders:`, error);
|
|
237
|
+
return { folders: [] };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async createPromptFolder(req, body) {
|
|
241
|
+
if (!body.name) {
|
|
242
|
+
throw new common_1.BadRequestException('Folder name is required');
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const appService = this.getAppService(req);
|
|
246
|
+
appService.createPromptFolder(body.name);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
console.error(`[${req.user?.sub}] Error creating prompt folder ${body.name}:`, error);
|
|
250
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
251
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
252
|
+
}
|
|
253
|
+
throw new common_1.HttpException('Failed to create prompt folder', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async deletePromptFolder(req, folderName) {
|
|
257
|
+
try {
|
|
258
|
+
const appService = this.getAppService(req);
|
|
259
|
+
appService.deletePromptFolder(folderName);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
console.error(`[${req.user?.sub}] Error deleting prompt folder ${folderName}:`, error);
|
|
263
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
264
|
+
throw new common_1.NotFoundException(error.message);
|
|
265
|
+
}
|
|
266
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
267
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
268
|
+
}
|
|
269
|
+
throw new common_1.HttpException('Failed to delete prompt folder', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async getPromptFiles(req, folderName) {
|
|
273
|
+
try {
|
|
274
|
+
const appService = this.getAppService(req);
|
|
275
|
+
return appService.listPromptFilesWithScope(folderName);
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
console.error(`[${req.user?.sub}] Error listing prompt files for folder ${folderName}:`, error);
|
|
279
|
+
return { files: [] };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async getPromptFile(req, folderName, fileName) {
|
|
283
|
+
try {
|
|
284
|
+
const appService = this.getAppService(req);
|
|
285
|
+
return appService.getPromptFile(folderName, fileName);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
console.error(`[${req.user?.sub}] Error getting prompt file ${folderName}/${fileName}:`, error);
|
|
289
|
+
return { content: '' };
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
async createPromptFile(req, folderName, body) {
|
|
293
|
+
if (!body.name) {
|
|
294
|
+
throw new common_1.BadRequestException('File name is required');
|
|
295
|
+
}
|
|
296
|
+
if (body.content === undefined) {
|
|
297
|
+
throw new common_1.BadRequestException('File content is required');
|
|
298
|
+
}
|
|
299
|
+
if (!body.fileType) {
|
|
300
|
+
throw new common_1.BadRequestException('File type is required');
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
const appService = this.getAppService(req);
|
|
304
|
+
appService.savePromptFile(folderName, body.name, body.content, body.fileType);
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
console.error(`[${req.user?.sub}] Error creating prompt file ${folderName}/${body.name}:`, error);
|
|
308
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
309
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
310
|
+
}
|
|
311
|
+
throw new common_1.HttpException('Failed to create prompt file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
async updatePromptFile(req, folderName, fileName, body) {
|
|
315
|
+
if (body.content === undefined) {
|
|
316
|
+
throw new common_1.BadRequestException('File content is required');
|
|
317
|
+
}
|
|
318
|
+
if (!body.fileType) {
|
|
319
|
+
throw new common_1.BadRequestException('File type is required');
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const appService = this.getAppService(req);
|
|
323
|
+
appService.savePromptFile(folderName, fileName, body.content, body.fileType);
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
console.error(`[${req.user?.sub}] Error updating prompt file ${folderName}/${fileName}:`, error);
|
|
327
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
328
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
329
|
+
}
|
|
330
|
+
throw new common_1.HttpException('Failed to update prompt file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async deletePromptFile(req, folderName, fileName) {
|
|
334
|
+
try {
|
|
335
|
+
const appService = this.getAppService(req);
|
|
336
|
+
appService.deletePromptFile(folderName, fileName);
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
console.error(`[${req.user?.sub}] Error deleting prompt file ${folderName}/${fileName}:`, error);
|
|
340
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
341
|
+
throw new common_1.NotFoundException(error.message);
|
|
342
|
+
}
|
|
343
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
344
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
345
|
+
}
|
|
346
|
+
throw new common_1.HttpException('Failed to delete prompt file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
listPromptFolders(req) {
|
|
350
|
+
try {
|
|
351
|
+
const appService = this.getAppService(req);
|
|
352
|
+
return appService.listPromptFolders();
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
console.error(`[${req.user?.sub}] Error listing prompt folders:`, error);
|
|
356
|
+
return [];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
listPrompts(req, agentId) {
|
|
360
|
+
try {
|
|
361
|
+
const appService = this.getAppService(req);
|
|
362
|
+
return appService.listPrompts(agentId);
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
console.error(`[${req.user?.sub}] Error listing prompts for agent ${agentId}:`, error);
|
|
366
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
367
|
+
throw new common_1.NotFoundException(error.message);
|
|
368
|
+
}
|
|
369
|
+
return [];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async runPreparedPrompt(req, agentId, promptName, body) {
|
|
373
|
+
if (!agentId) {
|
|
374
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
375
|
+
}
|
|
376
|
+
if (!promptName) {
|
|
377
|
+
throw new common_1.BadRequestException('Prompt name is required');
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
const appService = this.getAppService(req);
|
|
381
|
+
return await appService.runPreparedPrompt(agentId, promptName, body.variables);
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
console.error(`[${req.user?.sub}] Error running prepared prompt for agent ${agentId}:`, error);
|
|
385
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
386
|
+
throw new common_1.NotFoundException(error.message);
|
|
387
|
+
}
|
|
388
|
+
throw new common_1.HttpException('Failed to run prepared prompt', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async listAgents(req, published) {
|
|
392
|
+
try {
|
|
393
|
+
const appService = this.getAppService(req);
|
|
394
|
+
if (published === 'true') {
|
|
395
|
+
return await appService.listPublishedAgents();
|
|
396
|
+
}
|
|
397
|
+
return await appService.listAgents();
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
console.error(`[${req.user?.sub}] Error listing agents:`, error);
|
|
401
|
+
return [];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async createRoom(req, body) {
|
|
405
|
+
if (!body.roomName) {
|
|
406
|
+
throw new common_1.BadRequestException('Room name is required');
|
|
407
|
+
}
|
|
408
|
+
if (!body.agentIds || body.agentIds.length === 0) {
|
|
409
|
+
throw new common_1.BadRequestException('At least one agent ID is required');
|
|
410
|
+
}
|
|
411
|
+
if (!body.roomName?.trim()) {
|
|
412
|
+
throw new common_1.BadRequestException('Room name cannot be empty');
|
|
413
|
+
}
|
|
414
|
+
if (body.roomName.length > 200) {
|
|
415
|
+
throw new common_1.BadRequestException('Room name too long');
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
const appService = this.getAppService(req);
|
|
419
|
+
return await appService.createRoom(body.roomName, body.roomGoal, body.agentIds);
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
console.error(`[${req.user?.sub}] Error creating room ${body.roomName}:`, error);
|
|
423
|
+
throw new common_1.HttpException(error.message || 'Failed to create room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
async editRoom(req, roomId, body) {
|
|
427
|
+
try {
|
|
428
|
+
const appService = this.getAppService(req);
|
|
429
|
+
await appService.editRoom(roomId, body.roomName, body.roomGoal, body.baseRoomDir, body.agentIds);
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
console.error(`[${req.user?.sub}] Error editing room ${roomId}:`, error);
|
|
433
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
434
|
+
throw new common_1.NotFoundException(error.message);
|
|
435
|
+
}
|
|
436
|
+
throw new common_1.HttpException('Failed to edit room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
listRooms(req) {
|
|
440
|
+
try {
|
|
441
|
+
const appService = this.getAppService(req);
|
|
442
|
+
return appService.listRooms();
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
console.error(`[${req.user?.sub}] Error listing rooms:`, error);
|
|
446
|
+
return [];
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async getRoomDetails(req, roomId) {
|
|
450
|
+
try {
|
|
451
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
452
|
+
const roomDetails = await appService.getRoomDetails(roomId);
|
|
453
|
+
if (!roomDetails) {
|
|
454
|
+
throw new common_1.NotFoundException('Room not found');
|
|
455
|
+
}
|
|
456
|
+
return roomDetails;
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
console.error(`[${req.user?.sub}] Error getting room details for ${roomId}:`, error);
|
|
460
|
+
if (error instanceof common_1.NotFoundException) {
|
|
461
|
+
throw error;
|
|
462
|
+
}
|
|
463
|
+
throw new common_1.HttpException('Failed to get room details', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async getAgentDetails(req, agentId) {
|
|
467
|
+
try {
|
|
468
|
+
const appService = this.getAppService(req, agentId);
|
|
469
|
+
const agentDetails = await appService.getAgentDetails(agentId);
|
|
470
|
+
if (!agentDetails) {
|
|
471
|
+
throw new common_1.NotFoundException('Agent not found');
|
|
472
|
+
}
|
|
473
|
+
if (req.user.type === 'agent-access' && !agentDetails.isPublished) {
|
|
474
|
+
throw new common_1.ForbiddenException('Agent is not published');
|
|
475
|
+
}
|
|
476
|
+
return agentDetails;
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
console.error(`[${req.user?.sub}] Error getting agent details for ${agentId}:`, error);
|
|
480
|
+
if (error instanceof common_1.NotFoundException || error instanceof common_1.ForbiddenException) {
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
throw new common_1.HttpException('Failed to get agent details', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
getRoomMessages(req, roomId, fromIndex, showThoughts) {
|
|
487
|
+
try {
|
|
488
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
489
|
+
const index = parseInt(fromIndex, 10) || 0;
|
|
490
|
+
const includeThoughts = showThoughts === 'true';
|
|
491
|
+
return appService.getRoomMessages(roomId, index, includeThoughts);
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
console.error(`[${req.user?.sub}] Error getting room messages for ${roomId}:`, error);
|
|
495
|
+
return { messages: [], totalCost: 0 };
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async getAgentMessages(req, agentId, fromIndex) {
|
|
499
|
+
try {
|
|
500
|
+
const appService = this.getAppService(req, agentId);
|
|
501
|
+
if (req.user.type === 'agent-access') {
|
|
502
|
+
const agentDetails = await appService.getAgentDetails(agentId);
|
|
503
|
+
if (!agentDetails || !agentDetails.isPublished) {
|
|
504
|
+
throw new common_1.ForbiddenException('Agent is not published');
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const index = parseInt(fromIndex, 10) || 0;
|
|
508
|
+
return await appService.getAgentMessages(agentId, index);
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
console.error(`[${req.user?.sub}] Error getting agent messages for ${agentId}:`, error);
|
|
512
|
+
if (error instanceof common_1.ForbiddenException) {
|
|
513
|
+
throw error;
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
messages: [],
|
|
517
|
+
totalInputTokens: 0,
|
|
518
|
+
totalOutputTokens: 0,
|
|
519
|
+
totalCost: 0,
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
getStoryMessages(req, storyId, fromIndex) {
|
|
524
|
+
try {
|
|
525
|
+
const appService = this.getAppService(req);
|
|
526
|
+
const index = parseInt(fromIndex, 10) || 0;
|
|
527
|
+
return appService.getStoryMessages(storyId, index);
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
console.error(`[${req.user?.sub}] Error getting story messages for ${storyId}:`, error);
|
|
531
|
+
return { messages: [], totalCost: 0 };
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
async deleteAgent(req, agentId) {
|
|
535
|
+
if (!agentId) {
|
|
536
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
const appService = this.getAppService(req);
|
|
540
|
+
await appService.deleteAgent(agentId);
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
console.error(`[${req.user?.sub}] Error deleting agent ${agentId}:`, error);
|
|
544
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
545
|
+
throw new common_1.NotFoundException(error.message);
|
|
546
|
+
}
|
|
547
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
548
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
549
|
+
}
|
|
550
|
+
throw new common_1.HttpException('Failed to delete agent', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async publishAgentInstance(req, agentId, body) {
|
|
554
|
+
if (!agentId) {
|
|
555
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
556
|
+
}
|
|
557
|
+
if (!body.publishedAgentName) {
|
|
558
|
+
throw new common_1.BadRequestException('publishedAgentName field is required');
|
|
559
|
+
}
|
|
560
|
+
try {
|
|
561
|
+
const appService = this.getAppService(req);
|
|
562
|
+
const result = await appService.publishAgentInstance(agentId, body.publishedAgentName);
|
|
563
|
+
return result;
|
|
564
|
+
}
|
|
565
|
+
catch (error) {
|
|
566
|
+
console.error(`[${req.user?.sub}] Error publishing agent instance for ${agentId}:`, error);
|
|
567
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
568
|
+
throw new common_1.NotFoundException(error.message);
|
|
569
|
+
}
|
|
570
|
+
throw new common_1.HttpException('Failed to publish agent instance', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
async getPublishedInstances(req, agentId) {
|
|
574
|
+
if (!agentId) {
|
|
575
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
576
|
+
}
|
|
577
|
+
try {
|
|
578
|
+
const appService = this.getAppService(req);
|
|
579
|
+
return await appService.getPublishedInstances(agentId);
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
console.error(`[${req.user?.sub}] Error getting published instances for ${agentId}:`, error);
|
|
583
|
+
throw new common_1.HttpException('Failed to get published instances', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
async resetPublishedInstance(req, instanceId) {
|
|
587
|
+
if (!instanceId) {
|
|
588
|
+
throw new common_1.BadRequestException('Instance ID is required');
|
|
589
|
+
}
|
|
590
|
+
try {
|
|
591
|
+
const appService = this.getAppService(req);
|
|
592
|
+
await appService.resetPublishedInstance(instanceId);
|
|
593
|
+
}
|
|
594
|
+
catch (error) {
|
|
595
|
+
console.error(`[${req.user?.sub}] Error resetting published instance ${instanceId}:`, error);
|
|
596
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
597
|
+
throw new common_1.NotFoundException(error.message);
|
|
598
|
+
}
|
|
599
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
600
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
601
|
+
}
|
|
602
|
+
throw new common_1.HttpException('Failed to reset published instance', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
async deleteRoom(req, roomId) {
|
|
606
|
+
if (!roomId) {
|
|
607
|
+
throw new common_1.BadRequestException('Room ID is required');
|
|
608
|
+
}
|
|
609
|
+
try {
|
|
610
|
+
const appService = this.getAppService(req);
|
|
611
|
+
await appService.deleteRoom(roomId);
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
console.error(`[${req.user?.sub}] Error deleting room ${roomId}:`, error);
|
|
615
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
616
|
+
throw new common_1.NotFoundException(error.message);
|
|
617
|
+
}
|
|
618
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
619
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
620
|
+
}
|
|
621
|
+
throw new common_1.HttpException('Failed to delete room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
async sendRoomMessage(req, roomId, body) {
|
|
625
|
+
if (!body.content?.trim()) {
|
|
626
|
+
throw new common_1.BadRequestException('Message content cannot be empty');
|
|
627
|
+
}
|
|
628
|
+
if (body.content.length > 50000) {
|
|
629
|
+
throw new common_1.BadRequestException('Message too long');
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
633
|
+
await appService.sendRoomMessage(roomId, body.content, body.sender, body.action, body.targets, body.clearQueue || false);
|
|
634
|
+
}
|
|
635
|
+
catch (error) {
|
|
636
|
+
console.error(`[${req.user?.sub}] Error sending room message to ${roomId}:`, error);
|
|
637
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
638
|
+
throw new common_1.NotFoundException(error.message);
|
|
639
|
+
}
|
|
640
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
641
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
642
|
+
}
|
|
643
|
+
if (error instanceof common_1.NotFoundException || error instanceof common_1.BadRequestException) {
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
throw new common_1.HttpException('Failed to send room message', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
async pauseRoom(req, roomId) {
|
|
650
|
+
try {
|
|
651
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
652
|
+
await appService.pauseRoom(roomId);
|
|
653
|
+
return { success: true };
|
|
654
|
+
}
|
|
655
|
+
catch (error) {
|
|
656
|
+
console.error(`[${req.user?.sub}] Error pausing room ${roomId}:`, error);
|
|
657
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
658
|
+
throw new common_1.NotFoundException(error.message);
|
|
659
|
+
}
|
|
660
|
+
throw new common_1.HttpException('Failed to pause room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
async resumeRoom(req, roomId) {
|
|
664
|
+
try {
|
|
665
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
666
|
+
await appService.resumeRoom(roomId);
|
|
667
|
+
return { success: true };
|
|
668
|
+
}
|
|
669
|
+
catch (error) {
|
|
670
|
+
console.error(`[${req.user?.sub}] Error resuming room ${roomId}:`, error);
|
|
671
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
672
|
+
throw new common_1.NotFoundException(error.message);
|
|
673
|
+
}
|
|
674
|
+
throw new common_1.HttpException('Failed to resume room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
async getUserPreferences(req) {
|
|
678
|
+
try {
|
|
679
|
+
const appService = this.getAppService(req);
|
|
680
|
+
return appService.getUserPreferences();
|
|
681
|
+
}
|
|
682
|
+
catch (error) {
|
|
683
|
+
console.error(`[${req.user?.sub}] Error getting user preferences:`, error);
|
|
684
|
+
return {};
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
async saveUserPreferences(req, preferences) {
|
|
688
|
+
try {
|
|
689
|
+
const appService = this.getAppService(req);
|
|
690
|
+
appService.saveUserPreferences(preferences);
|
|
691
|
+
}
|
|
692
|
+
catch (error) {
|
|
693
|
+
console.error(`[${req.user?.sub}] Error saving user preferences:`, error);
|
|
694
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
695
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
696
|
+
}
|
|
697
|
+
throw new common_1.HttpException('Failed to save user preferences', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
async listPromptFilesDeprecated(req, folderName) {
|
|
701
|
+
try {
|
|
702
|
+
const appService = this.getAppService(req);
|
|
703
|
+
return appService.listPromptFiles(folderName);
|
|
704
|
+
}
|
|
705
|
+
catch (error) {
|
|
706
|
+
console.error(`[${req.user?.sub}] Error listing prompt files for folder ${folderName}:`, error);
|
|
707
|
+
return { files: [] };
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
async getPromptFileDeprecated(req, folderName, fileName) {
|
|
711
|
+
try {
|
|
712
|
+
const appService = this.getAppService(req);
|
|
713
|
+
return appService.getPromptFile(folderName, fileName);
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
console.error(`[${req.user?.sub}] Error getting prompt file ${folderName}/${fileName}:`, error);
|
|
717
|
+
return { content: '' };
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
async savePromptFileDeprecated(req, body) {
|
|
721
|
+
try {
|
|
722
|
+
const appService = this.getAppService(req);
|
|
723
|
+
appService.savePromptFile(body.folderName, body.fileName, body.content, body.fileType);
|
|
724
|
+
}
|
|
725
|
+
catch (error) {
|
|
726
|
+
console.error(`[${req.user?.sub}] Error saving prompt file ${body.folderName}/${body.fileName}:`, error);
|
|
727
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
728
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
729
|
+
}
|
|
730
|
+
throw new common_1.HttpException('Failed to save prompt file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
async deletePromptFileDeprecated(req, body) {
|
|
734
|
+
try {
|
|
735
|
+
const appService = this.getAppService(req);
|
|
736
|
+
appService.deletePromptFile(body.folderName, body.fileName);
|
|
737
|
+
}
|
|
738
|
+
catch (error) {
|
|
739
|
+
console.error(`[${req.user?.sub}] Error deleting prompt file ${body.folderName}/${body.fileName}:`, error);
|
|
740
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
741
|
+
throw new common_1.NotFoundException(error.message);
|
|
742
|
+
}
|
|
743
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
744
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
745
|
+
}
|
|
746
|
+
throw new common_1.HttpException('Failed to delete prompt file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
async deletePromptFolderDeprecated(req, body) {
|
|
750
|
+
try {
|
|
751
|
+
const appService = this.getAppService(req);
|
|
752
|
+
appService.deletePromptFolder(body.folderName);
|
|
753
|
+
}
|
|
754
|
+
catch (error) {
|
|
755
|
+
console.error(`[${req.user?.sub}] Error deleting prompt folder ${body.folderName}:`, error);
|
|
756
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
757
|
+
throw new common_1.NotFoundException(error.message);
|
|
758
|
+
}
|
|
759
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
760
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
761
|
+
}
|
|
762
|
+
throw new common_1.HttpException('Failed to delete prompt folder', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
async updateAgent(req, agentId, updateData) {
|
|
766
|
+
try {
|
|
767
|
+
const appService = this.getAppService(req);
|
|
768
|
+
await appService.updateAgent(agentId, updateData);
|
|
769
|
+
}
|
|
770
|
+
catch (error) {
|
|
771
|
+
console.error(`[${req.user?.sub}] Error updating agent ${agentId}:`, error);
|
|
772
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
773
|
+
throw new common_1.NotFoundException(error.message);
|
|
774
|
+
}
|
|
775
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
776
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
777
|
+
}
|
|
778
|
+
throw new common_1.HttpException('Failed to update agent', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
async deleteAttachedFile(req, agentId, documentId) {
|
|
782
|
+
if (!agentId) {
|
|
783
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
784
|
+
}
|
|
785
|
+
if (!documentId) {
|
|
786
|
+
throw new common_1.BadRequestException('Document ID is required');
|
|
787
|
+
}
|
|
788
|
+
try {
|
|
789
|
+
const appService = this.getAppService(req);
|
|
790
|
+
appService.deleteAttachedFileById(documentId);
|
|
791
|
+
}
|
|
792
|
+
catch (error) {
|
|
793
|
+
console.error(`[${req.user?.sub}] Error deleting attached file ${documentId} from agent ${agentId}:`, error);
|
|
794
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
795
|
+
throw new common_1.NotFoundException(error.message);
|
|
796
|
+
}
|
|
797
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
798
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
799
|
+
}
|
|
800
|
+
throw new common_1.HttpException('Failed to delete attached file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async reloadAgent(req, agentId) {
|
|
804
|
+
if (!agentId) {
|
|
805
|
+
throw new common_1.BadRequestException('Agent ID is required');
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
const appService = this.getAppService(req, agentId);
|
|
809
|
+
if (req.user.type === 'agent-access') {
|
|
810
|
+
const agentDetails = await appService.getAgentDetails(agentId);
|
|
811
|
+
if (!agentDetails || !agentDetails.isPublished) {
|
|
812
|
+
throw new common_1.ForbiddenException('Agent is not published');
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
await appService.reloadAgent(agentId);
|
|
816
|
+
}
|
|
817
|
+
catch (error) {
|
|
818
|
+
console.error(`[${req.user?.sub}] Error reloading agent ${agentId}:`, error);
|
|
819
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
820
|
+
throw new common_1.NotFoundException(error.message);
|
|
821
|
+
}
|
|
822
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
823
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
824
|
+
}
|
|
825
|
+
if (error instanceof common_1.ForbiddenException) {
|
|
826
|
+
throw error;
|
|
827
|
+
}
|
|
828
|
+
throw new common_1.HttpException('Failed to reload agent', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async resetRoom(req, roomId) {
|
|
832
|
+
if (!roomId) {
|
|
833
|
+
throw new common_1.BadRequestException('Room ID is required');
|
|
834
|
+
}
|
|
835
|
+
try {
|
|
836
|
+
const appService = this.getAppService(req);
|
|
837
|
+
await appService.resetRoom(roomId);
|
|
838
|
+
}
|
|
839
|
+
catch (error) {
|
|
840
|
+
console.error(`[${req.user?.sub}] Error resetting room ${roomId}:`, error);
|
|
841
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
842
|
+
throw new common_1.NotFoundException(error.message);
|
|
843
|
+
}
|
|
844
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
845
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
846
|
+
}
|
|
847
|
+
throw new common_1.HttpException('Failed to reset room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
async publishRoom(req, templateId, body) {
|
|
851
|
+
try {
|
|
852
|
+
const appService = this.getAppService(req);
|
|
853
|
+
const userId = req.user.sub;
|
|
854
|
+
const instanceId = await appService.publishRoom(templateId, body.publishedName, userId);
|
|
855
|
+
return { roomId: instanceId };
|
|
856
|
+
}
|
|
857
|
+
catch (error) {
|
|
858
|
+
console.error(`[${req.user?.sub}] Error publishing room ${templateId}:`, error);
|
|
859
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
860
|
+
throw new common_1.NotFoundException(error.message);
|
|
861
|
+
}
|
|
862
|
+
throw new common_1.HttpException('Failed to publish room', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
async getPublishedRoomInstances(req, templateId) {
|
|
866
|
+
try {
|
|
867
|
+
const appService = this.getAppService(req);
|
|
868
|
+
return await appService.getPublishedRoomInstances(templateId);
|
|
869
|
+
}
|
|
870
|
+
catch (error) {
|
|
871
|
+
console.error(`[${req.user?.sub}] Error getting published instances for room ${templateId}:`, error);
|
|
872
|
+
throw new common_1.HttpException('Failed to get published instances', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
async resetPublishedRoomInstance(req, instanceId) {
|
|
876
|
+
try {
|
|
877
|
+
const appService = this.getAppService(req);
|
|
878
|
+
await appService.resetPublishedRoomInstance(instanceId);
|
|
879
|
+
}
|
|
880
|
+
catch (error) {
|
|
881
|
+
console.error(`[${req.user?.sub}] Error resetting room instance ${instanceId}:`, error);
|
|
882
|
+
if (error instanceof errors_1.NotFoundError || error instanceof errors_1.OperationFailedError) {
|
|
883
|
+
throw new common_1.NotFoundException(error.message);
|
|
884
|
+
}
|
|
885
|
+
throw new common_1.HttpException('Failed to reset room instance', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
async resetStory(req, storyId) {
|
|
889
|
+
if (!storyId) {
|
|
890
|
+
throw new common_1.BadRequestException('Story ID is required');
|
|
891
|
+
}
|
|
892
|
+
try {
|
|
893
|
+
const appService = this.getAppService(req);
|
|
894
|
+
await appService.resetStory(storyId);
|
|
895
|
+
}
|
|
896
|
+
catch (error) {
|
|
897
|
+
console.error(`[${req.user?.sub}] Error resetting story ${storyId}:`, error);
|
|
898
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
899
|
+
throw new common_1.NotFoundException(error.message);
|
|
900
|
+
}
|
|
901
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
902
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
903
|
+
}
|
|
904
|
+
throw new common_1.HttpException('Failed to reset story', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
async getRoomArtifacts(req, roomId) {
|
|
908
|
+
try {
|
|
909
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
910
|
+
return appService.getRoomArtifacts(roomId);
|
|
911
|
+
}
|
|
912
|
+
catch (error) {
|
|
913
|
+
console.error(`[${req.user?.sub}] Error getting room artifacts for ${roomId}:`, error);
|
|
914
|
+
return { artifacts: [] };
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
async publishArtifact(req, roomId, body) {
|
|
918
|
+
try {
|
|
919
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
920
|
+
appService.publishArtifact(roomId, body.name, body.creator, body.body, body.viewers);
|
|
921
|
+
}
|
|
922
|
+
catch (error) {
|
|
923
|
+
console.error(`[${req.user?.sub}] Error publishing artifact to ${roomId}:`, error);
|
|
924
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
925
|
+
throw new common_1.NotFoundException(error.message);
|
|
926
|
+
}
|
|
927
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
928
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
929
|
+
}
|
|
930
|
+
if (error instanceof common_1.NotFoundException || error instanceof common_1.BadRequestException) {
|
|
931
|
+
throw error;
|
|
932
|
+
}
|
|
933
|
+
throw new common_1.HttpException('Failed to publish artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
async createPromptFolderDeprecated(req, body) {
|
|
937
|
+
if (!body.folderName) {
|
|
938
|
+
throw new common_1.BadRequestException('Folder name is required');
|
|
939
|
+
}
|
|
940
|
+
try {
|
|
941
|
+
const appService = this.getAppService(req);
|
|
942
|
+
appService.createPromptFolder(body.folderName);
|
|
943
|
+
}
|
|
944
|
+
catch (error) {
|
|
945
|
+
console.error(`[${req.user?.sub}] Error creating prompt folder ${body.folderName}:`, error);
|
|
946
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
947
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
948
|
+
}
|
|
949
|
+
throw new common_1.HttpException('Failed to create prompt folder', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
listStories(req) {
|
|
953
|
+
try {
|
|
954
|
+
const appService = this.getAppService(req);
|
|
955
|
+
return appService.listStories();
|
|
956
|
+
}
|
|
957
|
+
catch (error) {
|
|
958
|
+
console.error(`[${req.user?.sub}] Error listing stories:`, error);
|
|
959
|
+
return [];
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
listStoryGenres(req) {
|
|
963
|
+
try {
|
|
964
|
+
const appService = this.getAppService(req);
|
|
965
|
+
return appService.listStoryGenres();
|
|
966
|
+
}
|
|
967
|
+
catch (error) {
|
|
968
|
+
console.error(`[${req.user?.sub}] Error listing story genres:`, error);
|
|
969
|
+
return [];
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
async getRandomStoryIdea(req) {
|
|
973
|
+
try {
|
|
974
|
+
const appService = this.getAppService(req);
|
|
975
|
+
return appService.getRandomStoryIdea();
|
|
976
|
+
}
|
|
977
|
+
catch (error) {
|
|
978
|
+
console.error(`[${req.user?.sub}] Error getting random story idea:`, error);
|
|
979
|
+
throw new common_1.HttpException('Failed to get random story idea', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
async getStoryIdeasByGenre(req, genreName) {
|
|
983
|
+
try {
|
|
984
|
+
const appService = this.getAppService(req);
|
|
985
|
+
return appService.getRandomStoryIdeaByGenre(genreName);
|
|
986
|
+
}
|
|
987
|
+
catch (error) {
|
|
988
|
+
console.error(`[${req.user?.sub}] Error getting story idea for genre ${genreName}:`, error);
|
|
989
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
990
|
+
throw new common_1.NotFoundException(`Genre "${genreName}" not found`);
|
|
991
|
+
}
|
|
992
|
+
throw new common_1.HttpException('Failed to get story idea', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
async createStory(req, body) {
|
|
996
|
+
if (!body.name || !body.idea) {
|
|
997
|
+
throw new common_1.BadRequestException('Required fields missing');
|
|
998
|
+
}
|
|
999
|
+
try {
|
|
1000
|
+
const appService = this.getAppService(req);
|
|
1001
|
+
return appService.createStory(body.name, body.idea, body.userCharacterDesc, body.otherCharactersDesc, body.storyModel, body.isImport, body.imageModelName);
|
|
1002
|
+
}
|
|
1003
|
+
catch (error) {
|
|
1004
|
+
console.error(`[${req.user?.sub}] Error creating story ${body.name}:`, error);
|
|
1005
|
+
throw new common_1.HttpException(`Failed to create story: ${error}`, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
async importStoryZip(req, file) {
|
|
1009
|
+
if (!file) {
|
|
1010
|
+
throw new common_1.BadRequestException('No file uploaded');
|
|
1011
|
+
}
|
|
1012
|
+
const allowedMimeTypes = ['application/zip', 'application/x-zip-compressed'];
|
|
1013
|
+
if (!allowedMimeTypes.includes(file.mimetype) &&
|
|
1014
|
+
!file.originalname.toLowerCase().endsWith('.zip')) {
|
|
1015
|
+
throw new common_1.BadRequestException('Only .zip files are allowed');
|
|
1016
|
+
}
|
|
1017
|
+
try {
|
|
1018
|
+
const appService = this.getAppService(req);
|
|
1019
|
+
const storyInfo = await appService.importStoryFromZip(file.buffer);
|
|
1020
|
+
console.log(`[${req.user?.sub}] Successfully imported story: ${storyInfo.name} (${storyInfo.id})`);
|
|
1021
|
+
return storyInfo;
|
|
1022
|
+
}
|
|
1023
|
+
catch (error) {
|
|
1024
|
+
console.error(`[${req.user?.sub}] Error importing story from zip:`, error);
|
|
1025
|
+
if (error.message.includes('Invalid story structure')) {
|
|
1026
|
+
throw new common_1.BadRequestException(error.message);
|
|
1027
|
+
}
|
|
1028
|
+
if (error.message.includes('already exists')) {
|
|
1029
|
+
throw new common_1.BadRequestException(error.message);
|
|
1030
|
+
}
|
|
1031
|
+
if (error.message.includes('Security:')) {
|
|
1032
|
+
throw new common_1.BadRequestException('Invalid zip file structure');
|
|
1033
|
+
}
|
|
1034
|
+
if (error.message.includes('exceeds maximum size')) {
|
|
1035
|
+
throw new common_1.HttpException('File too large', common_1.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
1036
|
+
}
|
|
1037
|
+
throw new common_1.HttpException(`Failed to import story: ${error.message}`, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
async deleteStory(req, storyId) {
|
|
1041
|
+
if (!storyId) {
|
|
1042
|
+
throw new common_1.BadRequestException('Story ID is required');
|
|
1043
|
+
}
|
|
1044
|
+
try {
|
|
1045
|
+
const appService = this.getAppService(req);
|
|
1046
|
+
appService.deleteStory(storyId);
|
|
1047
|
+
}
|
|
1048
|
+
catch (error) {
|
|
1049
|
+
console.error(`[${req.user?.sub}] Error deleting story ${storyId}:`, error);
|
|
1050
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1051
|
+
throw new common_1.NotFoundException(error.message);
|
|
1052
|
+
}
|
|
1053
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1054
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1055
|
+
}
|
|
1056
|
+
throw new common_1.HttpException('Failed to delete story', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
async compactStory(req, storyId) {
|
|
1060
|
+
if (!storyId) {
|
|
1061
|
+
throw new common_1.BadRequestException('Story ID is required');
|
|
1062
|
+
}
|
|
1063
|
+
try {
|
|
1064
|
+
const appService = this.getAppService(req);
|
|
1065
|
+
await appService.compactStory(storyId);
|
|
1066
|
+
}
|
|
1067
|
+
catch (error) {
|
|
1068
|
+
console.error(`[${req.user?.sub}] Error compacting story ${storyId}:`, error);
|
|
1069
|
+
if (error instanceof common_1.HttpException) {
|
|
1070
|
+
throw error;
|
|
1071
|
+
}
|
|
1072
|
+
throw new common_1.HttpException(error.message || 'Failed to compact story', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
async progressStory(req, storyId) {
|
|
1076
|
+
if (!storyId) {
|
|
1077
|
+
throw new common_1.BadRequestException('Story ID is required');
|
|
1078
|
+
}
|
|
1079
|
+
try {
|
|
1080
|
+
const appService = this.getAppService(req);
|
|
1081
|
+
return appService.progressStory(storyId);
|
|
1082
|
+
}
|
|
1083
|
+
catch (error) {
|
|
1084
|
+
console.error(`[${req.user?.sub}] Error progressing story ${storyId}:`, error);
|
|
1085
|
+
if (error instanceof common_1.HttpException) {
|
|
1086
|
+
throw error;
|
|
1087
|
+
}
|
|
1088
|
+
throw new common_1.HttpException(error.message || 'Failed to progress story', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
async getStoryState(req, storyId) {
|
|
1092
|
+
try {
|
|
1093
|
+
const appService = this.getAppService(req);
|
|
1094
|
+
return appService.getStoryState(storyId);
|
|
1095
|
+
}
|
|
1096
|
+
catch (error) {
|
|
1097
|
+
console.error(`[${req.user?.sub}] Error getting story state for ${storyId}:`, error);
|
|
1098
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1099
|
+
throw new common_1.NotFoundException(error.message);
|
|
1100
|
+
}
|
|
1101
|
+
throw new common_1.HttpException('Failed to get story state', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
async respondToStory(req, storyId, body) {
|
|
1105
|
+
const trimmedContent = body.content?.trim();
|
|
1106
|
+
const isPassing = trimmedContent?.toUpperCase() === 'PASS';
|
|
1107
|
+
if (!trimmedContent && !isPassing) {
|
|
1108
|
+
throw new common_1.BadRequestException('Response content cannot be empty');
|
|
1109
|
+
}
|
|
1110
|
+
try {
|
|
1111
|
+
const appService = this.getAppService(req);
|
|
1112
|
+
await appService.respondToStory(storyId, body.content);
|
|
1113
|
+
}
|
|
1114
|
+
catch (error) {
|
|
1115
|
+
console.error(`[${req.user?.sub}] Error responding to story ${storyId}:`, error);
|
|
1116
|
+
if (error instanceof common_1.HttpException) {
|
|
1117
|
+
throw error;
|
|
1118
|
+
}
|
|
1119
|
+
throw new common_1.HttpException(error.message || 'Failed to respond to story', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
async introduceCharacter(req, storyId, body) {
|
|
1123
|
+
if (!body.name) {
|
|
1124
|
+
throw new common_1.BadRequestException('Name is a required field');
|
|
1125
|
+
}
|
|
1126
|
+
try {
|
|
1127
|
+
const appService = this.getAppService(req);
|
|
1128
|
+
await appService.introduceCharacterToStory(storyId, body.name, body.description || '', body.storyModel, body.fromNarratorSuggestion || false);
|
|
1129
|
+
}
|
|
1130
|
+
catch (error) {
|
|
1131
|
+
console.error(`[${req.user?.sub}] Error introducing character ${body.name} to story ${storyId}:`, error);
|
|
1132
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1133
|
+
throw new common_1.NotFoundException(error.message);
|
|
1134
|
+
}
|
|
1135
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1136
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1137
|
+
}
|
|
1138
|
+
throw new common_1.HttpException('Failed to introduce character', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
async declineCharacter(req, storyId, characterName) {
|
|
1142
|
+
try {
|
|
1143
|
+
const appService = this.getAppService(req);
|
|
1144
|
+
await appService.declineCharacter(storyId, characterName);
|
|
1145
|
+
return { success: true };
|
|
1146
|
+
}
|
|
1147
|
+
catch (error) {
|
|
1148
|
+
console.error(`[${req.user?.sub}] Error declining character for story ${storyId}:`, error);
|
|
1149
|
+
throw new common_1.HttpException(error.message || 'Failed to decline character', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
async deleteCharacter(req, storyId, characterName) {
|
|
1153
|
+
if (!characterName) {
|
|
1154
|
+
throw new common_1.BadRequestException('Character name is required');
|
|
1155
|
+
}
|
|
1156
|
+
try {
|
|
1157
|
+
const appService = this.getAppService(req);
|
|
1158
|
+
await appService.deleteCharacterFromStory(storyId, characterName);
|
|
1159
|
+
}
|
|
1160
|
+
catch (error) {
|
|
1161
|
+
console.error(`[${req.user?.sub}] Error deleting character ${characterName} from story ${storyId}:`, error);
|
|
1162
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1163
|
+
throw new common_1.NotFoundException(error.message);
|
|
1164
|
+
}
|
|
1165
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1166
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1167
|
+
}
|
|
1168
|
+
throw new common_1.HttpException('Failed to delete character', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
listChapters(req, storyId) {
|
|
1172
|
+
try {
|
|
1173
|
+
const appService = this.getAppService(req);
|
|
1174
|
+
return appService.listChapters(storyId);
|
|
1175
|
+
}
|
|
1176
|
+
catch (error) {
|
|
1177
|
+
console.error(`[${req.user?.sub}] Error listing chapters for story ${storyId}:`, error);
|
|
1178
|
+
return { chapters: [] };
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
async getChapter(req, storyId, chapterIndex) {
|
|
1182
|
+
const appService = this.getAppService(req);
|
|
1183
|
+
const chapterMessages = await appService.getChapter(storyId, parseInt(chapterIndex, 10));
|
|
1184
|
+
if (!chapterMessages) {
|
|
1185
|
+
throw new common_1.NotFoundException(`Chapter ${chapterIndex} not found`);
|
|
1186
|
+
}
|
|
1187
|
+
return { content: chapterMessages };
|
|
1188
|
+
}
|
|
1189
|
+
saveChapter(req, storyId, chapterIndex, body) {
|
|
1190
|
+
if (!body.content) {
|
|
1191
|
+
throw new common_1.BadRequestException('Content is required');
|
|
1192
|
+
}
|
|
1193
|
+
const chapterIndexNum = parseInt(chapterIndex, 10);
|
|
1194
|
+
if (isNaN(chapterIndexNum)) {
|
|
1195
|
+
throw new common_1.BadRequestException('Invalid chapter index');
|
|
1196
|
+
}
|
|
1197
|
+
try {
|
|
1198
|
+
const appService = this.getAppService(req);
|
|
1199
|
+
appService.saveChapter(storyId, chapterIndexNum, body.content);
|
|
1200
|
+
}
|
|
1201
|
+
catch (error) {
|
|
1202
|
+
console.error(`[${req.user?.sub}] Error saving chapter ${chapterIndex} for story ${storyId}:`, error);
|
|
1203
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1204
|
+
throw new common_1.NotFoundException(error.message);
|
|
1205
|
+
}
|
|
1206
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1207
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1208
|
+
}
|
|
1209
|
+
throw new common_1.HttpException('Failed to save chapter', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
deleteChapter(req, storyId, chapterIndex) {
|
|
1213
|
+
const chapterIndexNum = parseInt(chapterIndex, 10);
|
|
1214
|
+
if (isNaN(chapterIndexNum)) {
|
|
1215
|
+
throw new common_1.BadRequestException('Invalid chapter index');
|
|
1216
|
+
}
|
|
1217
|
+
try {
|
|
1218
|
+
const appService = this.getAppService(req);
|
|
1219
|
+
appService.deleteChapter(storyId, chapterIndexNum);
|
|
1220
|
+
}
|
|
1221
|
+
catch (error) {
|
|
1222
|
+
console.error(`[${req.user?.sub}] Error deleting chapter ${chapterIndex} for story ${storyId}:`, error);
|
|
1223
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1224
|
+
throw new common_1.NotFoundException(error.message);
|
|
1225
|
+
}
|
|
1226
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1227
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1228
|
+
}
|
|
1229
|
+
throw new common_1.HttpException('Failed to delete chapter', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
async exportStoryMarkdown(req, storyId, res) {
|
|
1233
|
+
try {
|
|
1234
|
+
const appService = this.getAppService(req);
|
|
1235
|
+
const markdown = await appService.downloadStoryMarkdown(storyId);
|
|
1236
|
+
const story = await appService.getStoryInfo(storyId);
|
|
1237
|
+
if (!story) {
|
|
1238
|
+
throw new common_1.NotFoundException(`Story ${storyId} not found`);
|
|
1239
|
+
}
|
|
1240
|
+
const filename = `${story.name.replace(/[^a-z0-9]/gi, '_')}.md`;
|
|
1241
|
+
res.setHeader('Content-Type', 'text/markdown');
|
|
1242
|
+
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
|
1243
|
+
res.send(markdown);
|
|
1244
|
+
}
|
|
1245
|
+
catch (error) {
|
|
1246
|
+
console.error(`[${req.user?.sub}] Failed to export story markdown:`, error);
|
|
1247
|
+
res.status(500).json({ error: 'Failed to export story markdown' });
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
async exportStoryZip(req, storyId, res) {
|
|
1251
|
+
try {
|
|
1252
|
+
const appService = this.getAppService(req);
|
|
1253
|
+
const { stream, filename } = await appService.exportStoryData(storyId);
|
|
1254
|
+
res.setHeader('Content-Type', 'application/zip');
|
|
1255
|
+
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
|
1256
|
+
stream.pipe(res);
|
|
1257
|
+
stream.on('error', (err) => {
|
|
1258
|
+
console.error(`[${req.user?.sub}] Stream error during story zip export:`, err);
|
|
1259
|
+
if (!res.headersSent) {
|
|
1260
|
+
res.status(500).json({ error: 'Failed to export story zip' });
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
catch (error) {
|
|
1265
|
+
console.error(`[${req.user?.sub}] Failed to export story zip:`, error);
|
|
1266
|
+
if (!res.headersSent) {
|
|
1267
|
+
res.status(500).json({ error: 'Failed to export story zip' });
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
async listCharacters(req, storyId) {
|
|
1272
|
+
try {
|
|
1273
|
+
const appService = this.getAppService(req);
|
|
1274
|
+
return await appService.listCharacters(storyId);
|
|
1275
|
+
}
|
|
1276
|
+
catch (error) {
|
|
1277
|
+
console.error(`[${req.user?.sub}] Error listing characters for story ${storyId}:`, error);
|
|
1278
|
+
return [];
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
async getCharacter(req, storyId, characterName) {
|
|
1282
|
+
try {
|
|
1283
|
+
const appService = this.getAppService(req);
|
|
1284
|
+
return await appService.getCharacter(storyId, characterName);
|
|
1285
|
+
}
|
|
1286
|
+
catch (error) {
|
|
1287
|
+
console.error(`[${req.user?.sub}] Error getting character ${characterName} for story ${storyId}:`, error);
|
|
1288
|
+
return { content: '' };
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
async saveCharacter(req, storyId, characterName, body) {
|
|
1292
|
+
if (!body.content) {
|
|
1293
|
+
throw new common_1.BadRequestException('Content is required');
|
|
1294
|
+
}
|
|
1295
|
+
try {
|
|
1296
|
+
const appService = this.getAppService(req);
|
|
1297
|
+
appService.saveCharacter(storyId, characterName, body.content);
|
|
1298
|
+
}
|
|
1299
|
+
catch (error) {
|
|
1300
|
+
console.error(`[${req.user?.sub}] Error saving character ${characterName} for story ${storyId}:`, error);
|
|
1301
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1302
|
+
throw new common_1.NotFoundException(error.message);
|
|
1303
|
+
}
|
|
1304
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1305
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1306
|
+
}
|
|
1307
|
+
throw new common_1.HttpException('Failed to save character', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
async getPlotPlan(req, storyId) {
|
|
1311
|
+
try {
|
|
1312
|
+
const appService = this.getAppService(req);
|
|
1313
|
+
return await appService.getPlotPlan(storyId);
|
|
1314
|
+
}
|
|
1315
|
+
catch (error) {
|
|
1316
|
+
console.error(`[${req.user?.sub}] Error getting plot plan for story ${storyId}:`, error);
|
|
1317
|
+
return { content: '' };
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
async getAgentHistory(req, storyId, agentId) {
|
|
1321
|
+
try {
|
|
1322
|
+
const appService = this.getAppService(req);
|
|
1323
|
+
return await appService.getAgentHistory(storyId, agentId);
|
|
1324
|
+
}
|
|
1325
|
+
catch (error) {
|
|
1326
|
+
console.error(`[${req.user?.sub}] Error getting agent history for ${agentId} in story ${storyId}:`, error);
|
|
1327
|
+
return { content: '' };
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
async savePlotPlan(req, storyId, body) {
|
|
1331
|
+
if (!body.content) {
|
|
1332
|
+
throw new common_1.BadRequestException('Content is required');
|
|
1333
|
+
}
|
|
1334
|
+
try {
|
|
1335
|
+
const appService = this.getAppService(req);
|
|
1336
|
+
appService.savePlotPlan(storyId, body.content);
|
|
1337
|
+
}
|
|
1338
|
+
catch (error) {
|
|
1339
|
+
console.error(`[${req.user?.sub}] Error saving plot plan for story ${storyId}:`, error);
|
|
1340
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1341
|
+
throw new common_1.NotFoundException(error.message);
|
|
1342
|
+
}
|
|
1343
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1344
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1345
|
+
}
|
|
1346
|
+
throw new common_1.HttpException('Failed to save plot plan', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
async listStoryArtifacts(req, storyId) {
|
|
1350
|
+
try {
|
|
1351
|
+
const appService = this.getAppService(req);
|
|
1352
|
+
return { artifacts: appService.listStoryArtifacts(storyId) };
|
|
1353
|
+
}
|
|
1354
|
+
catch (error) {
|
|
1355
|
+
console.error(`Error listing story artifacts for ${storyId}:`, error);
|
|
1356
|
+
return { artifacts: [] };
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
async getStoryArtifact(req, storyId, artifactId, res) {
|
|
1360
|
+
try {
|
|
1361
|
+
const appService = this.getAppService(req);
|
|
1362
|
+
const storyArtifactService = appService.getStoryArtifactService(storyId);
|
|
1363
|
+
const allArtifacts = storyArtifactService.listArtifacts();
|
|
1364
|
+
const artifactMetadata = allArtifacts.find((a) => a.artifactId === artifactId);
|
|
1365
|
+
if (!artifactMetadata) {
|
|
1366
|
+
throw new common_1.NotFoundException('Artifact not found');
|
|
1367
|
+
}
|
|
1368
|
+
const content = appService.getStoryArtifact(storyId, artifactId);
|
|
1369
|
+
if (!content) {
|
|
1370
|
+
throw new common_1.NotFoundException('Artifact content not found');
|
|
1371
|
+
}
|
|
1372
|
+
const mimeType = artifactMetadata.mimeType || 'application/octet-stream';
|
|
1373
|
+
res.setHeader('Content-Type', mimeType);
|
|
1374
|
+
res.send(content);
|
|
1375
|
+
}
|
|
1376
|
+
catch (error) {
|
|
1377
|
+
console.error(`Error getting story artifact ${artifactId} for story ${storyId}:`, error);
|
|
1378
|
+
if (error instanceof common_1.NotFoundException) {
|
|
1379
|
+
throw error;
|
|
1380
|
+
}
|
|
1381
|
+
throw new common_1.HttpException('Failed to get artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
storyProgress(req, storyId) {
|
|
1385
|
+
const appService = this.getAppService(req);
|
|
1386
|
+
const storyInfo = appService.listStories().find((s) => s.id === storyId);
|
|
1387
|
+
if (!storyInfo) {
|
|
1388
|
+
throw new common_1.NotFoundException(`Story ${storyId} not found`);
|
|
1389
|
+
}
|
|
1390
|
+
const emitter = appService.getStoryProgressEmitter(storyId);
|
|
1391
|
+
if (!emitter) {
|
|
1392
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
1393
|
+
subscriber.next({
|
|
1394
|
+
data: { step: 'error', message: 'Story progress not found' },
|
|
1395
|
+
});
|
|
1396
|
+
subscriber.complete();
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
return (0, rxjs_1.fromEvent)(emitter, 'progress').pipe((0, rxjs_1.map)((data) => ({ data })));
|
|
1400
|
+
}
|
|
1401
|
+
storyMessages(req, storyId) {
|
|
1402
|
+
const userId = req.user?.sub;
|
|
1403
|
+
try {
|
|
1404
|
+
const appService = this.getAppService(req);
|
|
1405
|
+
const storyInfo = appService.listStories().find((s) => s.id === storyId);
|
|
1406
|
+
if (!storyInfo) {
|
|
1407
|
+
console.log(`[SSE] Story ${storyId} not found for user ${userId}`);
|
|
1408
|
+
throw new common_1.NotFoundException(`Story ${storyId} not found`);
|
|
1409
|
+
}
|
|
1410
|
+
const emitter = appService.getStoryMessageEmitter(storyId);
|
|
1411
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
1412
|
+
console.log(`[SSE] Observable subscribed for story ${storyId}`);
|
|
1413
|
+
subscriber.next({
|
|
1414
|
+
data: { type: 'connected', storyId },
|
|
1415
|
+
});
|
|
1416
|
+
const updateHandler = (data) => {
|
|
1417
|
+
subscriber.next({ data });
|
|
1418
|
+
};
|
|
1419
|
+
emitter.on('update', updateHandler);
|
|
1420
|
+
return () => {
|
|
1421
|
+
console.log(`[SSE] Cleanup for story ${storyId}`);
|
|
1422
|
+
emitter.off('update', updateHandler);
|
|
1423
|
+
};
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
catch (error) {
|
|
1427
|
+
console.error(`[SSE] Error setting up SSE for story ${storyId}:`, error);
|
|
1428
|
+
throw error;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
async agentMessages(req, agentId) {
|
|
1432
|
+
const appService = this.getAppService(req, agentId);
|
|
1433
|
+
const agentDetails = await appService.getAgentDetails(agentId);
|
|
1434
|
+
if (!agentDetails) {
|
|
1435
|
+
throw new common_1.NotFoundException(`Agent ${agentId} not found`);
|
|
1436
|
+
}
|
|
1437
|
+
if (req.user.type === 'agent-access') {
|
|
1438
|
+
if (!agentDetails.isPublished) {
|
|
1439
|
+
throw new common_1.ForbiddenException('Agent is not published');
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
appService.ensureAgentStateCallback(agentId);
|
|
1443
|
+
const emitter = appService.getAgentMessageEmitter(agentId);
|
|
1444
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
1445
|
+
const updateHandler = (data) => {
|
|
1446
|
+
subscriber.next({ data });
|
|
1447
|
+
};
|
|
1448
|
+
emitter.on('update', updateHandler);
|
|
1449
|
+
return () => {
|
|
1450
|
+
emitter.off('update', updateHandler);
|
|
1451
|
+
};
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
async roomMessages(req, roomId) {
|
|
1455
|
+
const appService = this.getAppService(req, undefined, roomId);
|
|
1456
|
+
const roomDetails = await appService.getRoomDetails(roomId);
|
|
1457
|
+
if (!roomDetails) {
|
|
1458
|
+
throw new common_1.NotFoundException(`Room ${roomId} not found`);
|
|
1459
|
+
}
|
|
1460
|
+
appService.ensureRoomStateCallback(roomId);
|
|
1461
|
+
const emitter = appService.getRoomMessageEmitter(roomId);
|
|
1462
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
1463
|
+
const updateHandler = (data) => {
|
|
1464
|
+
subscriber.next({ data });
|
|
1465
|
+
};
|
|
1466
|
+
emitter.on('update', updateHandler);
|
|
1467
|
+
return () => {
|
|
1468
|
+
emitter.off('update', updateHandler);
|
|
1469
|
+
};
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
balanceUpdates(req) {
|
|
1473
|
+
const appService = this.getAppService(req);
|
|
1474
|
+
const userId = req.user.sub;
|
|
1475
|
+
const emitter = appService.getBalanceMessageEmitter(userId);
|
|
1476
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
1477
|
+
const updateHandler = (data) => {
|
|
1478
|
+
subscriber.next({ data });
|
|
1479
|
+
};
|
|
1480
|
+
emitter.on('update', updateHandler);
|
|
1481
|
+
return () => {
|
|
1482
|
+
emitter.off('update', updateHandler);
|
|
1483
|
+
};
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
async getBalance(req) {
|
|
1487
|
+
const appService = this.getAppService(req);
|
|
1488
|
+
const balance = await appService.getBalance();
|
|
1489
|
+
return { balance };
|
|
1490
|
+
}
|
|
1491
|
+
async listArtifacts(req) {
|
|
1492
|
+
try {
|
|
1493
|
+
const appService = this.getAppService(req);
|
|
1494
|
+
return { artifacts: appService.listUserArtifacts() };
|
|
1495
|
+
}
|
|
1496
|
+
catch (error) {
|
|
1497
|
+
console.error(`Error listing artifacts:`, error);
|
|
1498
|
+
return { artifacts: [] };
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
async getArtifact(req, artifactId) {
|
|
1502
|
+
try {
|
|
1503
|
+
const appService = this.getAppService(req);
|
|
1504
|
+
const content = appService.getUserArtifact(artifactId);
|
|
1505
|
+
if (!content) {
|
|
1506
|
+
throw new common_1.NotFoundException('Artifact not found');
|
|
1507
|
+
}
|
|
1508
|
+
return { content };
|
|
1509
|
+
}
|
|
1510
|
+
catch (error) {
|
|
1511
|
+
console.error(`Error getting artifact ${artifactId}:`, error);
|
|
1512
|
+
if (error instanceof common_1.NotFoundException) {
|
|
1513
|
+
throw error;
|
|
1514
|
+
}
|
|
1515
|
+
throw new common_1.HttpException('Failed to get artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
async createArtifact(req, body, file) {
|
|
1519
|
+
const extension = file.originalname.toLowerCase().split('.').pop();
|
|
1520
|
+
if (!['md', 'pdf'].includes(extension)) {
|
|
1521
|
+
throw new common_1.BadRequestException('Only .md and .pdf files are allowed');
|
|
1522
|
+
}
|
|
1523
|
+
const MAX_FILE_SIZE = extension === 'pdf' ? 50 * 1024 * 1024 : 10 * 1024 * 1024;
|
|
1524
|
+
if (file.size > MAX_FILE_SIZE) {
|
|
1525
|
+
const maxSizeMB = extension === 'pdf' ? '50MB' : '10MB';
|
|
1526
|
+
throw new common_1.HttpException(`File too large (max ${maxSizeMB})`, common_1.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
1527
|
+
}
|
|
1528
|
+
if (!body.name || !body.name.trim()) {
|
|
1529
|
+
throw new common_1.BadRequestException('Artifact name is required');
|
|
1530
|
+
}
|
|
1531
|
+
if (body.name.length > 200) {
|
|
1532
|
+
throw new common_1.BadRequestException('Artifact name too long (max 200 characters)');
|
|
1533
|
+
}
|
|
1534
|
+
try {
|
|
1535
|
+
const appService = this.getAppService(req);
|
|
1536
|
+
let artifactId;
|
|
1537
|
+
if (extension === 'md') {
|
|
1538
|
+
const content = file.buffer.toString('utf8');
|
|
1539
|
+
artifactId = appService.createUserArtifact(body.name.trim(), content);
|
|
1540
|
+
}
|
|
1541
|
+
else {
|
|
1542
|
+
artifactId = appService.convertUserArtifact(body.name.trim(), file.buffer);
|
|
1543
|
+
}
|
|
1544
|
+
return { artifactId };
|
|
1545
|
+
}
|
|
1546
|
+
catch (error) {
|
|
1547
|
+
console.error(`Error creating artifact:`, error);
|
|
1548
|
+
if (error.message?.includes('conversion')) {
|
|
1549
|
+
throw new common_1.HttpException(`Failed to convert PDF: ${error.message}`, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1550
|
+
}
|
|
1551
|
+
throw new common_1.HttpException('Failed to create artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
async updateArtifact(req, artifactId, body) {
|
|
1555
|
+
if (!body.content) {
|
|
1556
|
+
throw new common_1.BadRequestException('Content is required');
|
|
1557
|
+
}
|
|
1558
|
+
try {
|
|
1559
|
+
const appService = this.getAppService(req);
|
|
1560
|
+
const success = appService.updateUserArtifact(artifactId, body.content);
|
|
1561
|
+
if (!success) {
|
|
1562
|
+
throw new common_1.NotFoundException('Artifact not found');
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
catch (error) {
|
|
1566
|
+
console.error(`Error updating artifact ${artifactId}:`, error);
|
|
1567
|
+
if (error instanceof common_1.NotFoundException) {
|
|
1568
|
+
throw error;
|
|
1569
|
+
}
|
|
1570
|
+
throw new common_1.HttpException('Failed to update artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
async renameArtifact(req, artifactId, body) {
|
|
1574
|
+
if (!body.name || !body.name.trim()) {
|
|
1575
|
+
throw new common_1.BadRequestException('Name is required');
|
|
1576
|
+
}
|
|
1577
|
+
if (body.name.length > 200) {
|
|
1578
|
+
throw new common_1.BadRequestException('Name too long (max 200 characters)');
|
|
1579
|
+
}
|
|
1580
|
+
try {
|
|
1581
|
+
const appService = this.getAppService(req);
|
|
1582
|
+
const success = appService.renameUserArtifact(artifactId, body.name.trim());
|
|
1583
|
+
if (!success) {
|
|
1584
|
+
throw new common_1.NotFoundException('Artifact not found');
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
catch (error) {
|
|
1588
|
+
console.error(`Error renaming artifact ${artifactId}:`, error);
|
|
1589
|
+
if (error instanceof common_1.NotFoundException) {
|
|
1590
|
+
throw error;
|
|
1591
|
+
}
|
|
1592
|
+
throw new common_1.HttpException('Failed to rename artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
async deleteArtifact(req, artifactId) {
|
|
1596
|
+
try {
|
|
1597
|
+
const appService = this.getAppService(req);
|
|
1598
|
+
const success = appService.deleteUserArtifact(artifactId);
|
|
1599
|
+
if (!success) {
|
|
1600
|
+
throw new common_1.NotFoundException('Artifact not found');
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
catch (error) {
|
|
1604
|
+
console.error(`Error deleting artifact ${artifactId}:`, error);
|
|
1605
|
+
if (error instanceof common_1.NotFoundException) {
|
|
1606
|
+
throw error;
|
|
1607
|
+
}
|
|
1608
|
+
throw new common_1.HttpException('Failed to delete artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
async listAgentArtifacts(req, agentId) {
|
|
1612
|
+
try {
|
|
1613
|
+
const appService = this.getAppService(req);
|
|
1614
|
+
return { artifacts: await appService.listAgentArtifacts(agentId) };
|
|
1615
|
+
}
|
|
1616
|
+
catch (error) {
|
|
1617
|
+
console.error(`Error listing artifacts for agent ${agentId}:`, error);
|
|
1618
|
+
return { artifacts: [] };
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
async attachArtifactToAgent(req, agentId, body) {
|
|
1622
|
+
if (!body.artifactId) {
|
|
1623
|
+
throw new common_1.BadRequestException('Artifact ID is required');
|
|
1624
|
+
}
|
|
1625
|
+
try {
|
|
1626
|
+
const appService = this.getAppService(req);
|
|
1627
|
+
await appService.attachArtifactToAgent(agentId, body.artifactId);
|
|
1628
|
+
}
|
|
1629
|
+
catch (error) {
|
|
1630
|
+
console.error(`Error attaching artifact to agent ${agentId}:`, error);
|
|
1631
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1632
|
+
throw new common_1.NotFoundException(error.message);
|
|
1633
|
+
}
|
|
1634
|
+
throw new common_1.HttpException('Failed to attach artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
async detachArtifactFromAgent(req, agentId, artifactId) {
|
|
1638
|
+
try {
|
|
1639
|
+
const appService = this.getAppService(req);
|
|
1640
|
+
appService.detachArtifactFromAgent(agentId, artifactId);
|
|
1641
|
+
}
|
|
1642
|
+
catch (error) {
|
|
1643
|
+
console.error(`Error detaching artifact from agent ${agentId}:`, error);
|
|
1644
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1645
|
+
throw new common_1.NotFoundException(error.message);
|
|
1646
|
+
}
|
|
1647
|
+
throw new common_1.HttpException('Failed to detach artifact', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
exports.AppController = AppController;
|
|
1652
|
+
__decorate([
|
|
1653
|
+
(0, common_1.Get)('list-services'),
|
|
1654
|
+
__param(0, (0, common_1.Request)()),
|
|
1655
|
+
__metadata("design:type", Function),
|
|
1656
|
+
__metadata("design:paramtypes", [Object]),
|
|
1657
|
+
__metadata("design:returntype", Array)
|
|
1658
|
+
], AppController.prototype, "listServices", null);
|
|
1659
|
+
__decorate([
|
|
1660
|
+
(0, common_1.Get)('list-models/:aiServiceName'),
|
|
1661
|
+
__param(0, (0, common_1.Request)()),
|
|
1662
|
+
__param(1, (0, common_1.Param)('aiServiceName')),
|
|
1663
|
+
__metadata("design:type", Function),
|
|
1664
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1665
|
+
__metadata("design:returntype", Promise)
|
|
1666
|
+
], AppController.prototype, "listModels", null);
|
|
1667
|
+
__decorate([
|
|
1668
|
+
(0, common_1.Get)('list-image-models'),
|
|
1669
|
+
__param(0, (0, common_1.Request)()),
|
|
1670
|
+
__metadata("design:type", Function),
|
|
1671
|
+
__metadata("design:paramtypes", [Object]),
|
|
1672
|
+
__metadata("design:returntype", Promise)
|
|
1673
|
+
], AppController.prototype, "listImageModels", null);
|
|
1674
|
+
__decorate([
|
|
1675
|
+
(0, common_1.Get)('list-story-models'),
|
|
1676
|
+
__param(0, (0, common_1.Request)()),
|
|
1677
|
+
__metadata("design:type", Function),
|
|
1678
|
+
__metadata("design:paramtypes", [Object]),
|
|
1679
|
+
__metadata("design:returntype", Promise)
|
|
1680
|
+
], AppController.prototype, "listStoryModels", null);
|
|
1681
|
+
__decorate([
|
|
1682
|
+
(0, common_1.Get)('list-story-model-defaults'),
|
|
1683
|
+
__param(0, (0, common_1.Request)()),
|
|
1684
|
+
__metadata("design:type", Function),
|
|
1685
|
+
__metadata("design:paramtypes", [Object]),
|
|
1686
|
+
__metadata("design:returntype", typeof (_a = typeof app_types_1.StoryModelDefaults !== "undefined" && app_types_1.StoryModelDefaults) === "function" ? _a : Object)
|
|
1687
|
+
], AppController.prototype, "listStoryModelDefaults", null);
|
|
1688
|
+
__decorate([
|
|
1689
|
+
(0, common_1.Post)('agents'),
|
|
1690
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
1691
|
+
__param(0, (0, common_1.Request)()),
|
|
1692
|
+
__param(1, (0, common_1.Body)()),
|
|
1693
|
+
__metadata("design:type", Function),
|
|
1694
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
1695
|
+
__metadata("design:returntype", Promise)
|
|
1696
|
+
], AppController.prototype, "createAgent", null);
|
|
1697
|
+
__decorate([
|
|
1698
|
+
(0, agent_access_decorator_1.AgentAccess)(),
|
|
1699
|
+
(0, common_1.Post)('agents/:agentId/process'),
|
|
1700
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
1701
|
+
__param(0, (0, common_1.Request)()),
|
|
1702
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1703
|
+
__param(2, (0, common_1.Body)()),
|
|
1704
|
+
__metadata("design:type", Function),
|
|
1705
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
1706
|
+
__metadata("design:returntype", Promise)
|
|
1707
|
+
], AppController.prototype, "processText", null);
|
|
1708
|
+
__decorate([
|
|
1709
|
+
(0, common_1.Post)('agents/:agentId/files'),
|
|
1710
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
|
|
1711
|
+
__param(0, (0, common_1.Request)()),
|
|
1712
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1713
|
+
__param(2, (0, common_1.Body)()),
|
|
1714
|
+
__param(3, (0, common_1.UploadedFile)()),
|
|
1715
|
+
__metadata("design:type", Function),
|
|
1716
|
+
__metadata("design:paramtypes", [Object, String, Object, Object]),
|
|
1717
|
+
__metadata("design:returntype", Promise)
|
|
1718
|
+
], AppController.prototype, "attachDocument", null);
|
|
1719
|
+
__decorate([
|
|
1720
|
+
(0, common_1.Get)('agents/:agentId/files'),
|
|
1721
|
+
__param(0, (0, common_1.Request)()),
|
|
1722
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1723
|
+
__metadata("design:type", Function),
|
|
1724
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1725
|
+
__metadata("design:returntype", Promise)
|
|
1726
|
+
], AppController.prototype, "listAttachedFiles", null);
|
|
1727
|
+
__decorate([
|
|
1728
|
+
(0, common_1.Get)('prompts'),
|
|
1729
|
+
__param(0, (0, common_1.Request)()),
|
|
1730
|
+
__param(1, (0, common_1.Query)('scope')),
|
|
1731
|
+
__metadata("design:type", Function),
|
|
1732
|
+
__metadata("design:paramtypes", [Object, typeof (_b = typeof app_types_1.PromptScope !== "undefined" && app_types_1.PromptScope) === "function" ? _b : Object]),
|
|
1733
|
+
__metadata("design:returntype", typeof (_c = typeof app_types_1.PromptFoldersResponse !== "undefined" && app_types_1.PromptFoldersResponse) === "function" ? _c : Object)
|
|
1734
|
+
], AppController.prototype, "getPrompts", null);
|
|
1735
|
+
__decorate([
|
|
1736
|
+
(0, common_1.Post)('prompts'),
|
|
1737
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
1738
|
+
__param(0, (0, common_1.Request)()),
|
|
1739
|
+
__param(1, (0, common_1.Body)()),
|
|
1740
|
+
__metadata("design:type", Function),
|
|
1741
|
+
__metadata("design:paramtypes", [Object, typeof (_d = typeof app_types_1.CreatePromptFolderRequest !== "undefined" && app_types_1.CreatePromptFolderRequest) === "function" ? _d : Object]),
|
|
1742
|
+
__metadata("design:returntype", Promise)
|
|
1743
|
+
], AppController.prototype, "createPromptFolder", null);
|
|
1744
|
+
__decorate([
|
|
1745
|
+
(0, common_1.Delete)('prompts/:folderName'),
|
|
1746
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1747
|
+
__param(0, (0, common_1.Request)()),
|
|
1748
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
1749
|
+
__metadata("design:type", Function),
|
|
1750
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1751
|
+
__metadata("design:returntype", Promise)
|
|
1752
|
+
], AppController.prototype, "deletePromptFolder", null);
|
|
1753
|
+
__decorate([
|
|
1754
|
+
(0, common_1.Get)('prompts/:folderName/files'),
|
|
1755
|
+
__param(0, (0, common_1.Request)()),
|
|
1756
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
1757
|
+
__metadata("design:type", Function),
|
|
1758
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1759
|
+
__metadata("design:returntype", Promise)
|
|
1760
|
+
], AppController.prototype, "getPromptFiles", null);
|
|
1761
|
+
__decorate([
|
|
1762
|
+
(0, common_1.Get)('prompts/:folderName/files/:fileName'),
|
|
1763
|
+
__param(0, (0, common_1.Request)()),
|
|
1764
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
1765
|
+
__param(2, (0, common_1.Param)('fileName')),
|
|
1766
|
+
__metadata("design:type", Function),
|
|
1767
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
1768
|
+
__metadata("design:returntype", Promise)
|
|
1769
|
+
], AppController.prototype, "getPromptFile", null);
|
|
1770
|
+
__decorate([
|
|
1771
|
+
(0, common_1.Post)('prompts/:folderName/files'),
|
|
1772
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
1773
|
+
__param(0, (0, common_1.Request)()),
|
|
1774
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
1775
|
+
__param(2, (0, common_1.Body)()),
|
|
1776
|
+
__metadata("design:type", Function),
|
|
1777
|
+
__metadata("design:paramtypes", [Object, String, typeof (_e = typeof app_types_1.CreatePromptFileRequest !== "undefined" && app_types_1.CreatePromptFileRequest) === "function" ? _e : Object]),
|
|
1778
|
+
__metadata("design:returntype", Promise)
|
|
1779
|
+
], AppController.prototype, "createPromptFile", null);
|
|
1780
|
+
__decorate([
|
|
1781
|
+
(0, common_1.Put)('prompts/:folderName/files/:fileName'),
|
|
1782
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1783
|
+
__param(0, (0, common_1.Request)()),
|
|
1784
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
1785
|
+
__param(2, (0, common_1.Param)('fileName')),
|
|
1786
|
+
__param(3, (0, common_1.Body)()),
|
|
1787
|
+
__metadata("design:type", Function),
|
|
1788
|
+
__metadata("design:paramtypes", [Object, String, String, typeof (_f = typeof app_types_1.UpdatePromptFileRequest !== "undefined" && app_types_1.UpdatePromptFileRequest) === "function" ? _f : Object]),
|
|
1789
|
+
__metadata("design:returntype", Promise)
|
|
1790
|
+
], AppController.prototype, "updatePromptFile", null);
|
|
1791
|
+
__decorate([
|
|
1792
|
+
(0, common_1.Delete)('prompts/:folderName/files/:fileName'),
|
|
1793
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1794
|
+
__param(0, (0, common_1.Request)()),
|
|
1795
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
1796
|
+
__param(2, (0, common_1.Param)('fileName')),
|
|
1797
|
+
__metadata("design:type", Function),
|
|
1798
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
1799
|
+
__metadata("design:returntype", Promise)
|
|
1800
|
+
], AppController.prototype, "deletePromptFile", null);
|
|
1801
|
+
__decorate([
|
|
1802
|
+
(0, common_1.Get)('list-prompt-folders'),
|
|
1803
|
+
__param(0, (0, common_1.Request)()),
|
|
1804
|
+
__metadata("design:type", Function),
|
|
1805
|
+
__metadata("design:paramtypes", [Object]),
|
|
1806
|
+
__metadata("design:returntype", Array)
|
|
1807
|
+
], AppController.prototype, "listPromptFolders", null);
|
|
1808
|
+
__decorate([
|
|
1809
|
+
(0, common_1.Get)('agents/:agentId/prompts'),
|
|
1810
|
+
__param(0, (0, common_1.Request)()),
|
|
1811
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1812
|
+
__metadata("design:type", Function),
|
|
1813
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1814
|
+
__metadata("design:returntype", Array)
|
|
1815
|
+
], AppController.prototype, "listPrompts", null);
|
|
1816
|
+
__decorate([
|
|
1817
|
+
(0, common_1.Post)('agents/:agentId/prompts/:promptName'),
|
|
1818
|
+
__param(0, (0, common_1.Request)()),
|
|
1819
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1820
|
+
__param(2, (0, common_1.Param)('promptName')),
|
|
1821
|
+
__param(3, (0, common_1.Body)()),
|
|
1822
|
+
__metadata("design:type", Function),
|
|
1823
|
+
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
1824
|
+
__metadata("design:returntype", Promise)
|
|
1825
|
+
], AppController.prototype, "runPreparedPrompt", null);
|
|
1826
|
+
__decorate([
|
|
1827
|
+
(0, common_1.Get)('agents'),
|
|
1828
|
+
__param(0, (0, common_1.Request)()),
|
|
1829
|
+
__param(1, (0, common_1.Query)('published')),
|
|
1830
|
+
__metadata("design:type", Function),
|
|
1831
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1832
|
+
__metadata("design:returntype", Promise)
|
|
1833
|
+
], AppController.prototype, "listAgents", null);
|
|
1834
|
+
__decorate([
|
|
1835
|
+
(0, common_1.Post)('rooms'),
|
|
1836
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
1837
|
+
__param(0, (0, common_1.Request)()),
|
|
1838
|
+
__param(1, (0, common_1.Body)()),
|
|
1839
|
+
__metadata("design:type", Function),
|
|
1840
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
1841
|
+
__metadata("design:returntype", Promise)
|
|
1842
|
+
], AppController.prototype, "createRoom", null);
|
|
1843
|
+
__decorate([
|
|
1844
|
+
(0, common_1.Put)('rooms/:roomId'),
|
|
1845
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1846
|
+
__param(0, (0, common_1.Request)()),
|
|
1847
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1848
|
+
__param(2, (0, common_1.Body)()),
|
|
1849
|
+
__metadata("design:type", Function),
|
|
1850
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
1851
|
+
__metadata("design:returntype", Promise)
|
|
1852
|
+
], AppController.prototype, "editRoom", null);
|
|
1853
|
+
__decorate([
|
|
1854
|
+
(0, common_1.Get)('rooms'),
|
|
1855
|
+
__param(0, (0, common_1.Request)()),
|
|
1856
|
+
__metadata("design:type", Function),
|
|
1857
|
+
__metadata("design:paramtypes", [Object]),
|
|
1858
|
+
__metadata("design:returntype", Array)
|
|
1859
|
+
], AppController.prototype, "listRooms", null);
|
|
1860
|
+
__decorate([
|
|
1861
|
+
(0, room_access_decorator_1.RoomReadAccess)(),
|
|
1862
|
+
(0, common_1.Get)('rooms/:roomId'),
|
|
1863
|
+
__param(0, (0, common_1.Request)()),
|
|
1864
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1865
|
+
__metadata("design:type", Function),
|
|
1866
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1867
|
+
__metadata("design:returntype", Promise)
|
|
1868
|
+
], AppController.prototype, "getRoomDetails", null);
|
|
1869
|
+
__decorate([
|
|
1870
|
+
(0, agent_access_decorator_1.AgentReadAccess)(),
|
|
1871
|
+
(0, common_1.Get)('agents/:agentId'),
|
|
1872
|
+
__param(0, (0, common_1.Request)()),
|
|
1873
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1874
|
+
__metadata("design:type", Function),
|
|
1875
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1876
|
+
__metadata("design:returntype", Promise)
|
|
1877
|
+
], AppController.prototype, "getAgentDetails", null);
|
|
1878
|
+
__decorate([
|
|
1879
|
+
(0, room_access_decorator_1.RoomReadAccess)(),
|
|
1880
|
+
(0, common_1.Get)('rooms/:roomId/messages/:fromIndex'),
|
|
1881
|
+
__param(0, (0, common_1.Request)()),
|
|
1882
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1883
|
+
__param(2, (0, common_1.Param)('fromIndex')),
|
|
1884
|
+
__param(3, (0, common_1.Query)('showThoughts')),
|
|
1885
|
+
__metadata("design:type", Function),
|
|
1886
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
1887
|
+
__metadata("design:returntype", typeof (_g = typeof app_types_1.RoomMessagesResponse !== "undefined" && app_types_1.RoomMessagesResponse) === "function" ? _g : Object)
|
|
1888
|
+
], AppController.prototype, "getRoomMessages", null);
|
|
1889
|
+
__decorate([
|
|
1890
|
+
(0, agent_access_decorator_1.AgentReadAccess)(),
|
|
1891
|
+
(0, common_1.Get)('agents/:agentId/messages/:fromIndex'),
|
|
1892
|
+
__param(0, (0, common_1.Request)()),
|
|
1893
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1894
|
+
__param(2, (0, common_1.Param)('fromIndex')),
|
|
1895
|
+
__metadata("design:type", Function),
|
|
1896
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
1897
|
+
__metadata("design:returntype", Promise)
|
|
1898
|
+
], AppController.prototype, "getAgentMessages", null);
|
|
1899
|
+
__decorate([
|
|
1900
|
+
(0, common_1.Get)('stories/:storyId/messages/:fromIndex'),
|
|
1901
|
+
__param(0, (0, common_1.Request)()),
|
|
1902
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
1903
|
+
__param(2, (0, common_1.Param)('fromIndex')),
|
|
1904
|
+
__metadata("design:type", Function),
|
|
1905
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
1906
|
+
__metadata("design:returntype", typeof (_h = typeof app_types_1.RoomMessagesResponse !== "undefined" && app_types_1.RoomMessagesResponse) === "function" ? _h : Object)
|
|
1907
|
+
], AppController.prototype, "getStoryMessages", null);
|
|
1908
|
+
__decorate([
|
|
1909
|
+
(0, common_1.Delete)('agents/:agentId'),
|
|
1910
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1911
|
+
__param(0, (0, common_1.Request)()),
|
|
1912
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1913
|
+
__metadata("design:type", Function),
|
|
1914
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1915
|
+
__metadata("design:returntype", Promise)
|
|
1916
|
+
], AppController.prototype, "deleteAgent", null);
|
|
1917
|
+
__decorate([
|
|
1918
|
+
(0, common_1.Post)('agents/:agentId/publish-instance'),
|
|
1919
|
+
__param(0, (0, common_1.Request)()),
|
|
1920
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1921
|
+
__param(2, (0, common_1.Body)()),
|
|
1922
|
+
__metadata("design:type", Function),
|
|
1923
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
1924
|
+
__metadata("design:returntype", Promise)
|
|
1925
|
+
], AppController.prototype, "publishAgentInstance", null);
|
|
1926
|
+
__decorate([
|
|
1927
|
+
(0, common_1.Get)('agents/:agentId/published-instances'),
|
|
1928
|
+
__param(0, (0, common_1.Request)()),
|
|
1929
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
1930
|
+
__metadata("design:type", Function),
|
|
1931
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1932
|
+
__metadata("design:returntype", Promise)
|
|
1933
|
+
], AppController.prototype, "getPublishedInstances", null);
|
|
1934
|
+
__decorate([
|
|
1935
|
+
(0, common_1.Put)('agents/:instanceId/reset-from-template'),
|
|
1936
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1937
|
+
__param(0, (0, common_1.Request)()),
|
|
1938
|
+
__param(1, (0, common_1.Param)('instanceId')),
|
|
1939
|
+
__metadata("design:type", Function),
|
|
1940
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1941
|
+
__metadata("design:returntype", Promise)
|
|
1942
|
+
], AppController.prototype, "resetPublishedInstance", null);
|
|
1943
|
+
__decorate([
|
|
1944
|
+
(0, common_1.Delete)('rooms/:roomId'),
|
|
1945
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1946
|
+
__param(0, (0, common_1.Request)()),
|
|
1947
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1948
|
+
__metadata("design:type", Function),
|
|
1949
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1950
|
+
__metadata("design:returntype", Promise)
|
|
1951
|
+
], AppController.prototype, "deleteRoom", null);
|
|
1952
|
+
__decorate([
|
|
1953
|
+
(0, room_access_decorator_1.RoomAccess)(),
|
|
1954
|
+
(0, common_1.Post)('rooms/:roomId/messages'),
|
|
1955
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
1956
|
+
__param(0, (0, common_1.Request)()),
|
|
1957
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1958
|
+
__param(2, (0, common_1.Body)()),
|
|
1959
|
+
__metadata("design:type", Function),
|
|
1960
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
1961
|
+
__metadata("design:returntype", Promise)
|
|
1962
|
+
], AppController.prototype, "sendRoomMessage", null);
|
|
1963
|
+
__decorate([
|
|
1964
|
+
(0, room_access_decorator_1.RoomAccess)(),
|
|
1965
|
+
(0, common_1.Post)('rooms/:roomId/pause'),
|
|
1966
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
1967
|
+
__param(0, (0, common_1.Request)()),
|
|
1968
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1969
|
+
__metadata("design:type", Function),
|
|
1970
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1971
|
+
__metadata("design:returntype", Promise)
|
|
1972
|
+
], AppController.prototype, "pauseRoom", null);
|
|
1973
|
+
__decorate([
|
|
1974
|
+
(0, room_access_decorator_1.RoomAccess)(),
|
|
1975
|
+
(0, common_1.Post)('rooms/:roomId/resume'),
|
|
1976
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
1977
|
+
__param(0, (0, common_1.Request)()),
|
|
1978
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
1979
|
+
__metadata("design:type", Function),
|
|
1980
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1981
|
+
__metadata("design:returntype", Promise)
|
|
1982
|
+
], AppController.prototype, "resumeRoom", null);
|
|
1983
|
+
__decorate([
|
|
1984
|
+
(0, common_1.Get)('user-preferences'),
|
|
1985
|
+
__param(0, (0, common_1.Request)()),
|
|
1986
|
+
__metadata("design:type", Function),
|
|
1987
|
+
__metadata("design:paramtypes", [Object]),
|
|
1988
|
+
__metadata("design:returntype", Promise)
|
|
1989
|
+
], AppController.prototype, "getUserPreferences", null);
|
|
1990
|
+
__decorate([
|
|
1991
|
+
(0, common_1.Post)('save-preferences'),
|
|
1992
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
1993
|
+
__param(0, (0, common_1.Request)()),
|
|
1994
|
+
__param(1, (0, common_1.Body)()),
|
|
1995
|
+
__metadata("design:type", Function),
|
|
1996
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
1997
|
+
__metadata("design:returntype", Promise)
|
|
1998
|
+
], AppController.prototype, "saveUserPreferences", null);
|
|
1999
|
+
__decorate([
|
|
2000
|
+
(0, common_1.Get)('list-prompt-files/:folderName'),
|
|
2001
|
+
__param(0, (0, common_1.Request)()),
|
|
2002
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
2003
|
+
__metadata("design:type", Function),
|
|
2004
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2005
|
+
__metadata("design:returntype", Promise)
|
|
2006
|
+
], AppController.prototype, "listPromptFilesDeprecated", null);
|
|
2007
|
+
__decorate([
|
|
2008
|
+
(0, common_1.Get)('get-prompt-file/:folderName/:fileName'),
|
|
2009
|
+
__param(0, (0, common_1.Request)()),
|
|
2010
|
+
__param(1, (0, common_1.Param)('folderName')),
|
|
2011
|
+
__param(2, (0, common_1.Param)('fileName')),
|
|
2012
|
+
__metadata("design:type", Function),
|
|
2013
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2014
|
+
__metadata("design:returntype", Promise)
|
|
2015
|
+
], AppController.prototype, "getPromptFileDeprecated", null);
|
|
2016
|
+
__decorate([
|
|
2017
|
+
(0, common_1.Post)('save-prompt-file'),
|
|
2018
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2019
|
+
__param(0, (0, common_1.Request)()),
|
|
2020
|
+
__param(1, (0, common_1.Body)()),
|
|
2021
|
+
__metadata("design:type", Function),
|
|
2022
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2023
|
+
__metadata("design:returntype", Promise)
|
|
2024
|
+
], AppController.prototype, "savePromptFileDeprecated", null);
|
|
2025
|
+
__decorate([
|
|
2026
|
+
(0, common_1.Post)('delete-prompt-file'),
|
|
2027
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2028
|
+
__param(0, (0, common_1.Request)()),
|
|
2029
|
+
__param(1, (0, common_1.Body)()),
|
|
2030
|
+
__metadata("design:type", Function),
|
|
2031
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2032
|
+
__metadata("design:returntype", Promise)
|
|
2033
|
+
], AppController.prototype, "deletePromptFileDeprecated", null);
|
|
2034
|
+
__decorate([
|
|
2035
|
+
(0, common_1.Post)('delete-prompt-folder'),
|
|
2036
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2037
|
+
__param(0, (0, common_1.Request)()),
|
|
2038
|
+
__param(1, (0, common_1.Body)()),
|
|
2039
|
+
__metadata("design:type", Function),
|
|
2040
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2041
|
+
__metadata("design:returntype", Promise)
|
|
2042
|
+
], AppController.prototype, "deletePromptFolderDeprecated", null);
|
|
2043
|
+
__decorate([
|
|
2044
|
+
(0, agent_access_decorator_1.AgentAccess)(),
|
|
2045
|
+
(0, common_1.Put)('agents/:agentId'),
|
|
2046
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2047
|
+
__param(0, (0, common_1.Request)()),
|
|
2048
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2049
|
+
__param(2, (0, common_1.Body)()),
|
|
2050
|
+
__metadata("design:type", Function),
|
|
2051
|
+
__metadata("design:paramtypes", [Object, String, typeof (_j = typeof app_types_1.UpdateAgentRequest !== "undefined" && app_types_1.UpdateAgentRequest) === "function" ? _j : Object]),
|
|
2052
|
+
__metadata("design:returntype", Promise)
|
|
2053
|
+
], AppController.prototype, "updateAgent", null);
|
|
2054
|
+
__decorate([
|
|
2055
|
+
(0, common_1.Delete)('agents/:agentId/files/:documentId'),
|
|
2056
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2057
|
+
__param(0, (0, common_1.Request)()),
|
|
2058
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2059
|
+
__param(2, (0, common_1.Param)('documentId')),
|
|
2060
|
+
__metadata("design:type", Function),
|
|
2061
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2062
|
+
__metadata("design:returntype", Promise)
|
|
2063
|
+
], AppController.prototype, "deleteAttachedFile", null);
|
|
2064
|
+
__decorate([
|
|
2065
|
+
(0, agent_access_decorator_1.AgentAccess)(),
|
|
2066
|
+
(0, common_1.Post)('agents/:agentId/reload'),
|
|
2067
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2068
|
+
__param(0, (0, common_1.Request)()),
|
|
2069
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2070
|
+
__metadata("design:type", Function),
|
|
2071
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2072
|
+
__metadata("design:returntype", Promise)
|
|
2073
|
+
], AppController.prototype, "reloadAgent", null);
|
|
2074
|
+
__decorate([
|
|
2075
|
+
(0, common_1.Post)('rooms/:roomId/reset'),
|
|
2076
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2077
|
+
__param(0, (0, common_1.Request)()),
|
|
2078
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
2079
|
+
__metadata("design:type", Function),
|
|
2080
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2081
|
+
__metadata("design:returntype", Promise)
|
|
2082
|
+
], AppController.prototype, "resetRoom", null);
|
|
2083
|
+
__decorate([
|
|
2084
|
+
(0, common_1.Post)('rooms/:templateId/publish'),
|
|
2085
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2086
|
+
__param(0, (0, common_1.Request)()),
|
|
2087
|
+
__param(1, (0, common_1.Param)('templateId')),
|
|
2088
|
+
__param(2, (0, common_1.Body)()),
|
|
2089
|
+
__metadata("design:type", Function),
|
|
2090
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2091
|
+
__metadata("design:returntype", Promise)
|
|
2092
|
+
], AppController.prototype, "publishRoom", null);
|
|
2093
|
+
__decorate([
|
|
2094
|
+
(0, common_1.Get)('rooms/:templateId/published-instances'),
|
|
2095
|
+
__param(0, (0, common_1.Request)()),
|
|
2096
|
+
__param(1, (0, common_1.Param)('templateId')),
|
|
2097
|
+
__metadata("design:type", Function),
|
|
2098
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2099
|
+
__metadata("design:returntype", Promise)
|
|
2100
|
+
], AppController.prototype, "getPublishedRoomInstances", null);
|
|
2101
|
+
__decorate([
|
|
2102
|
+
(0, common_1.Put)('rooms/:instanceId/reset-from-template'),
|
|
2103
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2104
|
+
__param(0, (0, common_1.Request)()),
|
|
2105
|
+
__param(1, (0, common_1.Param)('instanceId')),
|
|
2106
|
+
__metadata("design:type", Function),
|
|
2107
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2108
|
+
__metadata("design:returntype", Promise)
|
|
2109
|
+
], AppController.prototype, "resetPublishedRoomInstance", null);
|
|
2110
|
+
__decorate([
|
|
2111
|
+
(0, common_1.Post)('stories/:storyId/reset'),
|
|
2112
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2113
|
+
__param(0, (0, common_1.Request)()),
|
|
2114
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2115
|
+
__metadata("design:type", Function),
|
|
2116
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2117
|
+
__metadata("design:returntype", Promise)
|
|
2118
|
+
], AppController.prototype, "resetStory", null);
|
|
2119
|
+
__decorate([
|
|
2120
|
+
(0, room_access_decorator_1.RoomReadAccess)(),
|
|
2121
|
+
(0, common_1.Get)('rooms/:roomId/artifacts'),
|
|
2122
|
+
__param(0, (0, common_1.Request)()),
|
|
2123
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
2124
|
+
__metadata("design:type", Function),
|
|
2125
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2126
|
+
__metadata("design:returntype", Promise)
|
|
2127
|
+
], AppController.prototype, "getRoomArtifacts", null);
|
|
2128
|
+
__decorate([
|
|
2129
|
+
(0, room_access_decorator_1.RoomAccess)(),
|
|
2130
|
+
(0, common_1.Post)('rooms/:roomId/artifacts'),
|
|
2131
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2132
|
+
__param(0, (0, common_1.Request)()),
|
|
2133
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
2134
|
+
__param(2, (0, common_1.Body)()),
|
|
2135
|
+
__metadata("design:type", Function),
|
|
2136
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2137
|
+
__metadata("design:returntype", Promise)
|
|
2138
|
+
], AppController.prototype, "publishArtifact", null);
|
|
2139
|
+
__decorate([
|
|
2140
|
+
(0, common_1.Post)('create-prompt-folder'),
|
|
2141
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2142
|
+
__param(0, (0, common_1.Request)()),
|
|
2143
|
+
__param(1, (0, common_1.Body)()),
|
|
2144
|
+
__metadata("design:type", Function),
|
|
2145
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2146
|
+
__metadata("design:returntype", Promise)
|
|
2147
|
+
], AppController.prototype, "createPromptFolderDeprecated", null);
|
|
2148
|
+
__decorate([
|
|
2149
|
+
(0, common_1.Get)('stories'),
|
|
2150
|
+
__param(0, (0, common_1.Request)()),
|
|
2151
|
+
__metadata("design:type", Function),
|
|
2152
|
+
__metadata("design:paramtypes", [Object]),
|
|
2153
|
+
__metadata("design:returntype", Array)
|
|
2154
|
+
], AppController.prototype, "listStories", null);
|
|
2155
|
+
__decorate([
|
|
2156
|
+
(0, common_1.Get)('stories/genres'),
|
|
2157
|
+
__param(0, (0, common_1.Request)()),
|
|
2158
|
+
__metadata("design:type", Function),
|
|
2159
|
+
__metadata("design:paramtypes", [Object]),
|
|
2160
|
+
__metadata("design:returntype", Array)
|
|
2161
|
+
], AppController.prototype, "listStoryGenres", null);
|
|
2162
|
+
__decorate([
|
|
2163
|
+
(0, common_1.Get)('stories/genres/random'),
|
|
2164
|
+
__param(0, (0, common_1.Request)()),
|
|
2165
|
+
__metadata("design:type", Function),
|
|
2166
|
+
__metadata("design:paramtypes", [Object]),
|
|
2167
|
+
__metadata("design:returntype", Promise)
|
|
2168
|
+
], AppController.prototype, "getRandomStoryIdea", null);
|
|
2169
|
+
__decorate([
|
|
2170
|
+
(0, common_1.Get)('stories/genres/:genreName'),
|
|
2171
|
+
__param(0, (0, common_1.Request)()),
|
|
2172
|
+
__param(1, (0, common_1.Param)('genreName')),
|
|
2173
|
+
__metadata("design:type", Function),
|
|
2174
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2175
|
+
__metadata("design:returntype", Promise)
|
|
2176
|
+
], AppController.prototype, "getStoryIdeasByGenre", null);
|
|
2177
|
+
__decorate([
|
|
2178
|
+
(0, common_1.Post)('stories/new'),
|
|
2179
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2180
|
+
__param(0, (0, common_1.Request)()),
|
|
2181
|
+
__param(1, (0, common_1.Body)()),
|
|
2182
|
+
__metadata("design:type", Function),
|
|
2183
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2184
|
+
__metadata("design:returntype", Promise)
|
|
2185
|
+
], AppController.prototype, "createStory", null);
|
|
2186
|
+
__decorate([
|
|
2187
|
+
(0, common_1.Post)('stories/import'),
|
|
2188
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file', {
|
|
2189
|
+
limits: {
|
|
2190
|
+
fileSize: 100 * 1024 * 1024,
|
|
2191
|
+
},
|
|
2192
|
+
})),
|
|
2193
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2194
|
+
__param(0, (0, common_1.Request)()),
|
|
2195
|
+
__param(1, (0, common_1.UploadedFile)()),
|
|
2196
|
+
__metadata("design:type", Function),
|
|
2197
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2198
|
+
__metadata("design:returntype", Promise)
|
|
2199
|
+
], AppController.prototype, "importStoryZip", null);
|
|
2200
|
+
__decorate([
|
|
2201
|
+
(0, common_1.Delete)('stories/:storyId'),
|
|
2202
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2203
|
+
__param(0, (0, common_1.Request)()),
|
|
2204
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2205
|
+
__metadata("design:type", Function),
|
|
2206
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2207
|
+
__metadata("design:returntype", Promise)
|
|
2208
|
+
], AppController.prototype, "deleteStory", null);
|
|
2209
|
+
__decorate([
|
|
2210
|
+
(0, common_1.Post)('stories/:storyId/compact'),
|
|
2211
|
+
__param(0, (0, common_1.Request)()),
|
|
2212
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2213
|
+
__metadata("design:type", Function),
|
|
2214
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2215
|
+
__metadata("design:returntype", Promise)
|
|
2216
|
+
], AppController.prototype, "compactStory", null);
|
|
2217
|
+
__decorate([
|
|
2218
|
+
(0, common_1.Post)('stories/:storyId/progress'),
|
|
2219
|
+
__param(0, (0, common_1.Request)()),
|
|
2220
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2221
|
+
__metadata("design:type", Function),
|
|
2222
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2223
|
+
__metadata("design:returntype", Promise)
|
|
2224
|
+
], AppController.prototype, "progressStory", null);
|
|
2225
|
+
__decorate([
|
|
2226
|
+
(0, common_1.Get)('stories/:storyId/state'),
|
|
2227
|
+
__param(0, (0, common_1.Request)()),
|
|
2228
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2229
|
+
__metadata("design:type", Function),
|
|
2230
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2231
|
+
__metadata("design:returntype", Promise)
|
|
2232
|
+
], AppController.prototype, "getStoryState", null);
|
|
2233
|
+
__decorate([
|
|
2234
|
+
(0, common_1.Post)('stories/:storyId/respond'),
|
|
2235
|
+
__param(0, (0, common_1.Request)()),
|
|
2236
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2237
|
+
__param(2, (0, common_1.Body)()),
|
|
2238
|
+
__metadata("design:type", Function),
|
|
2239
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2240
|
+
__metadata("design:returntype", Promise)
|
|
2241
|
+
], AppController.prototype, "respondToStory", null);
|
|
2242
|
+
__decorate([
|
|
2243
|
+
(0, common_1.Post)('stories/:storyId/characters'),
|
|
2244
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2245
|
+
__param(0, (0, common_1.Request)()),
|
|
2246
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2247
|
+
__param(2, (0, common_1.Body)()),
|
|
2248
|
+
__metadata("design:type", Function),
|
|
2249
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2250
|
+
__metadata("design:returntype", Promise)
|
|
2251
|
+
], AppController.prototype, "introduceCharacter", null);
|
|
2252
|
+
__decorate([
|
|
2253
|
+
(0, common_1.Post)('stories/:storyId/characters/:characterName/decline'),
|
|
2254
|
+
__param(0, (0, common_1.Request)()),
|
|
2255
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2256
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2257
|
+
__metadata("design:type", Function),
|
|
2258
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2259
|
+
__metadata("design:returntype", Promise)
|
|
2260
|
+
], AppController.prototype, "declineCharacter", null);
|
|
2261
|
+
__decorate([
|
|
2262
|
+
(0, common_1.Delete)('stories/:storyId/characters/:characterName'),
|
|
2263
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2264
|
+
__param(0, (0, common_1.Request)()),
|
|
2265
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2266
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2267
|
+
__metadata("design:type", Function),
|
|
2268
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2269
|
+
__metadata("design:returntype", Promise)
|
|
2270
|
+
], AppController.prototype, "deleteCharacter", null);
|
|
2271
|
+
__decorate([
|
|
2272
|
+
(0, common_1.Get)('stories/:storyId/chapters'),
|
|
2273
|
+
__param(0, (0, common_1.Request)()),
|
|
2274
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2275
|
+
__metadata("design:type", Function),
|
|
2276
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2277
|
+
__metadata("design:returntype", Object)
|
|
2278
|
+
], AppController.prototype, "listChapters", null);
|
|
2279
|
+
__decorate([
|
|
2280
|
+
(0, common_1.Get)('stories/:storyId/chapters/:chapterIndex'),
|
|
2281
|
+
__param(0, (0, common_1.Request)()),
|
|
2282
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2283
|
+
__param(2, (0, common_1.Param)('chapterIndex')),
|
|
2284
|
+
__metadata("design:type", Function),
|
|
2285
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2286
|
+
__metadata("design:returntype", Promise)
|
|
2287
|
+
], AppController.prototype, "getChapter", null);
|
|
2288
|
+
__decorate([
|
|
2289
|
+
(0, common_1.Put)('stories/:storyId/chapters/:chapterIndex'),
|
|
2290
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2291
|
+
__param(0, (0, common_1.Request)()),
|
|
2292
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2293
|
+
__param(2, (0, common_1.Param)('chapterIndex')),
|
|
2294
|
+
__param(3, (0, common_1.Body)()),
|
|
2295
|
+
__metadata("design:type", Function),
|
|
2296
|
+
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2297
|
+
__metadata("design:returntype", void 0)
|
|
2298
|
+
], AppController.prototype, "saveChapter", null);
|
|
2299
|
+
__decorate([
|
|
2300
|
+
(0, common_1.Delete)('stories/:storyId/chapters/:chapterIndex'),
|
|
2301
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2302
|
+
__param(0, (0, common_1.Request)()),
|
|
2303
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2304
|
+
__param(2, (0, common_1.Param)('chapterIndex')),
|
|
2305
|
+
__metadata("design:type", Function),
|
|
2306
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2307
|
+
__metadata("design:returntype", void 0)
|
|
2308
|
+
], AppController.prototype, "deleteChapter", null);
|
|
2309
|
+
__decorate([
|
|
2310
|
+
(0, common_1.Get)('stories/:storyId/export/md'),
|
|
2311
|
+
__param(0, (0, common_1.Request)()),
|
|
2312
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2313
|
+
__param(2, (0, common_1.Res)()),
|
|
2314
|
+
__metadata("design:type", Function),
|
|
2315
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2316
|
+
__metadata("design:returntype", Promise)
|
|
2317
|
+
], AppController.prototype, "exportStoryMarkdown", null);
|
|
2318
|
+
__decorate([
|
|
2319
|
+
(0, common_1.Get)('stories/:storyId/export/zip'),
|
|
2320
|
+
__param(0, (0, common_1.Request)()),
|
|
2321
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2322
|
+
__param(2, (0, common_1.Res)()),
|
|
2323
|
+
__metadata("design:type", Function),
|
|
2324
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2325
|
+
__metadata("design:returntype", Promise)
|
|
2326
|
+
], AppController.prototype, "exportStoryZip", null);
|
|
2327
|
+
__decorate([
|
|
2328
|
+
(0, common_1.Get)('stories/:storyId/characters'),
|
|
2329
|
+
__param(0, (0, common_1.Request)()),
|
|
2330
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2331
|
+
__metadata("design:type", Function),
|
|
2332
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2333
|
+
__metadata("design:returntype", Promise)
|
|
2334
|
+
], AppController.prototype, "listCharacters", null);
|
|
2335
|
+
__decorate([
|
|
2336
|
+
(0, common_1.Get)('stories/:storyId/characters/:characterName'),
|
|
2337
|
+
__param(0, (0, common_1.Request)()),
|
|
2338
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2339
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2340
|
+
__metadata("design:type", Function),
|
|
2341
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2342
|
+
__metadata("design:returntype", Promise)
|
|
2343
|
+
], AppController.prototype, "getCharacter", null);
|
|
2344
|
+
__decorate([
|
|
2345
|
+
(0, common_1.Put)('stories/:storyId/characters/:characterName'),
|
|
2346
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2347
|
+
__param(0, (0, common_1.Request)()),
|
|
2348
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2349
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2350
|
+
__param(3, (0, common_1.Body)()),
|
|
2351
|
+
__metadata("design:type", Function),
|
|
2352
|
+
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2353
|
+
__metadata("design:returntype", Promise)
|
|
2354
|
+
], AppController.prototype, "saveCharacter", null);
|
|
2355
|
+
__decorate([
|
|
2356
|
+
(0, common_1.Get)('stories/:storyId/plot-plan'),
|
|
2357
|
+
__param(0, (0, common_1.Request)()),
|
|
2358
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2359
|
+
__metadata("design:type", Function),
|
|
2360
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2361
|
+
__metadata("design:returntype", Promise)
|
|
2362
|
+
], AppController.prototype, "getPlotPlan", null);
|
|
2363
|
+
__decorate([
|
|
2364
|
+
(0, common_1.Get)('stories/:storyId/agent-history/:agentId'),
|
|
2365
|
+
__param(0, (0, common_1.Request)()),
|
|
2366
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2367
|
+
__param(2, (0, common_1.Param)('agentId')),
|
|
2368
|
+
__metadata("design:type", Function),
|
|
2369
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2370
|
+
__metadata("design:returntype", Promise)
|
|
2371
|
+
], AppController.prototype, "getAgentHistory", null);
|
|
2372
|
+
__decorate([
|
|
2373
|
+
(0, common_1.Put)('stories/:storyId/plot-plan'),
|
|
2374
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2375
|
+
__param(0, (0, common_1.Request)()),
|
|
2376
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2377
|
+
__param(2, (0, common_1.Body)()),
|
|
2378
|
+
__metadata("design:type", Function),
|
|
2379
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2380
|
+
__metadata("design:returntype", Promise)
|
|
2381
|
+
], AppController.prototype, "savePlotPlan", null);
|
|
2382
|
+
__decorate([
|
|
2383
|
+
(0, common_1.Get)('stories/:storyId/artifacts'),
|
|
2384
|
+
__param(0, (0, common_1.Request)()),
|
|
2385
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2386
|
+
__metadata("design:type", Function),
|
|
2387
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2388
|
+
__metadata("design:returntype", Promise)
|
|
2389
|
+
], AppController.prototype, "listStoryArtifacts", null);
|
|
2390
|
+
__decorate([
|
|
2391
|
+
(0, common_1.Get)('stories/:storyId/artifacts/:artifactId'),
|
|
2392
|
+
__param(0, (0, common_1.Request)()),
|
|
2393
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2394
|
+
__param(2, (0, common_1.Param)('artifactId')),
|
|
2395
|
+
__param(3, (0, common_1.Res)()),
|
|
2396
|
+
__metadata("design:type", Function),
|
|
2397
|
+
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2398
|
+
__metadata("design:returntype", Promise)
|
|
2399
|
+
], AppController.prototype, "getStoryArtifact", null);
|
|
2400
|
+
__decorate([
|
|
2401
|
+
(0, common_1.Sse)('stories/:storyId/progress'),
|
|
2402
|
+
__param(0, (0, common_1.Request)()),
|
|
2403
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2404
|
+
__metadata("design:type", Function),
|
|
2405
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2406
|
+
__metadata("design:returntype", rxjs_1.Observable)
|
|
2407
|
+
], AppController.prototype, "storyProgress", null);
|
|
2408
|
+
__decorate([
|
|
2409
|
+
(0, common_1.Sse)('stories/:storyId/messages'),
|
|
2410
|
+
__param(0, (0, common_1.Request)()),
|
|
2411
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2412
|
+
__metadata("design:type", Function),
|
|
2413
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2414
|
+
__metadata("design:returntype", rxjs_1.Observable)
|
|
2415
|
+
], AppController.prototype, "storyMessages", null);
|
|
2416
|
+
__decorate([
|
|
2417
|
+
(0, agent_access_decorator_1.AgentReadAccess)(),
|
|
2418
|
+
(0, common_1.Sse)('agents/:agentId/messages'),
|
|
2419
|
+
__param(0, (0, common_1.Request)()),
|
|
2420
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2421
|
+
__metadata("design:type", Function),
|
|
2422
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2423
|
+
__metadata("design:returntype", Promise)
|
|
2424
|
+
], AppController.prototype, "agentMessages", null);
|
|
2425
|
+
__decorate([
|
|
2426
|
+
(0, room_access_decorator_1.RoomReadAccess)(),
|
|
2427
|
+
(0, common_1.Sse)('rooms/:roomId/messages'),
|
|
2428
|
+
__param(0, (0, common_1.Request)()),
|
|
2429
|
+
__param(1, (0, common_1.Param)('roomId')),
|
|
2430
|
+
__metadata("design:type", Function),
|
|
2431
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2432
|
+
__metadata("design:returntype", Promise)
|
|
2433
|
+
], AppController.prototype, "roomMessages", null);
|
|
2434
|
+
__decorate([
|
|
2435
|
+
(0, common_1.Sse)('balance/updates'),
|
|
2436
|
+
__param(0, (0, common_1.Request)()),
|
|
2437
|
+
__metadata("design:type", Function),
|
|
2438
|
+
__metadata("design:paramtypes", [Object]),
|
|
2439
|
+
__metadata("design:returntype", rxjs_1.Observable)
|
|
2440
|
+
], AppController.prototype, "balanceUpdates", null);
|
|
2441
|
+
__decorate([
|
|
2442
|
+
(0, common_1.Get)('balance'),
|
|
2443
|
+
__param(0, (0, common_1.Request)()),
|
|
2444
|
+
__metadata("design:type", Function),
|
|
2445
|
+
__metadata("design:paramtypes", [Object]),
|
|
2446
|
+
__metadata("design:returntype", Promise)
|
|
2447
|
+
], AppController.prototype, "getBalance", null);
|
|
2448
|
+
__decorate([
|
|
2449
|
+
(0, common_1.Get)('artifacts'),
|
|
2450
|
+
__param(0, (0, common_1.Request)()),
|
|
2451
|
+
__metadata("design:type", Function),
|
|
2452
|
+
__metadata("design:paramtypes", [Object]),
|
|
2453
|
+
__metadata("design:returntype", Promise)
|
|
2454
|
+
], AppController.prototype, "listArtifacts", null);
|
|
2455
|
+
__decorate([
|
|
2456
|
+
(0, common_1.Get)('artifacts/:artifactId'),
|
|
2457
|
+
__param(0, (0, common_1.Request)()),
|
|
2458
|
+
__param(1, (0, common_1.Param)('artifactId')),
|
|
2459
|
+
__metadata("design:type", Function),
|
|
2460
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2461
|
+
__metadata("design:returntype", Promise)
|
|
2462
|
+
], AppController.prototype, "getArtifact", null);
|
|
2463
|
+
__decorate([
|
|
2464
|
+
(0, common_1.Post)('artifacts'),
|
|
2465
|
+
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
|
|
2466
|
+
__param(0, (0, common_1.Request)()),
|
|
2467
|
+
__param(1, (0, common_1.Body)()),
|
|
2468
|
+
__param(2, (0, common_1.UploadedFile)()),
|
|
2469
|
+
__metadata("design:type", Function),
|
|
2470
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
2471
|
+
__metadata("design:returntype", Promise)
|
|
2472
|
+
], AppController.prototype, "createArtifact", null);
|
|
2473
|
+
__decorate([
|
|
2474
|
+
(0, common_1.Put)('artifacts/:artifactId'),
|
|
2475
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2476
|
+
__param(0, (0, common_1.Request)()),
|
|
2477
|
+
__param(1, (0, common_1.Param)('artifactId')),
|
|
2478
|
+
__param(2, (0, common_1.Body)()),
|
|
2479
|
+
__metadata("design:type", Function),
|
|
2480
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2481
|
+
__metadata("design:returntype", Promise)
|
|
2482
|
+
], AppController.prototype, "updateArtifact", null);
|
|
2483
|
+
__decorate([
|
|
2484
|
+
(0, common_1.Put)('artifacts/:artifactId/rename'),
|
|
2485
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2486
|
+
__param(0, (0, common_1.Request)()),
|
|
2487
|
+
__param(1, (0, common_1.Param)('artifactId')),
|
|
2488
|
+
__param(2, (0, common_1.Body)()),
|
|
2489
|
+
__metadata("design:type", Function),
|
|
2490
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2491
|
+
__metadata("design:returntype", Promise)
|
|
2492
|
+
], AppController.prototype, "renameArtifact", null);
|
|
2493
|
+
__decorate([
|
|
2494
|
+
(0, common_1.Delete)('artifacts/:artifactId'),
|
|
2495
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2496
|
+
__param(0, (0, common_1.Request)()),
|
|
2497
|
+
__param(1, (0, common_1.Param)('artifactId')),
|
|
2498
|
+
__metadata("design:type", Function),
|
|
2499
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2500
|
+
__metadata("design:returntype", Promise)
|
|
2501
|
+
], AppController.prototype, "deleteArtifact", null);
|
|
2502
|
+
__decorate([
|
|
2503
|
+
(0, common_1.Get)('agents/:agentId/artifacts'),
|
|
2504
|
+
__param(0, (0, common_1.Request)()),
|
|
2505
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2506
|
+
__metadata("design:type", Function),
|
|
2507
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2508
|
+
__metadata("design:returntype", Promise)
|
|
2509
|
+
], AppController.prototype, "listAgentArtifacts", null);
|
|
2510
|
+
__decorate([
|
|
2511
|
+
(0, common_1.Post)('agents/:agentId/artifacts'),
|
|
2512
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2513
|
+
__param(0, (0, common_1.Request)()),
|
|
2514
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2515
|
+
__param(2, (0, common_1.Body)()),
|
|
2516
|
+
__metadata("design:type", Function),
|
|
2517
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2518
|
+
__metadata("design:returntype", Promise)
|
|
2519
|
+
], AppController.prototype, "attachArtifactToAgent", null);
|
|
2520
|
+
__decorate([
|
|
2521
|
+
(0, common_1.Delete)('agents/:agentId/artifacts/:artifactId'),
|
|
2522
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2523
|
+
__param(0, (0, common_1.Request)()),
|
|
2524
|
+
__param(1, (0, common_1.Param)('agentId')),
|
|
2525
|
+
__param(2, (0, common_1.Param)('artifactId')),
|
|
2526
|
+
__metadata("design:type", Function),
|
|
2527
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2528
|
+
__metadata("design:returntype", Promise)
|
|
2529
|
+
], AppController.prototype, "detachArtifactFromAgent", null);
|
|
2530
|
+
exports.AppController = AppController = __decorate([
|
|
2531
|
+
(0, common_1.Controller)('api'),
|
|
2532
|
+
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
2533
|
+
__metadata("design:paramtypes", [user_service_manager_1.UserServiceManager,
|
|
2534
|
+
published_agents_service_1.PublishedAgentsService,
|
|
2535
|
+
published_rooms_service_1.PublishedRoomsService])
|
|
2536
|
+
], AppController);
|