@smythos/sre 1.6.14 → 1.7.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/CHANGELOG +15 -0
- package/dist/index.js +66 -58
- package/dist/index.js.map +1 -1
- package/dist/types/Components/APIEndpoint.class.d.ts +2 -8
- package/dist/types/Components/Component.class.d.ts +9 -0
- package/dist/types/Components/Triggers/Gmail.trigger.d.ts +0 -17
- package/dist/types/Components/Triggers/JobScheduler.trigger.d.ts +10 -0
- package/dist/types/Components/Triggers/Trigger.class.d.ts +11 -0
- package/dist/types/Components/index.d.ts +6 -0
- package/dist/types/Core/Connector.class.d.ts +1 -0
- package/dist/types/Core/ConnectorsService.d.ts +2 -0
- package/dist/types/Core/HookService.d.ts +1 -1
- package/dist/types/helpers/BinaryInput.helper.d.ts +1 -1
- package/dist/types/helpers/Conversation.helper.d.ts +2 -0
- package/dist/types/helpers/Crypto.helper.d.ts +8 -0
- package/dist/types/helpers/LocalCache.helper.d.ts +18 -0
- package/dist/types/helpers/TemplateString.helper.d.ts +2 -1
- package/dist/types/index.d.ts +13 -0
- package/dist/types/subsystems/AgentManager/Agent.class.d.ts +4 -2
- package/dist/types/subsystems/AgentManager/AgentData.service/AgentDataConnector.d.ts +13 -0
- package/dist/types/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.d.ts +1 -4
- package/dist/types/subsystems/AgentManager/Scheduler.service/Job.class.d.ts +29 -6
- package/dist/types/subsystems/AgentManager/Scheduler.service/SchedulerConnector.d.ts +11 -3
- package/dist/types/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.d.ts +31 -7
- package/dist/types/subsystems/IO/VectorDB.service/VectorDBConnector.d.ts +4 -4
- package/dist/types/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.d.ts +2 -2
- package/dist/types/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.d.ts +2 -2
- package/dist/types/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.d.ts +2 -2
- package/dist/types/subsystems/IO/VectorDB.service/embed/BaseEmbedding.d.ts +16 -9
- package/dist/types/subsystems/IO/VectorDB.service/embed/index.d.ts +4 -1
- package/dist/types/subsystems/LLMManager/LLM.inference.d.ts +36 -2
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.d.ts +2 -5
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.d.ts +3 -6
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.d.ts +7 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/xAI.class.d.ts +2 -5
- package/dist/types/types/Agent.types.d.ts +1 -0
- package/dist/types/types/LLM.types.d.ts +56 -36
- package/dist/types/types/SRE.types.d.ts +4 -1
- package/dist/types/types/VectorDB.types.d.ts +6 -3
- package/dist/types/utils/string.utils.d.ts +0 -4
- package/package.json +6 -2
- package/src/Components/APICall/OAuth.helper.ts +30 -35
- package/src/Components/APIEndpoint.class.ts +25 -6
- package/src/Components/Classifier.class.ts +8 -2
- package/src/Components/Component.class.ts +11 -0
- package/src/Components/GenAILLM.class.ts +11 -7
- package/src/Components/LLMAssistant.class.ts +12 -3
- package/src/Components/ScrapflyWebScrape.class.ts +8 -1
- package/src/Components/TavilyWebSearch.class.ts +4 -1
- package/src/Components/Triggers/Gmail.trigger.ts +282 -0
- package/src/Components/Triggers/JobScheduler.trigger.ts +45 -0
- package/src/Components/Triggers/README.md +3 -0
- package/src/Components/Triggers/Trigger.class.ts +101 -0
- package/src/Components/Triggers/WhatsApp.trigger.ts +219 -0
- package/src/Components/index.ts +8 -0
- package/src/Core/AgentProcess.helper.ts +4 -6
- package/src/Core/Connector.class.ts +11 -3
- package/src/Core/ConnectorsService.ts +5 -0
- package/src/Core/ExternalEventsReceiver.ts +317 -0
- package/src/Core/HookService.ts +20 -6
- package/src/Core/SmythRuntime.class.ts +20 -2
- package/src/Core/SystemEvents.ts +17 -0
- package/src/Core/boot.ts +2 -0
- package/src/helpers/BinaryInput.helper.ts +8 -8
- package/src/helpers/Conversation.helper.ts +46 -12
- package/src/helpers/Crypto.helper.ts +28 -0
- package/src/helpers/LocalCache.helper.ts +18 -0
- package/src/helpers/TemplateString.helper.ts +20 -9
- package/src/index.ts +13 -0
- package/src/index.ts.bak +13 -0
- package/src/subsystems/AGENTS.md +594 -0
- package/src/subsystems/AgentManager/Agent.class.ts +73 -21
- package/src/subsystems/AgentManager/AgentData.service/AgentDataConnector.ts +30 -6
- package/src/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.ts +2 -2
- package/src/subsystems/AgentManager/AgentLogger.class.ts +1 -1
- package/src/subsystems/AgentManager/AgentRuntime.class.ts +34 -5
- package/src/subsystems/AgentManager/Scheduler.service/Job.class.ts +414 -0
- package/src/subsystems/AgentManager/Scheduler.service/Schedule.class.ts +200 -0
- package/src/subsystems/AgentManager/Scheduler.service/SchedulerConnector.ts +200 -0
- package/src/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.ts +767 -0
- package/src/subsystems/AgentManager/Scheduler.service/index.ts +11 -0
- package/src/subsystems/IO/VectorDB.service/VectorDBConnector.ts +15 -4
- package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +32 -11
- package/src/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.ts +27 -10
- package/src/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.ts +25 -9
- package/src/subsystems/IO/VectorDB.service/embed/BaseEmbedding.ts +182 -12
- package/src/subsystems/IO/VectorDB.service/embed/GoogleEmbedding.ts +1 -1
- package/src/subsystems/IO/VectorDB.service/embed/OpenAIEmbedding.ts +1 -1
- package/src/subsystems/IO/VectorDB.service/embed/index.ts +12 -2
- package/src/subsystems/LLMManager/LLM.inference.ts +76 -17
- package/src/subsystems/LLMManager/LLM.service/LLMCredentials.helper.ts +61 -2
- package/src/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.ts +3 -1
- package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +5 -1
- package/src/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.ts +247 -56
- package/src/subsystems/LLMManager/LLM.service/connectors/Groq.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Ollama.class.ts +28 -21
- package/src/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.ts +121 -33
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.ts +38 -27
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts +3 -2
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +117 -20
- package/src/subsystems/LLMManager/LLM.service/connectors/xAI.class.ts +3 -0
- package/src/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.ts +3 -8
- package/src/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.ts +4 -1
- package/src/subsystems/MemoryManager/Cache.service/connectors/RedisCache.class.ts +12 -0
- package/src/subsystems/MemoryManager/LLMContext.ts +3 -8
- package/src/subsystems/MemoryManager/RuntimeContext.ts +10 -9
- package/src/subsystems/Security/Credentials/Credentials.class.ts +1 -0
- package/src/subsystems/Security/Credentials/ManagedOAuth2Credentials.class.ts +106 -0
- package/src/types/Agent.types.ts +1 -0
- package/src/types/LLM.types.ts +68 -40
- package/src/types/SRE.types.ts +3 -0
- package/src/types/VectorDB.types.ts +7 -3
- package/src/utils/string.utils.ts +193 -191
|
@@ -19,7 +19,7 @@ export async function asyncReplace(str, regex, asyncFn) {
|
|
|
19
19
|
matches.map(async (match) => {
|
|
20
20
|
// Call the async function with all match groups
|
|
21
21
|
return asyncFn(...match);
|
|
22
|
-
})
|
|
22
|
+
})
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
// Reassemble the string with replacements
|
|
@@ -222,193 +222,195 @@ export const identifyMimetypeFromString = (input: string) => {
|
|
|
222
222
|
return 'text/plain';
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
-
export function chunkText(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
): string[] {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
225
|
+
// export function chunkText(
|
|
226
|
+
// text: string,
|
|
227
|
+
// {
|
|
228
|
+
// chunkSize,
|
|
229
|
+
// chunkOverlap,
|
|
230
|
+
// }: {
|
|
231
|
+
// chunkSize: number;
|
|
232
|
+
// chunkOverlap: number;
|
|
233
|
+
// }
|
|
234
|
+
// ): string[] {
|
|
235
|
+
// const textSplitter = new TextSplitter({
|
|
236
|
+
// chunkSize,
|
|
237
|
+
// chunkOverlap,
|
|
238
|
+
// separators: ['\n\n', '\n', ' ', ''],
|
|
239
|
+
// keepSeparator: true,
|
|
240
|
+
// });
|
|
241
|
+
// let output = textSplitter.splitText(text);
|
|
242
|
+
|
|
243
|
+
// return output;
|
|
244
|
+
// }
|
|
245
|
+
// class TextSplitter {
|
|
246
|
+
// private chunkSize: number;
|
|
247
|
+
// private chunkOverlap: number;
|
|
248
|
+
// private separators: string[] = ['\n\n', '\n', ' ', ''];
|
|
249
|
+
// private keepSeparator: boolean = true;
|
|
250
|
+
|
|
251
|
+
// constructor({
|
|
252
|
+
// chunkSize = 1000,
|
|
253
|
+
// chunkOverlap = 200,
|
|
254
|
+
// separators,
|
|
255
|
+
// keepSeparator,
|
|
256
|
+
// }: {
|
|
257
|
+
// chunkSize?: number;
|
|
258
|
+
// chunkOverlap?: number;
|
|
259
|
+
// separators?: string[];
|
|
260
|
+
// keepSeparator?: boolean;
|
|
261
|
+
// } = {}) {
|
|
262
|
+
// this.chunkSize = chunkSize;
|
|
263
|
+
// this.chunkOverlap = chunkOverlap;
|
|
264
|
+
|
|
265
|
+
// if (separators) {
|
|
266
|
+
// this.separators = separators;
|
|
267
|
+
// }
|
|
268
|
+
|
|
269
|
+
// if (keepSeparator !== undefined) {
|
|
270
|
+
// this.keepSeparator = keepSeparator;
|
|
271
|
+
// }
|
|
272
|
+
|
|
273
|
+
// if (this.chunkOverlap >= this.chunkSize) {
|
|
274
|
+
// throw new Error('Cannot have chunkOverlap >= chunkSize');
|
|
275
|
+
// }
|
|
276
|
+
// }
|
|
277
|
+
|
|
278
|
+
// public splitText(text: string): string[] {
|
|
279
|
+
// return this._splitText(text, this.separators);
|
|
280
|
+
// }
|
|
281
|
+
|
|
282
|
+
// private _splitText(text: string, separators: string[]): string[] {
|
|
283
|
+
// const finalChunks: string[] = [];
|
|
284
|
+
|
|
285
|
+
// // Get appropriate separator to use
|
|
286
|
+
// let separator: string = separators[separators.length - 1];
|
|
287
|
+
// let newSeparators: string[] | undefined;
|
|
288
|
+
|
|
289
|
+
// for (let i = 0; i < separators.length; i += 1) {
|
|
290
|
+
// const s = separators[i];
|
|
291
|
+
// if (s === '') {
|
|
292
|
+
// separator = s;
|
|
293
|
+
// break;
|
|
294
|
+
// }
|
|
295
|
+
// if (text.includes(s)) {
|
|
296
|
+
// separator = s;
|
|
297
|
+
// newSeparators = separators.slice(i + 1);
|
|
298
|
+
// break;
|
|
299
|
+
// }
|
|
300
|
+
// }
|
|
301
|
+
|
|
302
|
+
// // Split the text using the identified separator
|
|
303
|
+
// const splits = this.splitOnSeparator(text, separator);
|
|
304
|
+
|
|
305
|
+
// // Process splits, recursively splitting longer texts
|
|
306
|
+
// let goodSplits: string[] = [];
|
|
307
|
+
// const _separator = this.keepSeparator ? '' : separator;
|
|
308
|
+
|
|
309
|
+
// for (const s of splits) {
|
|
310
|
+
// if (this.lengthFunction(s) < this.chunkSize) {
|
|
311
|
+
// goodSplits.push(s);
|
|
312
|
+
// } else {
|
|
313
|
+
// if (goodSplits.length) {
|
|
314
|
+
// const mergedText = this.mergeSplits(goodSplits, _separator);
|
|
315
|
+
// finalChunks.push(...mergedText);
|
|
316
|
+
// goodSplits = [];
|
|
317
|
+
// }
|
|
318
|
+
|
|
319
|
+
// if (!newSeparators) {
|
|
320
|
+
// finalChunks.push(s);
|
|
321
|
+
// } else {
|
|
322
|
+
// const otherInfo = this._splitText(s, newSeparators);
|
|
323
|
+
// finalChunks.push(...otherInfo);
|
|
324
|
+
// }
|
|
325
|
+
// }
|
|
326
|
+
// }
|
|
327
|
+
|
|
328
|
+
// if (goodSplits.length) {
|
|
329
|
+
// const mergedText = this.mergeSplits(goodSplits, _separator);
|
|
330
|
+
// finalChunks.push(...mergedText);
|
|
331
|
+
// }
|
|
332
|
+
|
|
333
|
+
// return finalChunks;
|
|
334
|
+
// }
|
|
335
|
+
|
|
336
|
+
// private splitOnSeparator(text: string, separator: string): string[] {
|
|
337
|
+
// let splits: string[];
|
|
338
|
+
|
|
339
|
+
// if (separator) {
|
|
340
|
+
// if (this.keepSeparator) {
|
|
341
|
+
// const regexEscapedSeparator = separator.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
342
|
+
// splits = text.split(new RegExp(`(?=${regexEscapedSeparator})`));
|
|
343
|
+
// } else {
|
|
344
|
+
// splits = text.split(separator);
|
|
345
|
+
// }
|
|
346
|
+
// } else {
|
|
347
|
+
// splits = text.split('');
|
|
348
|
+
// }
|
|
349
|
+
|
|
350
|
+
// return splits.filter((s) => s !== '');
|
|
351
|
+
// }
|
|
352
|
+
|
|
353
|
+
// private lengthFunction(text: string): number {
|
|
354
|
+
// return text.length;
|
|
355
|
+
// }
|
|
356
|
+
|
|
357
|
+
// private joinDocs(docs: string[], separator: string): string | null {
|
|
358
|
+
// const text = docs.join(separator).trim();
|
|
359
|
+
// return text === '' ? null : text;
|
|
360
|
+
// }
|
|
361
|
+
|
|
362
|
+
// private mergeSplits(splits: string[], separator: string): string[] {
|
|
363
|
+
// const docs: string[] = [];
|
|
364
|
+
// const currentDoc: string[] = [];
|
|
365
|
+
// let total = 0;
|
|
366
|
+
|
|
367
|
+
// for (const d of splits) {
|
|
368
|
+
// const _len = this.lengthFunction(d);
|
|
369
|
+
|
|
370
|
+
// if (total + _len + currentDoc.length * separator.length > this.chunkSize) {
|
|
371
|
+
// if (total > this.chunkSize) {
|
|
372
|
+
// console.warn(`Created a chunk of size ${total}, which is longer than the specified ${this.chunkSize}`);
|
|
373
|
+
// }
|
|
374
|
+
|
|
375
|
+
// if (currentDoc.length > 0) {
|
|
376
|
+
// const doc = this.joinDocs(currentDoc, separator);
|
|
377
|
+
// if (doc !== null) {
|
|
378
|
+
// docs.push(doc);
|
|
379
|
+
// }
|
|
380
|
+
|
|
381
|
+
// // Keep popping if conditions are met
|
|
382
|
+
// while (total > this.chunkOverlap || (total + _len + currentDoc.length * separator.length > this.chunkSize && total > 0)) {
|
|
383
|
+
// total -= this.lengthFunction(currentDoc[0]);
|
|
384
|
+
// currentDoc.shift();
|
|
385
|
+
// }
|
|
386
|
+
// }
|
|
387
|
+
// }
|
|
388
|
+
|
|
389
|
+
// currentDoc.push(d);
|
|
390
|
+
// total += _len;
|
|
391
|
+
// }
|
|
392
|
+
|
|
393
|
+
// const doc = this.joinDocs(currentDoc, separator);
|
|
394
|
+
// if (doc !== null) {
|
|
395
|
+
// docs.push(doc);
|
|
396
|
+
// }
|
|
397
|
+
|
|
398
|
+
// return docs;
|
|
399
|
+
// }
|
|
400
|
+
// }
|
|
401
|
+
|
|
402
|
+
// class RecursiveTextSplitter extends TextSplitter {
|
|
403
|
+
// constructor({
|
|
404
|
+
// chunkSize = 1000,
|
|
405
|
+
// chunkOverlap = 200,
|
|
406
|
+
// separators = ['\n\n', '\n', ' ', ''],
|
|
407
|
+
// keepSeparator = true,
|
|
408
|
+
// }: {
|
|
409
|
+
// chunkSize?: number;
|
|
410
|
+
// chunkOverlap?: number;
|
|
411
|
+
// separators?: string[];
|
|
412
|
+
// keepSeparator?: boolean;
|
|
413
|
+
// } = {}) {
|
|
414
|
+
// super({ chunkSize, chunkOverlap, separators, keepSeparator });
|
|
415
|
+
// }
|
|
416
|
+
// }
|