briyah 1.1.6 → 1.2.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/dist-sdk/server/src/ai/LLM/anthropic.service.d.ts +3 -2
- package/dist-sdk/server/src/ai/LLM/anthropic.service.js +2 -2
- package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +3 -2
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +10 -10
- package/dist-sdk/server/src/ai/agent-factory.d.ts +5 -3
- package/dist-sdk/server/src/ai/agent-factory.js +6 -4
- package/dist-sdk/server/src/ai/agent-store.service.d.ts +5 -3
- package/dist-sdk/server/src/ai/agent-store.service.js +15 -15
- package/dist-sdk/server/src/ai/agent.d.ts +5 -3
- package/dist-sdk/server/src/ai/agent.js +10 -1
- package/dist-sdk/server/src/ai/artifact.module.js +2 -2
- package/dist-sdk/server/src/ai/artifact.service.d.ts +3 -3
- package/dist-sdk/server/src/ai/artifact.service.js +6 -6
- package/dist-sdk/server/src/ai/attached-file.module.js +2 -2
- package/dist-sdk/server/src/ai/attached-file.service.d.ts +3 -3
- package/dist-sdk/server/src/ai/attached-file.service.js +6 -6
- package/dist-sdk/server/src/app/balance.service.d.ts +3 -3
- package/dist-sdk/server/src/app/balance.service.js +7 -7
- package/dist-sdk/server/src/app/transaction.service.d.ts +3 -3
- package/dist-sdk/server/src/app/transaction.service.js +4 -4
- package/dist-sdk/server/src/app/user-service-factory.d.ts +3 -1
- package/dist-sdk/server/src/app/user-service-factory.js +18 -14
- package/dist-sdk/server/src/app/user-service-manager.d.ts +1 -3
- package/dist-sdk/server/src/app.service.d.ts +3 -3
- package/dist-sdk/server/src/app.service.js +30 -30
- package/dist-sdk/server/src/config/env-config.d.ts +3 -0
- package/dist-sdk/server/src/config/env-config.js +2 -0
- package/dist-sdk/server/src/config/user-paths.module.d.ts +2 -0
- package/dist-sdk/server/src/config/{configuration.module.js → user-paths.module.js} +8 -8
- package/dist-sdk/server/src/config/{configuration.service.d.ts → user-paths.service.d.ts} +1 -1
- package/dist-sdk/server/src/config/{configuration.service.js → user-paths.service.js} +3 -3
- package/dist-sdk/server/src/room/room-store.module.js +2 -2
- package/dist-sdk/server/src/room/room-store.service.d.ts +3 -3
- package/dist-sdk/server/src/room/room-store.service.js +6 -6
- package/dist-sdk/server/src/sdk/briyah-config.d.ts +2 -1
- package/dist-sdk/server/src/sdk/briyah-config.js +4 -0
- package/dist-sdk/server/src/sdk/briyah.js +1 -1
- package/dist-sdk/server/src/story/story-store.service.d.ts +3 -3
- package/dist-sdk/server/src/story/story-store.service.js +6 -6
- package/dist-sdk/server/src/story/story.service.d.ts +3 -3
- package/dist-sdk/server/src/story/story.service.js +13 -13
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Agent.html +15 -14
- package/docs/classes/Briyah.html +12 -12
- package/docs/classes/BriyahConfigService.html +5 -5
- package/docs/classes/Room.html +24 -24
- package/docs/classes/RoomMessage.html +10 -10
- package/docs/enums/MessageAction.html +3 -3
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +2 -2
- package/docs/interfaces/AgentInfo.html +2 -2
- package/docs/interfaces/AgentMessagesResponse.html +2 -2
- package/docs/interfaces/AppService.html +154 -154
- 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 +9 -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 +3 -3
- 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 +1 -1
- package/dist-sdk/server/src/config/configuration.module.d.ts +0 -2
|
@@ -11,8 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UserServiceFactory = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
14
15
|
const app_service_1 = require("../app.service");
|
|
15
|
-
const
|
|
16
|
+
const user_paths_service_1 = require("../config/user-paths.service");
|
|
16
17
|
const agent_store_service_1 = require("../ai/agent-store.service");
|
|
17
18
|
const room_store_service_1 = require("../room/room-store.service");
|
|
18
19
|
const artifact_store_service_1 = require("../room/artifact-store.service");
|
|
@@ -41,7 +42,8 @@ let UserServiceFactory = class UserServiceFactory {
|
|
|
41
42
|
publishedAgentsService;
|
|
42
43
|
publishedRoomsService;
|
|
43
44
|
balanceMessageService;
|
|
44
|
-
|
|
45
|
+
configService;
|
|
46
|
+
constructor(aiFactoryService, agentMessageService, roomMessageService, storyProgressService, storyMessageService, publishedAgentsService, publishedRoomsService, balanceMessageService, configService) {
|
|
45
47
|
this.aiFactoryService = aiFactoryService;
|
|
46
48
|
this.agentMessageService = agentMessageService;
|
|
47
49
|
this.roomMessageService = roomMessageService;
|
|
@@ -50,21 +52,22 @@ let UserServiceFactory = class UserServiceFactory {
|
|
|
50
52
|
this.publishedAgentsService = publishedAgentsService;
|
|
51
53
|
this.publishedRoomsService = publishedRoomsService;
|
|
52
54
|
this.balanceMessageService = balanceMessageService;
|
|
55
|
+
this.configService = configService;
|
|
53
56
|
}
|
|
54
57
|
createAppService(userId) {
|
|
55
|
-
const
|
|
56
|
-
const balanceService = new balance_service_1.BalanceService(userId,
|
|
57
|
-
const transactionService = new transaction_service_1.TransactionService(userId,
|
|
58
|
-
const attachedFileService = new attached_file_service_1.AttachedFileService(
|
|
59
|
-
const artifactService = new artifact_service_1.ArtifactService(
|
|
60
|
-
const agentStore = new agent_store_service_1.AgentStoreService(this.aiFactoryService,
|
|
61
|
-
const agentFactory = new agent_factory_1.AgentFactory(this.aiFactoryService, agentStore,
|
|
58
|
+
const userPaths = new user_paths_service_1.UserPathsService(userId);
|
|
59
|
+
const balanceService = new balance_service_1.BalanceService(userId, userPaths, this.balanceMessageService);
|
|
60
|
+
const transactionService = new transaction_service_1.TransactionService(userId, userPaths);
|
|
61
|
+
const attachedFileService = new attached_file_service_1.AttachedFileService(userPaths);
|
|
62
|
+
const artifactService = new artifact_service_1.ArtifactService(userPaths);
|
|
63
|
+
const agentStore = new agent_store_service_1.AgentStoreService(this.aiFactoryService, userPaths, attachedFileService, balanceService, artifactService, this.configService);
|
|
64
|
+
const agentFactory = new agent_factory_1.AgentFactory(this.aiFactoryService, agentStore, userPaths, balanceService, artifactService, this.configService);
|
|
62
65
|
const artifactStore = new artifact_store_service_1.ArtifactStoreService();
|
|
63
|
-
const roomStore = new room_store_service_1.RoomStoreService(
|
|
66
|
+
const roomStore = new room_store_service_1.RoomStoreService(userPaths, agentStore, attachedFileService, artifactStore);
|
|
64
67
|
const roomFactory = new room_factory_1.RoomFactory(roomStore);
|
|
65
|
-
const storyStore = new story_store_service_1.StoryStoreService(
|
|
66
|
-
const storyService = new story_service_1.StoryService(storyStore, agentStore, roomStore, this.storyProgressService, this.storyMessageService,
|
|
67
|
-
return new app_service_1.AppService(this.aiFactoryService, agentStore, this.agentMessageService, roomStore, this.roomMessageService,
|
|
68
|
+
const storyStore = new story_store_service_1.StoryStoreService(userPaths, roomStore);
|
|
69
|
+
const storyService = new story_service_1.StoryService(storyStore, agentStore, roomStore, this.storyProgressService, this.storyMessageService, userPaths, agentFactory, roomFactory);
|
|
70
|
+
return new app_service_1.AppService(this.aiFactoryService, agentStore, this.agentMessageService, roomStore, this.roomMessageService, userPaths, attachedFileService, artifactService, storyStore, storyService, this.publishedAgentsService, this.publishedRoomsService, balanceService, this.balanceMessageService, transactionService, agentFactory, roomFactory);
|
|
68
71
|
}
|
|
69
72
|
};
|
|
70
73
|
exports.UserServiceFactory = UserServiceFactory;
|
|
@@ -77,5 +80,6 @@ exports.UserServiceFactory = UserServiceFactory = __decorate([
|
|
|
77
80
|
story_message_service_1.StoryMessageService,
|
|
78
81
|
published_agents_service_1.PublishedAgentsService,
|
|
79
82
|
published_rooms_service_1.PublishedRoomsService,
|
|
80
|
-
balance_message_service_1.BalanceMessageService
|
|
83
|
+
balance_message_service_1.BalanceMessageService,
|
|
84
|
+
config_1.ConfigService])
|
|
81
85
|
], UserServiceFactory);
|
|
@@ -2,9 +2,7 @@ import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
|
2
2
|
import { ConfigService } from '@nestjs/config';
|
|
3
3
|
import { AppService } from '../app.service';
|
|
4
4
|
import { UserServiceFactory } from './user-service-factory';
|
|
5
|
-
export
|
|
6
|
-
get<T = string>(key: string, defaultValue?: T): T;
|
|
7
|
-
}
|
|
5
|
+
export { IConfigService } from '../config/env-config';
|
|
8
6
|
export declare class UserServiceManager implements OnModuleInit, OnModuleDestroy {
|
|
9
7
|
private readonly userServiceFactory;
|
|
10
8
|
private readonly configService;
|
|
@@ -9,7 +9,7 @@ import { RoomStoreService } from './room/room-store.service';
|
|
|
9
9
|
import { RoomMessageService } from './room/room-message.service';
|
|
10
10
|
import { StoryStoreService } from './story/story-store.service';
|
|
11
11
|
import { StoryService } from './story/story.service';
|
|
12
|
-
import {
|
|
12
|
+
import { UserPathsService } from './config/user-paths.service';
|
|
13
13
|
import { AttachedFileService } from './ai/attached-file.service';
|
|
14
14
|
import { ArtifactService } from './ai/artifact.service';
|
|
15
15
|
import { ArtifactMetadata, ModelInfo, ChapterInfo, StoryIdea } from '../../shared/types/app.types';
|
|
@@ -29,7 +29,7 @@ export declare class AppService {
|
|
|
29
29
|
private readonly agentMessageService;
|
|
30
30
|
private readonly roomStore;
|
|
31
31
|
private readonly roomMessageService;
|
|
32
|
-
private readonly
|
|
32
|
+
private readonly userPaths;
|
|
33
33
|
private readonly attachedFileService;
|
|
34
34
|
private readonly artifactService;
|
|
35
35
|
private readonly storyStore;
|
|
@@ -43,7 +43,7 @@ export declare class AppService {
|
|
|
43
43
|
private readonly roomFactory;
|
|
44
44
|
private aiServices;
|
|
45
45
|
private readonly userPreferencesFile;
|
|
46
|
-
constructor(aiFactoryService: AiFactoryService, agentStore: AgentStoreService, agentMessageService: AgentMessageService, roomStore: RoomStoreService, roomMessageService: RoomMessageService,
|
|
46
|
+
constructor(aiFactoryService: AiFactoryService, agentStore: AgentStoreService, agentMessageService: AgentMessageService, roomStore: RoomStoreService, roomMessageService: RoomMessageService, userPaths: UserPathsService, attachedFileService: AttachedFileService, artifactService: ArtifactService, storyStore: StoryStoreService, storyService: StoryService, publishedAgentsService: PublishedAgentsService, publishedRoomsService: PublishedRoomsService, balanceService: BalanceService, balanceMessageService: BalanceMessageService, transactionService: TransactionService, agentFactory: AgentFactory, roomFactory: RoomFactory);
|
|
47
47
|
getAiServiceNames(): string[];
|
|
48
48
|
getAiServiceFromServiceName(serviceName: string): BaseAiService;
|
|
49
49
|
listAiModels(aiServiceName: string): Promise<ModelInfo[]>;
|
|
@@ -47,7 +47,7 @@ class AppService {
|
|
|
47
47
|
agentMessageService;
|
|
48
48
|
roomStore;
|
|
49
49
|
roomMessageService;
|
|
50
|
-
|
|
50
|
+
userPaths;
|
|
51
51
|
attachedFileService;
|
|
52
52
|
artifactService;
|
|
53
53
|
storyStore;
|
|
@@ -61,13 +61,13 @@ class AppService {
|
|
|
61
61
|
roomFactory;
|
|
62
62
|
aiServices;
|
|
63
63
|
userPreferencesFile = 'user-preferences.json';
|
|
64
|
-
constructor(aiFactoryService, agentStore, agentMessageService, roomStore, roomMessageService,
|
|
64
|
+
constructor(aiFactoryService, agentStore, agentMessageService, roomStore, roomMessageService, userPaths, attachedFileService, artifactService, storyStore, storyService, publishedAgentsService, publishedRoomsService, balanceService, balanceMessageService, transactionService, agentFactory, roomFactory) {
|
|
65
65
|
this.aiFactoryService = aiFactoryService;
|
|
66
66
|
this.agentStore = agentStore;
|
|
67
67
|
this.agentMessageService = agentMessageService;
|
|
68
68
|
this.roomStore = roomStore;
|
|
69
69
|
this.roomMessageService = roomMessageService;
|
|
70
|
-
this.
|
|
70
|
+
this.userPaths = userPaths;
|
|
71
71
|
this.attachedFileService = attachedFileService;
|
|
72
72
|
this.artifactService = artifactService;
|
|
73
73
|
this.storyStore = storyStore;
|
|
@@ -92,7 +92,7 @@ class AppService {
|
|
|
92
92
|
return service.listModels();
|
|
93
93
|
}
|
|
94
94
|
async listImageModels() {
|
|
95
|
-
const imageModelsPath = path.join(this.
|
|
95
|
+
const imageModelsPath = path.join(this.userPaths.getCommonConfigDir(), 'image_models.json');
|
|
96
96
|
try {
|
|
97
97
|
return JSON.parse(fs.readFileSync(imageModelsPath, 'utf8'));
|
|
98
98
|
}
|
|
@@ -102,7 +102,7 @@ class AppService {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
async listStoryModels() {
|
|
105
|
-
const storyModelsPath = path.join(this.
|
|
105
|
+
const storyModelsPath = path.join(this.userPaths.getCommonConfigDir(), 'story_models.json');
|
|
106
106
|
try {
|
|
107
107
|
return JSON.parse(fs.readFileSync(storyModelsPath, 'utf8'));
|
|
108
108
|
}
|
|
@@ -112,7 +112,7 @@ class AppService {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
listStoryGenres() {
|
|
115
|
-
const storyIdeasPath = path.join(this.
|
|
115
|
+
const storyIdeasPath = path.join(this.userPaths.getDataDir(), 'common', 'story_ideas');
|
|
116
116
|
try {
|
|
117
117
|
if (!fs.existsSync(storyIdeasPath)) {
|
|
118
118
|
logger_1.logger.warn(`Story ideas directory does not exist: ${storyIdeasPath}`);
|
|
@@ -128,7 +128,7 @@ class AppService {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
getRandomStoryIdeaByGenre(genreName) {
|
|
131
|
-
const storyIdeasPath = path.join(this.
|
|
131
|
+
const storyIdeasPath = path.join(this.userPaths.getDataDir(), 'common', 'story_ideas', `${genreName}.json`);
|
|
132
132
|
try {
|
|
133
133
|
if (!fs.existsSync(storyIdeasPath)) {
|
|
134
134
|
throw new errors_1.NotFoundError(`Genre "${genreName}" not found`);
|
|
@@ -207,13 +207,13 @@ class AppService {
|
|
|
207
207
|
}
|
|
208
208
|
listPromptFolders() {
|
|
209
209
|
const folders = new Set();
|
|
210
|
-
const commonDir = this.
|
|
210
|
+
const commonDir = this.userPaths.getCommonPromptsDir();
|
|
211
211
|
if (fs.existsSync(commonDir)) {
|
|
212
212
|
fs.readdirSync(commonDir, { withFileTypes: true })
|
|
213
213
|
.filter((dirent) => dirent.isDirectory())
|
|
214
214
|
.forEach((dirent) => folders.add(dirent.name));
|
|
215
215
|
}
|
|
216
|
-
const userDir = this.
|
|
216
|
+
const userDir = this.userPaths.getUserPromptsDir();
|
|
217
217
|
if (fs.existsSync(userDir)) {
|
|
218
218
|
fs.readdirSync(userDir, { withFileTypes: true })
|
|
219
219
|
.filter((dirent) => dirent.isDirectory())
|
|
@@ -224,7 +224,7 @@ class AppService {
|
|
|
224
224
|
listPromptFoldersWithScope(scope) {
|
|
225
225
|
const folders = [];
|
|
226
226
|
const folderMap = new Map();
|
|
227
|
-
const commonDir = this.
|
|
227
|
+
const commonDir = this.userPaths.getCommonPromptsDir();
|
|
228
228
|
if ((!scope || scope === 'common') && fs.existsSync(commonDir)) {
|
|
229
229
|
fs.readdirSync(commonDir, { withFileTypes: true })
|
|
230
230
|
.filter((dirent) => dirent.isDirectory())
|
|
@@ -232,7 +232,7 @@ class AppService {
|
|
|
232
232
|
folderMap.set(dirent.name, 'common');
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
const userDir = this.
|
|
235
|
+
const userDir = this.userPaths.getUserPromptsDir();
|
|
236
236
|
if ((!scope || scope === 'user') && fs.existsSync(userDir)) {
|
|
237
237
|
fs.readdirSync(userDir, { withFileTypes: true })
|
|
238
238
|
.filter((dirent) => dirent.isDirectory())
|
|
@@ -251,7 +251,7 @@ class AppService {
|
|
|
251
251
|
if (!agent) {
|
|
252
252
|
throw new errors_1.NotFoundError(`Agent with ID ${agentId} not found`);
|
|
253
253
|
}
|
|
254
|
-
let agentPromptsDir = path.join(this.
|
|
254
|
+
let agentPromptsDir = path.join(this.userPaths.getPromptsDir(), agent.promptFolder);
|
|
255
255
|
let promptFiles = [];
|
|
256
256
|
if (fs.existsSync(agentPromptsDir)) {
|
|
257
257
|
promptFiles = fs
|
|
@@ -260,7 +260,7 @@ class AppService {
|
|
|
260
260
|
.map((file) => file.replace('.prompt', ''));
|
|
261
261
|
}
|
|
262
262
|
const rootPromptFiles = fs
|
|
263
|
-
.readdirSync(this.
|
|
263
|
+
.readdirSync(this.userPaths.getPromptsDir())
|
|
264
264
|
.filter((file) => file.endsWith('.prompt') && file !== 'system_instruction.prompt')
|
|
265
265
|
.map((file) => file.replace('.prompt', ''));
|
|
266
266
|
promptFiles = [...new Set([...promptFiles, ...rootPromptFiles])];
|
|
@@ -508,7 +508,7 @@ class AppService {
|
|
|
508
508
|
if (!template) {
|
|
509
509
|
throw new errors_1.NotFoundError('Template agent not found');
|
|
510
510
|
}
|
|
511
|
-
const userId = this.
|
|
511
|
+
const userId = this.userPaths.getUserId();
|
|
512
512
|
const instanceId = await this.agentStore.cloneAgentAsPublished(templateId, instanceName, userId);
|
|
513
513
|
this.publishedAgentsService.addPublishedAgent(instanceId, userId);
|
|
514
514
|
return {
|
|
@@ -651,14 +651,14 @@ class AppService {
|
|
|
651
651
|
instance.saveMetadata();
|
|
652
652
|
}
|
|
653
653
|
getUserPreferences() {
|
|
654
|
-
if (!this.
|
|
654
|
+
if (!this.userPaths.exists(this.userPreferencesFile)) {
|
|
655
655
|
return {};
|
|
656
656
|
}
|
|
657
|
-
const preferencesData = this.
|
|
657
|
+
const preferencesData = this.userPaths.load(this.userPreferencesFile);
|
|
658
658
|
return preferencesData ? JSON.parse(preferencesData) : {};
|
|
659
659
|
}
|
|
660
660
|
saveUserPreferences(preferences) {
|
|
661
|
-
this.
|
|
661
|
+
this.userPaths.store(this.userPreferencesFile, JSON.stringify(preferences, null, 2));
|
|
662
662
|
}
|
|
663
663
|
listPromptFiles(folderName) {
|
|
664
664
|
const baseNames = new Set();
|
|
@@ -677,8 +677,8 @@ class AppService {
|
|
|
677
677
|
baseNames.add(baseName);
|
|
678
678
|
});
|
|
679
679
|
};
|
|
680
|
-
scanDirectory(this.
|
|
681
|
-
scanDirectory(this.
|
|
680
|
+
scanDirectory(this.userPaths.getCommonPromptsDir());
|
|
681
|
+
scanDirectory(this.userPaths.getUserPromptsDir());
|
|
682
682
|
return { files: Array.from(baseNames).sort() };
|
|
683
683
|
}
|
|
684
684
|
listPromptFilesWithScope(folderName) {
|
|
@@ -697,8 +697,8 @@ class AppService {
|
|
|
697
697
|
fileMap.set(file, scope);
|
|
698
698
|
});
|
|
699
699
|
};
|
|
700
|
-
scanDirectory(this.
|
|
701
|
-
scanDirectory(this.
|
|
700
|
+
scanDirectory(this.userPaths.getCommonPromptsDir(), 'common');
|
|
701
|
+
scanDirectory(this.userPaths.getUserPromptsDir(), 'user');
|
|
702
702
|
const files = [];
|
|
703
703
|
fileMap.forEach((scope, name) => {
|
|
704
704
|
files.push({ name, scope });
|
|
@@ -709,8 +709,8 @@ class AppService {
|
|
|
709
709
|
getPromptFile(folderName, fileName) {
|
|
710
710
|
const fileExtension = fileName.endsWith('.prompt') || fileName.endsWith('.json') ? '' : '.prompt';
|
|
711
711
|
const fullFileName = fileName + fileExtension;
|
|
712
|
-
const userDir = this.
|
|
713
|
-
const commonDir = this.
|
|
712
|
+
const userDir = this.userPaths.getUserPromptsDir();
|
|
713
|
+
const commonDir = this.userPaths.getCommonPromptsDir();
|
|
714
714
|
const searchPaths = [];
|
|
715
715
|
if (folderName === 'shared') {
|
|
716
716
|
searchPaths.push({ path: path.join(userDir, fullFileName), scope: 'user' }, { path: path.join(commonDir, fullFileName), scope: 'common' });
|
|
@@ -730,9 +730,9 @@ class AppService {
|
|
|
730
730
|
return { content: '' };
|
|
731
731
|
}
|
|
732
732
|
savePromptFile(folderName, fileName, content, fileType) {
|
|
733
|
-
let targetDir = this.
|
|
733
|
+
let targetDir = this.userPaths.getUserPromptsDir();
|
|
734
734
|
if (folderName !== 'shared') {
|
|
735
|
-
targetDir = path.join(this.
|
|
735
|
+
targetDir = path.join(this.userPaths.getUserPromptsDir(), folderName);
|
|
736
736
|
}
|
|
737
737
|
if (!fs.existsSync(targetDir)) {
|
|
738
738
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
@@ -748,7 +748,7 @@ class AppService {
|
|
|
748
748
|
fs.writeFileSync(filePath, content);
|
|
749
749
|
}
|
|
750
750
|
deletePromptFile(folderName, fileName) {
|
|
751
|
-
const baseDir = this.
|
|
751
|
+
const baseDir = this.userPaths.getUserPromptsDir();
|
|
752
752
|
const targetDir = folderName === 'shared' ? baseDir : path.join(baseDir, folderName);
|
|
753
753
|
const hasExtension = fileName.endsWith('.prompt') || fileName.endsWith('.json');
|
|
754
754
|
if (hasExtension) {
|
|
@@ -781,10 +781,10 @@ class AppService {
|
|
|
781
781
|
room.publishArtifact(name, creator, body, viewers);
|
|
782
782
|
}
|
|
783
783
|
getUserPromptsDir() {
|
|
784
|
-
return this.
|
|
784
|
+
return this.userPaths.getUserPromptsDir();
|
|
785
785
|
}
|
|
786
786
|
createPromptFolder(folderName) {
|
|
787
|
-
const targetDir = path.join(this.
|
|
787
|
+
const targetDir = path.join(this.userPaths.getUserPromptsDir(), folderName);
|
|
788
788
|
if (fs.existsSync(targetDir)) {
|
|
789
789
|
throw new errors_1.OperationFailedError(`Folder ${folderName} already exists`);
|
|
790
790
|
}
|
|
@@ -796,7 +796,7 @@ class AppService {
|
|
|
796
796
|
if (folderName === 'shared') {
|
|
797
797
|
throw new errors_1.OperationFailedError('Cannot delete the shared folder');
|
|
798
798
|
}
|
|
799
|
-
const targetDir = path.join(this.
|
|
799
|
+
const targetDir = path.join(this.userPaths.getUserPromptsDir(), folderName);
|
|
800
800
|
if (!fs.existsSync(targetDir)) {
|
|
801
801
|
throw new errors_1.NotFoundError(`Folder ${folderName} does not exist`);
|
|
802
802
|
}
|
|
@@ -937,7 +937,7 @@ class AppService {
|
|
|
937
937
|
const openingSceneMessage = roomMessages.find((msg) => msg.sender === 'Opening Scene');
|
|
938
938
|
const openingSceneText = openingSceneMessage?.content || '';
|
|
939
939
|
const storageDir = room.getStorageDir() ||
|
|
940
|
-
path.join(this.
|
|
940
|
+
path.join(this.userPaths.getUserDataDir(), 'stories', storyId, 'rooms');
|
|
941
941
|
this.roomStore.clearRoomMessages(story.roomId, storageDir);
|
|
942
942
|
room.setRoomMessages([]);
|
|
943
943
|
const chapters = this.storyStore.listChapters(storyId);
|
|
@@ -6,15 +6,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.UserPathsModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
|
-
const
|
|
12
|
-
let
|
|
11
|
+
const user_paths_service_1 = require("./user-paths.service");
|
|
12
|
+
let UserPathsModule = class UserPathsModule {
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
14
|
+
exports.UserPathsModule = UserPathsModule;
|
|
15
|
+
exports.UserPathsModule = UserPathsModule = __decorate([
|
|
16
16
|
(0, common_1.Module)({
|
|
17
|
-
providers: [
|
|
18
|
-
exports: [
|
|
17
|
+
providers: [user_paths_service_1.UserPathsService],
|
|
18
|
+
exports: [user_paths_service_1.UserPathsService],
|
|
19
19
|
})
|
|
20
|
-
],
|
|
20
|
+
], UserPathsModule);
|
|
@@ -33,10 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.UserPathsService = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
-
class
|
|
39
|
+
class UserPathsService {
|
|
40
40
|
dataDir;
|
|
41
41
|
promptsDir;
|
|
42
42
|
commonPromptsDir;
|
|
@@ -128,4 +128,4 @@ class ConfigurationService {
|
|
|
128
128
|
return this.userId;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
exports.
|
|
131
|
+
exports.UserPathsService = UserPathsService;
|
|
@@ -10,7 +10,7 @@ exports.RoomStoreModule = void 0;
|
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
11
|
const room_store_service_1 = require("./room-store.service");
|
|
12
12
|
const artifact_store_service_1 = require("./artifact-store.service");
|
|
13
|
-
const
|
|
13
|
+
const user_paths_module_1 = require("../config/user-paths.module");
|
|
14
14
|
const agent_store_module_1 = require("../ai/agent-store.module");
|
|
15
15
|
const attached_file_module_1 = require("../ai/attached-file.module");
|
|
16
16
|
let RoomStoreModule = class RoomStoreModule {
|
|
@@ -18,7 +18,7 @@ let RoomStoreModule = class RoomStoreModule {
|
|
|
18
18
|
exports.RoomStoreModule = RoomStoreModule;
|
|
19
19
|
exports.RoomStoreModule = RoomStoreModule = __decorate([
|
|
20
20
|
(0, common_1.Module)({
|
|
21
|
-
imports: [
|
|
21
|
+
imports: [user_paths_module_1.UserPathsModule, agent_store_module_1.AgentStoreModule, attached_file_module_1.AttachedFileModule],
|
|
22
22
|
providers: [room_store_service_1.RoomStoreService, artifact_store_service_1.ArtifactStoreService],
|
|
23
23
|
exports: [room_store_service_1.RoomStoreService],
|
|
24
24
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Room } from './room';
|
|
2
|
-
import {
|
|
2
|
+
import { UserPathsService } from '../config/user-paths.service';
|
|
3
3
|
import { AgentStoreService } from '../ai/agent-store.service';
|
|
4
4
|
import { AttachedFileService } from '../ai/attached-file.service';
|
|
5
5
|
import { RoomInfo } from '../../../shared/types/app.types';
|
|
@@ -7,7 +7,7 @@ import { RoomMessage } from './message';
|
|
|
7
7
|
import { ArtifactStoreService } from './artifact-store.service';
|
|
8
8
|
import { Artifact } from './artifact';
|
|
9
9
|
export declare class RoomStoreService {
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly userPaths;
|
|
11
11
|
private readonly agentStore;
|
|
12
12
|
private readonly attachedFileService;
|
|
13
13
|
private readonly artifactStoreService;
|
|
@@ -15,7 +15,7 @@ export declare class RoomStoreService {
|
|
|
15
15
|
private readonly defaultStorageDir;
|
|
16
16
|
private loaded;
|
|
17
17
|
private loadPromise;
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(userPaths: UserPathsService, agentStore: AgentStoreService, attachedFileService: AttachedFileService, artifactStoreService: ArtifactStoreService);
|
|
19
19
|
getDefaultStorageDir(): string;
|
|
20
20
|
storeRoom(room: Room, storageDir?: string): string;
|
|
21
21
|
getRoom(id: string): Promise<Room | null>;
|
|
@@ -48,13 +48,13 @@ const room_1 = require("./room");
|
|
|
48
48
|
const crypto_1 = require("crypto");
|
|
49
49
|
const fs = __importStar(require("fs"));
|
|
50
50
|
const path = __importStar(require("path"));
|
|
51
|
-
const
|
|
51
|
+
const user_paths_service_1 = require("../config/user-paths.service");
|
|
52
52
|
const agent_store_service_1 = require("../ai/agent-store.service");
|
|
53
53
|
const attached_file_service_1 = require("../ai/attached-file.service");
|
|
54
54
|
const artifact_store_service_1 = require("./artifact-store.service");
|
|
55
55
|
const logger_1 = require("../common/logger");
|
|
56
56
|
let RoomStoreService = class RoomStoreService {
|
|
57
|
-
|
|
57
|
+
userPaths;
|
|
58
58
|
agentStore;
|
|
59
59
|
attachedFileService;
|
|
60
60
|
artifactStoreService;
|
|
@@ -62,12 +62,12 @@ let RoomStoreService = class RoomStoreService {
|
|
|
62
62
|
defaultStorageDir;
|
|
63
63
|
loaded = false;
|
|
64
64
|
loadPromise = null;
|
|
65
|
-
constructor(
|
|
66
|
-
this.
|
|
65
|
+
constructor(userPaths, agentStore, attachedFileService, artifactStoreService) {
|
|
66
|
+
this.userPaths = userPaths;
|
|
67
67
|
this.agentStore = agentStore;
|
|
68
68
|
this.attachedFileService = attachedFileService;
|
|
69
69
|
this.artifactStoreService = artifactStoreService;
|
|
70
|
-
this.defaultStorageDir = path.join(this.
|
|
70
|
+
this.defaultStorageDir = path.join(this.userPaths.getUserDataDir(), 'rooms');
|
|
71
71
|
}
|
|
72
72
|
getDefaultStorageDir() {
|
|
73
73
|
return this.defaultStorageDir;
|
|
@@ -350,7 +350,7 @@ let RoomStoreService = class RoomStoreService {
|
|
|
350
350
|
exports.RoomStoreService = RoomStoreService;
|
|
351
351
|
exports.RoomStoreService = RoomStoreService = __decorate([
|
|
352
352
|
(0, common_1.Injectable)(),
|
|
353
|
-
__metadata("design:paramtypes", [
|
|
353
|
+
__metadata("design:paramtypes", [user_paths_service_1.UserPathsService,
|
|
354
354
|
agent_store_service_1.AgentStoreService,
|
|
355
355
|
attached_file_service_1.AttachedFileService,
|
|
356
356
|
artifact_store_service_1.ArtifactStoreService])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IConfigService } from '../
|
|
1
|
+
import { IConfigService } from '../config/env-config';
|
|
2
2
|
export interface LoggingOptions {
|
|
3
3
|
enabled?: boolean;
|
|
4
4
|
logFile?: string;
|
|
@@ -9,6 +9,7 @@ export interface BriyahConfigOptions {
|
|
|
9
9
|
dataPath?: string;
|
|
10
10
|
userServiceCacheTimeoutMinutes?: number;
|
|
11
11
|
startingBalance?: number;
|
|
12
|
+
markupRate?: number;
|
|
12
13
|
envOverrides?: Record<string, string>;
|
|
13
14
|
logging?: LoggingOptions;
|
|
14
15
|
}
|
|
@@ -19,6 +19,10 @@ class BriyahConfigService {
|
|
|
19
19
|
this.env.STARTING_BALANCE = String(options.startingBalance);
|
|
20
20
|
process.env.STARTING_BALANCE = String(options.startingBalance);
|
|
21
21
|
}
|
|
22
|
+
if (options?.markupRate !== undefined) {
|
|
23
|
+
this.env.DEFAULT_MARKUP_RATE = String(options.markupRate);
|
|
24
|
+
process.env.DEFAULT_MARKUP_RATE = String(options.markupRate);
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
get(key, defaultValue) {
|
|
24
28
|
const value = this.env[key];
|
|
@@ -115,7 +115,7 @@ class Briyah {
|
|
|
115
115
|
this.balanceMessageService = new balance_message_service_1.BalanceMessageService();
|
|
116
116
|
this.publishedAgentsService = new published_agents_service_1.PublishedAgentsService();
|
|
117
117
|
this.publishedRoomsService = new published_rooms_service_1.PublishedRoomsService();
|
|
118
|
-
this.userServiceFactory = new user_service_factory_1.UserServiceFactory(this.aiFactoryService, this.agentMessageService, this.roomMessageService, this.storyProgressService, this.storyMessageService, this.publishedAgentsService, this.publishedRoomsService, this.balanceMessageService);
|
|
118
|
+
this.userServiceFactory = new user_service_factory_1.UserServiceFactory(this.aiFactoryService, this.agentMessageService, this.roomMessageService, this.storyProgressService, this.storyMessageService, this.publishedAgentsService, this.publishedRoomsService, this.balanceMessageService, this.configService);
|
|
119
119
|
this.userServiceManager = new user_service_manager_1.UserServiceManager(this.userServiceFactory, this.configService);
|
|
120
120
|
}
|
|
121
121
|
async init() {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserPathsService } from '../config/user-paths.service';
|
|
2
2
|
import { StoryInfo, ChapterInfo } from '../../../shared/types/app.types';
|
|
3
3
|
import { RoomMessage } from '../room/message';
|
|
4
4
|
import { RoomStoreService } from '../room/room-store.service';
|
|
5
5
|
export declare class StoryStoreService {
|
|
6
|
-
private readonly
|
|
6
|
+
private readonly userPaths;
|
|
7
7
|
private readonly roomStore;
|
|
8
8
|
private readonly storiesDir;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(userPaths: UserPathsService, roomStore: RoomStoreService);
|
|
10
10
|
createStory(name: string): StoryInfo;
|
|
11
11
|
getStory(id: string): StoryInfo | null;
|
|
12
12
|
updateStoryMetadata(id: string, storyInfo: StoryInfo): boolean;
|
|
@@ -45,19 +45,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.StoryStoreService = void 0;
|
|
46
46
|
const common_1 = require("@nestjs/common");
|
|
47
47
|
const crypto_1 = require("crypto");
|
|
48
|
-
const
|
|
48
|
+
const user_paths_service_1 = require("../config/user-paths.service");
|
|
49
49
|
const fs = __importStar(require("fs"));
|
|
50
50
|
const path = __importStar(require("path"));
|
|
51
51
|
const room_store_service_1 = require("../room/room-store.service");
|
|
52
52
|
const logger_1 = require("../common/logger");
|
|
53
53
|
let StoryStoreService = class StoryStoreService {
|
|
54
|
-
|
|
54
|
+
userPaths;
|
|
55
55
|
roomStore;
|
|
56
56
|
storiesDir;
|
|
57
|
-
constructor(
|
|
58
|
-
this.
|
|
57
|
+
constructor(userPaths, roomStore) {
|
|
58
|
+
this.userPaths = userPaths;
|
|
59
59
|
this.roomStore = roomStore;
|
|
60
|
-
this.storiesDir = path.join(this.
|
|
60
|
+
this.storiesDir = path.join(this.userPaths.getUserDataDir(), 'stories');
|
|
61
61
|
if (!fs.existsSync(this.storiesDir)) {
|
|
62
62
|
fs.mkdirSync(this.storiesDir, { recursive: true });
|
|
63
63
|
}
|
|
@@ -426,6 +426,6 @@ let StoryStoreService = class StoryStoreService {
|
|
|
426
426
|
exports.StoryStoreService = StoryStoreService;
|
|
427
427
|
exports.StoryStoreService = StoryStoreService = __decorate([
|
|
428
428
|
(0, common_1.Injectable)(),
|
|
429
|
-
__metadata("design:paramtypes", [
|
|
429
|
+
__metadata("design:paramtypes", [user_paths_service_1.UserPathsService,
|
|
430
430
|
room_store_service_1.RoomStoreService])
|
|
431
431
|
], StoryStoreService);
|
|
@@ -7,7 +7,7 @@ import { Room } from '../room/room';
|
|
|
7
7
|
import { RoomFactory } from '../room/room-factory';
|
|
8
8
|
import { RoomStoreService } from '../room/room-store.service';
|
|
9
9
|
import { StoryInfo, StoryState, Character } from '../../../shared/types/app.types';
|
|
10
|
-
import {
|
|
10
|
+
import { UserPathsService } from '../config/user-paths.service';
|
|
11
11
|
import { ArtifactService } from '../ai/artifact.service';
|
|
12
12
|
import { Readable } from 'stream';
|
|
13
13
|
export declare class StoryService {
|
|
@@ -16,12 +16,12 @@ export declare class StoryService {
|
|
|
16
16
|
private readonly roomStore;
|
|
17
17
|
private readonly progressService;
|
|
18
18
|
private readonly messageService;
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly userPaths;
|
|
20
20
|
private readonly agentFactory;
|
|
21
21
|
private readonly roomFactory;
|
|
22
22
|
private readonly storyArtifactServices;
|
|
23
23
|
private readonly chaptersInProgress;
|
|
24
|
-
constructor(storyStore: StoryStoreService, agentStore: AgentStoreService, roomStore: RoomStoreService, progressService: StoryProgressService, messageService: StoryMessageService,
|
|
24
|
+
constructor(storyStore: StoryStoreService, agentStore: AgentStoreService, roomStore: RoomStoreService, progressService: StoryProgressService, messageService: StoryMessageService, userPaths: UserPathsService, agentFactory: AgentFactory, roomFactory: RoomFactory);
|
|
25
25
|
getProgressEmitter(storyId: string): import("node:events")<any>;
|
|
26
26
|
getMessageEmitter(storyId: string): import("node:events")<any>;
|
|
27
27
|
cleanupProgressEmitter(storyId: string): void;
|