briyah 1.0.2 → 1.0.3

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.
Files changed (177) hide show
  1. package/dist/server/src/ai/LLM/deepseek.service.js +1 -1
  2. package/package.json +2 -2
  3. package/dist/ai/LLM/anthropic.module.d.ts +0 -2
  4. package/dist/ai/LLM/anthropic.module.js +0 -21
  5. package/dist/ai/LLM/anthropic.service.d.ts +0 -27
  6. package/dist/ai/LLM/anthropic.service.js +0 -329
  7. package/dist/ai/LLM/base-ai.service.d.ts +0 -45
  8. package/dist/ai/LLM/base-ai.service.js +0 -409
  9. package/dist/ai/LLM/deepseek.module.d.ts +0 -2
  10. package/dist/ai/LLM/deepseek.module.js +0 -21
  11. package/dist/ai/LLM/deepseek.service.d.ts +0 -15
  12. package/dist/ai/LLM/deepseek.service.js +0 -279
  13. package/dist/ai/LLM/fal.module.d.ts +0 -2
  14. package/dist/ai/LLM/fal.module.js +0 -21
  15. package/dist/ai/LLM/fal.service.d.ts +0 -17
  16. package/dist/ai/LLM/fal.service.js +0 -314
  17. package/dist/ai/LLM/googleai.module.d.ts +0 -2
  18. package/dist/ai/LLM/googleai.module.js +0 -21
  19. package/dist/ai/LLM/googleai.service.d.ts +0 -20
  20. package/dist/ai/LLM/googleai.service.js +0 -271
  21. package/dist/ai/LLM/grok.module.d.ts +0 -2
  22. package/dist/ai/LLM/grok.module.js +0 -21
  23. package/dist/ai/LLM/grok.service.d.ts +0 -14
  24. package/dist/ai/LLM/grok.service.js +0 -263
  25. package/dist/ai/LLM/mock.module.d.ts +0 -2
  26. package/dist/ai/LLM/mock.module.js +0 -21
  27. package/dist/ai/LLM/mock.service.d.ts +0 -13
  28. package/dist/ai/LLM/mock.service.js +0 -194
  29. package/dist/ai/LLM/openai.module.d.ts +0 -2
  30. package/dist/ai/LLM/openai.module.js +0 -21
  31. package/dist/ai/LLM/openai.service.d.ts +0 -21
  32. package/dist/ai/LLM/openai.service.js +0 -421
  33. package/dist/ai/LLM/together.module.d.ts +0 -2
  34. package/dist/ai/LLM/together.module.js +0 -21
  35. package/dist/ai/LLM/together.service.d.ts +0 -18
  36. package/dist/ai/LLM/together.service.js +0 -285
  37. package/dist/ai/LLM/vertexai.module.d.ts +0 -2
  38. package/dist/ai/LLM/vertexai.module.js +0 -21
  39. package/dist/ai/LLM/vertexai.service.d.ts +0 -17
  40. package/dist/ai/LLM/vertexai.service.js +0 -323
  41. package/dist/ai/agent-config.d.ts +0 -32
  42. package/dist/ai/agent-config.js +0 -2
  43. package/dist/ai/agent-factory.d.ts +0 -15
  44. package/dist/ai/agent-factory.js +0 -24
  45. package/dist/ai/agent-message.service.d.ts +0 -9
  46. package/dist/ai/agent-message.service.js +0 -56
  47. package/dist/ai/agent-store.module.d.ts +0 -2
  48. package/dist/ai/agent-store.module.js +0 -21
  49. package/dist/ai/agent-store.service.d.ts +0 -31
  50. package/dist/ai/agent-store.service.js +0 -352
  51. package/dist/ai/agent.d.ts +0 -75
  52. package/dist/ai/agent.js +0 -174
  53. package/dist/ai/ai-factory.module.d.ts +0 -2
  54. package/dist/ai/ai-factory.module.js +0 -40
  55. package/dist/ai/ai-factory.service.d.ts +0 -24
  56. package/dist/ai/ai-factory.service.js +0 -94
  57. package/dist/ai/artifact.module.d.ts +0 -2
  58. package/dist/ai/artifact.module.js +0 -22
  59. package/dist/ai/artifact.service.d.ts +0 -21
  60. package/dist/ai/artifact.service.js +0 -239
  61. package/dist/ai/attached-file.module.d.ts +0 -2
  62. package/dist/ai/attached-file.module.js +0 -22
  63. package/dist/ai/attached-file.service.d.ts +0 -35
  64. package/dist/ai/attached-file.service.js +0 -253
  65. package/dist/ai/model_prices.d.ts +0 -2
  66. package/dist/ai/model_prices.js +0 -54
  67. package/dist/ai/published-agents.service.d.ts +0 -13
  68. package/dist/ai/published-agents.service.js +0 -118
  69. package/dist/app/balance-message.service.d.ts +0 -8
  70. package/dist/app/balance-message.service.js +0 -45
  71. package/dist/app/balance.module.d.ts +0 -2
  72. package/dist/app/balance.module.js +0 -20
  73. package/dist/app/balance.service.d.ts +0 -18
  74. package/dist/app/balance.service.js +0 -158
  75. package/dist/app/stripe.controller.d.ts +0 -31
  76. package/dist/app/stripe.controller.js +0 -150
  77. package/dist/app/stripe.module.d.ts +0 -2
  78. package/dist/app/stripe.module.js +0 -22
  79. package/dist/app/stripe.service.d.ts +0 -28
  80. package/dist/app/stripe.service.js +0 -198
  81. package/dist/app/transaction.service.d.ts +0 -15
  82. package/dist/app/transaction.service.js +0 -139
  83. package/dist/app/user-service-factory.d.ts +0 -21
  84. package/dist/app/user-service-factory.js +0 -81
  85. package/dist/app/user-service-manager.d.ts +0 -28
  86. package/dist/app/user-service-manager.js +0 -102
  87. package/dist/app.controller.d.ts +0 -232
  88. package/dist/app.controller.js +0 -2536
  89. package/dist/app.module.d.ts +0 -2
  90. package/dist/app.module.js +0 -45
  91. package/dist/app.service.d.ts +0 -186
  92. package/dist/app.service.js +0 -1334
  93. package/dist/auth/agent-access.decorator.d.ts +0 -2
  94. package/dist/auth/agent-access.decorator.js +0 -10
  95. package/dist/auth/auth.controller.d.ts +0 -38
  96. package/dist/auth/auth.controller.js +0 -356
  97. package/dist/auth/auth.module.d.ts +0 -2
  98. package/dist/auth/auth.module.js +0 -55
  99. package/dist/auth/auth.service.d.ts +0 -14
  100. package/dist/auth/auth.service.js +0 -84
  101. package/dist/auth/dto/bot-login.dto.d.ts +0 -4
  102. package/dist/auth/dto/bot-login.dto.js +0 -2
  103. package/dist/auth/dto/password-reset.dto.d.ts +0 -11
  104. package/dist/auth/dto/password-reset.dto.js +0 -2
  105. package/dist/auth/dto/phone-login.dto.d.ts +0 -8
  106. package/dist/auth/dto/phone-login.dto.js +0 -2
  107. package/dist/auth/dto/phone-verification.dto.d.ts +0 -9
  108. package/dist/auth/dto/phone-verification.dto.js +0 -2
  109. package/dist/auth/jwt-auth.guard.d.ts +0 -13
  110. package/dist/auth/jwt-auth.guard.js +0 -143
  111. package/dist/auth/jwt.strategy.d.ts +0 -17
  112. package/dist/auth/jwt.strategy.js +0 -45
  113. package/dist/auth/phone-validation.service.d.ts +0 -7
  114. package/dist/auth/phone-validation.service.js +0 -50
  115. package/dist/auth/public.decorator.d.ts +0 -2
  116. package/dist/auth/public.decorator.js +0 -7
  117. package/dist/auth/rate-limit.service.d.ts +0 -16
  118. package/dist/auth/rate-limit.service.js +0 -84
  119. package/dist/auth/room-access.decorator.d.ts +0 -2
  120. package/dist/auth/room-access.decorator.js +0 -10
  121. package/dist/auth/scopes.decorator.d.ts +0 -2
  122. package/dist/auth/scopes.decorator.js +0 -7
  123. package/dist/auth/scopes.guard.d.ts +0 -9
  124. package/dist/auth/scopes.guard.js +0 -82
  125. package/dist/auth/session.guard.d.ts +0 -7
  126. package/dist/auth/session.guard.js +0 -55
  127. package/dist/auth/twilio.service.d.ts +0 -15
  128. package/dist/auth/twilio.service.js +0 -139
  129. package/dist/auth/users.service.d.ts +0 -24
  130. package/dist/auth/users.service.js +0 -149
  131. package/dist/common/errors.d.ts +0 -12
  132. package/dist/common/errors.js +0 -43
  133. package/dist/config/configuration.module.d.ts +0 -2
  134. package/dist/config/configuration.module.js +0 -20
  135. package/dist/config/configuration.service.d.ts +0 -26
  136. package/dist/config/configuration.service.js +0 -131
  137. package/dist/main.js +0 -15749
  138. package/dist/room/artifact-store.service.d.ts +0 -15
  139. package/dist/room/artifact-store.service.js +0 -226
  140. package/dist/room/artifact.d.ts +0 -6
  141. package/dist/room/artifact.js +0 -2
  142. package/dist/room/message.d.ts +0 -19
  143. package/dist/room/message.js +0 -70
  144. package/dist/room/published-rooms.service.d.ts +0 -12
  145. package/dist/room/published-rooms.service.js +0 -108
  146. package/dist/room/room-config.d.ts +0 -12
  147. package/dist/room/room-config.js +0 -2
  148. package/dist/room/room-factory.d.ts +0 -7
  149. package/dist/room/room-factory.js +0 -16
  150. package/dist/room/room-message.module.d.ts +0 -2
  151. package/dist/room/room-message.module.js +0 -21
  152. package/dist/room/room-message.service.d.ts +0 -8
  153. package/dist/room/room-message.service.js +0 -44
  154. package/dist/room/room-store.module.d.ts +0 -2
  155. package/dist/room/room-store.module.js +0 -25
  156. package/dist/room/room-store.service.d.ts +0 -38
  157. package/dist/room/room-store.service.js +0 -353
  158. package/dist/room/room.d.ts +0 -107
  159. package/dist/room/room.js +0 -833
  160. package/dist/sdk/briyah-config.d.ts +0 -13
  161. package/dist/sdk/briyah-config.js +0 -32
  162. package/dist/sdk/briyah.d.ts +0 -36
  163. package/dist/sdk/briyah.js +0 -122
  164. package/dist/sdk/index.d.ts +0 -6
  165. package/dist/sdk/index.js +0 -11
  166. package/dist/shared/shared.module.d.ts +0 -2
  167. package/dist/shared/shared.module.js +0 -46
  168. package/dist/story/story-message.service.d.ts +0 -10
  169. package/dist/story/story-message.service.js +0 -57
  170. package/dist/story/story-progress.service.d.ts +0 -8
  171. package/dist/story/story-progress.service.js +0 -44
  172. package/dist/story/story-store.module.d.ts +0 -2
  173. package/dist/story/story-store.module.js +0 -22
  174. package/dist/story/story-store.service.d.ts +0 -23
  175. package/dist/story/story-store.service.js +0 -392
  176. package/dist/story/story.service.d.ts +0 -94
  177. package/dist/story/story.service.js +0 -1797
