briyah 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -6
- package/data/common/config/image_models.json +160 -97
- package/data/common/config/markup +1 -1
- package/data/common/config/model_prices.json +31 -0
- package/data/common/config/story_models.json +31 -11
- package/data/common/config/story_models_full.json +25 -7
- 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 +6 -4
- 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 +10 -1
- 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.js +7 -3
- package/dist-sdk/server/src/app.controller.d.ts +15 -4
- package/dist-sdk/server/src/app.controller.js +171 -5
- package/dist-sdk/server/src/app.service.d.ts +19 -5
- package/dist-sdk/server/src/app.service.js +50 -4
- 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 +25 -4
- package/dist-sdk/server/src/room/room.js +393 -96
- package/dist-sdk/server/src/sdk/index.d.ts +1 -1
- 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/tool-execution.service.d.ts +19 -0
- package/dist-sdk/server/src/tools/tool-execution.service.js +100 -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 +44 -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 +10 -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 +12 -5
- package/docs/interfaces/AgentInfo.html +3 -2
- package/docs/interfaces/AgentMessagesResponse.html +2 -2
- package/docs/interfaces/AppService.html +184 -149
- 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 +7 -7
- 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/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/ToolParameter.html +5 -0
- package/docs/interfaces/ToolsResponse.html +2 -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/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,68 @@ 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 { tools: await appService.listTools() };
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
logger_1.logger.error(`[${req.user?.sub}] Error listing tools:`, error);
|
|
372
|
+
return { tools: [] };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
async createTool(req, body) {
|
|
376
|
+
if (!body.name) {
|
|
377
|
+
throw new common_1.BadRequestException('Tool name is required');
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
const appService = this.getAppService(req);
|
|
381
|
+
return await appService.createTool(body);
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
logger_1.logger.error(`[${req.user?.sub}] Error creating tool ${body.name}:`, error);
|
|
385
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
386
|
+
throw new common_1.ConflictException(error.message);
|
|
387
|
+
}
|
|
388
|
+
throw new common_1.HttpException(error.message || 'Failed to create tool', common_1.HttpStatus.BAD_REQUEST);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async updateTool(req, name, body) {
|
|
392
|
+
try {
|
|
393
|
+
const appService = this.getAppService(req);
|
|
394
|
+
return await appService.updateTool(name, body);
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
logger_1.logger.error(`[${req.user?.sub}] Error updating tool ${name}:`, error);
|
|
398
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
399
|
+
throw new common_1.NotFoundException(error.message);
|
|
400
|
+
}
|
|
401
|
+
throw new common_1.HttpException(error.message || 'Failed to update tool', common_1.HttpStatus.BAD_REQUEST);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async deleteTool(req, name) {
|
|
405
|
+
try {
|
|
406
|
+
const appService = this.getAppService(req);
|
|
407
|
+
await appService.deleteTool(name);
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
logger_1.logger.error(`[${req.user?.sub}] Error deleting tool ${name}:`, error);
|
|
411
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
412
|
+
throw new common_1.NotFoundException(error.message);
|
|
413
|
+
}
|
|
414
|
+
throw new common_1.HttpException('Failed to delete tool', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
async testTool(req, name, body) {
|
|
418
|
+
try {
|
|
419
|
+
const appService = this.getAppService(req);
|
|
420
|
+
return await appService.testTool(name, body?.args || {});
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
logger_1.logger.error(`[${req.user?.sub}] Error testing tool ${name}:`, error);
|
|
424
|
+
return { ok: false, error: error.message || 'Tool test failed' };
|
|
425
|
+
}
|
|
426
|
+
}
|
|
353
427
|
listLibraryPrompts() {
|
|
354
428
|
return { prompts: this.libraryService.listLocalPrompts() };
|
|
355
429
|
}
|
|
@@ -1154,7 +1228,7 @@ let AppController = class AppController {
|
|
|
1154
1228
|
}
|
|
1155
1229
|
try {
|
|
1156
1230
|
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.
|
|
1231
|
+
return appService.createStory(body.name, body.idea, body.userCharacterDesc, body.otherCharactersDesc, body.illustrateStory ?? true, body.storyModel, body.isImport, body.imageModelName, body.skipDetailedPlot ?? false);
|
|
1158
1232
|
}
|
|
1159
1233
|
catch (error) {
|
|
1160
1234
|
logger_1.logger.error(`[${req.user?.sub}] Error creating story ${body.name}:`, error);
|
|
@@ -1476,6 +1550,35 @@ let AppController = class AppController {
|
|
|
1476
1550
|
throw new common_1.HttpException('Failed to save character', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1477
1551
|
}
|
|
1478
1552
|
}
|
|
1553
|
+
async getCharacterInventory(req, storyId, characterName) {
|
|
1554
|
+
try {
|
|
1555
|
+
const appService = this.getAppService(req);
|
|
1556
|
+
return await appService.getCharacterInventory(storyId, characterName);
|
|
1557
|
+
}
|
|
1558
|
+
catch (error) {
|
|
1559
|
+
logger_1.logger.error(`[${req.user?.sub}] Error getting inventory for character ${characterName} in story ${storyId}:`, error);
|
|
1560
|
+
return { content: '' };
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
async saveCharacterInventory(req, storyId, characterName, body) {
|
|
1564
|
+
if (body.content === undefined || body.content === null) {
|
|
1565
|
+
throw new common_1.BadRequestException('Content is required');
|
|
1566
|
+
}
|
|
1567
|
+
try {
|
|
1568
|
+
const appService = this.getAppService(req);
|
|
1569
|
+
await appService.saveCharacterInventory(storyId, characterName, body.content);
|
|
1570
|
+
}
|
|
1571
|
+
catch (error) {
|
|
1572
|
+
logger_1.logger.error(`[${req.user?.sub}] Error saving inventory for character ${characterName} in story ${storyId}:`, error);
|
|
1573
|
+
if (error instanceof errors_1.NotFoundError) {
|
|
1574
|
+
throw new common_1.NotFoundException(error.message);
|
|
1575
|
+
}
|
|
1576
|
+
if (error instanceof errors_1.OperationFailedError) {
|
|
1577
|
+
throw new common_1.HttpException(error.message, common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1578
|
+
}
|
|
1579
|
+
throw new common_1.HttpException('Failed to save inventory', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1479
1582
|
async getPlotPlan(req, storyId) {
|
|
1480
1583
|
try {
|
|
1481
1584
|
const appService = this.getAppService(req);
|
|
@@ -1861,7 +1964,7 @@ __decorate([
|
|
|
1861
1964
|
__param(0, (0, common_1.Request)()),
|
|
1862
1965
|
__metadata("design:type", Function),
|
|
1863
1966
|
__metadata("design:paramtypes", [Object]),
|
|
1864
|
-
__metadata("design:returntype",
|
|
1967
|
+
__metadata("design:returntype", Promise)
|
|
1865
1968
|
], AppController.prototype, "listStoryModelDefaults", null);
|
|
1866
1969
|
__decorate([
|
|
1867
1970
|
(0, common_1.Post)('agents'),
|
|
@@ -1976,6 +2079,49 @@ __decorate([
|
|
|
1976
2079
|
__metadata("design:paramtypes", [Object, String, String]),
|
|
1977
2080
|
__metadata("design:returntype", Promise)
|
|
1978
2081
|
], AppController.prototype, "deletePromptFile", null);
|
|
2082
|
+
__decorate([
|
|
2083
|
+
(0, common_1.Get)('tools'),
|
|
2084
|
+
__param(0, (0, common_1.Request)()),
|
|
2085
|
+
__metadata("design:type", Function),
|
|
2086
|
+
__metadata("design:paramtypes", [Object]),
|
|
2087
|
+
__metadata("design:returntype", Promise)
|
|
2088
|
+
], AppController.prototype, "getTools", null);
|
|
2089
|
+
__decorate([
|
|
2090
|
+
(0, common_1.Post)('tools'),
|
|
2091
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
|
2092
|
+
__param(0, (0, common_1.Request)()),
|
|
2093
|
+
__param(1, (0, common_1.Body)()),
|
|
2094
|
+
__metadata("design:type", Function),
|
|
2095
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
2096
|
+
__metadata("design:returntype", Promise)
|
|
2097
|
+
], AppController.prototype, "createTool", null);
|
|
2098
|
+
__decorate([
|
|
2099
|
+
(0, common_1.Put)('tools/:name'),
|
|
2100
|
+
__param(0, (0, common_1.Request)()),
|
|
2101
|
+
__param(1, (0, common_1.Param)('name')),
|
|
2102
|
+
__param(2, (0, common_1.Body)()),
|
|
2103
|
+
__metadata("design:type", Function),
|
|
2104
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2105
|
+
__metadata("design:returntype", Promise)
|
|
2106
|
+
], AppController.prototype, "updateTool", null);
|
|
2107
|
+
__decorate([
|
|
2108
|
+
(0, common_1.Delete)('tools/:name'),
|
|
2109
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2110
|
+
__param(0, (0, common_1.Request)()),
|
|
2111
|
+
__param(1, (0, common_1.Param)('name')),
|
|
2112
|
+
__metadata("design:type", Function),
|
|
2113
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
2114
|
+
__metadata("design:returntype", Promise)
|
|
2115
|
+
], AppController.prototype, "deleteTool", null);
|
|
2116
|
+
__decorate([
|
|
2117
|
+
(0, common_1.Post)('tools/:name/test'),
|
|
2118
|
+
__param(0, (0, common_1.Request)()),
|
|
2119
|
+
__param(1, (0, common_1.Param)('name')),
|
|
2120
|
+
__param(2, (0, common_1.Body)()),
|
|
2121
|
+
__metadata("design:type", Function),
|
|
2122
|
+
__metadata("design:paramtypes", [Object, String, Object]),
|
|
2123
|
+
__metadata("design:returntype", Promise)
|
|
2124
|
+
], AppController.prototype, "testTool", null);
|
|
1979
2125
|
__decorate([
|
|
1980
2126
|
(0, common_1.Get)('library/prompts'),
|
|
1981
2127
|
(0, public_decorator_1.Public)(),
|
|
@@ -2611,6 +2757,26 @@ __decorate([
|
|
|
2611
2757
|
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2612
2758
|
__metadata("design:returntype", Promise)
|
|
2613
2759
|
], AppController.prototype, "saveCharacter", null);
|
|
2760
|
+
__decorate([
|
|
2761
|
+
(0, common_1.Get)('stories/:storyId/characters/:characterName/inventory'),
|
|
2762
|
+
__param(0, (0, common_1.Request)()),
|
|
2763
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2764
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2765
|
+
__metadata("design:type", Function),
|
|
2766
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
2767
|
+
__metadata("design:returntype", Promise)
|
|
2768
|
+
], AppController.prototype, "getCharacterInventory", null);
|
|
2769
|
+
__decorate([
|
|
2770
|
+
(0, common_1.Put)('stories/:storyId/characters/:characterName/inventory'),
|
|
2771
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
2772
|
+
__param(0, (0, common_1.Request)()),
|
|
2773
|
+
__param(1, (0, common_1.Param)('storyId')),
|
|
2774
|
+
__param(2, (0, common_1.Param)('characterName')),
|
|
2775
|
+
__param(3, (0, common_1.Body)()),
|
|
2776
|
+
__metadata("design:type", Function),
|
|
2777
|
+
__metadata("design:paramtypes", [Object, String, String, Object]),
|
|
2778
|
+
__metadata("design:returntype", Promise)
|
|
2779
|
+
], AppController.prototype, "saveCharacterInventory", null);
|
|
2614
2780
|
__decorate([
|
|
2615
2781
|
(0, common_1.Get)('stories/:storyId/plot-plan'),
|
|
2616
2782
|
__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, 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;
|
|
@@ -107,7 +111,13 @@ export declare class AppService {
|
|
|
107
111
|
maxOutputTokens?: number;
|
|
108
112
|
allowSearch?: boolean;
|
|
109
113
|
beginInstruction?: string;
|
|
114
|
+
toolNames?: string[];
|
|
110
115
|
}): Promise<void>;
|
|
116
|
+
listTools(): Promise<ToolDefinition[]>;
|
|
117
|
+
createTool(tool: ToolDefinition): Promise<ToolDefinition>;
|
|
118
|
+
updateTool(name: string, tool: ToolDefinition): Promise<ToolDefinition>;
|
|
119
|
+
deleteTool(name: string): Promise<void>;
|
|
120
|
+
testTool(name: string, args: Record<string, any>): Promise<ToolRunResult>;
|
|
111
121
|
listAttachedFiles(agentId: string): Promise<FileList>;
|
|
112
122
|
deleteAttachedFile(agentId: string, fileName: string): Promise<void>;
|
|
113
123
|
deleteAttachedFileById(documentId: string): Promise<void>;
|
|
@@ -116,7 +126,7 @@ export declare class AppService {
|
|
|
116
126
|
resetRoom(roomId: string): Promise<void>;
|
|
117
127
|
resetStory(storyId: string): Promise<void>;
|
|
118
128
|
revertStoryChapter(storyId: string): Promise<void>;
|
|
119
|
-
createStory(name: string, idea: string, userCharacterDesc: string, otherCharactersDesc: string, illustrateStory: boolean, storyModel?: string, isImport?: boolean, imageModelName?: string,
|
|
129
|
+
createStory(name: string, idea: string, userCharacterDesc: string, otherCharactersDesc: string, illustrateStory: boolean, storyModel?: string, isImport?: boolean, imageModelName?: string, skipDetailedPlot?: boolean): Promise<StoryInfo>;
|
|
120
130
|
importStoryFromZip(zipBuffer: Buffer): Promise<StoryInfo>;
|
|
121
131
|
getStoryProgressEmitter(storyId: string): EventEmitter<any>;
|
|
122
132
|
getStoryMessageEmitter(storyId: string): EventEmitter<any>;
|
|
@@ -156,6 +166,10 @@ export declare class AppService {
|
|
|
156
166
|
content: string;
|
|
157
167
|
}>;
|
|
158
168
|
saveCharacter(storyId: string, characterName: string, content: string): void;
|
|
169
|
+
getCharacterInventory(storyId: string, characterName: string): Promise<{
|
|
170
|
+
content: string;
|
|
171
|
+
}>;
|
|
172
|
+
saveCharacterInventory(storyId: string, characterName: string, content: string): Promise<void>;
|
|
159
173
|
getPlotPlan(storyId: string): Promise<{
|
|
160
174
|
content: string;
|
|
161
175
|
}>;
|
|
@@ -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) {
|
|
@@ -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,36 @@ 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
|
+
async listTools() {
|
|
842
|
+
return this.toolStore.listTools();
|
|
843
|
+
}
|
|
844
|
+
async createTool(tool) {
|
|
845
|
+
const existing = await this.toolStore.getTool(tool.name);
|
|
846
|
+
if (existing) {
|
|
847
|
+
throw new errors_1.OperationFailedError(`Tool "${tool.name}" already exists`);
|
|
848
|
+
}
|
|
849
|
+
return this.toolStore.saveTool(tool);
|
|
850
|
+
}
|
|
851
|
+
async updateTool(name, tool) {
|
|
852
|
+
const existing = await this.toolStore.getTool(name);
|
|
853
|
+
if (!existing) {
|
|
854
|
+
throw new errors_1.NotFoundError(`Tool "${name}" not found`);
|
|
855
|
+
}
|
|
856
|
+
return this.toolStore.saveTool({ ...tool, name });
|
|
857
|
+
}
|
|
858
|
+
async deleteTool(name) {
|
|
859
|
+
const deleted = await this.toolStore.deleteTool(name);
|
|
860
|
+
if (!deleted) {
|
|
861
|
+
throw new errors_1.NotFoundError(`Tool "${name}" not found`);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
async testTool(name, args) {
|
|
865
|
+
return this.toolExecution.test(name, args);
|
|
866
|
+
}
|
|
828
867
|
async listAttachedFiles(agentId) {
|
|
829
868
|
const agent = await this.agentStore.getAgent(agentId);
|
|
830
869
|
if (!agent) {
|
|
@@ -972,8 +1011,8 @@ class AppService {
|
|
|
972
1011
|
async revertStoryChapter(storyId) {
|
|
973
1012
|
return this.storyService.revertStoryChapter(storyId);
|
|
974
1013
|
}
|
|
975
|
-
async createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName,
|
|
976
|
-
return this.storyService.createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName,
|
|
1014
|
+
async createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName, skipDetailedPlot) {
|
|
1015
|
+
return this.storyService.createStory(name, idea, userCharacterDesc, otherCharactersDesc, illustrateStory, storyModel, isImport, imageModelName, skipDetailedPlot);
|
|
977
1016
|
}
|
|
978
1017
|
async importStoryFromZip(zipBuffer) {
|
|
979
1018
|
return this.storyService.importStoryFromZip(zipBuffer);
|
|
@@ -1148,6 +1187,13 @@ class AppService {
|
|
|
1148
1187
|
saveCharacter(storyId, characterName, content) {
|
|
1149
1188
|
this.storyService.saveCharacter(storyId, characterName, content);
|
|
1150
1189
|
}
|
|
1190
|
+
async getCharacterInventory(storyId, characterName) {
|
|
1191
|
+
const content = await this.storyService.getCharacterInventory(storyId, characterName);
|
|
1192
|
+
return { content: content || '' };
|
|
1193
|
+
}
|
|
1194
|
+
async saveCharacterInventory(storyId, characterName, content) {
|
|
1195
|
+
await this.storyService.saveCharacterInventory(storyId, characterName, content);
|
|
1196
|
+
}
|
|
1151
1197
|
async getPlotPlan(storyId) {
|
|
1152
1198
|
const content = await this.storyService.getPlotPlan(storyId);
|
|
1153
1199
|
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);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Agent } from '../ai/agent';
|
|
2
2
|
import { RoomMessage } from './message';
|
|
3
3
|
import { Artifact } from './artifact';
|
|
4
|
+
import { ToolStoreService } from '../tools/tool-store.service';
|
|
5
|
+
import { ToolExecutionService } from '../tools/tool-execution.service';
|
|
4
6
|
export declare class Room {
|
|
7
|
+
private static readonly MAX_TOOL_ITERATIONS;
|
|
5
8
|
private id;
|
|
6
9
|
private name;
|
|
7
10
|
private goal;
|
|
@@ -22,11 +25,14 @@ export declare class Room {
|
|
|
22
25
|
private onStateChangeCallbacks;
|
|
23
26
|
private onError?;
|
|
24
27
|
private currentSituation;
|
|
28
|
+
private currentSituationTime;
|
|
25
29
|
private onSituationUpdate?;
|
|
26
30
|
private onModeratorResponseCallback?;
|
|
27
31
|
private templateRoomId;
|
|
28
32
|
private storageDir;
|
|
29
33
|
private roomStoreService;
|
|
34
|
+
private toolStoreService?;
|
|
35
|
+
private toolExecutionService?;
|
|
30
36
|
constructor(id: string | null, name: string, goal: string, baseRoomDir?: string, storageDir?: string, roomStoreService?: any);
|
|
31
37
|
deleteRoom(): void;
|
|
32
38
|
setLoading(isLoading: boolean): void;
|
|
@@ -59,7 +65,9 @@ export declare class Room {
|
|
|
59
65
|
};
|
|
60
66
|
getLatestRoomMessages(fromIndex?: number, includeThoughts?: boolean): RoomMessage[];
|
|
61
67
|
setRoomMessages(messages: RoomMessage[]): void;
|
|
62
|
-
addRoomMessage(message: RoomMessage
|
|
68
|
+
addRoomMessage(message: RoomMessage, options?: {
|
|
69
|
+
suppressSituationUpdate?: boolean;
|
|
70
|
+
}): void;
|
|
63
71
|
addRoomMessages(messages: RoomMessage[]): void;
|
|
64
72
|
getCreatedAt(): Date;
|
|
65
73
|
setCreatedAt(date: Date): void;
|
|
@@ -69,6 +77,14 @@ export declare class Room {
|
|
|
69
77
|
private parseAgentResponse;
|
|
70
78
|
private static extractPreamble;
|
|
71
79
|
private static coerceMessageAction;
|
|
80
|
+
private getPresentCharacters;
|
|
81
|
+
private buildCharacterPrivateContextDigest;
|
|
82
|
+
private buildAvailableTools;
|
|
83
|
+
private buildPerceiveVariables;
|
|
84
|
+
private buildTransientPrompt;
|
|
85
|
+
private promptAgentOnce;
|
|
86
|
+
private runAgentTurn;
|
|
87
|
+
private executeToolForAgent;
|
|
72
88
|
private getAgentAiResponse;
|
|
73
89
|
perceive(agent: Agent, message: RoomMessage, onResponse: (message: RoomMessage | null) => void): void;
|
|
74
90
|
moderate(moderatorAgent: Agent, message: RoomMessage, onResponse: (message: RoomMessage | null) => void): Promise<void>;
|
|
@@ -83,6 +99,7 @@ export declare class Room {
|
|
|
83
99
|
setStorageDir(dir: string): void;
|
|
84
100
|
getRoomStoreService(): any;
|
|
85
101
|
setRoomStoreService(service: any): void;
|
|
102
|
+
setToolServices(toolStore: ToolStoreService, toolExecution: ToolExecutionService): void;
|
|
86
103
|
saveMessages(messages: RoomMessage[]): void;
|
|
87
104
|
saveMetadata(): string;
|
|
88
105
|
setOnStateChange(key: string, callback: () => void): void;
|
|
@@ -93,13 +110,14 @@ export declare class Room {
|
|
|
93
110
|
getHumanAgentName(): string;
|
|
94
111
|
getModeratorAgent(): Agent | undefined;
|
|
95
112
|
getSituation(): string;
|
|
113
|
+
getSituationTime(): string;
|
|
114
|
+
setSituationTime(time: string): void;
|
|
115
|
+
private buildSituationHeader;
|
|
96
116
|
setSituation(situation: string): void;
|
|
97
|
-
setOnSituationUpdate(callback: (situation: string) => void): void;
|
|
117
|
+
setOnSituationUpdate(callback: (situation: string, messageBody?: string) => void | Promise<void>): void;
|
|
98
118
|
setOnModeratorResponse(callback: (message: RoomMessage) => void): void;
|
|
99
119
|
private handleSituationUpdate;
|
|
100
120
|
handlePublishMessages(messages: RoomMessage[]): void;
|
|
101
|
-
handleExecuteMessages(messages: RoomMessage[]): void;
|
|
102
|
-
private executeCommand;
|
|
103
121
|
handleAdjournMessages(messages: RoomMessage[]): void;
|
|
104
122
|
addPendingMessage(message: RoomMessage, clearQueue?: boolean): void;
|
|
105
123
|
isProcessingInProgress(): boolean;
|
|
@@ -108,6 +126,9 @@ export declare class Room {
|
|
|
108
126
|
interrupt(): void;
|
|
109
127
|
checkAgentNicknameMatch(existingNickname: string, targetNickname: string): boolean;
|
|
110
128
|
private handleModeratorResponse;
|
|
129
|
+
private runDeliverTurn;
|
|
130
|
+
private handleCommissionMessage;
|
|
131
|
+
private respondToCommissioner;
|
|
111
132
|
private processPendingMessages;
|
|
112
133
|
private filterConcurrentMessages;
|
|
113
134
|
}
|