briyah 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/data/common/config/markup +1 -0
- package/data/common/config/model_prices.json +5153 -3680
- package/data/common/config/story_models.json +10 -2
- package/data/common/config/story_models_full.json +2 -2
- package/data/common/prompts/compact_agent.prompt +16 -0
- package/data/common/prompts/narrator/perceive.prompt +30 -28
- package/data/common/prompts/story_moderator/moderate.prompt +12 -8
- package/{dist → dist-sdk}/server/src/ai/LLM/anthropic.service.js +22 -12
- package/{dist → dist-sdk}/server/src/ai/LLM/base-ai.service.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/base-ai.service.js +8 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/deepseek.service.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/deepseek.service.js +3 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/fal.service.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/fal.service.js +3 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/grok.service.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/grok.service.js +3 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/together.service.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/ai/LLM/together.service.js +3 -0
- package/{dist → dist-sdk}/server/src/ai/agent.d.ts +7 -0
- package/{dist → dist-sdk}/server/src/ai/agent.js +32 -0
- package/dist-sdk/server/src/ai/model_prices.d.ts +3 -0
- package/{dist → dist-sdk}/server/src/ai/model_prices.js +19 -1
- package/{dist → dist-sdk}/server/src/ai/published-agents.service.js +1 -1
- package/{dist → dist-sdk}/server/src/app/stripe.controller.d.ts +3 -0
- package/{dist → dist-sdk}/server/src/app/stripe.controller.js +13 -0
- package/{dist → dist-sdk}/server/src/app/stripe.service.d.ts +4 -0
- package/{dist → dist-sdk}/server/src/app/stripe.service.js +16 -0
- package/{dist → dist-sdk}/server/src/app.controller.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/app.controller.js +41 -0
- package/{dist → dist-sdk}/server/src/app.service.d.ts +1 -0
- package/{dist → dist-sdk}/server/src/app.service.js +7 -0
- package/{dist → dist-sdk}/server/src/auth/users.service.js +1 -1
- package/{dist → dist-sdk}/server/src/config/configuration.service.js +1 -1
- package/{dist → dist-sdk}/server/src/room/published-rooms.service.js +1 -1
- package/{dist → dist-sdk}/server/src/room/room.js +1 -0
- package/{dist → dist-sdk}/server/src/sdk/briyah-config.js +2 -2
- package/{dist → dist-sdk}/server/src/sdk/briyah.js +2 -2
- package/{dist → dist-sdk}/server/src/story/story-message.service.js +24 -32
- package/{dist → dist-sdk}/server/src/story/story.service.d.ts +1 -1
- package/{dist → dist-sdk}/server/src/story/story.service.js +103 -76
- package/{dist → dist-sdk}/shared/types/app.types.d.ts +1 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Agent.html +18 -13
- package/docs/classes/Briyah.html +12 -12
- package/docs/classes/BriyahConfigService.html +5 -5
- package/docs/classes/Room.html +23 -23
- package/docs/classes/RoomMessage.html +10 -10
- package/docs/enums/MessageAction.html +3 -3
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +4 -4
- package/docs/interfaces/AgentInfo.html +2 -2
- package/docs/interfaces/AgentMessagesResponse.html +2 -2
- package/docs/interfaces/AppService.html +148 -143
- package/docs/interfaces/Artifact.html +3 -3
- package/docs/interfaces/ArtifactMetadata.html +2 -2
- package/docs/interfaces/AttachDocumentResponse.html +2 -2
- package/docs/interfaces/BriyahConfigOptions.html +6 -6
- package/docs/interfaces/ChapterInfo.html +2 -2
- package/docs/interfaces/Character.html +2 -2
- package/docs/interfaces/CreateAgentResponse.html +2 -2
- package/docs/interfaces/CreateRoomResponse.html +2 -2
- package/docs/interfaces/CreateStoryResponse.html +2 -2
- package/docs/interfaces/FileList.html +2 -2
- package/docs/interfaces/LoggingOptions.html +5 -5
- package/docs/interfaces/Message.html +2 -2
- package/docs/interfaces/ModelInfo.html +2 -2
- package/docs/interfaces/PreparedPromptResponse.html +2 -2
- package/docs/interfaces/ProcessTextResponse.html +2 -2
- package/docs/interfaces/PromptFile.html +2 -2
- package/docs/interfaces/PromptFileContent.html +2 -2
- package/docs/interfaces/PromptFilesResponse.html +2 -2
- package/docs/interfaces/PromptFolder.html +2 -2
- package/docs/interfaces/PromptFoldersResponse.html +2 -2
- package/docs/interfaces/RoomDetails.html +2 -2
- package/docs/interfaces/RoomInfo.html +2 -2
- package/docs/interfaces/RoomMessagesResponse.html +2 -2
- package/docs/interfaces/StoryErrorEvent.html +3 -3
- package/docs/interfaces/StoryIdea.html +2 -2
- package/docs/interfaces/StoryInfo.html +6 -2
- package/docs/interfaces/StoryIntroduceCharacterEvent.html +3 -3
- package/docs/interfaces/StoryProgressChapterEvent.html +3 -3
- package/docs/interfaces/StoryState.html +5 -5
- package/docs/interfaces/StoryStateEvent.html +3 -3
- package/docs/interfaces/Transaction.html +2 -2
- package/docs/interfaces/TransactionHistoryResponse.html +2 -2
- package/docs/modules.html +1 -1
- package/docs/types/PromptScope.html +1 -1
- package/package.json +8 -8
- package/dist/server/src/ai/model_prices.d.ts +0 -1
- /package/data/common/prompts/character/{compact_story.json → compact_agent.json} +0 -0
- /package/data/common/prompts/character/{compact_story.prompt → compact_agent.prompt} +0 -0
- /package/data/common/prompts/narrator/{compact_story.json → compact_agent.json} +0 -0
- /package/data/common/prompts/narrator/{compact_story.prompt → compact_agent.prompt} +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/anthropic.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/anthropic.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/anthropic.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/deepseek.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/deepseek.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/fal.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/fal.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/googleai.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/googleai.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/googleai.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/googleai.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/grok.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/grok.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/mock.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/mock.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/mock.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/mock.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/openai.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/openai.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/openai.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/openai.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/together.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/together.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/vertexai.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/vertexai.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/vertexai.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/LLM/vertexai.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-config.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-config.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-factory.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-factory.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-message.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-message.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-store.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-store.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-store.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/agent-store.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/ai-factory.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/ai-factory.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/ai-factory.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/ai-factory.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/artifact.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/artifact.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/artifact.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/artifact.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/attached-file.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/attached-file.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/attached-file.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/ai/attached-file.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/ai/published-agents.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/balance-message.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/balance-message.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/app/balance.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/balance.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/app/balance.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/balance.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/app/stripe.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/stripe.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/app/transaction.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/transaction.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/app/user-service-factory.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/user-service-factory.js +0 -0
- /package/{dist → dist-sdk}/server/src/app/user-service-manager.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app/user-service-manager.js +0 -0
- /package/{dist → dist-sdk}/server/src/app.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/app.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/agent-access.decorator.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/agent-access.decorator.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/auth.controller.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/auth.controller.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/auth.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/auth.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/auth.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/auth.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/bot-login.dto.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/bot-login.dto.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/password-reset.dto.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/password-reset.dto.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/phone-login.dto.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/phone-login.dto.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/phone-verification.dto.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/dto/phone-verification.dto.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/jwt-auth.guard.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/jwt-auth.guard.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/jwt.strategy.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/jwt.strategy.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/phone-validation.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/phone-validation.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/public.decorator.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/public.decorator.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/rate-limit.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/rate-limit.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/room-access.decorator.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/room-access.decorator.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/scopes.decorator.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/scopes.decorator.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/scopes.guard.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/scopes.guard.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/session.guard.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/session.guard.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/twilio.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/auth/twilio.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/auth/users.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/common/errors.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/common/errors.js +0 -0
- /package/{dist → dist-sdk}/server/src/common/logger.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/common/logger.js +0 -0
- /package/{dist → dist-sdk}/server/src/config/configuration.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/config/configuration.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/config/configuration.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/artifact-store.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/artifact-store.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/artifact.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/artifact.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/message.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/message.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/published-rooms.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-config.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-config.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-factory.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-factory.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-message.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-message.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-message.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-message.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-store.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-store.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-store.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/room/room-store.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/room/room.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/sdk/briyah-config.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/sdk/briyah.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/sdk/index.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/sdk/index.js +0 -0
- /package/{dist → dist-sdk}/server/src/shared/shared.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/shared/shared.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-message.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-progress.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-progress.service.js +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-store.module.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-store.module.js +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-store.service.d.ts +0 -0
- /package/{dist → dist-sdk}/server/src/story/story-store.service.js +0 -0
- /package/{dist → dist-sdk}/shared/types/app.types.js +0 -0
|
@@ -14,10 +14,18 @@
|
|
|
14
14
|
"cost": "80"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"name": "Claude Opus 4.
|
|
17
|
+
"name": "Claude Opus 4.7",
|
|
18
18
|
"description": "Overkill for storytelling",
|
|
19
19
|
"service": "Anthropic",
|
|
20
|
-
"model": "claude-opus-4-
|
|
20
|
+
"model": "claude-opus-4-7",
|
|
21
21
|
"cost": "1500"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Grok 4.20",
|
|
25
|
+
"description": "",
|
|
26
|
+
"service": "Grok",
|
|
27
|
+
"model": "grok-4.20-0309-reasoning",
|
|
28
|
+
"cost": "300"
|
|
22
29
|
}
|
|
30
|
+
|
|
23
31
|
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
You are helping to compact a conversation history to save space while preserving all important information.
|
|
2
|
+
|
|
3
|
+
Please create a comprehensive summary of the following conversation that includes:
|
|
4
|
+
1. Key events, exchanges, and outcomes
|
|
5
|
+
2. Decisions, commitments, and agreements made
|
|
6
|
+
3. Significant information revealed or discovered
|
|
7
|
+
4. Questions or issues still open
|
|
8
|
+
5. Any artifacts, objects, or entities introduced
|
|
9
|
+
6. Relationships and attitudes between participants
|
|
10
|
+
7. Ongoing goals, tasks, or objectives
|
|
11
|
+
8. The current state and context
|
|
12
|
+
|
|
13
|
+
The summary should be written from the perspective of {{agentName}} and should allow the conversation to continue seamlessly as if no compaction occurred. Focus on anything that would change {{agentName}}'s future behavior or responses.
|
|
14
|
+
|
|
15
|
+
CONVERSATION HISTORY TO SUMMARIZE:
|
|
16
|
+
{{formattedHistory}}
|
|
@@ -26,10 +26,11 @@ Use this information to guide your narration letting characters discover any sec
|
|
|
26
26
|
|
|
27
27
|
## Your Role as Narrator
|
|
28
28
|
|
|
29
|
-
### When you receive a message that a character
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
29
|
+
### When you receive a user message, that means a character is requesting to perform an action and you must narrate both the action and its outcome
|
|
30
|
+
- **IMPORTANT**: Every user message you receive (even lengthly prose with dialog) does *not* get incorporated into the user-readable story. Only your narration is ultimately visible to the story readers. Even if you end up just restating exactly what the user said, narrate every user message.
|
|
31
|
+
NARRATION RULES:
|
|
32
|
+
- Ignore any part of the requested action that specifies a certain outcome (characters only get to specify what they want to do; you must determine what actually happens).
|
|
33
|
+
- Think about what the most realistic outcomes of that action might be using your knowledge of the story world
|
|
33
34
|
- Narrate the requested action and the details of how it plays out
|
|
34
35
|
- If the character has included any dialog in their request, try to incorporate it into your narration as appropriate
|
|
35
36
|
- Describe what happens with vivid details
|
|
@@ -40,15 +41,11 @@ You must:
|
|
|
40
41
|
- Use present tense for descriptions
|
|
41
42
|
- If a character's words or actions contain explicit content, narrate actions that will redirect the story and prevent the explicit content from happening
|
|
42
43
|
|
|
43
|
-
### When you receive a message that a character wants to speak to another character
|
|
44
|
-
You must:
|
|
45
|
-
- Use the Character Profile of the Human agent to create a realistic response to the current situation
|
|
46
|
-
|
|
47
44
|
### Progressing to the next chapter
|
|
48
45
|
When the story gets to a point where the characters have worked through a lot of the content in the plot plan
|
|
49
46
|
or if the characters are moving a story in a different direction than the plot plan anticipated, return the single string `# Situation: PROGRESS`
|
|
50
|
-
This will cause the system to
|
|
51
|
-
Try to do this when there is a
|
|
47
|
+
This will cause the system to update the plot plan and the character profiles to move the story along.
|
|
48
|
+
Try to do this when there is a notable pause (end of day) or a significant transition in the story direction.
|
|
52
49
|
|
|
53
50
|
### When you receive a PASS message
|
|
54
51
|
This means the user has decided not to take any particular action, so just continue narrating more of the story.
|
|
@@ -59,9 +56,8 @@ You must:
|
|
|
59
56
|
- Narrate the consequences of the passage of time and what happens next
|
|
60
57
|
|
|
61
58
|
### When you receive an INTRODUCE character message from the 'system'
|
|
62
|
-
You must:
|
|
63
59
|
- If the character already exists in the story, this just means they have a new character profile. Narrate the next bit of the story taking this character's profile into consideration.
|
|
64
|
-
- If the character does *not* already exist in the story, find a way to introduce the new character into the story in a way that fits into the narrative
|
|
60
|
+
- If the character does *not* already exist in the story, find a way to introduce the new character (as described) into the story in a way that fits into the narrative.
|
|
65
61
|
|
|
66
62
|
|
|
67
63
|
## Response Format
|
|
@@ -75,7 +71,7 @@ It **must** be on a single line that begins with `# Situation: `
|
|
|
75
71
|
|
|
76
72
|
**Good situation examples:**
|
|
77
73
|
- # Situation: 19:45 - Mike and Jessica are having a conversation around the fire while the others rest
|
|
78
|
-
- # Situation:
|
|
74
|
+
- # Situation: 21:40 - Alex, Bob, and Cindy are rowing down the river together at dusk
|
|
79
75
|
- # Situation: 18:05 - Alex is sneaking off into the woods alone
|
|
80
76
|
|
|
81
77
|
**Why situation matters:**
|
|
@@ -111,7 +107,6 @@ Mike and Jessica spend half an hour climbing down the stairs and find themselves
|
|
|
111
107
|
- **Do NOT end with a question to the characters (like 'What does Mike do next?') - this is the moderator's job**'
|
|
112
108
|
|
|
113
109
|
## Content Guidelines
|
|
114
|
-
- Do *not* use the words 'god' or 'Jesus' unless you are actually referring to those persons.
|
|
115
110
|
- Do *not* use profanity or swear words like: hell, damn, and shit
|
|
116
111
|
- Do *not* use substitution words for profanity; simply find another way to express the same idea.
|
|
117
112
|
- Do *not* use phrases like 'God only knows' or 'Oh my God' or even substitutes like 'Oh my gosh'
|
|
@@ -125,7 +120,7 @@ Mike and Jessica spend half an hour climbing down the stairs and find themselves
|
|
|
125
120
|
## Examples
|
|
126
121
|
|
|
127
122
|
**Example 1: Character declares an action**
|
|
128
|
-
> Mike
|
|
123
|
+
> From Mike: Mike carefully examines the ancient inscription on the temple wall, running his fingers along the carved symbols.
|
|
129
124
|
|
|
130
125
|
Correct response:
|
|
131
126
|
```
|
|
@@ -134,8 +129,9 @@ As Mike traces the weathered symbols with his fingers, he notices they form a pa
|
|
|
134
129
|
```
|
|
135
130
|
NOTE: The character's own declaration of their action is not automatically included in the message history of the story, so you must narrate what the character does as well as the result.
|
|
136
131
|
|
|
132
|
+
|
|
137
133
|
**Example 2: Character declares action including dialog**
|
|
138
|
-
> Mike
|
|
134
|
+
> From Mike: "I'm coming!" Mike moves quickly to Jessica's side and positions himself next to her at the door. Together they brace their feet against the ground, and Mike nods to her. "On three. One... two... three!" Mike puts his full weight into pushing the door.
|
|
139
135
|
|
|
140
136
|
Correct response:
|
|
141
137
|
```
|
|
@@ -143,32 +139,37 @@ Correct response:
|
|
|
143
139
|
"I'm coming!" Mike moves quickly to Jessica's side and positions himself next to her at the door. Together they brace their feet against the ground, and Mike nods to her. "On three. One... two... three!" Mike puts his full weight into pushing the door. At first, the door doesn't budge - it hasn't moved in centuries. Then, with a low grinding sound that echoes through the chamber, the stone begins to shift. Inch by inch, they force it open, their muscles straining with the effort. Ancient dust cascades from the top of the doorway as the door swings inward, revealing only darkness beyond. The air that rushes out is stale and carries an odd metallic scent. From somewhere in the darkness ahead, everyone hears a sound - rhythmic and distant. Drip... drip... drip.
|
|
144
140
|
```
|
|
145
141
|
NOTE: If the character includes dialog in their declared action, try to incorporate it into your narration of the action and the outcome if appropriate.
|
|
142
|
+
Remember, the user will only see your narration, so you must narrate the requested action itself and the outcome.
|
|
143
|
+
|
|
146
144
|
|
|
147
|
-
**Example 3:
|
|
148
|
-
>
|
|
145
|
+
**Example 3: Character includes action outcomes in their request**
|
|
146
|
+
> From Mike: "I'll get it, Jessica!" Mike lunges toward the rolling artifact and catches it just before it plunges into the ravine.
|
|
149
147
|
|
|
150
148
|
Correct response:
|
|
151
149
|
```
|
|
152
|
-
# Situation:
|
|
153
|
-
|
|
150
|
+
# Situation: 14:00 - Jessica and Mike are recovering an ancient artifact
|
|
151
|
+
"I'll get it, Jessica!" Mike lunges toward the rolling artifact, but it's moving far too quickly. It tumbles into the ravine before Mike is able to reach it.
|
|
154
152
|
```
|
|
153
|
+
NOTE: Try to preserve the dialog and the character's intended action but only you, the narrator, get to determine the actual outcome.
|
|
154
|
+
|
|
155
155
|
|
|
156
|
-
**Example 4:
|
|
157
|
-
>
|
|
156
|
+
**Example 4: Character tries to narrate the story**
|
|
157
|
+
> From Mike: Mike raises his parched face and suddenly sees an oasis. "Look, Jessica! It's an oasis! Water at last!"
|
|
158
158
|
|
|
159
159
|
Correct response:
|
|
160
160
|
```
|
|
161
|
-
# Situation:
|
|
162
|
-
|
|
161
|
+
# Situation: 15:00 - Jessica and Mike are dehydrated and wandering in the desert
|
|
162
|
+
Mike raises his parched face points ahead of them. "Look, Jessica! It's an oasis! Water at last!" But as they approach it, it turns out to be only a mirage.
|
|
163
163
|
```
|
|
164
|
+
NOTE: Decide outcomes based on the plot plan and your judgement of what is most realistic in the story world. Do *not* let the characters narrate their own outcomes.
|
|
164
165
|
|
|
165
|
-
**Example 5:
|
|
166
|
-
>
|
|
166
|
+
**Example 5: Advancing time and setting new scene**
|
|
167
|
+
> PASS
|
|
167
168
|
|
|
168
169
|
Correct response:
|
|
169
170
|
```
|
|
170
|
-
# Situation:
|
|
171
|
-
|
|
171
|
+
# Situation: 19:30 - Mike and Jessica are camping at night near the temple ruins
|
|
172
|
+
Time passes. As the sun begins to set, painting the sky in shades of orange and crimson, the group makes camp at the edge of the temple ruins. The temperature drops rapidly with nightfall, and strange sounds echo from the jungle around them - howls and chittering that seem too organized to be entirely natural. During the night watch, Elena notices something troubling: the symbols on the artifact they discovered are glowing faintly in the darkness, pulsing with a rhythm that matches her own heartbeat. Whatever they've awakened with their discovery, it's not content to remain dormant.
|
|
172
173
|
```
|
|
173
174
|
|
|
174
175
|
**Example 6: Progressing to a New Chapter**
|
|
@@ -184,3 +185,4 @@ Correct response:
|
|
|
184
185
|
- **Use your plot plan** - weave in prepared story elements, secrets, and twists
|
|
185
186
|
- **Challenge the characters** - create obstacles, danger, and difficult choices
|
|
186
187
|
- **Be fair but realistic** - actions have logical consequences in the story world
|
|
188
|
+
- **Only your narration appears in the story, not the user's original message. So, narrate both their intended action the outcome.
|
|
@@ -26,22 +26,26 @@ Filter inappropriate language and content from messages.
|
|
|
26
26
|
Based upon the provided context, determine:
|
|
27
27
|
1. Which characters should realistically be able to hear the Recent Message.
|
|
28
28
|
2. Which single character should be expected to respond to the Recent Message.
|
|
29
|
-
3. Whether or not the Recent Message should
|
|
29
|
+
3. Whether or not the Recent Message represents an action and should be passed to the narrator.
|
|
30
30
|
|
|
31
31
|
To accomplish your task:
|
|
32
32
|
- Analyze the Current Situation in the context of the Story Scenario and your (limited) message history
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
- Determine whether the Sender of the recent message is trying to 1) perform an action or 2) only participate in dialog
|
|
34
|
+
|
|
35
|
+
### If the Sender is intending to perform an action:
|
|
36
|
+
Route the message to the Narrator.
|
|
37
|
+
The Narrator will interpret the message and narrate the outcome of the action.
|
|
38
|
+
This request will *not* become part of the readable story, only the narrator's response
|
|
39
|
+
|
|
40
|
+
### If the Sender is only intending to dialog with other characters
|
|
41
|
+
- Determine which characters would realistically be able to hear this dialog.
|
|
38
42
|
- Decide which of the Available Characters should respond next to best maintain the flow of the conversation and further the story.
|
|
39
43
|
- This dialog message *will* immediately become part of the readable story.
|
|
40
44
|
- If a character sends "PASS", they are choosing not to act or speak at this time. Route to another character (either Narrator with PASS command, or another character if contextually appropriate) to continue the story.
|
|
41
45
|
|
|
42
46
|
## How to respond
|
|
43
47
|
1. Action: Should be "relay" or "relay_silent".
|
|
44
|
-
- Use "relay" when the message should become part of the readable story (dialog or narration).
|
|
48
|
+
- Use "relay" when the message should become part of the readable story (dialog from a character or narration from the narrator).
|
|
45
49
|
- Use "relay_silent" for character action requests that go to the narrator for processing and should not be part of the readable story.
|
|
46
50
|
2. Content: Contains the body of the message to send.
|
|
47
51
|
- If it is appropriate to relay the message unchanged, set 'content' to the string 'relay'.
|
|
@@ -79,7 +83,7 @@ You must respond with a valid JSON object in the following format:
|
|
|
79
83
|
## Introductions
|
|
80
84
|
- Only set "name" to the exact character name (nickname) of one of the characters in **Available Characters** list.
|
|
81
85
|
- However, if a message from the Human Character directly addresses someone in the story who is not listed in the **Available Characters** list, you may introduce that character like this:
|
|
82
|
-
- Set the **name** field to a character name (nickname) of the referenced character.
|
|
86
|
+
- Set the **name** field to a single-word character name (nickname) of the referenced character.
|
|
83
87
|
- Doing this will give the system the opportunity to create a new character profile for that character using the name you provide so that they will appear in the **Available Characters** list in the future.
|
|
84
88
|
- If you receive a message from the system like "INTRODUCE [Character name]", relay the INTRODUCE [Character name] message to the Narrator so they may properly introduce the new character.
|
|
85
89
|
|
|
@@ -201,20 +201,30 @@ let AnthropicAiService = class AnthropicAiService extends base_ai_service_1.Base
|
|
|
201
201
|
else
|
|
202
202
|
maxOutputTokens = modelInfo.max_output_tokens;
|
|
203
203
|
}
|
|
204
|
+
let createParams = {
|
|
205
|
+
model: agent.modelName,
|
|
206
|
+
messages: messages,
|
|
207
|
+
system: systemBlocks,
|
|
208
|
+
max_tokens: maxOutputTokens,
|
|
209
|
+
tools: tools.length > 0 ? tools : undefined,
|
|
210
|
+
};
|
|
211
|
+
if (agent.modelName.includes('4-7')) {
|
|
212
|
+
createParams.temperature = 1;
|
|
213
|
+
createParams.thinking = { type: 'adaptive' };
|
|
214
|
+
createParams.output_config = { effort: agent.reasoningEffort };
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
if (thinkingTokens > 0) {
|
|
218
|
+
createParams.thinking = { type: 'enabled', budget_tokens: thinkingTokens };
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
createParams.thinking = { type: 'disabled' };
|
|
222
|
+
createParams.temperature = 0;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
204
225
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
205
226
|
try {
|
|
206
|
-
const response = await this.anthropic.messages.create(
|
|
207
|
-
model: agent.modelName,
|
|
208
|
-
messages: messages,
|
|
209
|
-
system: systemBlocks,
|
|
210
|
-
max_tokens: maxOutputTokens,
|
|
211
|
-
temperature: thinkingTokens > 0 ? undefined : 0,
|
|
212
|
-
thinking: {
|
|
213
|
-
type: thinkingTokens > 0 ? 'enabled' : 'disabled',
|
|
214
|
-
budget_tokens: thinkingTokens > 0 ? thinkingTokens : undefined,
|
|
215
|
-
},
|
|
216
|
-
tools: tools.length > 0 ? tools : undefined,
|
|
217
|
-
});
|
|
227
|
+
const response = await this.anthropic.messages.create(createParams);
|
|
218
228
|
let responseText = '';
|
|
219
229
|
if (response.content && response.content.length > 0) {
|
|
220
230
|
for (let i = 0; i < response.content.length; i++) {
|
|
@@ -16,6 +16,7 @@ export declare class BaseAiService {
|
|
|
16
16
|
constructor();
|
|
17
17
|
get isAvailable(): boolean;
|
|
18
18
|
getServiceName(): string;
|
|
19
|
+
getModelPricePrefix(): string | null;
|
|
19
20
|
supportsImageGeneration(): boolean;
|
|
20
21
|
supportsPromptCaching(): boolean;
|
|
21
22
|
getCacheConfig(_agent: Agent, _cacheMessage: boolean): any;
|
|
@@ -51,6 +51,7 @@ const fs = __importStar(require("fs"));
|
|
|
51
51
|
const handlebars_1 = require("handlebars");
|
|
52
52
|
const errors_1 = require("../../common/errors");
|
|
53
53
|
const logger_1 = require("../../common/logger");
|
|
54
|
+
const model_prices_1 = require("../model_prices");
|
|
54
55
|
let BaseAiService = class BaseAiService {
|
|
55
56
|
modelsCache = null;
|
|
56
57
|
_isAvailable = true;
|
|
@@ -61,6 +62,9 @@ let BaseAiService = class BaseAiService {
|
|
|
61
62
|
getServiceName() {
|
|
62
63
|
return '';
|
|
63
64
|
}
|
|
65
|
+
getModelPricePrefix() {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
64
68
|
supportsImageGeneration() {
|
|
65
69
|
return false;
|
|
66
70
|
}
|
|
@@ -147,6 +151,10 @@ let BaseAiService = class BaseAiService {
|
|
|
147
151
|
if (!agentName) {
|
|
148
152
|
throw new Error('Agent name is required');
|
|
149
153
|
}
|
|
154
|
+
if (!(0, model_prices_1.isKnownModel)(modelName, this.getModelPricePrefix())) {
|
|
155
|
+
throw new Error(`Model '${modelName}' is not listed in model_prices.json for ${this.getServiceName()}. ` +
|
|
156
|
+
`Add a pricing entry before using this model.`);
|
|
157
|
+
}
|
|
150
158
|
const tempAgent = { promptFolder, configService };
|
|
151
159
|
const systemInstructionFile = this.findPromptFile(tempAgent, 'system_instruction', '.prompt');
|
|
152
160
|
let systemInstructionPrompt = null;
|
|
@@ -6,6 +6,7 @@ export declare class DeepSeekAiService extends BaseAiService {
|
|
|
6
6
|
protected deepseekClient: ReturnType<typeof createDeepSeek>;
|
|
7
7
|
constructor();
|
|
8
8
|
getServiceName(): string;
|
|
9
|
+
getModelPricePrefix(): string;
|
|
9
10
|
fetchModelsFromApi(): Promise<ModelInfo[]>;
|
|
10
11
|
addToConversationHistory(agent: Agent, message: string, fromSelf?: boolean): void;
|
|
11
12
|
private jsonSchemaToZod;
|
|
@@ -41,6 +41,9 @@ let DeepSeekAiService = class DeepSeekAiService extends base_ai_service_1.BaseAi
|
|
|
41
41
|
getServiceName() {
|
|
42
42
|
return 'DeepSeek';
|
|
43
43
|
}
|
|
44
|
+
getModelPricePrefix() {
|
|
45
|
+
return 'deepseek';
|
|
46
|
+
}
|
|
44
47
|
async fetchModelsFromApi() {
|
|
45
48
|
try {
|
|
46
49
|
const apiKey = process.env['DEEPSEEK_API_KEY'];
|
|
@@ -4,6 +4,7 @@ import { ModelInfo } from '../../../../shared/types/app.types';
|
|
|
4
4
|
export declare class FalAiService extends BaseAiService {
|
|
5
5
|
constructor();
|
|
6
6
|
getServiceName(): string;
|
|
7
|
+
getModelPricePrefix(): string;
|
|
7
8
|
supportsImageGeneration(): boolean;
|
|
8
9
|
fetchModelsFromApi(): Promise<ModelInfo[]>;
|
|
9
10
|
addToConversationHistory(agent: Agent, message: string, fromSelf?: boolean, developer?: boolean): void;
|
|
@@ -5,6 +5,7 @@ export declare class GrokAiService extends BaseAiService {
|
|
|
5
5
|
private openai;
|
|
6
6
|
constructor();
|
|
7
7
|
getServiceName(): string;
|
|
8
|
+
getModelPricePrefix(): string;
|
|
8
9
|
fetchModelsFromApi(): Promise<ModelInfo[]>;
|
|
9
10
|
attachDocument(agent: Agent, fileName: string, fileData: Uint8Array): Promise<string>;
|
|
10
11
|
finishAgent(agent: Agent): Promise<void>;
|
|
@@ -44,6 +44,9 @@ let GrokAiService = class GrokAiService extends base_ai_service_1.BaseAiService
|
|
|
44
44
|
getServiceName() {
|
|
45
45
|
return 'Grok';
|
|
46
46
|
}
|
|
47
|
+
getModelPricePrefix() {
|
|
48
|
+
return 'xai';
|
|
49
|
+
}
|
|
47
50
|
async fetchModelsFromApi() {
|
|
48
51
|
const models = await this.openai.models.list();
|
|
49
52
|
return models.data.map((model) => {
|
|
@@ -5,6 +5,7 @@ export declare class TogetherAiService extends BaseAiService {
|
|
|
5
5
|
private togetherClient;
|
|
6
6
|
constructor();
|
|
7
7
|
getServiceName(): string;
|
|
8
|
+
getModelPricePrefix(): string;
|
|
8
9
|
supportsImageGeneration(): boolean;
|
|
9
10
|
fetchModelsFromApi(): Promise<ModelInfo[]>;
|
|
10
11
|
addToConversationHistory(agent: Agent, message: string, fromSelf?: boolean, developer?: boolean): void;
|
|
@@ -67,6 +67,13 @@ export declare class Agent {
|
|
|
67
67
|
trimHistoryIfNeeded(threshold?: number): void;
|
|
68
68
|
instructedPrompt(prompt: string, instructionFileName: string, variables: any, saveResponse?: boolean, cacheMessage?: boolean, maxOutputChars?: number): Promise<any>;
|
|
69
69
|
preparedPrompt(promptFileName: string, variables: any, saveResponse?: boolean, cacheMessage?: boolean): Promise<any>;
|
|
70
|
+
compact(): Promise<{
|
|
71
|
+
success: boolean;
|
|
72
|
+
originalLength: number;
|
|
73
|
+
newLength: number;
|
|
74
|
+
message: string;
|
|
75
|
+
summary?: string;
|
|
76
|
+
}>;
|
|
70
77
|
textPrompt(prompt: string, jsonSchema?: any, saveResponse?: boolean, promptInstructions?: string, cacheMessage?: boolean, maxOutputChars?: number): Promise<any>;
|
|
71
78
|
generateImage(prompt: string, width: number, height: number, quality: string, referenceImageArtifactIds?: string[]): Promise<{
|
|
72
79
|
artifactId?: string;
|
|
@@ -164,6 +164,38 @@ class Agent {
|
|
|
164
164
|
async preparedPrompt(promptFileName, variables, saveResponse = true, cacheMessage = false) {
|
|
165
165
|
return await this.aiService.preparedPrompt(this, promptFileName, variables, saveResponse, this.aiService.getCacheConfig(this, cacheMessage));
|
|
166
166
|
}
|
|
167
|
+
async compact() {
|
|
168
|
+
const originalHistory = [...(this.history || [])];
|
|
169
|
+
const originalLength = originalHistory.length;
|
|
170
|
+
if (originalLength === 0) {
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
originalLength,
|
|
174
|
+
newLength: originalLength,
|
|
175
|
+
message: 'No conversation history to compact',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const formattedHistory = this.getFormattedMessages(0);
|
|
179
|
+
try {
|
|
180
|
+
this.history = [];
|
|
181
|
+
const summaryResponse = await this.preparedPrompt('compact_agent', { agentName: this.agentNickname, formattedHistory }, false);
|
|
182
|
+
const summary = summaryResponse?.summary || summaryResponse;
|
|
183
|
+
this.addToConversationHistory(`[CONVERSATION HISTORY SUMMARY]\n\n${summary}`, true);
|
|
184
|
+
const newLength = this.history.length;
|
|
185
|
+
this.save();
|
|
186
|
+
return {
|
|
187
|
+
success: true,
|
|
188
|
+
originalLength,
|
|
189
|
+
newLength,
|
|
190
|
+
message: `${originalLength} messages -> ${newLength} messages`,
|
|
191
|
+
summary,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
this.history = originalHistory;
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
167
199
|
async textPrompt(prompt, jsonSchema = null, saveResponse = true, promptInstructions = null, cacheMessage = false, maxOutputChars = 0) {
|
|
168
200
|
return await this.aiService.textPrompt(this, prompt, jsonSchema, saveResponse, promptInstructions, this.aiService.getCacheConfig(this, cacheMessage), maxOutputChars);
|
|
169
201
|
}
|
|
@@ -34,13 +34,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getModelPrices = getModelPrices;
|
|
37
|
+
exports.resolveModelInfo = resolveModelInfo;
|
|
38
|
+
exports.isKnownModel = isKnownModel;
|
|
37
39
|
const fs = __importStar(require("fs"));
|
|
38
40
|
const path = __importStar(require("path"));
|
|
39
41
|
let _modelPrices = null;
|
|
40
42
|
function getModelPrices() {
|
|
41
43
|
if (_modelPrices !== null)
|
|
42
44
|
return _modelPrices;
|
|
43
|
-
const dataDir = process.env.
|
|
45
|
+
const dataDir = process.env.BRIYAH_DATA_PATH || path.resolve(process.cwd(), 'briyah-data');
|
|
44
46
|
const pricesFilePath = path.join(dataDir, 'common', 'config', 'model_prices.json');
|
|
45
47
|
if (!fs.existsSync(pricesFilePath)) {
|
|
46
48
|
throw new Error(`Model prices file not found at ${pricesFilePath}. Cannot proceed without pricing data.`);
|
|
@@ -53,3 +55,19 @@ function getModelPrices() {
|
|
|
53
55
|
}
|
|
54
56
|
return _modelPrices;
|
|
55
57
|
}
|
|
58
|
+
function resolveModelInfo(modelName, prefix) {
|
|
59
|
+
if (!modelName)
|
|
60
|
+
return null;
|
|
61
|
+
const prices = getModelPrices();
|
|
62
|
+
if (prices[modelName])
|
|
63
|
+
return prices[modelName];
|
|
64
|
+
if (prefix) {
|
|
65
|
+
const prefixed = `${prefix}/${modelName}`;
|
|
66
|
+
if (prices[prefixed])
|
|
67
|
+
return prices[prefixed];
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function isKnownModel(modelName, prefix) {
|
|
72
|
+
return resolveModelInfo(modelName, prefix) !== null;
|
|
73
|
+
}
|
|
@@ -51,7 +51,7 @@ let PublishedAgentsService = class PublishedAgentsService {
|
|
|
51
51
|
mapping = new Map();
|
|
52
52
|
mappingFile;
|
|
53
53
|
constructor() {
|
|
54
|
-
const dataPath = process.env.
|
|
54
|
+
const dataPath = process.env.BRIYAH_DATA_PATH || path.resolve(process.cwd(), 'briyah-data');
|
|
55
55
|
const dataDir = path.resolve(dataPath, 'common');
|
|
56
56
|
if (!fs.existsSync(dataDir)) {
|
|
57
57
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
@@ -17,6 +17,9 @@ export declare class StripeController {
|
|
|
17
17
|
userId: string;
|
|
18
18
|
};
|
|
19
19
|
}, body: CreateCheckoutSessionRequest): Promise<CreateCheckoutSessionResponse>;
|
|
20
|
+
getCheckoutSessionBalance(sessionId: string): Promise<{
|
|
21
|
+
balance: number;
|
|
22
|
+
}>;
|
|
20
23
|
getStripeConfig(): Promise<{
|
|
21
24
|
publishableKey: string;
|
|
22
25
|
}>;
|
|
@@ -40,6 +40,11 @@ let StripeController = class StripeController {
|
|
|
40
40
|
const result = await this.stripeService.createCheckoutSession(userId, amount, appService);
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
|
+
async getCheckoutSessionBalance(sessionId) {
|
|
44
|
+
const { userId } = await this.stripeService.getCheckoutSessionUser(sessionId);
|
|
45
|
+
const appService = this.userServiceManager.getAppService(userId);
|
|
46
|
+
return { balance: appService.getBalance() };
|
|
47
|
+
}
|
|
43
48
|
async getStripeConfig() {
|
|
44
49
|
return this.stripeService.getStripeConfig();
|
|
45
50
|
}
|
|
@@ -114,6 +119,14 @@ __decorate([
|
|
|
114
119
|
__metadata("design:paramtypes", [Object, Object]),
|
|
115
120
|
__metadata("design:returntype", Promise)
|
|
116
121
|
], StripeController.prototype, "createCheckoutSession", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, public_decorator_1.Public)(),
|
|
124
|
+
(0, common_1.Get)('session/:sessionId/balance'),
|
|
125
|
+
__param(0, (0, common_1.Param)('sessionId')),
|
|
126
|
+
__metadata("design:type", Function),
|
|
127
|
+
__metadata("design:paramtypes", [String]),
|
|
128
|
+
__metadata("design:returntype", Promise)
|
|
129
|
+
], StripeController.prototype, "getCheckoutSessionBalance", null);
|
|
117
130
|
__decorate([
|
|
118
131
|
(0, common_1.Get)('config'),
|
|
119
132
|
__metadata("design:type", Function),
|
|
@@ -17,6 +17,10 @@ export declare class StripeService {
|
|
|
17
17
|
createCheckoutSession(userId: string, amount: number, appService: AppService): Promise<{
|
|
18
18
|
url: string;
|
|
19
19
|
}>;
|
|
20
|
+
getCheckoutSessionUser(sessionId: string): Promise<{
|
|
21
|
+
userId: string;
|
|
22
|
+
paymentStatus: string;
|
|
23
|
+
}>;
|
|
20
24
|
getStripeConfig(): {
|
|
21
25
|
publishableKey: string;
|
|
22
26
|
};
|
|
@@ -124,6 +124,22 @@ let StripeService = class StripeService {
|
|
|
124
124
|
throw new common_1.InternalServerErrorException('Failed to create checkout session');
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
async getCheckoutSessionUser(sessionId) {
|
|
128
|
+
try {
|
|
129
|
+
const session = await this.stripe.checkout.sessions.retrieve(sessionId);
|
|
130
|
+
const userId = session.metadata?.userId;
|
|
131
|
+
if (!userId) {
|
|
132
|
+
throw new common_1.BadRequestException('Session has no userId in metadata');
|
|
133
|
+
}
|
|
134
|
+
return { userId, paymentStatus: session.payment_status };
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (error instanceof common_1.BadRequestException)
|
|
138
|
+
throw error;
|
|
139
|
+
logger_1.logger.error('Error retrieving checkout session:', error);
|
|
140
|
+
throw new common_1.BadRequestException('Invalid or expired session ID');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
127
143
|
getStripeConfig() {
|
|
128
144
|
return {
|
|
129
145
|
publishableKey: this.publishableKey,
|
|
@@ -110,6 +110,7 @@ export declare class AppController {
|
|
|
110
110
|
updateAgent(req: ExpressRequest, agentId: string, updateData: UpdateAgentRequest): Promise<void>;
|
|
111
111
|
deleteAttachedFile(req: ExpressRequest, agentId: string, documentId: string): Promise<void>;
|
|
112
112
|
reloadAgent(req: ExpressRequest, agentId: string): Promise<void>;
|
|
113
|
+
compactAgentConversation(req: ExpressRequest, agentId: string): Promise<void>;
|
|
113
114
|
resetRoom(req: ExpressRequest, roomId: string): Promise<void>;
|
|
114
115
|
publishRoom(req: ExpressRequest, templateId: string, body: {
|
|
115
116
|
publishedName?: string;
|