@@ -1,323 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.VertexAiService = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const vertexai_1 = require("@google-cloud/vertexai");
18
- const storage_1 = require("@google-cloud/storage");
19
- const crypto_1 = require("crypto");
20
- const base_ai_service_1 = require("./base-ai.service");
21
- const model_prices_1 = __importDefault(require("../model_prices"));
22
- const errors_1 = require("../../common/errors");
23
- let VertexAiService = class VertexAiService extends base_ai_service_1.BaseAiService {
24
- vertexAI = null;
25
- constructor() {
26
- super();
27
- try {
28
- if (!process.env.GOOGLE_PROJECT_ID || !process.env.GOOGLE_CLOUD_LOCATION) {
29
- console.warn('GOOGLE_PROJECT_ID and GOOGLE_CLOUD_LOCATION environment variables are required for Vertex AI service. Service will not be available.');
30
- this._isAvailable = false;
31
- return;
32
- }
33
- this.vertexAI = new vertexai_1.VertexAI({
34
- project: process.env.GOOGLE_PROJECT_ID,
35
- location: process.env.GOOGLE_CLOUD_LOCATION,
36
- });
37
- }
38
- catch (error) {
39
- console.error('Error initializing Vertex AI service:', error);
40
- this._isAvailable = false;
41
- }
42
- }
43
- getServiceName() {
44
- return 'Vertex AI';
45
- }
46
- async fetchModelsFromApi() {
47
- return [
48
- {
49
- name: 'gemini-3-pro-preview',
50
- description: 'gemini-3-pro-preview',
51
- model: 'gemini-3-pro-preview',
52
- service: 'Vertex AI',
53
- },
54
- {
55
- name: 'gemini-2.5-pro',
56
- description: 'gemini-2.5-pro',
57
- model: 'gemini-2.5-pro',
58
- service: 'Vertex AI',
59
- },
60
- {
61
- name: 'gemini-2.5-flash',
62
- description: 'gemini-2.5-flash',
63
- model: 'gemini-2.5-flash',
64
- service: 'Vertex AI',
65
- },
66
- {
67
- name: 'gemini-2.5-flash-lite',
68
- description: 'gemini-2.5-flash-lite',
69
- model: 'gemini-2.5-flash-lite',
70
- service: 'Vertex AI',
71
- },
72
- {
73
- name: 'gemini-2.0-flash-lite',
74
- description: 'gemini-2.0-flash-lite',
75
- model: 'gemini-2.0-flash-lite',
76
- service: 'Vertex AI',
77
- },
78
- {
79
- name: 'gemini-2.0-flash',
80
- description: 'gemini-2.0-flash',
81
- model: 'gemini-2.0-flash',
82
- service: 'Vertex AI',
83
- },
84
- ];
85
- }
86
- async uploadFile(fileContents) {
87
- let cloudStorage = new storage_1.Storage();
88
- let bucketName = process.env.GOOGLE_CLOUD_STORAGE_BUCKET;
89
- const bucket = cloudStorage.bucket(bucketName);
90
- const fileName = `${(0, crypto_1.randomUUID)()}.pdf`;
91
- const file = bucket.file(fileName);
92
- await file.save(Buffer.from(fileContents), {
93
- metadata: { contentType: 'application/octet-stream' },
94
- });
95
- console.log(`Successfully uploaded ${fileName} to ${bucketName}`);
96
- return `gs://${bucketName}/${fileName}`;
97
- }
98
- addToConversationHistory(agent, message, fromSelf = false) {
99
- if (!agent.history) {
100
- agent.history = [];
101
- }
102
- if (!message)
103
- return;
104
- agent.history.push({
105
- role: fromSelf ? 'model' : 'user',
106
- parts: [{ text: message }],
107
- });
108
- agent.trimHistoryIfNeeded();
109
- }
110
- async textPrompt(agent, prompt, jsonSchema = null, saveResponse = true, promptInstructions = null, _cacheConfig = null, maxOutputChars = 0) {
111
- if (agent.balanceService && !agent.disableBalanceCheck) {
112
- const hasSufficientBalance = agent.balanceService.hasSufficientBalance();
113
- if (!hasSufficientBalance) {
114
- throw new errors_1.InsufficientBalanceError('Insufficient balance. Please add funds to continue using AI services.');
115
- }
116
- }
117
- let generationConfig = {
118
- candidateCount: 1,
119
- maxOutputTokens: 16384,
120
- temperature: 0,
121
- };
122
- let instructions = promptInstructions || agent.systemInstruction;
123
- if (jsonSchema) {
124
- generationConfig.responseMimeType = 'application/json';
125
- if (jsonSchema.description) {
126
- instructions +=
127
- '\n\nPlease generate only valid JSON according to the schema.\n' +
128
- jsonSchema.description;
129
- }
130
- delete jsonSchema.name;
131
- delete jsonSchema.description;
132
- generationConfig.responseSchema = jsonSchema;
133
- }
134
- let generativeModel = this.vertexAI.getGenerativeModel({
135
- model: agent.modelName,
136
- generationConfig: generationConfig,
137
- systemInstruction: instructions,
138
- });
139
- const identity = `Your agent identity is ${agent.agentName}: ${agent.description}`;
140
- const messages = [{ role: 'user', parts: [{ text: identity }] }];
141
- if (agent.attachedFiles && agent.attachedFiles.length > 0) {
142
- for (const file of agent.attachedFiles) {
143
- if (file.serviceMetadata?.uri) {
144
- const ext = file.fileName.split('.').pop() || 'pdf';
145
- messages.push({
146
- role: 'user',
147
- parts: [
148
- {
149
- fileData: {
150
- mimeType: 'application/' + ext,
151
- fileUri: file.serviceMetadata.uri,
152
- },
153
- },
154
- {
155
- text: `This document will be referenced as ${file.fileName}.`,
156
- },
157
- ],
158
- });
159
- }
160
- else {
161
- const fileData = new Uint8Array(file.serviceMetadata.fileData);
162
- const textContent = Buffer.from(fileData).toString('utf-8');
163
- messages.push({
164
- role: 'user',
165
- parts: [{ text: textContent }],
166
- });
167
- }
168
- }
169
- }
170
- if (agent.attachedArtifacts && agent.attachedArtifacts.length > 0) {
171
- for (const artifactId of agent.attachedArtifacts) {
172
- const content = agent.artifactService.getArtifact(artifactId);
173
- if (content && typeof content === 'string') {
174
- const metadata = agent.artifactService.getArtifactMetadata(artifactId);
175
- const fileName = metadata ? `${metadata.name}.md` : 'artifact.md';
176
- messages.push({
177
- role: 'user',
178
- parts: [{ text: `Attached document: ${fileName}\n\n${content}` }],
179
- });
180
- }
181
- }
182
- }
183
- messages.push(...agent.history);
184
- if (prompt) {
185
- messages.push({ role: 'user', parts: [{ text: prompt }] });
186
- }
187
- let resp;
188
- try {
189
- resp = await generativeModel.generateContent({ contents: messages });
190
- }
191
- catch (error) {
192
- console.error(error);
193
- return error.message;
194
- }
195
- let responseText = resp.response.candidates[0].content.parts[0].text;
196
- if (jsonSchema) {
197
- responseText = this.trimToJson(responseText);
198
- responseText = this.sanitizeJsonString(responseText);
199
- }
200
- let usage = resp.response.usageMetadata;
201
- if (usage) {
202
- this.computeMessageCost(agent, usage);
203
- }
204
- if (saveResponse) {
205
- this.addToConversationHistory(agent, prompt, false);
206
- this.addToConversationHistory(agent, responseText, true);
207
- }
208
- if (jsonSchema) {
209
- return JSON.parse(responseText);
210
- }
211
- return responseText;
212
- }
213
- computeMessageCost(agent, usage) {
214
- const inputTokens = usage.promptTokenCount || 0;
215
- const outputTokens = usage.candidatesTokenCount || 0;
216
- const modelInfo = model_prices_1.default[agent.modelName];
217
- if (!modelInfo) {
218
- console.error(`No price info found for model ${agent.modelName}`);
219
- return;
220
- }
221
- const inputCost = inputTokens * modelInfo.input_cost_per_token;
222
- const outputCost = outputTokens * modelInfo.output_cost_per_token;
223
- const markup = agent.disableMarkup ? 0 : outputCost * agent.markupRate;
224
- const cost = inputCost + outputCost + markup;
225
- agent.totalInputTokens += inputTokens;
226
- agent.totalOutputTokens += outputTokens;
227
- agent.totalCost += cost;
228
- agent.totalMarkup += markup;
229
- console.log(`Cost for ${agent.agentName} message: ${cost} (markup: ${markup.toFixed(4)})`);
230
- if (agent.balanceService && cost > 0) {
231
- agent.balanceService.decrementBalance(cost, markup);
232
- }
233
- }
234
- async attachDocument(agent, fileName, fileData) {
235
- if (agent === null) {
236
- throw new Error('Shared document attachment not supported by Vertex AI service');
237
- }
238
- if (agent.fullContextFiles) {
239
- return super.attachDocument(agent, fileName, fileData);
240
- }
241
- let ext = fileName.split('.').pop();
242
- const existingMetadata = agent.attachedFiles.find((f) => f.fileName === fileName &&
243
- f.serviceMetadata?.serviceName === this.getServiceName() &&
244
- f.serviceMetadata?.uri);
245
- let gsUri;
246
- if (existingMetadata?.serviceMetadata?.uri) {
247
- gsUri = existingMetadata.serviceMetadata.uri;
248
- console.log(`Using existing Google Cloud Storage file: ${gsUri}`);
249
- }
250
- else {
251
- gsUri = await this.uploadFile(fileData);
252
- const additionalMetadata = {
253
- mimeType: 'application/' + ext,
254
- serviceMetadata: {
255
- serviceName: this.getServiceName(),
256
- uri: gsUri,
257
- },
258
- };
259
- const fileMetadataIndex = agent.attachedFiles.findIndex((f) => f.fileName === fileName);
260
- if (fileMetadataIndex >= 0) {
261
- agent.attachedFiles[fileMetadataIndex] = {
262
- ...agent.attachedFiles[fileMetadataIndex],
263
- ...additionalMetadata,
264
- };
265
- }
266
- }
267
- return existingMetadata?.serviceMetadata?.uri
268
- ? `Using existing file ${fileName} from Google Cloud Storage`
269
- : `Uploaded ${fileName} to Google Cloud Storage`;
270
- }
271
- formatMessage(message) {
272
- if (!message) {
273
- return 'No message';
274
- }
275
- if (message.role && message.parts) {
276
- const parts = message.parts
277
- .map((part) => {
278
- if (part.text) {
279
- return part.text;
280
- }
281
- else if (part.fileData) {
282
- return `[File: ${part.fileData.fileUri || 'attached file'}]`;
283
- }
284
- else {
285
- return JSON.stringify(part);
286
- }
287
- })
288
- .join('\n');
289
- return `${message.role}: ${parts}`;
290
- }
291
- return super.formatMessage(message);
292
- }
293
- async finishAgent(agent) {
294
- if (!agent)
295
- return;
296
- for (const metadata of agent.attachedFiles) {
297
- if (metadata.serviceMetadata?.serviceName === this.getServiceName() &&
298
- metadata.serviceMetadata?.uri) {
299
- try {
300
- const uri = metadata.serviceMetadata.uri;
301
- const match = uri.match(/gs:\/\/([^\/]+)\/(.+)/);
302
- if (match) {
303
- const bucketName = match[1];
304
- const fileName = match[2];
305
- const storage = new storage_1.Storage();
306
- const bucket = storage.bucket(bucketName);
307
- const file = bucket.file(fileName);
308
- await file.delete();
309
- console.log(`Deleted Google Cloud Storage file ${uri} for agent ${agent.id}`);
310
- }
311
- }
312
- catch (error) {
313
- console.error(`Error deleting Google Cloud Storage file ${metadata.serviceMetadata.uri}:`, error);
314
- }
315
- }
316
- }
317
- }
318
- };
319
- exports.VertexAiService = VertexAiService;
320
- exports.VertexAiService = VertexAiService = __decorate([
321
- (0, common_1.Injectable)(),
322
- __metadata("design:paramtypes", [])
323
- ], VertexAiService);
@@ -1,32 +0,0 @@
1
- import { FileMetadata } from './attached-file.service';
2
- export interface AgentConfig {
3
- id: string;
4
- agentName: string;
5
- agentNickname: string;
6
- description: string;
7
- promptFolder: string;
8
- systemInstruction: string;
9
- modelName: string;
10
- serviceName: string;
11
- reasoningEffort: 'low' | 'medium' | 'high' | null;
12
- allowSearch: boolean;
13
- maxOutputTokens: number;
14
- createdAt: string;
15
- attachedFiles?: FileMetadata[];
16
- attachedArtifacts?: string[];
17
- history?: any[];
18
- maxHistoryMessages: number;
19
- totalInputTokens?: number;
20
- totalOutputTokens?: number;
21
- totalCost?: number;
22
- totalMarkup?: number;
23
- markupRate?: number;
24
- disableMarkup?: boolean;
25
- disableBalanceCheck?: boolean;
26
- isControlledByHuman?: boolean;
27
- isPublished?: boolean;
28
- templateAgentId?: string;
29
- beginInstruction?: string;
30
- promptCacheTTL?: number;
31
- ownerRoomId?: string;
32
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,15 +0,0 @@
1
- import { AiFactoryService } from './ai-factory.service';
2
- import { AgentStoreService } from './agent-store.service';
3
- import { ArtifactService } from './artifact.service';
4
- import { ConfigurationService } from '../config/configuration.service';
5
- import { BalanceService } from '../app/balance.service';
6
- import { Agent } from './agent';
7
- export declare class AgentFactory {
8
- private readonly aiFactoryService;
9
- private readonly agentStoreService;
10
- private readonly configService;
11
- private readonly balanceService;
12
- private readonly artifactService;
13
- constructor(aiFactoryService: AiFactoryService, agentStoreService: AgentStoreService, configService: ConfigurationService, balanceService: BalanceService, artifactService: ArtifactService);
14
- createAgent(aiServiceName: string, agentName: string, agentNickname: string, description: string, promptFolder: string, modelName: string, storageDir?: string, artifactService?: ArtifactService): Agent;
15
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentFactory = void 0;
4
- class AgentFactory {
5
- aiFactoryService;
6
- agentStoreService;
7
- configService;
8
- balanceService;
9
- artifactService;
10
- constructor(aiFactoryService, agentStoreService, configService, balanceService, artifactService) {
11
- this.aiFactoryService = aiFactoryService;
12
- this.agentStoreService = agentStoreService;
13
- this.configService = configService;
14
- this.balanceService = balanceService;
15
- this.artifactService = artifactService;
16
- }
17
- createAgent(aiServiceName, agentName, agentNickname, description, promptFolder, modelName, storageDir = '', artifactService) {
18
- const aiService = this.aiFactoryService.createAiService(aiServiceName);
19
- const finalStorageDir = storageDir || this.agentStoreService.getDefaultStorageDir();
20
- const finalArtifactService = artifactService || this.artifactService;
21
- return aiService.createAgent(this.configService, this.agentStoreService, this.balanceService, finalArtifactService, agentName, agentNickname, description, promptFolder, modelName, finalStorageDir);
22
- }
23
- }
24
- exports.AgentFactory = AgentFactory;
@@ -1,9 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- export declare class AgentMessageService {
3
- private messageEmitters;
4
- getOrCreateEmitter(agentId: string): EventEmitter;
5
- getEmitter(agentId: string): EventEmitter | undefined;
6
- emitUpdate(agentId: string, agentState: any): void;
7
- emitError(agentId: string, error: Error): void;
8
- cleanup(agentId: string): void;
9
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AgentMessageService = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const events_1 = require("events");
12
- let AgentMessageService = class AgentMessageService {
13
- messageEmitters = new Map();
14
- getOrCreateEmitter(agentId) {
15
- let emitter = this.messageEmitters.get(agentId);
16
- if (!emitter) {
17
- emitter = new events_1.EventEmitter();
18
- this.messageEmitters.set(agentId, emitter);
19
- }
20
- return emitter;
21
- }
22
- getEmitter(agentId) {
23
- return this.messageEmitters.get(agentId);
24
- }
25
- emitUpdate(agentId, agentState) {
26
- const emitter = this.messageEmitters.get(agentId);
27
- if (emitter) {
28
- emitter.emit('update', {
29
- timestamp: Date.now(),
30
- state: agentState,
31
- });
32
- }
33
- }
34
- emitError(agentId, error) {
35
- const emitter = this.messageEmitters.get(agentId);
36
- if (emitter) {
37
- emitter.emit('update', {
38
- timestamp: Date.now(),
39
- type: 'error',
40
- errorType: error.name,
41
- message: error.message,
42
- });
43
- }
44
- }
45
- cleanup(agentId) {
46
- const emitter = this.messageEmitters.get(agentId);
47
- if (emitter) {
48
- emitter.removeAllListeners();
49
- this.messageEmitters.delete(agentId);
50
- }
51
- }
52
- };
53
- exports.AgentMessageService = AgentMessageService;
54
- exports.AgentMessageService = AgentMessageService = __decorate([
55
- (0, common_1.Injectable)()
56
- ], AgentMessageService);
@@ -1,2 +0,0 @@
1
- export declare class AgentStoreModule {
2
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AgentStoreModule = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const agent_message_service_1 = require("./agent-message.service");
12
- let AgentStoreModule = class AgentStoreModule {
13
- };
14
- exports.AgentStoreModule = AgentStoreModule;
15
- exports.AgentStoreModule = AgentStoreModule = __decorate([
16
- (0, common_1.Module)({
17
- imports: [],
18
- providers: [agent_message_service_1.AgentMessageService],
19
- exports: [agent_message_service_1.AgentMessageService],
20
- })
21
- ], AgentStoreModule);
@@ -1,31 +0,0 @@
1
- import { Agent } from './agent';
2
- import { AiFactoryService } from './ai-factory.service';
3
- import { ArtifactService } from './artifact.service';
4
- import { ConfigurationService } from '../config/configuration.service';
5
- import { AttachedFileService } from './attached-file.service';
6
- import { BalanceService } from '../app/balance.service';
7
- export declare class AgentStoreService {
8
- private readonly aiFactoryService;
9
- private readonly configService;
10
- private readonly attachedFileService;
11
- private readonly balanceService;
12
- private readonly artifactService;
13
- private agents;
14
- private readonly defaultStorageDir;
15
- private loaded;
16
- private loadPromise;
17
- constructor(aiFactoryService: AiFactoryService, configService: ConfigurationService, attachedFileService: AttachedFileService, balanceService: BalanceService, artifactService: ArtifactService);
18
- getDefaultStorageDir(): string;
19
- storeAgent(agent: Agent, storageDir?: string): string;
20
- getAgent(id: string): Promise<Agent | undefined>;
21
- removeAgent(id: string): boolean;
22
- getAllAgentIds(): Promise<string[]>;
23
- getAgentCount(): Promise<number>;
24
- cloneAgentAsPublished(templateId: string, publishedName: string, _userId: string): Promise<string>;
25
- getPublishedInstances(templateId: string): Promise<Agent[]>;
26
- resetPublishedInstance(instanceId: string, templateId: string): Promise<void>;
27
- private ensureLoaded;
28
- loadAgentsFromDirectory(storageDir: string, artifactService?: ArtifactService): Promise<void>;
29
- private saveAgentToFile;
30
- private deleteAgentFile;
31
- }