briyah 1.2.4 → 1.2.6
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 +89 -6
- package/data/common/config/image_models.json +160 -97
- package/data/common/config/markup +1 -1
- package/data/common/config/story_models.json +15 -3
- package/data/common/config/story_models_full.json +2 -2
- package/data/common/prompts/character/create_user_character.prompt +3 -12
- package/data/common/prompts/character/introduce_character.json +18 -0
- package/data/common/prompts/character/introduce_character.mock +4 -0
- package/data/common/prompts/character/introduce_character.prompt +58 -0
- package/data/common/prompts/character/perceive.prompt +3 -0
- package/data/common/prompts/character/progress_character.json +8 -4
- package/data/common/prompts/character/progress_character.mock +1 -0
- package/data/common/prompts/character/progress_character.prompt +20 -2
- package/data/common/prompts/character/update_portrait.json +18 -0
- package/data/common/prompts/character/update_portrait.mock +4 -0
- package/data/common/prompts/character/update_portrait.prompt +17 -1
- package/data/common/prompts/narrator/create_simple_plot.json +0 -0
- package/data/common/prompts/narrator/create_simple_plot.mock +13 -0
- package/data/common/prompts/narrator/create_simple_plot.prompt +35 -0
- package/data/common/prompts/narrator/perceive.prompt +12 -9
- package/data/common/prompts/narrator/progress_simple_plot.json +0 -0
- package/data/common/prompts/narrator/progress_simple_plot.mock +13 -0
- package/data/common/prompts/narrator/progress_simple_plot.prompt +40 -0
- package/data/common/prompts/perceive.json +1 -1
- package/data/common/prompts/perceive.prompt +82 -20
- package/data/common/prompts/story_moderator/moderate.json +1 -1
- package/data/common/prompts/story_moderator/moderate.prompt +26 -6
- package/dist-sdk/server/src/ai/LLM/anthropic.service.js +1 -2
- package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +1 -1
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +13 -42
- package/dist-sdk/server/src/ai/LLM/deepseek.service.js +9 -0
- package/dist-sdk/server/src/ai/LLM/fal.service.js +1 -2
- package/dist-sdk/server/src/ai/LLM/googleai.service.js +1 -2
- package/dist-sdk/server/src/ai/LLM/grok.service.js +1 -2
- package/dist-sdk/server/src/ai/LLM/openai.service.js +1 -2
- package/dist-sdk/server/src/ai/LLM/together.service.js +1 -2
- package/dist-sdk/server/src/ai/agent-config.d.ts +2 -0
- package/dist-sdk/server/src/ai/agent-store.service.js +8 -0
- package/dist-sdk/server/src/ai/agent.d.ts +2 -0
- package/dist-sdk/server/src/ai/agent.js +2 -0
- package/dist-sdk/server/src/ai/model_prices.js +2 -1
- package/dist-sdk/server/src/app/user-service-factory.d.ts +3 -1
- package/dist-sdk/server/src/app/user-service-factory.js +14 -5
- package/dist-sdk/server/src/app.controller.d.ts +15 -4
- package/dist-sdk/server/src/app.controller.js +184 -5
- package/dist-sdk/server/src/app.service.d.ts +23 -6
- package/dist-sdk/server/src/app.service.js +72 -6
- package/dist-sdk/server/src/room/message.js +5 -1
- package/dist-sdk/server/src/room/room-factory.d.ts +5 -1
- package/dist-sdk/server/src/room/room-factory.js +6 -1
- package/dist-sdk/server/src/room/room-store.service.d.ts +5 -1
- package/dist-sdk/server/src/room/room-store.service.js +13 -2
- package/dist-sdk/server/src/room/room.d.ts +27 -5
- package/dist-sdk/server/src/room/room.js +397 -96
- package/dist-sdk/server/src/sdk/briyah-config.d.ts +3 -0
- package/dist-sdk/server/src/sdk/briyah-config.js +4 -0
- package/dist-sdk/server/src/sdk/briyah.d.ts +6 -0
- package/dist-sdk/server/src/sdk/briyah.js +19 -1
- package/dist-sdk/server/src/sdk/index.d.ts +2 -1
- package/dist-sdk/server/src/shared/shared.module.js +3 -0
- package/dist-sdk/server/src/story/story.service.d.ts +5 -4
- package/dist-sdk/server/src/story/story.service.js +207 -120
- package/dist-sdk/server/src/tools/native-tool-registry.service.d.ts +10 -0
- package/dist-sdk/server/src/tools/native-tool-registry.service.js +46 -0
- package/dist-sdk/server/src/tools/native-tool.types.d.ts +12 -0
- package/dist-sdk/server/src/tools/native-tool.types.js +2 -0
- package/dist-sdk/server/src/tools/tool-execution.service.d.ts +23 -0
- package/dist-sdk/server/src/tools/tool-execution.service.js +125 -0
- package/dist-sdk/server/src/tools/tool-store.service.d.ts +17 -0
- package/dist-sdk/server/src/tools/tool-store.service.js +143 -0
- package/dist-sdk/shared/types/app.types.d.ts +51 -5
- package/dist-sdk/shared/types/app.types.js +3 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +0 -7
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Agent.html +22 -14
- package/docs/classes/Briyah.html +35 -10
- package/docs/classes/BriyahConfigService.html +5 -5
- package/docs/classes/Room.html +32 -26
- package/docs/classes/RoomMessage.html +10 -10
- package/docs/enums/MessageAction.html +6 -3
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +23 -6
- package/docs/interfaces/AgentInfo.html +3 -2
- package/docs/interfaces/AgentMessagesResponse.html +2 -2
- package/docs/interfaces/AppService.html +194 -150
- 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 +16 -8
- 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/FileMetadata.html +3 -3
- package/docs/interfaces/IConfigService.html +3 -3
- package/docs/interfaces/LoggingOptions.html +6 -6
- package/docs/interfaces/Message.html +2 -2
- package/docs/interfaces/ModelInfo.html +2 -3
- package/docs/interfaces/NativeToolDefinition.html +16 -0
- 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 +5 -4
- 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/ToolDefinition.html +6 -0
- package/docs/interfaces/ToolHelpers.html +7 -0
- package/docs/interfaces/ToolParameter.html +5 -0
- package/docs/interfaces/ToolSummary.html +4 -0
- package/docs/interfaces/ToolsResponse.html +4 -0
- 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/docs/types/ToolContext.html +6 -0
- package/docs/types/ToolRunResult.html +1 -0
- package/package.json +2 -1
|
@@ -128,11 +128,23 @@ let AppController = class AppController {
|
|
|
128
128
|
throw new common_1.HttpException('Failed to list story models', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
listStoryModelDefaults(
|
|
131
|
+
async listStoryModelDefaults(req) {
|
|
132
|
+
const appService = this.getAppService(req);
|
|
133
|
+
const imageModels = await appService.listImageModels();
|
|
134
|
+
const resolveImageDefault = (envName) => {
|
|
135
|
+
const exact = imageModels.find((m) => m.name === envName);
|
|
136
|
+
if (exact)
|
|
137
|
+
return exact.name;
|
|
138
|
+
if (envName) {
|
|
139
|
+
const ci = imageModels.find((m) => m.name.toLowerCase() === envName.toLowerCase());
|
|
140
|
+
if (ci)
|
|
141
|
+
return ci.name;
|
|
142
|
+
}
|
|
143
|
+
return imageModels[0]?.name ?? '';
|
|
144
|
+
};
|
|
132
145
|
return {
|
|
133
146
|
selectedStoryModel: process.env.DEFAULT_STORY_MODEL,
|
|
134
|
-
selectedImageModel: process.env.DEFAULT_IMAGE_MODEL,
|
|
135
|
-
selectedImageEditModel: process.env.DEFAULT_IMAGE_EDIT_MODEL,
|
|
147
|
+
selectedImageModel: resolveImageDefault(process.env.DEFAULT_IMAGE_MODEL),
|
|
136
148
|
enforceDefaultModels: process.env.ENFORCE_DEFAULT_MODELS === 'true',
|
|
137
149
|
};
|
|
138
150
|
}
|
|
@@ -350,6 +362,81 @@ let AppController = class AppController {
|
|
|
350
362
|
throw new common_1.HttpException('Failed to delete prompt file', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
351
363
|
}
|
|
352
364
|
}
|
|
365
|
+
async getTools(req) {
|
|
366
|
+
try {
|
|
367
|
+
const appService = this.getAppService(req);
|
|
368
|
+
return {
|
|
369
|
+
tools: await appService.listTools(),
|
|
370
|
+
nativeTools: appService.listNativeToolSummaries(),
|
|
371
|
+
allowUserAuthored: appService.userAuthoredToolsEnabled,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
logger_1.logger.error(`[${req.user?.sub}] Error listing tools:`, error);
|
|
376
|
+
return { tools: [], nativeTools: [], allowUserAuthored: false };
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async createTool(req, body) {
|
|
380
|
+
if (!body.name) {
|
|
381
|
+
throw new common_1.BadRequestException('Tool name is required');
|
|
382
|
+
}
|
|
383
|
+
const appService = this.getAppService(req);
|
|
384
|
+
if (!appService.userAuthoredToolsEnabled) {
|
|
385
|
+
throw new common_1.ForbiddenException('User-authored tools are disabled on this deployment');
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
return await appService.createTool(body);
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
logger_1.logger.error(`[${req.user?.sub}] Error creating tool ${body.name}:`, error);
|
|
392
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
393
|
+
throw new common_1.ConflictException(error.message);
|
|
394
|
+
}
|
|
395
|
+
throw new common_1.HttpException(error.message || 'Failed to create tool', common_1.HttpStatus.BAD_REQUEST);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async updateTool(req, name, body) {
|
|
399
|
+
const appService = this.getAppService(req);
|
|
400
|
+
if (!appService.userAuthoredToolsEnabled) {
|
|
401
|
+
throw new common_1.ForbiddenException('User-authored tools are disabled on this deployment');
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
return await appService.updateTool(name, body);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
logger_1.logger.error(`[${req.user?.sub}] Error updating tool ${name}:`, error);
|
|
408
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
409
|
+
throw new common_1.NotFoundException(error.message);
|
|
410
|
+
}
|
|
411
|
+
throw new common_1.HttpException(error.message || 'Failed to update tool', common_1.HttpStatus.BAD_REQUEST);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
async deleteTool(req, name) {
|
|
415
|
+
const appService = this.getAppService(req);
|
|
416
|
+
if (!appService.userAuthoredToolsEnabled) {
|
|
417
|
+
throw new common_1.ForbiddenException('User-authored tools are disabled on this deployment');
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
await appService.deleteTool(name);
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
logger_1.logger.error(`[${req.user?.sub}] Error deleting tool ${name}:`, error);
|
|
424
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
425
|
+
throw new common_1.NotFoundException(error.message);
|
|
426
|
+
}
|
|
427
|
+
throw new common_1.HttpException('Failed to delete tool', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
async testTool(req, name, body) {
|
|
431
|
+
try {
|
|
432
|
+
const appService = this.getAppService(req);
|
|
433
|
+
return await appService.testTool(name, body?.args || {});
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
logger_1.logger.error(`[${req.user?.sub}] Error testing tool ${name}:`, error);
|
|
437
|
+
return { ok: false, error: error.message || 'Tool test failed' };
|
|
438
|
+
}
|
|
439
|
+
}
|
|
353
440
|
listLibraryPrompts() {
|
|
354
441
|
return { prompts: this.libraryService.listLocalPrompts() };
|
|
355
442
|
}
|
|
@@ -1154,7 +1241,7 @@ let AppController = class AppController {
|
|
|
1154
1241
|
}
|
|
1155
1242
|
try {
|
|
1156
1243
|
const appService = this.getAppService(req);
|
|
1157
|
-
return appService.createStory(body.name, body.idea, body.userCharacterDesc, body.otherCharactersDesc, body.illustrateStory ?? true, body.storyModel, body.isImport, body.imageModelName, body.
|
|
1244
|
+
return appService.createStory(body.name, body.idea, body.userCharacterDesc, body.otherCharactersDesc, body.illustrateStory ?? true, body.storyModel, body.isImport, body.imageModelName, body.skipDetailedPlot ?? false);
|
|
1158
1245
|
}
|
|
1159
1246
|
catch (error) {
|
|
1160
1247
|
logger_1.logger.error(`[${req.user?.sub}] Error creating story ${body.name}:`, error);
|
|
@@ -1476,6 +1563,35 @@ let AppController = class AppController {
|
|
|
1476
1563
|
throw new common_1.HttpException('Failed to save character', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1477
1564
|
}
|
|
1478
1565
|
}
|
|
1566
|
+
async getCharacterInventory(req, storyId, characterName) {
|
|
1567
|
+
try {
|
|
1568
|
+
const appService = this.getAppService(req);
|
|
1569
|
+
return await appService.getCharacterInventory(storyId, characterName);
|
|
1570
|
+
}
|
|
1571
|
+
catch (error) {
|
|
1572
|
+
logger_1.logger.error(`[${req.user?.sub}] Error getting inventory for character ${characterName} in story ${storyId}:`, error);
|
|
1573
|
+
return { content: '' };
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
async saveCharacterInventory(req, storyId, characterName, body) {
|
|
1577
|
+
if (body.content === undefined || body.content === null) {
|
|
1578
|
+
throw new common_1.BadRequestException('Content is required');
|
|
1579
|
+
}
|
|
1580
|
+
try {
|
|
1581
|
+
const appService = this.getAppService(req);
|
|
1582
|
+
await appService.saveCharacterInventory(storyId, characterName, body.content);
|
|
1583
|
+
}
|
|
1584
|
+
catch (error) {
|
|
1585
|
+
logger_1.logger.error(`[${req.user?.sub}] Error saving inventory for character ${characterName} in story ${storyId}:`, error);
|
|
1586
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1587
|
+
throw new common_1.NotFoundException(error.message);
|
|
1588
|
+
}
|
|
1589
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1590
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1591
|
+
}
|
|
1592
|
+
throw new common_1.HttpException('Failed to save inventory', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1479
1595
|
async getPlotPlan(req, storyId) {
|
|
1480
1596
|
try {
|
|
1481
1597
|
const appService = this.getAppService(req);
|
|
@@ -1861,7 +1977,7 @@ __decorate([
|
|
|
1861
1977
|
__param(0, (0, common_1.Request)()),
|
|
1862
1978
|
__metadata("design:type", Function),
|
|
1863
1979
|
__metadata("design:paramtypes", [Object]),
|
|
1864
|
-
__metadata("design:returntype",
|
|
1980
|
+
__metadata("design:returntype", Promise)
|
|
1865
1981
|
], AppController.prototype, "listStoryModelDefaults", null);
|
|
1866
1982
|
__decorate([
|
|
1867
1983
|
(0, common_1.Post)('agents'),
|
|
@@ -1976,6 +2092,49 @@ __decorate([
|
|
|
1976
2092
|
__metadata("design:paramtypes", [Object, String, String]),
|
|
1977
2093
|
__metadata("design:returntype", Promise)
|
|
1978
2094
|
], AppController.prototype, "deletePromptFile", null);
|
|
2095
|
+
__decorate([
|
|
2096
|
+
(0, common_1.Get)('tools'),
|
|
2097
|
+
__param(0, (0, common_1.Request)()),
|
|
2098
|
+
__metadata("design:type", Function),
|
|
2099
|
+
__metadata("design:paramtypes", [Object]),
|
|
2100
|
+
__metadata("design:returntype", Promise)
|
|
2101
|
+
], AppController.prototype, "getTools", null);
|
|
2102
|
+
__decorate([
|
|
2103
|
+
(0, common_1.Post)('tools'),
|
|
2104
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2105
|
+
__param(0, (0, common_1.Request)()),
|
|
2106
|
+
__param(1, (0, common_1.Body)()),
|
|
2107
|
+
__metadata("design:type", Function),
|
|
2108
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2109
|
+
__metadata("design:returntype", Promise)
|
|
2110
|
+
], AppController.prototype, "createTool", null);
|
|
2111
|
+
__decorate([
|
|
2112
|
+
(0, common_1.Put)('tools/:name'),
|
|
2113
|
+
__param(0, (0, common_1.Request)()),
|
|
2114
|
+
__param(1, (0, common_1.Param)('name')),
|
|
2115
|
+
__param(2, (0, common_1.Body)()),
|
|
2116
|
+
__metadata("design:type", Function),
|
|
2117
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2118
|
+
__metadata("design:returntype", Promise)
|
|
2119
|
+
], AppController.prototype, "updateTool", null);
|
|
2120
|
+
__decorate([
|
|
2121
|
+
(0, common_1.Delete)('tools/:name'),
|
|
2122
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2123
|
+
__param(0, (0, common_1.Request)()),
|
|
2124
|
+
__param(1, (0, common_1.Param)('name')),
|
|
2125
|
+
__metadata("design:type", Function),
|
|
2126
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2127
|
+
__metadata("design:returntype", Promise)
|
|
2128
|
+
], AppController.prototype, "deleteTool", null);
|
|
2129
|
+
__decorate([
|
|
2130
|
+
(0, common_1.Post)('tools/:name/test'),
|
|
2131
|
+
__param(0, (0, common_1.Request)()),
|
|
2132
|
+
__param(1, (0, common_1.Param)('name')),
|
|
2133
|
+
__param(2, (0, common_1.Body)()),
|
|
2134
|
+
__metadata("design:type", Function),
|
|
2135
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2136
|
+
__metadata("design:returntype", Promise)
|
|
2137
|
+
], AppController.prototype, "testTool", null);
|
|
1979
2138
|
__decorate([
|
|
1980
2139
|
(0, common_1.Get)('library/prompts'),
|
|
1981
2140
|
(0, public_decorator_1.Public)(),
|
|
@@ -2611,6 +2770,26 @@ __decorate([
|
|
|
2611
2770
|
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2612
2771
|
__metadata("design:returntype", Promise)
|
|
2613
2772
|
], AppController.prototype, "saveCharacter", null);
|
|
2773
|
+
__decorate([
|
|
2774
|
+
(0, common_1.Get)('stories/:storyId/characters/:characterName/inventory'),
|
|
2775
|
+
__param(0, (0, common_1.Request)()),
|
|
2776
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2777
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2778
|
+
__metadata("design:type", Function),
|
|
2779
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2780
|
+
__metadata("design:returntype", Promise)
|
|
2781
|
+
], AppController.prototype, "getCharacterInventory", null);
|
|
2782
|
+
__decorate([
|
|
2783
|
+
(0, common_1.Put)('stories/:storyId/characters/:characterName/inventory'),
|
|
2784
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2785
|
+
__param(0, (0, common_1.Request)()),
|
|
2786
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2787
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2788
|
+
__param(3, (0, common_1.Body)()),
|
|
2789
|
+
__metadata("design:type", Function),
|
|
2790
|
+
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2791
|
+
__metadata("design:returntype", Promise)
|
|
2792
|
+
], AppController.prototype, "saveCharacterInventory", null);
|
|
2614
2793
|
__decorate([
|
|
2615
2794
|
(0, common_1.Get)('stories/:storyId/plot-plan'),
|
|
2616
2795
|
__param(0, (0, common_1.Request)()),
|
|
@@ -12,7 +12,7 @@ import { StoryService } from './story/story.service';
|
|
|
12
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
|
-
import { ArtifactMetadata, ModelInfo, ChapterInfo, StoryIdea } from '../../shared/types/app.types';
|
|
15
|
+
import { ArtifactMetadata, ModelInfo, ImageModelOption, ChapterInfo, StoryIdea } from '../../shared/types/app.types';
|
|
16
16
|
import { PublishedAgentsService } from './ai/published-agents.service';
|
|
17
17
|
import { PublishedRoomsService } from './room/published-rooms.service';
|
|
18
18
|
import { BalanceService } from './app/balance.service';
|
|
@@ -21,8 +21,10 @@ import { TransactionService } from './app/transaction.service';
|
|
|
21
21
|
import { AgentFactory } from './ai/agent-factory';
|
|
22
22
|
import { RoomFactory } from './room/room-factory';
|
|
23
23
|
import { EventEmitter } from 'events';
|
|
24
|
-
import { AgentInfo, RoomInfo, RoomDetails, CreateRoomResponse, FileList, PromptFileContent, PromptFoldersResponse, PromptFilesResponse, PromptScope, ProcessTextResponse, PreparedPromptResponse, AttachDocumentResponse, AgentMessagesResponse, RoomMessagesResponse, StoryInfo, StoryState, Character, Transaction, TransactionHistoryResponse } from '../../shared/types/app.types';
|
|
24
|
+
import { AgentInfo, RoomInfo, RoomDetails, CreateRoomResponse, FileList, PromptFileContent, PromptFoldersResponse, PromptFilesResponse, PromptScope, ProcessTextResponse, PreparedPromptResponse, AttachDocumentResponse, AgentMessagesResponse, RoomMessagesResponse, StoryInfo, StoryState, Character, Transaction, TransactionHistoryResponse, ToolDefinition, ToolSummary, ToolRunResult } from '../../shared/types/app.types';
|
|
25
25
|
import { RoomMessage } from './room/message';
|
|
26
|
+
import { ToolStoreService } from './tools/tool-store.service';
|
|
27
|
+
import { ToolExecutionService } from './tools/tool-execution.service';
|
|
26
28
|
export declare class AppService {
|
|
27
29
|
private readonly aiFactoryService;
|
|
28
30
|
private readonly agentStore;
|
|
@@ -41,13 +43,15 @@ export declare class AppService {
|
|
|
41
43
|
private readonly transactionService;
|
|
42
44
|
private readonly agentFactory;
|
|
43
45
|
private readonly roomFactory;
|
|
46
|
+
private readonly toolStore;
|
|
47
|
+
private readonly toolExecution;
|
|
44
48
|
private aiServices;
|
|
45
49
|
private readonly userPreferencesFile;
|
|
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);
|
|
50
|
+
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, toolStore: ToolStoreService, toolExecution: ToolExecutionService);
|
|
47
51
|
getAiServiceNames(): string[];
|
|
48
52
|
getAiServiceFromServiceName(serviceName: string): BaseAiService;
|
|
49
53
|
listAiModels(aiServiceName: string): Promise<ModelInfo[]>;
|
|
50
|
-
listImageModels(): Promise<
|
|
54
|
+
listImageModels(): Promise<ImageModelOption[]>;
|
|
51
55
|
listStoryModels(): Promise<ModelInfo[]>;
|
|
52
56
|
listStoryGenres(): string[];
|
|
53
57
|
getRandomStoryIdeaByGenre(genreName: string): StoryIdea | null;
|
|
@@ -69,7 +73,7 @@ export declare class AppService {
|
|
|
69
73
|
getRoomMessages(roomId: string, fromIndex?: number, includeThoughts?: boolean): Promise<RoomMessagesResponse>;
|
|
70
74
|
getAgentMessages(agentId: string, fromIndex?: number): Promise<AgentMessagesResponse>;
|
|
71
75
|
getStoryMessages(storyId: string, fromIndex: number): Promise<RoomMessagesResponse>;
|
|
72
|
-
sendRoomMessage(roomId: string, content: string, sender: string, action?: string, targets?: string[], clearQueue?: boolean): Promise<void>;
|
|
76
|
+
sendRoomMessage(roomId: string, content: string, sender: string, action?: string, targets?: string[], clearQueue?: boolean, context?: unknown): Promise<void>;
|
|
73
77
|
pauseRoom(roomId: string): Promise<void>;
|
|
74
78
|
resumeRoom(roomId: string): Promise<void>;
|
|
75
79
|
deleteAgent(agentId: string): Promise<void>;
|
|
@@ -107,7 +111,16 @@ export declare class AppService {
|
|
|
107
111
|
maxOutputTokens?: number;
|
|
108
112
|
allowSearch?: boolean;
|
|
109
113
|
beginInstruction?: string;
|
|
114
|
+
toolNames?: string[];
|
|
110
115
|
}): Promise<void>;
|
|
116
|
+
get userAuthoredToolsEnabled(): boolean;
|
|
117
|
+
listTools(): Promise<ToolDefinition[]>;
|
|
118
|
+
listNativeToolSummaries(): ToolSummary[];
|
|
119
|
+
createTool(tool: ToolDefinition): Promise<ToolDefinition>;
|
|
120
|
+
updateTool(name: string, tool: ToolDefinition): Promise<ToolDefinition>;
|
|
121
|
+
deleteTool(name: string): Promise<void>;
|
|
122
|
+
private assertUserAuthoringAllowed;
|
|
123
|
+
testTool(name: string, args: Record<string, any>): Promise<ToolRunResult>;
|
|
111
124
|
listAttachedFiles(agentId: string): Promise<FileList>;
|
|
112
125
|
deleteAttachedFile(agentId: string, fileName: string): Promise<void>;
|
|
113
126
|
deleteAttachedFileById(documentId: string): Promise<void>;
|
|
@@ -116,7 +129,7 @@ export declare class AppService {
|
|
|
116
129
|
resetRoom(roomId: string): Promise<void>;
|
|
117
130
|
resetStory(storyId: string): Promise<void>;
|
|
118
131
|
revertStoryChapter(storyId: string): Promise<void>;
|
|
119
|
-
createStory(name: string, idea: string, userCharacterDesc: string, otherCharactersDesc: string, illustrateStory: boolean, storyModel?: string, isImport?: boolean, imageModelName?: string,
|
|
132
|
+
createStory(name: string, idea: string, userCharacterDesc: string, otherCharactersDesc: string, illustrateStory: boolean, storyModel?: string, isImport?: boolean, imageModelName?: string, skipDetailedPlot?: boolean): Promise<StoryInfo>;
|
|
120
133
|
importStoryFromZip(zipBuffer: Buffer): Promise<StoryInfo>;
|
|
121
134
|
getStoryProgressEmitter(storyId: string): EventEmitter<any>;
|
|
122
135
|
getStoryMessageEmitter(storyId: string): EventEmitter<any>;
|
|
@@ -156,6 +169,10 @@ export declare class AppService {
|
|
|
156
169
|
content: string;
|
|
157
170
|
}>;
|
|
158
171
|
saveCharacter(storyId: string, characterName: string, content: string): void;
|
|
172
|
+
getCharacterInventory(storyId: string, characterName: string): Promise<{
|
|
173
|
+
content: string;
|
|
174
|
+
}>;
|
|
175
|
+
saveCharacterInventory(storyId: string, characterName: string, content: string): Promise<void>;
|
|
159
176
|
getPlotPlan(storyId: string): Promise<{
|
|
160
177
|
content: string;
|
|
161
178
|
}>;
|
|
@@ -59,9 +59,11 @@ class AppService {
|
|
|
59
59
|
transactionService;
|
|
60
60
|
agentFactory;
|
|
61
61
|
roomFactory;
|
|
62
|
+
toolStore;
|
|
63
|
+
toolExecution;
|
|
62
64
|
aiServices;
|
|
63
65
|
userPreferencesFile = 'user-preferences.json';
|
|
64
|
-
constructor(aiFactoryService, agentStore, agentMessageService, roomStore, roomMessageService, userPaths, attachedFileService, artifactService, storyStore, storyService, publishedAgentsService, publishedRoomsService, balanceService, balanceMessageService, transactionService, agentFactory, roomFactory) {
|
|
66
|
+
constructor(aiFactoryService, agentStore, agentMessageService, roomStore, roomMessageService, userPaths, attachedFileService, artifactService, storyStore, storyService, publishedAgentsService, publishedRoomsService, balanceService, balanceMessageService, transactionService, agentFactory, roomFactory, toolStore, toolExecution) {
|
|
65
67
|
this.aiFactoryService = aiFactoryService;
|
|
66
68
|
this.agentStore = agentStore;
|
|
67
69
|
this.agentMessageService = agentMessageService;
|
|
@@ -79,6 +81,8 @@ class AppService {
|
|
|
79
81
|
this.transactionService = transactionService;
|
|
80
82
|
this.agentFactory = agentFactory;
|
|
81
83
|
this.roomFactory = roomFactory;
|
|
84
|
+
this.toolStore = toolStore;
|
|
85
|
+
this.toolExecution = toolExecution;
|
|
82
86
|
this.aiServices = this.aiFactoryService.getAllAiServices();
|
|
83
87
|
}
|
|
84
88
|
getAiServiceNames() {
|
|
@@ -94,7 +98,10 @@ class AppService {
|
|
|
94
98
|
async listImageModels() {
|
|
95
99
|
const imageModelsPath = path.join(this.userPaths.getCommonConfigDir(), 'image_models.json');
|
|
96
100
|
try {
|
|
97
|
-
|
|
101
|
+
const entries = JSON.parse(fs.readFileSync(imageModelsPath, 'utf8'));
|
|
102
|
+
return entries
|
|
103
|
+
.filter((entry) => entry.name && entry.name !== 'No images')
|
|
104
|
+
.map((entry) => ({ name: entry.name, description: entry.description ?? '' }));
|
|
98
105
|
}
|
|
99
106
|
catch (error) {
|
|
100
107
|
logger_1.logger.error(`Image models file could not be read from ${imageModelsPath}: `, error);
|
|
@@ -299,6 +306,7 @@ class AppService {
|
|
|
299
306
|
totalCost: agent.totalCost,
|
|
300
307
|
isPublished: agent.isPublished,
|
|
301
308
|
beginInstruction: agent.beginInstruction,
|
|
309
|
+
toolNames: agent.toolNames,
|
|
302
310
|
});
|
|
303
311
|
}
|
|
304
312
|
}
|
|
@@ -327,6 +335,7 @@ class AppService {
|
|
|
327
335
|
totalCost: agent.totalCost,
|
|
328
336
|
isPublished: agent.isPublished,
|
|
329
337
|
beginInstruction: agent.beginInstruction,
|
|
338
|
+
toolNames: agent.toolNames,
|
|
330
339
|
};
|
|
331
340
|
}
|
|
332
341
|
catch (error) {
|
|
@@ -454,7 +463,7 @@ class AppService {
|
|
|
454
463
|
const totalCost = story.totalCost || 0;
|
|
455
464
|
return { messages, totalCost };
|
|
456
465
|
}
|
|
457
|
-
async sendRoomMessage(roomId, content, sender, action = 'moderate', targets = [], clearQueue = false) {
|
|
466
|
+
async sendRoomMessage(roomId, content, sender, action = 'moderate', targets = [], clearQueue = false, context) {
|
|
458
467
|
const room = await this.roomStore.getRoom(roomId);
|
|
459
468
|
if (!room) {
|
|
460
469
|
throw new errors_1.NotFoundError('Room not found');
|
|
@@ -477,7 +486,7 @@ class AppService {
|
|
|
477
486
|
messageAction = app_types_1.MessageAction.SPEAK;
|
|
478
487
|
}
|
|
479
488
|
room.ready();
|
|
480
|
-
room.addPendingMessage(new message_1.RoomMessage(sender, messageAction, content, targets), clearQueue);
|
|
489
|
+
room.addPendingMessage(new message_1.RoomMessage(sender, messageAction, content, targets), clearQueue, context);
|
|
481
490
|
}
|
|
482
491
|
async pauseRoom(roomId) {
|
|
483
492
|
const room = await this.roomStore.getRoom(roomId);
|
|
@@ -535,6 +544,7 @@ class AppService {
|
|
|
535
544
|
totalCost: agent.totalCost,
|
|
536
545
|
isPublished: agent.isPublished,
|
|
537
546
|
beginInstruction: agent.beginInstruction,
|
|
547
|
+
toolNames: agent.toolNames,
|
|
538
548
|
}));
|
|
539
549
|
}
|
|
540
550
|
async resetPublishedInstance(instanceId) {
|
|
@@ -570,6 +580,7 @@ class AppService {
|
|
|
570
580
|
totalCost: agent.totalCost,
|
|
571
581
|
isPublished: agent.isPublished,
|
|
572
582
|
beginInstruction: agent.beginInstruction,
|
|
583
|
+
toolNames: agent.toolNames,
|
|
573
584
|
});
|
|
574
585
|
}
|
|
575
586
|
}
|
|
@@ -823,8 +834,56 @@ class AppService {
|
|
|
823
834
|
agent.allowSearch = updates.allowSearch;
|
|
824
835
|
if (updates.beginInstruction !== undefined)
|
|
825
836
|
agent.beginInstruction = updates.beginInstruction;
|
|
837
|
+
if (updates.toolNames !== undefined)
|
|
838
|
+
agent.toolNames = updates.toolNames;
|
|
826
839
|
agent.save();
|
|
827
840
|
}
|
|
841
|
+
get userAuthoredToolsEnabled() {
|
|
842
|
+
return this.toolExecution.userAuthoredToolsEnabled;
|
|
843
|
+
}
|
|
844
|
+
async listTools() {
|
|
845
|
+
if (!this.userAuthoredToolsEnabled)
|
|
846
|
+
return [];
|
|
847
|
+
return this.toolStore.listTools();
|
|
848
|
+
}
|
|
849
|
+
listNativeToolSummaries() {
|
|
850
|
+
return this.toolExecution.listNativeTools().map((t) => ({
|
|
851
|
+
name: t.name,
|
|
852
|
+
description: t.description,
|
|
853
|
+
parameters: t.parameters || [],
|
|
854
|
+
}));
|
|
855
|
+
}
|
|
856
|
+
async createTool(tool) {
|
|
857
|
+
this.assertUserAuthoringAllowed();
|
|
858
|
+
const existing = await this.toolStore.getTool(tool.name);
|
|
859
|
+
if (existing) {
|
|
860
|
+
throw new errors_1.OperationFailedError(`Tool "${tool.name}" already exists`);
|
|
861
|
+
}
|
|
862
|
+
return this.toolStore.saveTool(tool);
|
|
863
|
+
}
|
|
864
|
+
async updateTool(name, tool) {
|
|
865
|
+
this.assertUserAuthoringAllowed();
|
|
866
|
+
const existing = await this.toolStore.getTool(name);
|
|
867
|
+
if (!existing) {
|
|
868
|
+
throw new errors_1.NotFoundError(`Tool "${name}" not found`);
|
|
869
|
+
}
|
|
870
|
+
return this.toolStore.saveTool({ ...tool, name });
|
|
871
|
+
}
|
|
872
|
+
async deleteTool(name) {
|
|
873
|
+
this.assertUserAuthoringAllowed();
|
|
874
|
+
const deleted = await this.toolStore.deleteTool(name);
|
|
875
|
+
if (!deleted) {
|
|
876
|
+
throw new errors_1.NotFoundError(`Tool "${name}" not found`);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
assertUserAuthoringAllowed() {
|
|
880
|
+
if (!this.userAuthoredToolsEnabled) {
|
|
881
|
+
throw new errors_1.OperationFailedError('User-authored tools are disabled on this deployment');
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
async testTool(name, args) {
|
|
885
|
+
return this.toolExecution.test(name, args);
|
|
886
|
+
}
|
|
828
887
|
async listAttachedFiles(agentId) {
|
|
829
888
|
const agent = await this.agentStore.getAgent(agentId);
|
|
830
889
|
if (!agent) {
|
|
@@ -972,8 +1031,8 @@ class AppService {
|
|
|
972
1031
|
async revertStoryChapter(storyId) {
|
|
973
1032
|
return this.storyService.revertStoryChapter(storyId);
|
|
974
1033
|
}
|
|
975
|
-
async createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName,
|
|
976
|
-
return this.storyService.createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName,
|
|
1034
|
+
async createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName, skipDetailedPlot) {
|
|
1035
|
+
return this.storyService.createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName, skipDetailedPlot);
|
|
977
1036
|
}
|
|
978
1037
|
async importStoryFromZip(zipBuffer) {
|
|
979
1038
|
return this.storyService.importStoryFromZip(zipBuffer);
|
|
@@ -1148,6 +1207,13 @@ class AppService {
|
|
|
1148
1207
|
saveCharacter(storyId, characterName, content) {
|
|
1149
1208
|
this.storyService.saveCharacter(storyId, characterName, content);
|
|
1150
1209
|
}
|
|
1210
|
+
async getCharacterInventory(storyId, characterName) {
|
|
1211
|
+
const content = await this.storyService.getCharacterInventory(storyId, characterName);
|
|
1212
|
+
return { content: content || '' };
|
|
1213
|
+
}
|
|
1214
|
+
async saveCharacterInventory(storyId, characterName, content) {
|
|
1215
|
+
await this.storyService.saveCharacterInventory(storyId, characterName, content);
|
|
1216
|
+
}
|
|
1151
1217
|
async getPlotPlan(storyId) {
|
|
1152
1218
|
const content = await this.storyService.getPlotPlan(storyId);
|
|
1153
1219
|
return { content: content || '' };
|
|
@@ -44,7 +44,9 @@ class RoomMessage {
|
|
|
44
44
|
}
|
|
45
45
|
if (this.action === app_types_1.MessageAction.WHISPER ||
|
|
46
46
|
this.action === app_types_1.MessageAction.RELAY ||
|
|
47
|
-
this.action === app_types_1.MessageAction.RELAY_SILENT
|
|
47
|
+
this.action === app_types_1.MessageAction.RELAY_SILENT ||
|
|
48
|
+
this.action === app_types_1.MessageAction.COMMISSION ||
|
|
49
|
+
this.action === app_types_1.MessageAction.DELIVER) {
|
|
48
50
|
return this.targets.includes(agentName);
|
|
49
51
|
}
|
|
50
52
|
if (this.targets.length > 0) {
|
|
@@ -56,6 +58,8 @@ class RoomMessage {
|
|
|
56
58
|
if (this.sender === agentNickname) {
|
|
57
59
|
return false;
|
|
58
60
|
}
|
|
61
|
+
if (this.action === app_types_1.MessageAction.TOOL)
|
|
62
|
+
return false;
|
|
59
63
|
if (this.action === app_types_1.MessageAction.RELAY || this.action === app_types_1.MessageAction.RELAY_SILENT)
|
|
60
64
|
return this.targets.includes(agentNickname);
|
|
61
65
|
if (this.action === app_types_1.MessageAction.PUBLISH)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Room } from './room';
|
|
2
2
|
import { RoomStoreService } from './room-store.service';
|
|
3
|
+
import { ToolStoreService } from '../tools/tool-store.service';
|
|
4
|
+
import { ToolExecutionService } from '../tools/tool-execution.service';
|
|
3
5
|
export declare class RoomFactory {
|
|
4
6
|
private readonly roomStoreService;
|
|
5
|
-
|
|
7
|
+
private readonly toolStoreService;
|
|
8
|
+
private readonly toolExecutionService;
|
|
9
|
+
constructor(roomStoreService: RoomStoreService, toolStoreService: ToolStoreService, toolExecutionService: ToolExecutionService);
|
|
6
10
|
createRoom(name: string, goal: string, baseRoomDir?: string, storageDir?: string): Room;
|
|
7
11
|
}
|
|
@@ -4,12 +4,17 @@ exports.RoomFactory = void 0;
|
|
|
4
4
|
const room_1 = require("./room");
|
|
5
5
|
class RoomFactory {
|
|
6
6
|
roomStoreService;
|
|
7
|
-
|
|
7
|
+
toolStoreService;
|
|
8
|
+
toolExecutionService;
|
|
9
|
+
constructor(roomStoreService, toolStoreService, toolExecutionService) {
|
|
8
10
|
this.roomStoreService = roomStoreService;
|
|
11
|
+
this.toolStoreService = toolStoreService;
|
|
12
|
+
this.toolExecutionService = toolExecutionService;
|
|
9
13
|
}
|
|
10
14
|
createRoom(name, goal, baseRoomDir = '', storageDir = '') {
|
|
11
15
|
const finalStorageDir = storageDir || this.roomStoreService.getDefaultStorageDir();
|
|
12
16
|
const room = new room_1.Room(null, name, goal, baseRoomDir, finalStorageDir, this.roomStoreService);
|
|
17
|
+
room.setToolServices(this.toolStoreService, this.toolExecutionService);
|
|
13
18
|
return room;
|
|
14
19
|
}
|
|
15
20
|
}
|
|
@@ -6,16 +6,20 @@ import { RoomInfo } from '../../../shared/types/app.types';
|
|
|
6
6
|
import { RoomMessage } from './message';
|
|
7
7
|
import { ArtifactStoreService } from './artifact-store.service';
|
|
8
8
|
import { Artifact } from './artifact';
|
|
9
|
+
import { ToolStoreService } from '../tools/tool-store.service';
|
|
10
|
+
import { ToolExecutionService } from '../tools/tool-execution.service';
|
|
9
11
|
export declare class RoomStoreService {
|
|
10
12
|
private readonly userPaths;
|
|
11
13
|
private readonly agentStore;
|
|
12
14
|
private readonly attachedFileService;
|
|
13
15
|
private readonly artifactStoreService;
|
|
16
|
+
private readonly toolStoreService;
|
|
17
|
+
private readonly toolExecutionService;
|
|
14
18
|
private rooms;
|
|
15
19
|
private readonly defaultStorageDir;
|
|
16
20
|
private loaded;
|
|
17
21
|
private loadPromise;
|
|
18
|
-
constructor(userPaths: UserPathsService, agentStore: AgentStoreService, attachedFileService: AttachedFileService, artifactStoreService: ArtifactStoreService);
|
|
22
|
+
constructor(userPaths: UserPathsService, agentStore: AgentStoreService, attachedFileService: AttachedFileService, artifactStoreService: ArtifactStoreService, toolStoreService: ToolStoreService, toolExecutionService: ToolExecutionService);
|
|
19
23
|
getDefaultStorageDir(): string;
|
|
20
24
|
storeRoom(room: Room, storageDir?: string): string;
|
|
21
25
|
getRoom(id: string): Promise<Room | null>;
|
|
@@ -52,21 +52,27 @@ 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
|
+
const tool_store_service_1 = require("../tools/tool-store.service");
|
|
56
|
+
const tool_execution_service_1 = require("../tools/tool-execution.service");
|
|
55
57
|
const logger_1 = require("../common/logger");
|
|
56
58
|
let RoomStoreService = class RoomStoreService {
|
|
57
59
|
userPaths;
|
|
58
60
|
agentStore;
|
|
59
61
|
attachedFileService;
|
|
60
62
|
artifactStoreService;
|
|
63
|
+
toolStoreService;
|
|
64
|
+
toolExecutionService;
|
|
61
65
|
rooms = new Map();
|
|
62
66
|
defaultStorageDir;
|
|
63
67
|
loaded = false;
|
|
64
68
|
loadPromise = null;
|
|
65
|
-
constructor(userPaths, agentStore, attachedFileService, artifactStoreService) {
|
|
69
|
+
constructor(userPaths, agentStore, attachedFileService, artifactStoreService, toolStoreService, toolExecutionService) {
|
|
66
70
|
this.userPaths = userPaths;
|
|
67
71
|
this.agentStore = agentStore;
|
|
68
72
|
this.attachedFileService = attachedFileService;
|
|
69
73
|
this.artifactStoreService = artifactStoreService;
|
|
74
|
+
this.toolStoreService = toolStoreService;
|
|
75
|
+
this.toolExecutionService = toolExecutionService;
|
|
70
76
|
this.defaultStorageDir = path.join(this.userPaths.getUserDataDir(), 'rooms');
|
|
71
77
|
}
|
|
72
78
|
getDefaultStorageDir() {
|
|
@@ -76,6 +82,7 @@ let RoomStoreService = class RoomStoreService {
|
|
|
76
82
|
const finalStorageDir = storageDir || this.defaultStorageDir;
|
|
77
83
|
room.setStorageDir(finalStorageDir);
|
|
78
84
|
room.setRoomStoreService(this);
|
|
85
|
+
room.setToolServices(this.toolStoreService, this.toolExecutionService);
|
|
79
86
|
this.rooms.set(room.getId(), room);
|
|
80
87
|
this.saveRoomToFile(room, finalStorageDir);
|
|
81
88
|
return room.getId();
|
|
@@ -118,6 +125,7 @@ let RoomStoreService = class RoomStoreService {
|
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
const instance = new room_1.Room(instanceId, publishedName, template.getGoal(), template.getBaseRoomDir(), this.defaultStorageDir, this);
|
|
128
|
+
instance.setToolServices(this.toolStoreService, this.toolExecutionService);
|
|
121
129
|
for (const agentId of clonedAgentIds) {
|
|
122
130
|
const agent = await this.agentStore.getAgent(agentId);
|
|
123
131
|
if (agent) {
|
|
@@ -219,6 +227,7 @@ let RoomStoreService = class RoomStoreService {
|
|
|
219
227
|
const config = JSON.parse(fileContent);
|
|
220
228
|
let messages = await this.readRoomMessagesFromFileAsync(messagesPath);
|
|
221
229
|
const room = new room_1.Room(config.id, config.name, config.goal, '', storageDir, this);
|
|
230
|
+
room.setToolServices(this.toolStoreService, this.toolExecutionService);
|
|
222
231
|
room.setLoading(true);
|
|
223
232
|
room.setCreatedAt(new Date(config.createdAt));
|
|
224
233
|
room.setRoomMessages(messages);
|
|
@@ -353,5 +362,7 @@ exports.RoomStoreService = RoomStoreService = __decorate([
|
|
|
353
362
|
__metadata("design:paramtypes", [user_paths_service_1.UserPathsService,
|
|
354
363
|
agent_store_service_1.AgentStoreService,
|
|
355
364
|
attached_file_service_1.AttachedFileService,
|
|
356
|
-
artifact_store_service_1.ArtifactStoreService
|
|
365
|
+
artifact_store_service_1.ArtifactStoreService,
|
|
366
|
+
tool_store_service_1.ToolStoreService,
|
|
367
|
+
tool_execution_service_1.ToolExecutionService])
|
|
357
368
|
], RoomStoreService);
|