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
|
@@ -51,6 +51,7 @@ const fs = __importStar(require("fs"));
|
|
|
51
51
|
const handlebars_1 = require("handlebars");
|
|
52
52
|
const errors_1 = require("../../common/errors");
|
|
53
53
|
const logger_1 = require("../../common/logger");
|
|
54
|
+
const jsonrepair_1 = require("jsonrepair");
|
|
54
55
|
const model_prices_1 = require("../model_prices");
|
|
55
56
|
const ai_debug_logger_1 = require("../ai-debug-logger");
|
|
56
57
|
let BaseAiService = class BaseAiService {
|
|
@@ -381,51 +382,21 @@ let BaseAiService = class BaseAiService {
|
|
|
381
382
|
}
|
|
382
383
|
return str;
|
|
383
384
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
result += char;
|
|
396
|
-
}
|
|
397
|
-
escapeNext = false;
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
if (char === '\\') {
|
|
401
|
-
result += char;
|
|
402
|
-
escapeNext = true;
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
if (char === '"') {
|
|
406
|
-
inString = !inString;
|
|
407
|
-
result += char;
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
if (inString) {
|
|
411
|
-
if (char === '\n') {
|
|
412
|
-
result += '\\n';
|
|
413
|
-
}
|
|
414
|
-
else if (char === '\r') {
|
|
415
|
-
result += '\\r';
|
|
416
|
-
}
|
|
417
|
-
else if (char === '\t') {
|
|
418
|
-
result += '\\t';
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
result += char;
|
|
422
|
-
}
|
|
385
|
+
parseStructuredResponse(text) {
|
|
386
|
+
try {
|
|
387
|
+
return JSON.parse(text);
|
|
388
|
+
}
|
|
389
|
+
catch (firstError) {
|
|
390
|
+
try {
|
|
391
|
+
const repaired = (0, jsonrepair_1.jsonrepair)(text);
|
|
392
|
+
logger_1.logger.warn('Structured response was not valid JSON; recovered via jsonrepair');
|
|
393
|
+
return JSON.parse(repaired);
|
|
423
394
|
}
|
|
424
|
-
|
|
425
|
-
|
|
395
|
+
catch {
|
|
396
|
+
logger_1.logger.error('Failed to parse structured response even after repair');
|
|
397
|
+
throw firstError;
|
|
426
398
|
}
|
|
427
399
|
}
|
|
428
|
-
return result;
|
|
429
400
|
}
|
|
430
401
|
};
|
|
431
402
|
exports.BaseAiService = BaseAiService;
|
|
@@ -13,6 +13,7 @@ exports.DeepSeekAiService = void 0;
|
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const deepseek_1 = require("@ai-sdk/deepseek");
|
|
15
15
|
const ai_1 = require("ai");
|
|
16
|
+
const jsonrepair_1 = require("jsonrepair");
|
|
16
17
|
const base_ai_service_1 = require("./base-ai.service");
|
|
17
18
|
const zod_1 = require("zod");
|
|
18
19
|
const model_prices_1 = require("../model_prices");
|
|
@@ -201,6 +202,14 @@ let DeepSeekAiService = class DeepSeekAiService extends base_ai_service_1.BaseAi
|
|
|
201
202
|
messages: messages,
|
|
202
203
|
temperature: 0,
|
|
203
204
|
schema: this.jsonSchemaToZod(jsonSchema),
|
|
205
|
+
experimental_repairText: async ({ text }) => {
|
|
206
|
+
try {
|
|
207
|
+
return (0, jsonrepair_1.jsonrepair)(text);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
},
|
|
204
213
|
providerOptions: {
|
|
205
214
|
deepseek: {
|
|
206
215
|
reasoningEffort: reasoningEffort,
|
|
@@ -151,7 +151,6 @@ let FalAiService = class FalAiService extends base_ai_service_1.BaseAiService {
|
|
|
151
151
|
estimatedOutputTokens = Math.ceil(responseText.length / 4);
|
|
152
152
|
if (jsonSchema) {
|
|
153
153
|
responseText = this.trimToJson(responseText);
|
|
154
|
-
responseText = this.sanitizeJsonString(responseText);
|
|
155
154
|
}
|
|
156
155
|
else {
|
|
157
156
|
responseText = this.trimResponseText(responseText);
|
|
@@ -179,7 +178,7 @@ let FalAiService = class FalAiService extends base_ai_service_1.BaseAiService {
|
|
|
179
178
|
}
|
|
180
179
|
if (jsonSchema) {
|
|
181
180
|
try {
|
|
182
|
-
return
|
|
181
|
+
return this.parseStructuredResponse(responseText);
|
|
183
182
|
}
|
|
184
183
|
catch (parseError) {
|
|
185
184
|
logger_1.logger.error('Failed to parse JSON response:', parseError);
|
|
@@ -133,7 +133,6 @@ let GoogleAiService = class GoogleAiService extends base_ai_service_1.BaseAiServ
|
|
|
133
133
|
}
|
|
134
134
|
if (jsonSchema) {
|
|
135
135
|
responseText = this.trimToJson(responseText);
|
|
136
|
-
responseText = this.sanitizeJsonString(responseText);
|
|
137
136
|
}
|
|
138
137
|
else {
|
|
139
138
|
responseText = this.trimResponseText(responseText);
|
|
@@ -152,7 +151,7 @@ let GoogleAiService = class GoogleAiService extends base_ai_service_1.BaseAiServ
|
|
|
152
151
|
this.addToConversationHistory(agent, responseText, true);
|
|
153
152
|
}
|
|
154
153
|
if (jsonSchema) {
|
|
155
|
-
return
|
|
154
|
+
return this.parseStructuredResponse(responseText);
|
|
156
155
|
}
|
|
157
156
|
return responseText;
|
|
158
157
|
}
|
|
@@ -194,7 +194,6 @@ let GrokAiService = class GrokAiService extends base_ai_service_1.BaseAiService
|
|
|
194
194
|
}
|
|
195
195
|
if (jsonSchema) {
|
|
196
196
|
responseText = this.trimToJson(responseText);
|
|
197
|
-
responseText = this.sanitizeJsonString(responseText);
|
|
198
197
|
}
|
|
199
198
|
this.debugLogResponse(agent.agentName, responseText);
|
|
200
199
|
if (response.usage) {
|
|
@@ -210,7 +209,7 @@ let GrokAiService = class GrokAiService extends base_ai_service_1.BaseAiService
|
|
|
210
209
|
this.addToConversationHistory(agent, responseText, true);
|
|
211
210
|
}
|
|
212
211
|
if (jsonSchema)
|
|
213
|
-
return
|
|
212
|
+
return this.parseStructuredResponse(responseText);
|
|
214
213
|
return responseText;
|
|
215
214
|
}
|
|
216
215
|
addToConversationHistory(agent, message, fromSelf = false, developer = false) {
|
|
@@ -211,7 +211,6 @@ let OpenAiService = class OpenAiService extends base_ai_service_1.BaseAiService
|
|
|
211
211
|
response = await this.openai.responses.create(requestParams);
|
|
212
212
|
if (jsonSchema) {
|
|
213
213
|
responseText = this.trimToJson(response.output_text);
|
|
214
|
-
responseText = this.sanitizeJsonString(responseText);
|
|
215
214
|
}
|
|
216
215
|
else {
|
|
217
216
|
responseText = response.output_text;
|
|
@@ -230,7 +229,7 @@ let OpenAiService = class OpenAiService extends base_ai_service_1.BaseAiService
|
|
|
230
229
|
this.addToConversationHistory(agent, responseText, true);
|
|
231
230
|
}
|
|
232
231
|
if (jsonSchema)
|
|
233
|
-
return
|
|
232
|
+
return this.parseStructuredResponse(responseText);
|
|
234
233
|
return responseText;
|
|
235
234
|
}
|
|
236
235
|
async attachDocument(agent, fileName, fileData) {
|
|
@@ -138,7 +138,6 @@ let TogetherAiService = class TogetherAiService extends base_ai_service_1.BaseAi
|
|
|
138
138
|
}
|
|
139
139
|
if (jsonSchema) {
|
|
140
140
|
responseText = this.trimToJson(responseText);
|
|
141
|
-
responseText = this.sanitizeJsonString(responseText);
|
|
142
141
|
}
|
|
143
142
|
else {
|
|
144
143
|
responseText = this.trimResponseText(responseText);
|
|
@@ -157,7 +156,7 @@ let TogetherAiService = class TogetherAiService extends base_ai_service_1.BaseAi
|
|
|
157
156
|
this.addToConversationHistory(agent, responseText, true);
|
|
158
157
|
}
|
|
159
158
|
if (jsonSchema) {
|
|
160
|
-
return
|
|
159
|
+
return this.parseStructuredResponse(responseText);
|
|
161
160
|
}
|
|
162
161
|
return responseText;
|
|
163
162
|
}
|
|
@@ -4,6 +4,7 @@ export interface AgentConfig {
|
|
|
4
4
|
agentName: string;
|
|
5
5
|
agentNickname: string;
|
|
6
6
|
description: string;
|
|
7
|
+
privateContext?: string;
|
|
7
8
|
promptFolder: string;
|
|
8
9
|
systemInstruction: string;
|
|
9
10
|
modelName: string;
|
|
@@ -30,4 +31,5 @@ export interface AgentConfig {
|
|
|
30
31
|
beginInstruction?: string;
|
|
31
32
|
promptCacheTTL?: number;
|
|
32
33
|
ownerRoomId?: string;
|
|
34
|
+
toolNames?: string[];
|
|
33
35
|
}
|
|
@@ -140,12 +140,14 @@ let AgentStoreService = class AgentStoreService {
|
|
|
140
140
|
instance.totalOutputTokens = 0;
|
|
141
141
|
instance.totalCost = 0;
|
|
142
142
|
instance.totalMarkup = 0;
|
|
143
|
+
instance.privateContext = template.privateContext;
|
|
143
144
|
instance.attachedFiles = [...template.attachedFiles];
|
|
144
145
|
instance.attachedArtifacts = [...template.attachedArtifacts];
|
|
145
146
|
instance.maxHistoryMessages = template.maxHistoryMessages;
|
|
146
147
|
instance.promptCacheTTL = template.promptCacheTTL;
|
|
147
148
|
instance.markupRate = template.markupRate;
|
|
148
149
|
instance.smallModelName = template.smallModelName;
|
|
150
|
+
instance.toolNames = [...template.toolNames];
|
|
149
151
|
this.storeAgent(instance);
|
|
150
152
|
return instanceId;
|
|
151
153
|
}
|
|
@@ -173,6 +175,7 @@ let AgentStoreService = class AgentStoreService {
|
|
|
173
175
|
throw new Error(`Instance ${instanceId} does not belong to template ${templateId}`);
|
|
174
176
|
}
|
|
175
177
|
instance.description = template.description;
|
|
178
|
+
instance.privateContext = template.privateContext;
|
|
176
179
|
instance.agentNickname = template.agentNickname;
|
|
177
180
|
instance.promptFolder = template.promptFolder;
|
|
178
181
|
instance.systemInstruction = template.systemInstruction;
|
|
@@ -188,6 +191,7 @@ let AgentStoreService = class AgentStoreService {
|
|
|
188
191
|
instance.maxHistoryMessages = template.maxHistoryMessages;
|
|
189
192
|
instance.promptCacheTTL = template.promptCacheTTL;
|
|
190
193
|
instance.markupRate = template.markupRate;
|
|
194
|
+
instance.toolNames = [...template.toolNames];
|
|
191
195
|
instance.history = [];
|
|
192
196
|
instance.totalInputTokens = 0;
|
|
193
197
|
instance.totalOutputTokens = 0;
|
|
@@ -236,6 +240,7 @@ let AgentStoreService = class AgentStoreService {
|
|
|
236
240
|
const aiService = this.aiFactoryService.createAiService(config.serviceName);
|
|
237
241
|
const finalArtifactService = artifactService || this.artifactService;
|
|
238
242
|
const agent = new agent_1.Agent(config.id, this.userPaths, this.configService, this, this.balanceService, finalArtifactService, config.agentName, config.agentNickname || config.agentName, config.description, config.promptFolder, config.systemInstruction, config.history || [], config.modelName, config.serviceName, aiService, config.reasoningEffort, config.allowSearch, config.maxOutputTokens, config.beginInstruction || '', storageDir);
|
|
243
|
+
agent.privateContext = config.privateContext || '';
|
|
239
244
|
agent.createdAt = new Date(config.createdAt);
|
|
240
245
|
agent.userPaths = this.userPaths;
|
|
241
246
|
agent.smallModelName = config.smallModelName;
|
|
@@ -255,6 +260,7 @@ let AgentStoreService = class AgentStoreService {
|
|
|
255
260
|
agent.beginInstruction = config.beginInstruction || '';
|
|
256
261
|
agent.maxHistoryMessages = config.maxHistoryMessages || undefined;
|
|
257
262
|
agent.promptCacheTTL = Number(config.promptCacheTTL) ?? 0;
|
|
263
|
+
agent.toolNames = config.toolNames || [];
|
|
258
264
|
agent.id = config.id;
|
|
259
265
|
this.agents.set(config.id, agent);
|
|
260
266
|
if (config.attachedFiles && config.attachedFiles.length > 0) {
|
|
@@ -305,6 +311,7 @@ let AgentStoreService = class AgentStoreService {
|
|
|
305
311
|
agentName: agent.agentName,
|
|
306
312
|
agentNickname: agent.agentNickname,
|
|
307
313
|
description: agent.description,
|
|
314
|
+
privateContext: agent.privateContext,
|
|
308
315
|
promptFolder: agent.promptFolder,
|
|
309
316
|
systemInstruction: agent.systemInstruction,
|
|
310
317
|
modelName: agent.modelName,
|
|
@@ -331,6 +338,7 @@ let AgentStoreService = class AgentStoreService {
|
|
|
331
338
|
beginInstruction: agent.beginInstruction,
|
|
332
339
|
promptCacheTTL: agent.promptCacheTTL,
|
|
333
340
|
ownerRoomId: agent.ownerRoomId,
|
|
341
|
+
toolNames: agent.toolNames,
|
|
334
342
|
};
|
|
335
343
|
const filePath = path.join(storageDir, `${agent.id}.json`);
|
|
336
344
|
fs.writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8');
|
|
@@ -36,6 +36,7 @@ export declare class Agent {
|
|
|
36
36
|
configService: IConfigService;
|
|
37
37
|
balanceService?: BalanceService;
|
|
38
38
|
description: string;
|
|
39
|
+
privateContext: string;
|
|
39
40
|
promptFolder: string;
|
|
40
41
|
systemInstruction: string;
|
|
41
42
|
maxHistoryMessages?: number;
|
|
@@ -49,6 +50,7 @@ export declare class Agent {
|
|
|
49
50
|
attachedArtifacts: string[];
|
|
50
51
|
isControlledByHuman: boolean;
|
|
51
52
|
beginInstruction: string;
|
|
53
|
+
toolNames: string[];
|
|
52
54
|
promptCacheTTL: number;
|
|
53
55
|
private onStateChange;
|
|
54
56
|
storageDir: string;
|
|
@@ -34,6 +34,7 @@ class Agent {
|
|
|
34
34
|
configService;
|
|
35
35
|
balanceService;
|
|
36
36
|
description;
|
|
37
|
+
privateContext = '';
|
|
37
38
|
promptFolder;
|
|
38
39
|
systemInstruction;
|
|
39
40
|
maxHistoryMessages;
|
|
@@ -47,6 +48,7 @@ class Agent {
|
|
|
47
48
|
attachedArtifacts = [];
|
|
48
49
|
isControlledByHuman = false;
|
|
49
50
|
beginInstruction = '';
|
|
51
|
+
toolNames = [];
|
|
50
52
|
promptCacheTTL = 0;
|
|
51
53
|
onStateChange = null;
|
|
52
54
|
storageDir;
|
|
@@ -89,5 +89,6 @@ function resolveModelInfo(modelName, prefix) {
|
|
|
89
89
|
function isKnownModel(modelName, prefix) {
|
|
90
90
|
if (resolveModelInfo(modelName, prefix) !== null)
|
|
91
91
|
return true;
|
|
92
|
-
return getImageModels().some((m) => m.model === modelName && m.centsPerImage != null)
|
|
92
|
+
return getImageModels().some((m) => (m.generation?.model === modelName && m.generation?.centsPerImage != null) ||
|
|
93
|
+
(m.editing?.model === modelName && m.editing?.centsPerImage != null));
|
|
93
94
|
}
|
|
@@ -8,6 +8,7 @@ import { StoryMessageService } from '../story/story-message.service';
|
|
|
8
8
|
import { PublishedAgentsService } from '../ai/published-agents.service';
|
|
9
9
|
import { PublishedRoomsService } from '../room/published-rooms.service';
|
|
10
10
|
import { BalanceMessageService } from './balance-message.service';
|
|
11
|
+
import { NativeToolRegistry } from '../tools/native-tool-registry.service';
|
|
11
12
|
export declare class UserServiceFactory {
|
|
12
13
|
private readonly aiFactoryService;
|
|
13
14
|
private readonly agentMessageService;
|
|
@@ -18,6 +19,7 @@ export declare class UserServiceFactory {
|
|
|
18
19
|
private readonly publishedRoomsService;
|
|
19
20
|
private readonly balanceMessageService;
|
|
20
21
|
private readonly configService;
|
|
21
|
-
|
|
22
|
+
private readonly nativeToolRegistry;
|
|
23
|
+
constructor(aiFactoryService: AiFactoryService, agentMessageService: AgentMessageService, roomMessageService: RoomMessageService, storyProgressService: StoryProgressService, storyMessageService: StoryMessageService, publishedAgentsService: PublishedAgentsService, publishedRoomsService: PublishedRoomsService, balanceMessageService: BalanceMessageService, configService: ConfigService, nativeToolRegistry: NativeToolRegistry);
|
|
22
24
|
createAppService(userId: string): AppService;
|
|
23
25
|
}
|
|
@@ -33,6 +33,9 @@ const balance_message_service_1 = require("./balance-message.service");
|
|
|
33
33
|
const transaction_service_1 = require("./transaction.service");
|
|
34
34
|
const agent_factory_1 = require("../ai/agent-factory");
|
|
35
35
|
const room_factory_1 = require("../room/room-factory");
|
|
36
|
+
const tool_store_service_1 = require("../tools/tool-store.service");
|
|
37
|
+
const tool_execution_service_1 = require("../tools/tool-execution.service");
|
|
38
|
+
const native_tool_registry_service_1 = require("../tools/native-tool-registry.service");
|
|
36
39
|
let UserServiceFactory = class UserServiceFactory {
|
|
37
40
|
aiFactoryService;
|
|
38
41
|
agentMessageService;
|
|
@@ -43,7 +46,8 @@ let UserServiceFactory = class UserServiceFactory {
|
|
|
43
46
|
publishedRoomsService;
|
|
44
47
|
balanceMessageService;
|
|
45
48
|
configService;
|
|
46
|
-
|
|
49
|
+
nativeToolRegistry;
|
|
50
|
+
constructor(aiFactoryService, agentMessageService, roomMessageService, storyProgressService, storyMessageService, publishedAgentsService, publishedRoomsService, balanceMessageService, configService, nativeToolRegistry) {
|
|
47
51
|
this.aiFactoryService = aiFactoryService;
|
|
48
52
|
this.agentMessageService = agentMessageService;
|
|
49
53
|
this.roomMessageService = roomMessageService;
|
|
@@ -53,6 +57,7 @@ let UserServiceFactory = class UserServiceFactory {
|
|
|
53
57
|
this.publishedRoomsService = publishedRoomsService;
|
|
54
58
|
this.balanceMessageService = balanceMessageService;
|
|
55
59
|
this.configService = configService;
|
|
60
|
+
this.nativeToolRegistry = nativeToolRegistry;
|
|
56
61
|
}
|
|
57
62
|
createAppService(userId) {
|
|
58
63
|
const userPaths = new user_paths_service_1.UserPathsService(userId);
|
|
@@ -63,11 +68,14 @@ let UserServiceFactory = class UserServiceFactory {
|
|
|
63
68
|
const agentStore = new agent_store_service_1.AgentStoreService(this.aiFactoryService, userPaths, attachedFileService, balanceService, artifactService, this.configService);
|
|
64
69
|
const agentFactory = new agent_factory_1.AgentFactory(this.aiFactoryService, agentStore, userPaths, balanceService, artifactService, this.configService);
|
|
65
70
|
const artifactStore = new artifact_store_service_1.ArtifactStoreService();
|
|
66
|
-
const
|
|
67
|
-
const
|
|
71
|
+
const toolStore = new tool_store_service_1.ToolStoreService(userPaths);
|
|
72
|
+
const allowUserAuthoredTools = String(this.configService.get('ALLOW_USER_AUTHORED_TOOLS')).toLowerCase() === 'true';
|
|
73
|
+
const toolExecution = new tool_execution_service_1.ToolExecutionService(toolStore, this.nativeToolRegistry, allowUserAuthoredTools);
|
|
74
|
+
const roomStore = new room_store_service_1.RoomStoreService(userPaths, agentStore, attachedFileService, artifactStore, toolStore, toolExecution);
|
|
75
|
+
const roomFactory = new room_factory_1.RoomFactory(roomStore, toolStore, toolExecution);
|
|
68
76
|
const storyStore = new story_store_service_1.StoryStoreService(userPaths, roomStore);
|
|
69
77
|
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);
|
|
78
|
+
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, toolStore, toolExecution);
|
|
71
79
|
}
|
|
72
80
|
};
|
|
73
81
|
exports.UserServiceFactory = UserServiceFactory;
|
|
@@ -81,5 +89,6 @@ exports.UserServiceFactory = UserServiceFactory = __decorate([
|
|
|
81
89
|
published_agents_service_1.PublishedAgentsService,
|
|
82
90
|
published_rooms_service_1.PublishedRoomsService,
|
|
83
91
|
balance_message_service_1.BalanceMessageService,
|
|
84
|
-
config_1.ConfigService
|
|
92
|
+
config_1.ConfigService,
|
|
93
|
+
native_tool_registry_service_1.NativeToolRegistry])
|
|
85
94
|
], UserServiceFactory);
|
|
@@ -5,7 +5,7 @@ import { UserServiceManager } from './app/user-service-manager';
|
|
|
5
5
|
import { PublishedAgentsService } from './ai/published-agents.service';
|
|
6
6
|
import { PublishedRoomsService } from './room/published-rooms.service';
|
|
7
7
|
import { LibraryService } from './library/library.service';
|
|
8
|
-
import { AgentInfo, CreateAgentResponse, UpdateAgentRequest, RoomInfo, RoomDetails, CreateRoomResponse, AgentMessagesResponse, RoomMessagesResponse, FileList, PromptFileContent, PromptFoldersResponse, PromptFilesResponse, PromptScope, CreatePromptFolderRequest, CreatePromptFileRequest, UpdatePromptFileRequest, ProcessTextResponse, PreparedPromptResponse, AttachDocumentResponse, StoryInfo, StoryState, Character, ModelInfo, StoryModelDefaults, ChapterInfo, StoryIdea, LibraryPromptsResponse, LibraryFilesResponse, LibraryFileContent, LibraryDefaultUrlResponse, CopyFromLibraryRequest } from '../../shared/types/app.types';
|
|
8
|
+
import { AgentInfo, CreateAgentResponse, UpdateAgentRequest, RoomInfo, RoomDetails, CreateRoomResponse, AgentMessagesResponse, RoomMessagesResponse, FileList, PromptFileContent, PromptFoldersResponse, PromptFilesResponse, PromptScope, CreatePromptFolderRequest, CreatePromptFileRequest, UpdatePromptFileRequest, ProcessTextResponse, PreparedPromptResponse, AttachDocumentResponse, StoryInfo, StoryState, Character, ModelInfo, ImageModelOption, StoryModelDefaults, ChapterInfo, StoryIdea, LibraryPromptsResponse, LibraryFilesResponse, LibraryFileContent, LibraryDefaultUrlResponse, CopyFromLibraryRequest, ToolDefinition, ToolsResponse, ToolRunResult, ToolTestRequest } from '../../shared/types/app.types';
|
|
9
9
|
import { RoomMessage } from './room/message';
|
|
10
10
|
export declare class AppController {
|
|
11
11
|
private readonly userServiceManager;
|
|
@@ -16,9 +16,9 @@ export declare class AppController {
|
|
|
16
16
|
private getAppService;
|
|
17
17
|
listServices(req: ExpressRequest): string[];
|
|
18
18
|
listModels(req: ExpressRequest, aiServiceName: string): Promise<ModelInfo[]>;
|
|
19
|
-
listImageModels(req: ExpressRequest): Promise<
|
|
19
|
+
listImageModels(req: ExpressRequest): Promise<ImageModelOption[]>;
|
|
20
20
|
listStoryModels(req: ExpressRequest): Promise<ModelInfo[]>;
|
|
21
|
-
listStoryModelDefaults(
|
|
21
|
+
listStoryModelDefaults(req: ExpressRequest): Promise<StoryModelDefaults>;
|
|
22
22
|
createAgent(req: ExpressRequest, body: {
|
|
23
23
|
aiServiceName: string;
|
|
24
24
|
agentName: string;
|
|
@@ -46,6 +46,11 @@ export declare class AppController {
|
|
|
46
46
|
createPromptFile(req: ExpressRequest, folderName: string, body: CreatePromptFileRequest): Promise<void>;
|
|
47
47
|
updatePromptFile(req: ExpressRequest, folderName: string, fileName: string, body: UpdatePromptFileRequest): Promise<void>;
|
|
48
48
|
deletePromptFile(req: ExpressRequest, folderName: string, fileName: string): Promise<void>;
|
|
49
|
+
getTools(req: ExpressRequest): Promise<ToolsResponse>;
|
|
50
|
+
createTool(req: ExpressRequest, body: ToolDefinition): Promise<ToolDefinition>;
|
|
51
|
+
updateTool(req: ExpressRequest, name: string, body: ToolDefinition): Promise<ToolDefinition>;
|
|
52
|
+
deleteTool(req: ExpressRequest, name: string): Promise<void>;
|
|
53
|
+
testTool(req: ExpressRequest, name: string, body: ToolTestRequest): Promise<ToolRunResult>;
|
|
49
54
|
listLibraryPrompts(): LibraryPromptsResponse;
|
|
50
55
|
listLibraryFiles(folder: string): LibraryFilesResponse;
|
|
51
56
|
getLibraryFile(folder: string, file: string): LibraryFileContent;
|
|
@@ -155,7 +160,7 @@ export declare class AppController {
|
|
|
155
160
|
storyModel?: string;
|
|
156
161
|
isImport?: boolean;
|
|
157
162
|
imageModelName?: string;
|
|
158
|
-
|
|
163
|
+
skipDetailedPlot?: boolean;
|
|
159
164
|
}): Promise<StoryInfo>;
|
|
160
165
|
importStoryZip(req: ExpressRequest, file: Express.Multer.File): Promise<StoryInfo>;
|
|
161
166
|
deleteStory(req: ExpressRequest, storyId: string): Promise<void>;
|
|
@@ -197,6 +202,12 @@ export declare class AppController {
|
|
|
197
202
|
saveCharacter(req: ExpressRequest, storyId: string, characterName: string, body: {
|
|
198
203
|
content: string;
|
|
199
204
|
}): Promise<void>;
|
|
205
|
+
getCharacterInventory(req: ExpressRequest, storyId: string, characterName: string): Promise<{
|
|
206
|
+
content: string;
|
|
207
|
+
}>;
|
|
208
|
+
saveCharacterInventory(req: ExpressRequest, storyId: string, characterName: string, body: {
|
|
209
|
+
content: string;
|
|
210
|
+
}): Promise<void>;
|
|
200
211
|
getPlotPlan(req: ExpressRequest, storyId: string): Promise<{
|
|
201
212
|
content: string;
|
|
202
213
|
}>;
|