@smythos/sre 1.5.0

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 (188) hide show
  1. package/README.md +135 -0
  2. package/dist/index.js +7 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/types/Components/APICall/APICall.class.d.ts +34 -0
  5. package/dist/types/Components/APICall/AccessTokenManager.d.ts +17 -0
  6. package/dist/types/Components/APICall/ArrayBufferResponse.helper.d.ts +3 -0
  7. package/dist/types/Components/APICall/OAuth.helper.d.ts +10 -0
  8. package/dist/types/Components/APICall/mimeTypeCategories.d.ts +6 -0
  9. package/dist/types/Components/APICall/parseData.d.ts +5 -0
  10. package/dist/types/Components/APICall/parseHeaders.d.ts +3 -0
  11. package/dist/types/Components/APICall/parseProxy.d.ts +4 -0
  12. package/dist/types/Components/APICall/parseUrl.d.ts +7 -0
  13. package/dist/types/Components/APIEndpoint.class.d.ts +16 -0
  14. package/dist/types/Components/APIOutput.class.d.ts +15 -0
  15. package/dist/types/Components/AgentPlugin.class.d.ts +16 -0
  16. package/dist/types/Components/Async.class.d.ts +17 -0
  17. package/dist/types/Components/Await.class.d.ts +22 -0
  18. package/dist/types/Components/Classifier.class.d.ts +33 -0
  19. package/dist/types/Components/Component.class.d.ts +35 -0
  20. package/dist/types/Components/ComponentHost.class.d.ts +12 -0
  21. package/dist/types/Components/DataSourceCleaner.class.d.ts +19 -0
  22. package/dist/types/Components/DataSourceIndexer.class.d.ts +25 -0
  23. package/dist/types/Components/DataSourceLookup.class.d.ts +17 -0
  24. package/dist/types/Components/FEncDec.class.d.ts +17 -0
  25. package/dist/types/Components/FHash.class.d.ts +17 -0
  26. package/dist/types/Components/FSign.class.d.ts +18 -0
  27. package/dist/types/Components/FSleep.class.d.ts +19 -0
  28. package/dist/types/Components/FTimestamp.class.d.ts +19 -0
  29. package/dist/types/Components/FileStore.class.d.ts +11 -0
  30. package/dist/types/Components/ForEach.class.d.ts +16 -0
  31. package/dist/types/Components/GPTPlugin.class.d.ts +17 -0
  32. package/dist/types/Components/GenAILLM.class.d.ts +130 -0
  33. package/dist/types/Components/HuggingFace.class.d.ts +17 -0
  34. package/dist/types/Components/Image/imageSettings.config.d.ts +21 -0
  35. package/dist/types/Components/ImageGenerator.class.d.ts +17 -0
  36. package/dist/types/Components/JSONFilter.class.d.ts +13 -0
  37. package/dist/types/Components/LLMAssistant.class.d.ts +19 -0
  38. package/dist/types/Components/LogicAND.class.d.ts +7 -0
  39. package/dist/types/Components/LogicAtLeast.class.d.ts +9 -0
  40. package/dist/types/Components/LogicAtMost.class.d.ts +9 -0
  41. package/dist/types/Components/LogicOR.class.d.ts +7 -0
  42. package/dist/types/Components/LogicXOR.class.d.ts +7 -0
  43. package/dist/types/Components/MCPClient.class.d.ts +17 -0
  44. package/dist/types/Components/PromptGenerator.class.d.ts +19 -0
  45. package/dist/types/Components/ScrapflyWebScrape.class.d.ts +30 -0
  46. package/dist/types/Components/TavilyWebSearch.class.d.ts +31 -0
  47. package/dist/types/Components/index.d.ts +74 -0
  48. package/dist/types/Core/AgentProcess.helper.d.ts +36 -0
  49. package/dist/types/Core/Connector.class.d.ts +34 -0
  50. package/dist/types/Core/ConnectorsService.d.ts +64 -0
  51. package/dist/types/Core/DummyConnector.d.ts +4 -0
  52. package/dist/types/Core/HookService.d.ts +27 -0
  53. package/dist/types/Core/SmythRuntime.class.d.ts +28 -0
  54. package/dist/types/Core/SystemEvents.d.ts +12 -0
  55. package/dist/types/Core/boot.d.ts +1 -0
  56. package/dist/types/config.d.ts +11 -0
  57. package/dist/types/constants.d.ts +79 -0
  58. package/dist/types/helpers/BinaryInput.helper.d.ts +33 -0
  59. package/dist/types/helpers/Conversation.helper.d.ts +85 -0
  60. package/dist/types/helpers/JsonContent.helper.d.ts +16 -0
  61. package/dist/types/helpers/LocalCache.helper.d.ts +14 -0
  62. package/dist/types/helpers/Log.helper.d.ts +22 -0
  63. package/dist/types/helpers/OpenApiParser.helper.d.ts +10 -0
  64. package/dist/types/helpers/S3Cache.helper.d.ts +9 -0
  65. package/dist/types/helpers/SmythURI.helper.d.ts +3 -0
  66. package/dist/types/helpers/TemplateString.helper.d.ts +71 -0
  67. package/dist/types/helpers/TypeChecker.helper.d.ts +10 -0
  68. package/dist/types/index.d.ts +173 -0
  69. package/dist/types/subsystems/AgentManager/Agent.class.d.ts +78 -0
  70. package/dist/types/subsystems/AgentManager/Agent.helper.d.ts +1 -0
  71. package/dist/types/subsystems/AgentManager/AgentData.service/AgentDataConnector.d.ts +33 -0
  72. package/dist/types/subsystems/AgentManager/AgentData.service/connectors/CLIAgentDataConnector.class.d.ts +20 -0
  73. package/dist/types/subsystems/AgentManager/AgentData.service/connectors/LocalAgentDataConnector.class.d.ts +48 -0
  74. package/dist/types/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.d.ts +19 -0
  75. package/dist/types/subsystems/AgentManager/AgentData.service/index.d.ts +4 -0
  76. package/dist/types/subsystems/AgentManager/AgentLogger.class.d.ts +11 -0
  77. package/dist/types/subsystems/AgentManager/AgentRequest.class.d.ts +15 -0
  78. package/dist/types/subsystems/AgentManager/AgentRuntime.class.d.ts +91 -0
  79. package/dist/types/subsystems/AgentManager/AgentSSE.class.d.ts +40 -0
  80. package/dist/types/subsystems/AgentManager/AgentSettings.class.d.ts +12 -0
  81. package/dist/types/subsystems/AgentManager/Component.service/ComponentConnector.d.ts +17 -0
  82. package/dist/types/subsystems/AgentManager/Component.service/connectors/LocalComponentConnector.class.d.ts +14 -0
  83. package/dist/types/subsystems/AgentManager/Component.service/index.d.ts +4 -0
  84. package/dist/types/subsystems/AgentManager/EmbodimentSettings.class.d.ts +8 -0
  85. package/dist/types/subsystems/AgentManager/ForkedAgent.class.d.ts +15 -0
  86. package/dist/types/subsystems/AgentManager/OSResourceMonitor.d.ts +2 -0
  87. package/dist/types/subsystems/ComputeManager/Code.service/CodeConnector.d.ts +58 -0
  88. package/dist/types/subsystems/ComputeManager/Code.service/connectors/AWSLambdaCode.class.d.ts +15 -0
  89. package/dist/types/subsystems/ComputeManager/Code.service/index.d.ts +4 -0
  90. package/dist/types/subsystems/IO/CLI.service/CLIConnector.d.ts +21 -0
  91. package/dist/types/subsystems/IO/CLI.service/index.d.ts +4 -0
  92. package/dist/types/subsystems/IO/Log.service/LogConnector.d.ts +17 -0
  93. package/dist/types/subsystems/IO/Log.service/connectors/ConsoleLog.class.d.ts +12 -0
  94. package/dist/types/subsystems/IO/Log.service/index.d.ts +4 -0
  95. package/dist/types/subsystems/IO/NKV.service/NKVConnector.d.ts +33 -0
  96. package/dist/types/subsystems/IO/NKV.service/connectors/NKVRAM.class.d.ts +43 -0
  97. package/dist/types/subsystems/IO/NKV.service/connectors/NKVRedis.class.d.ts +27 -0
  98. package/dist/types/subsystems/IO/NKV.service/index.d.ts +4 -0
  99. package/dist/types/subsystems/IO/Router.service/RouterConnector.d.ts +11 -0
  100. package/dist/types/subsystems/IO/Router.service/connectors/ExpressRouter.class.d.ts +21 -0
  101. package/dist/types/subsystems/IO/Router.service/connectors/NullRouter.class.d.ts +12 -0
  102. package/dist/types/subsystems/IO/Router.service/index.d.ts +4 -0
  103. package/dist/types/subsystems/IO/Storage.service/SmythFS.class.d.ts +49 -0
  104. package/dist/types/subsystems/IO/Storage.service/StorageConnector.d.ts +30 -0
  105. package/dist/types/subsystems/IO/Storage.service/connectors/LocalStorage.class.d.ts +58 -0
  106. package/dist/types/subsystems/IO/Storage.service/connectors/S3Storage.class.d.ts +53 -0
  107. package/dist/types/subsystems/IO/Storage.service/index.d.ts +4 -0
  108. package/dist/types/subsystems/IO/VectorDB.service/VectorDBConnector.d.ts +41 -0
  109. package/dist/types/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.d.ts +49 -0
  110. package/dist/types/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.d.ts +50 -0
  111. package/dist/types/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.d.ts +52 -0
  112. package/dist/types/subsystems/IO/VectorDB.service/embed/BaseEmbedding.d.ts +53 -0
  113. package/dist/types/subsystems/IO/VectorDB.service/embed/OpenAIEmbedding.d.ts +16 -0
  114. package/dist/types/subsystems/IO/VectorDB.service/embed/index.d.ts +16 -0
  115. package/dist/types/subsystems/IO/VectorDB.service/index.d.ts +4 -0
  116. package/dist/types/subsystems/LLMManager/LLM.helper.d.ts +125 -0
  117. package/dist/types/subsystems/LLMManager/LLM.inference.d.ts +36 -0
  118. package/dist/types/subsystems/LLMManager/LLM.service/LLMConnector.d.ts +62 -0
  119. package/dist/types/subsystems/LLMManager/LLM.service/LLMCredentials.helper.d.ts +3 -0
  120. package/dist/types/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.d.ts +68 -0
  121. package/dist/types/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.d.ts +46 -0
  122. package/dist/types/subsystems/LLMManager/LLM.service/connectors/Echo.class.d.ts +18 -0
  123. package/dist/types/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.d.ts +57 -0
  124. package/dist/types/subsystems/LLMManager/LLM.service/connectors/Groq.class.d.ts +55 -0
  125. package/dist/types/subsystems/LLMManager/LLM.service/connectors/OpenAI.class.d.ts +92 -0
  126. package/dist/types/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.d.ts +86 -0
  127. package/dist/types/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.d.ts +38 -0
  128. package/dist/types/subsystems/LLMManager/LLM.service/index.d.ts +5 -0
  129. package/dist/types/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.d.ts +36 -0
  130. package/dist/types/subsystems/LLMManager/ModelsProvider.service/connectors/SmythModelsProvider.class.d.ts +39 -0
  131. package/dist/types/subsystems/LLMManager/ModelsProvider.service/index.d.ts +4 -0
  132. package/dist/types/subsystems/LLMManager/custom-models.d.ts +785 -0
  133. package/dist/types/subsystems/LLMManager/models.d.ts +2629 -0
  134. package/dist/types/subsystems/LLMManager/paramMappings.d.ts +69 -0
  135. package/dist/types/subsystems/MemoryManager/Cache.service/CacheConnector.d.ts +41 -0
  136. package/dist/types/subsystems/MemoryManager/Cache.service/connectors/LocalStorageCache.class.d.ts +33 -0
  137. package/dist/types/subsystems/MemoryManager/Cache.service/connectors/RAMCache.class.d.ts +31 -0
  138. package/dist/types/subsystems/MemoryManager/Cache.service/connectors/RedisCache.class.d.ts +33 -0
  139. package/dist/types/subsystems/MemoryManager/Cache.service/connectors/S3Cache.class.d.ts +38 -0
  140. package/dist/types/subsystems/MemoryManager/Cache.service/index.d.ts +4 -0
  141. package/dist/types/subsystems/MemoryManager/LLMCache.d.ts +27 -0
  142. package/dist/types/subsystems/MemoryManager/LLMContext.d.ts +25 -0
  143. package/dist/types/subsystems/MemoryManager/RuntimeContext.d.ts +50 -0
  144. package/dist/types/subsystems/Security/AccessControl/ACL.class.d.ts +29 -0
  145. package/dist/types/subsystems/Security/AccessControl/AccessCandidate.class.d.ts +21 -0
  146. package/dist/types/subsystems/Security/AccessControl/AccessRequest.class.d.ts +13 -0
  147. package/dist/types/subsystems/Security/Account.service/AccountConnector.d.ts +27 -0
  148. package/dist/types/subsystems/Security/Account.service/connectors/AWSAccount.class.d.ts +19 -0
  149. package/dist/types/subsystems/Security/Account.service/connectors/DummyAccount.class.d.ts +19 -0
  150. package/dist/types/subsystems/Security/Account.service/connectors/JSONFileAccount.class.d.ts +25 -0
  151. package/dist/types/subsystems/Security/Account.service/index.d.ts +4 -0
  152. package/dist/types/subsystems/Security/Credentials.helper.d.ts +16 -0
  153. package/dist/types/subsystems/Security/ManagedVault.service/ManagedVaultConnector.d.ts +23 -0
  154. package/dist/types/subsystems/Security/ManagedVault.service/connectors/NullManagedVault.class.d.ts +14 -0
  155. package/dist/types/subsystems/Security/ManagedVault.service/connectors/SecretManagerManagedVault.d.ts +22 -0
  156. package/dist/types/subsystems/Security/ManagedVault.service/index.d.ts +4 -0
  157. package/dist/types/subsystems/Security/SecureConnector.class.d.ts +13 -0
  158. package/dist/types/subsystems/Security/Vault.service/Vault.helper.d.ts +5 -0
  159. package/dist/types/subsystems/Security/Vault.service/VaultConnector.d.ts +17 -0
  160. package/dist/types/subsystems/Security/Vault.service/connectors/HashicorpVault.class.d.ts +13 -0
  161. package/dist/types/subsystems/Security/Vault.service/connectors/JSONFileVault.class.d.ts +23 -0
  162. package/dist/types/subsystems/Security/Vault.service/connectors/NullVault.class.d.ts +16 -0
  163. package/dist/types/subsystems/Security/Vault.service/connectors/SecretsManager.class.d.ts +20 -0
  164. package/dist/types/subsystems/Security/Vault.service/index.d.ts +4 -0
  165. package/dist/types/types/ACL.types.d.ts +83 -0
  166. package/dist/types/types/AWS.types.d.ts +7 -0
  167. package/dist/types/types/Agent.types.d.ts +52 -0
  168. package/dist/types/types/AgentLogger.types.d.ts +16 -0
  169. package/dist/types/types/Cache.types.d.ts +1 -0
  170. package/dist/types/types/Common.types.d.ts +3 -0
  171. package/dist/types/types/LLM.types.d.ts +365 -0
  172. package/dist/types/types/Redis.types.d.ts +6 -0
  173. package/dist/types/types/SRE.types.d.ts +60 -0
  174. package/dist/types/types/Security.types.d.ts +16 -0
  175. package/dist/types/types/Storage.types.d.ts +3 -0
  176. package/dist/types/types/VectorDB.types.d.ts +66 -0
  177. package/dist/types/utils/base64.utils.d.ts +86 -0
  178. package/dist/types/utils/cli.utils.d.ts +20 -0
  179. package/dist/types/utils/data.utils.d.ts +17 -0
  180. package/dist/types/utils/date-time.utils.d.ts +3 -0
  181. package/dist/types/utils/general.utils.d.ts +75 -0
  182. package/dist/types/utils/index.d.ts +9 -0
  183. package/dist/types/utils/numbers.utils.d.ts +2 -0
  184. package/dist/types/utils/oauth.utils.d.ts +7 -0
  185. package/dist/types/utils/string.utils.d.ts +28 -0
  186. package/dist/types/utils/url.utils.d.ts +1 -0
  187. package/dist/types/utils/validation.utils.d.ts +25 -0
  188. package/package.json +117 -0
@@ -0,0 +1,60 @@
1
+ import { AgentDataService } from '@sre/AgentManager/AgentData.service';
2
+ import { CLIService } from '@sre/IO/CLI.service';
3
+ import { NKVService } from '@sre/IO/NKV.service';
4
+ import { StorageService } from '@sre/IO/Storage.service';
5
+ import { VectorDBService } from '@sre/IO/VectorDB.service';
6
+ import { LLMService } from '@sre/LLMManager/LLM.service';
7
+ import { CacheService } from '@sre/MemoryManager/Cache.service';
8
+ import { AccountService } from '@sre/Security/Account.service';
9
+ import { VaultService } from '@sre/Security/Vault.service';
10
+ import { RouterService } from '@sre/IO/Router.service';
11
+ import { ManagedVaultService } from '@sre/Security/ManagedVault.service';
12
+ import { LogService } from '@sre/IO/Log.service';
13
+ import { ComponentService } from '@sre/AgentManager/Component.service';
14
+ import { ModelsProviderService } from '@sre/LLMManager/ModelsProvider.service';
15
+ import { CodeService } from '@sre/ComputeManager/Code.service';
16
+ export type TServiceRegistry = {
17
+ Storage?: StorageService;
18
+ VectorDB?: VectorDBService;
19
+ Cache?: CacheService;
20
+ LLM?: LLMService;
21
+ Vault?: VaultService;
22
+ Account?: AccountService;
23
+ AgentData?: AgentDataService;
24
+ CLI?: CLIService;
25
+ NKV?: NKVService;
26
+ Router?: RouterService;
27
+ ManagedVault?: ManagedVaultService;
28
+ Log?: LogService;
29
+ Component?: ComponentService;
30
+ ModelsProvider?: ModelsProviderService;
31
+ Code?: CodeService;
32
+ };
33
+ export declare enum TConnectorService {
34
+ Storage = "Storage",
35
+ VectorDB = "VectorDB",
36
+ Cache = "Cache",
37
+ LLM = "LLM",
38
+ Vault = "Vault",
39
+ Account = "Account",
40
+ AgentData = "AgentData",
41
+ CLI = "CLI",
42
+ NKV = "NKV",
43
+ Router = "Router",
44
+ ManagedVault = "ManagedVault",
45
+ Log = "Log",
46
+ Component = "Component",
47
+ ModelsProvider = "ModelsProvider",
48
+ Code = "Code"
49
+ }
50
+ export type SREConnectorConfig = {
51
+ Connector: string;
52
+ Id?: string;
53
+ Default?: boolean;
54
+ Settings?: {
55
+ [hashedOwnerKey: string]: any;
56
+ };
57
+ };
58
+ export type SREConfig = {
59
+ [key in TConnectorService]?: SREConnectorConfig[] | SREConnectorConfig | {};
60
+ };
@@ -0,0 +1,16 @@
1
+ export type OAuthConfig = {
2
+ oAuthAppID: string;
3
+ oAuthAppSecret: string;
4
+ oAuthBaseUrl: string;
5
+ oAuthResource?: string;
6
+ oAuthScope?: string;
7
+ };
8
+ export type EncryptionSettings = {
9
+ encryption?: {
10
+ key?: string;
11
+ algorithm?: string;
12
+ };
13
+ };
14
+ export type SmythConfigs = {
15
+ smythAPIBaseUrl: string;
16
+ };
@@ -0,0 +1,3 @@
1
+ import { Readable } from 'stream';
2
+ export type StorageMetadata = Record<string, any> | undefined;
3
+ export type StorageData = string | Uint8Array | Buffer | Readable;
@@ -0,0 +1,66 @@
1
+ export type VectorDBMetadata = ({
2
+ text?: string;
3
+ user?: string;
4
+ } & Record<string, string>) | undefined;
5
+ export type VectorsResultData = {
6
+ id: string;
7
+ score?: number;
8
+ values: number[];
9
+ metadata?: ({
10
+ text?: string;
11
+ user?: Record<string, string>;
12
+ } & Record<string, any>) | undefined;
13
+ }[];
14
+ export interface NsKnownMetadata {
15
+ isOnCustomStorage?: boolean;
16
+ [key: string]: any;
17
+ }
18
+ export interface QueryOptions {
19
+ topK?: number;
20
+ includeMetadata?: boolean;
21
+ }
22
+ export interface SourceTypes {
23
+ Vector: number[];
24
+ Text: string;
25
+ }
26
+ export type Source = SourceTypes[keyof SourceTypes];
27
+ export interface IVectorDataSourceDto {
28
+ id: string;
29
+ source: number[] | string;
30
+ metadata?: VectorDBMetadata;
31
+ }
32
+ export interface IStorageVectorDataSource {
33
+ namespaceId: string;
34
+ candidateId: string;
35
+ candidateRole: string;
36
+ name: string;
37
+ metadata: string;
38
+ text: string;
39
+ vectorIds: string[];
40
+ id: string;
41
+ }
42
+ export interface IStorageVectorNamespace {
43
+ namespace: string;
44
+ displayName: string;
45
+ candidateId: string;
46
+ candidateRole: string;
47
+ metadata?: StorageVectorNamespaceMetadata;
48
+ }
49
+ export type StorageVectorNamespaceMetadata = Partial<PineconeNamespaceMetadata> & {
50
+ isOnCustomStorage?: boolean;
51
+ } & {
52
+ [key: string]: any;
53
+ };
54
+ export interface PineconeNamespaceMetadata {
55
+ indexName: string;
56
+ }
57
+ export interface DatasourceDto {
58
+ text: string;
59
+ metadata?: Record<string, string> & {
60
+ smyth_metadata?: Record<string, string>;
61
+ };
62
+ chunkSize?: number;
63
+ chunkOverlap?: number;
64
+ label?: string;
65
+ id?: string;
66
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * This function converts a text string to a base64 URL.
3
+ * @param text
4
+ * @returns
5
+ */
6
+ export declare function textToBase64Url(text: any): string;
7
+ export declare const isBase64FileUrl: (url: string) => boolean;
8
+ export declare const getMimetypeFromBase64Data: (data: string) => Promise<"" | import("file-type").MimeType>;
9
+ export declare function getBase64FileInfo(data: string): Promise<{
10
+ data: string;
11
+ mimetype: string;
12
+ size: number;
13
+ } | null>;
14
+ /**
15
+ * Checks if the input is a data URL.
16
+ *
17
+ * @param {string} input - The input string.
18
+ * @returns {boolean} True if the input is a data URL, false otherwise.
19
+ */
20
+ export declare function isBase64DataUrl(input: string): boolean;
21
+ /**
22
+ * Checks if the given string is a valid Base64-encoded string.
23
+ *
24
+ * @param {string} str - The string to check.
25
+ * @returns {boolean} True if the string is a valid Base64-encoded string, false otherwise.
26
+ */
27
+ export declare function isBase64(str: string): boolean;
28
+ /**
29
+ * Parses a Base64-encoded string and extracts the MIME type and cleaned data.
30
+ *
31
+ * @param {string} input - The Base64-encoded string.
32
+ * @returns {Promise<{ mimetype: string; data: string }>} An object containing the MIME type and the cleaned Base64 data.
33
+ */
34
+ export declare function parseBase64(input: string): Promise<{
35
+ mimetype: string;
36
+ data: string;
37
+ }>;
38
+ /**
39
+ * Identifies the MIME type from a Base64-encoded string.
40
+ *
41
+ * This function cleans the input Base64 string, converts it to a buffer, and then identifies the MIME type
42
+ * using the `fileTypeFromBuffer` function.
43
+ *
44
+ * @param {string} data - The Base64-encoded string from which to identify the MIME type.
45
+ * @returns {Promise<string>} A promise that resolves to the MIME type of the data, or an empty string if the MIME type cannot be determined.
46
+ *
47
+ * @throws {Error} If an error occurs during the process, it logs the error and returns an empty string.
48
+ */
49
+ export declare function identifyMimetypeFromBase64(data: string): Promise<string>;
50
+ /**
51
+ * Identifies the MIME type from a Base64-encoded string.
52
+ *
53
+ * This function cleans the input Base64 string, converts it to a buffer, and then identifies the MIME type
54
+ * using the `fileTypeFromBuffer` function.
55
+ *
56
+ * @param {string} data - The Base64-encoded string from which to identify the MIME type.
57
+ * @returns {Promise<string>} A promise that resolves to the MIME type of the data, or an empty string if the MIME type cannot be determined.
58
+ *
59
+ * @throws {Error} If an error occurs during the process, it logs the error and returns an empty string.
60
+ */
61
+ export declare function identifyMimeTypeFromBase64DataUrl(input: string): Promise<string>;
62
+ /**
63
+ * Calculates the size of a Base64-encoded string in bytes.
64
+ *
65
+ * This function validates the input string to ensure it is a valid Base64-encoded string,
66
+ * converts it to a buffer, and then returns the byte length of the buffer.
67
+ *
68
+ * @param {string} str - The Base64-encoded string whose size is to be calculated.
69
+ * @returns {number} The size of the Base64-encoded string in bytes.
70
+ *
71
+ * @throws {Error} If the input string is not a valid Base64-encoded string or if an error occurs during conversion.
72
+ */
73
+ export declare function getSizeOfBase64(str: string): number;
74
+ /**
75
+ * Generates a Base64 Data URL from a Base64-encoded string.
76
+ *
77
+ * This function validates the input Base64 string, removes any newline characters,
78
+ * and constructs a Data URL with the specified MIME type.
79
+ *
80
+ * @param {string} data - The Base64-encoded string to be converted into a Data URL.
81
+ * @param {string} [mimetype='application/octet-stream'] - The MIME type of the data. Defaults to 'application/octet-stream'.
82
+ * @returns {string} The generated Base64 Data URL.
83
+ *
84
+ * @throws {Error} If the input string is not a valid Base64-encoded string.
85
+ */
86
+ export declare function makeBase64Url(data: string, mimetype?: string): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This function parses the command line arguments and returns an object with the parsed values.
3
+ * The expected format is --file ./path/to/file.txt or --settings key1=value1 key2=value2
4
+ * Examples:
5
+ * --file ./path/to/file.txt : calling parseCLIArgs('file', process.argv) will return {file: './path/to/file.txt'}
6
+ * --settings key1=value1 key2=value2 : calling parseCLIArgs('settings', process.argv) will return {settings: {key1: 'value1', key2: 'value2'}}
7
+ * it can also parse multiple arguments at once, for example:
8
+ * parseCLIArgs(['file', 'settings'], process.argv) will return {file: './path/to/file.txt', settings: {key1: 'value1', key2: 'value2'}}
9
+ *
10
+ * @param argList the argument to parse
11
+ * @param argv the command line arguments, usually process.argv
12
+ * @returns parsed arguments object
13
+ */
14
+ export declare function parseCLIArgs(argList: string | Array<string>, argv?: Array<string>): Record<string, any>;
15
+ /**
16
+ * List all cli main arguments
17
+ * example : node index.js --file ./path/to/file.txt --settings key1=value1 key2=value2
18
+ * calling getMainArgs(process.argv) will return ['file', 'settings']
19
+ */
20
+ export declare function getMainArgs(argv?: Array<string>): Array<string>;
@@ -0,0 +1,17 @@
1
+ import { Readable } from 'stream';
2
+ import { BinaryInput } from '@sre/helpers/BinaryInput.helper';
3
+ export declare function streamToBuffer(stream: Readable): Promise<Buffer>;
4
+ export declare function dataToBuffer(data: any): Buffer | null;
5
+ export declare const getSizeFromBinary: (data: any) => number;
6
+ export declare const isPlainObject: (data: any) => boolean;
7
+ export declare const isBuffer: (data: any) => boolean;
8
+ export declare const isBinaryMimeType: (mimetype: any) => boolean;
9
+ export declare const isBinaryData: (data: any) => boolean;
10
+ export declare function isUrl(str: string): boolean;
11
+ export declare function isSmythFsUrl(str: string): boolean;
12
+ export declare const isSmythFileObject: (data: any) => boolean;
13
+ export declare const isBufferObject: (data: Record<string, any>) => boolean;
14
+ export declare const isBase64Object: (data: Record<string, any>) => boolean;
15
+ export declare function getMimeType(data: any): Promise<string>;
16
+ export declare function formatDataForDebug(data: any): Promise<any>;
17
+ export declare function normalizeImageInput(inputImage: string | BinaryInput): Promise<string>;
@@ -0,0 +1,3 @@
1
+ export declare function getCurrentFormattedDate(): string;
2
+ export declare function getDayFormattedDate(): string;
3
+ export declare function delay(ms: any): Promise<unknown>;
@@ -0,0 +1,75 @@
1
+ import { LogHelper } from '@sre/helpers/Log.helper';
2
+ export declare function uid(): string;
3
+ /**
4
+ * this function is used to check if a class is a subclass of another class
5
+ * @param subClass
6
+ * @param superClass
7
+ * @returns
8
+ */
9
+ export declare function isSubclassOf(subClass: any, superClass: any): boolean;
10
+ /**
11
+ * Processes an array of tasks concurrently with a specified concurrency limit.
12
+ *
13
+ * @template T - The type of the result returned by each task.
14
+ *
15
+ * @param {(() => Promise<T>)[]} tasks - An array of functions that return promises.
16
+ * Each function represents a task to be processed.
17
+ * @param {number} [maxConcurrentTasks=10] - The maximum number of concurrent tasks.
18
+ *
19
+ * @returns {Promise<T[]>} - A promise that resolves to an array of results.
20
+ * Only successfully fulfilled promises are included in the result array.
21
+ *
22
+ * @throws {TypeError} - Throws an error if the tasks parameter is not an array of functions.
23
+ *
24
+ * @example
25
+ * const tasks = [
26
+ * () => await processFile('file1.txt'),
27
+ * () => await processFile('file2.txt'),
28
+ * () => await processFile('file3.txt'),
29
+ * ];
30
+ *
31
+ * const maxConcurrentTasks = 2;
32
+ *
33
+ * processWithConcurrencyLimit(tasks, maxConcurrentTasks)
34
+ * .then(results => console.log(results)) // Array of results from the fulfilled promises
35
+ * .catch(error => console.error(error));
36
+ *
37
+ * @note Currently, this function ignores tasks that fail to process.
38
+ * Only successfully fulfilled promises are included in the result array.
39
+ * To improve this behavior, we could add an option to control whether to exit the function if a task fails.
40
+ */
41
+ export declare function processWithConcurrencyLimit<T>(tasks: (() => Promise<T>)[], maxConcurrentTasks?: number): Promise<T[]>;
42
+ export declare const detectURLSourceType: (url: string) => "PDF" | "SITEMAP" | "WEBPAGE" | "WORD";
43
+ /**
44
+ * This function checks if a string is a valid JSON string.
45
+ * @param str
46
+ * @returns
47
+ */
48
+ export declare const isJSONString: (str: string) => boolean;
49
+ export declare class ControlledPromise<T> extends Promise<T> {
50
+ private _isSettled;
51
+ readonly isSettled: () => boolean;
52
+ resolve: (value: T) => void;
53
+ reject: (reason?: any) => void;
54
+ constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void, isSettled: () => boolean) => void);
55
+ }
56
+ /**
57
+ * This function ensures that a function is called at most once per wait time.
58
+ * @param func - The function to debounce
59
+ * @param wait - The wait time in milliseconds
60
+ * @param options - The options object : leading means the function will be called immediately if it's called within the wait time,
61
+ * trailing means the function will be called after the wait time has passed. maxWait is the maximum time to wait before calling the function.
62
+ * if maxWait is provided, the function will be called after the maxWait time has passed.
63
+ *
64
+ * @returns
65
+ */
66
+ export declare function debounce(func: Function, wait: number, options: {
67
+ leading: boolean;
68
+ trailing: boolean;
69
+ maxWait?: number;
70
+ }): (this: any, ...args: any[]) => void;
71
+ /**
72
+ * Extracts and formats the last N calls from the stack trace in a user-friendly way
73
+ */
74
+ export declare function getFormattedStackTrace(limit?: number, skip?: number): string[];
75
+ export declare function printStackTrace(logger: LogHelper | Console, limit?: number, skip?: number): void;
@@ -0,0 +1,9 @@
1
+ export * from './general.utils';
2
+ export * from './date-time.utils';
3
+ export * from './data.utils';
4
+ export * from './base64.utils';
5
+ export * from './cli.utils';
6
+ export * from './numbers.utils';
7
+ export * from './string.utils';
8
+ export * from './url.utils';
9
+ export * from './validation.utils';
@@ -0,0 +1,2 @@
1
+ export declare function isDigits(str: string): boolean;
2
+ export declare function isSafeNumber(str: string): boolean;
@@ -0,0 +1,7 @@
1
+ export declare function getM2MToken(configs: {
2
+ oauthAppId: string;
3
+ oauthAppSecret: string;
4
+ resource: string;
5
+ scope: string;
6
+ baseUrl: string;
7
+ }): Promise<string>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * perform a replace operation on a string asynchronously
3
+ * @param str
4
+ * @param regex
5
+ * @param asyncFn
6
+ * @returns
7
+ */
8
+ export declare function asyncReplace(str: any, regex: any, asyncFn: any): Promise<string>;
9
+ export declare function isValidString(str: string): boolean;
10
+ /**
11
+ * The function parseJson() won't parse the data for property values.
12
+ * For instance, if you have '{"a": "1","b": "true"}', it will be parsed as {a: '1', b: 'true'}. That's why we parse the appropriate data type for property values
13
+ * so that the data will be parsed as {a: 1, b: true}
14
+ * @param data
15
+ * @returns
16
+ */
17
+ export declare function convertStringToRespectiveType(data: any): any;
18
+ export declare const kebabToCamel: (input: any) => any;
19
+ export declare const kebabToCapitalize: (input: any) => any;
20
+ /**
21
+ * This function reads a string and tries to identify the mimetype (e.g. text/plain, application/json, application/xml ...)
22
+ * @param input
23
+ */
24
+ export declare const identifyMimetypeFromString: (input: string) => "application/json" | "text/plain" | "application/xml" | "text/html" | "text/css" | "text/csv" | "text/markdown" | "" | "image/svg+xml" | "application/javascript" | "application/yaml" | "application/sql";
25
+ export declare function chunkText(text: string, { chunkSize, chunkOverlap, }?: {
26
+ chunkSize?: number;
27
+ chunkOverlap?: number;
28
+ }): string[];
@@ -0,0 +1 @@
1
+ export declare function getMimeTypeFromUrl(url: string): Promise<string>;
@@ -0,0 +1,25 @@
1
+ interface RangeValidationArgs {
2
+ min?: number;
3
+ max?: number;
4
+ }
5
+ /**
6
+ * Custom validation function to check if a string contains only specified characters.
7
+ * @param {string} value - The string to validate.
8
+ * @returns {string} - The validated string.
9
+ */
10
+ export declare function validateCharacterSet(value: string): boolean;
11
+ /**
12
+ * Validates whether a given string value can be converted to an integer that falls within a specified range.
13
+ * This function is designed to be used as a custom validator in Joi schemas.
14
+ *
15
+ * @param {RangeValidationArgs} args - An object containing optional 'min' and 'max' properties to define the range.
16
+ * @returns {Function} A function that takes a string value and a Joi helper object, and performs the validation.
17
+ *
18
+ * The validation function first converts the string value to a number. It then checks if the number is within the
19
+ * specified range (if provided). If the value is not a number or falls outside the range, it throws an error with a
20
+ * descriptive message.
21
+ *
22
+ * The error message includes the field name for clarity, using the label from the Joi schema if available.
23
+ */
24
+ export declare const validateInteger: (args: RangeValidationArgs) => (value: string, helpers: any) => string;
25
+ export {};
package/package.json ADDED
@@ -0,0 +1,117 @@
1
+ {
2
+ "name": "@smythos/sre",
3
+ "version": "1.5.0",
4
+ "description": "Smyth Runtime Environment",
5
+ "author": "Alaa-eddine KADDOURI",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "types": "dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/types/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "type": "module",
19
+ "scripts": {
20
+ "gen:barrel": "ctix build",
21
+ "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
22
+ "build:jsbundle": "cross-env rollup -c",
23
+ "build": "pnpm run build:jsbundle && pnpm run build:types",
24
+ "doc:gen": "typedoc",
25
+ "doc:graphgen": "npx depcruise src --config ./doc/.dep-minimal.json --output-type dot > ./doc/dep-graph.dot && dot -Tpng ./doc/dep-graph.dot -o ./doc/dep-graph.png",
26
+ "knip": "knip"
27
+ },
28
+ "devDependencies": {
29
+ "@faker-js/faker": "^8.4.1",
30
+ "@istanbuljs/nyc-config-typescript": "^1.0.2",
31
+ "@rollup/plugin-json": "^6.1.0",
32
+ "@rollup/plugin-node-resolve": "^15.2.3",
33
+ "@rollup/pluginutils": "^5.1.0",
34
+ "@types/cookie-parser": "^1.4.7",
35
+ "@types/express": "^4.17.23",
36
+ "@types/express-session": "^1.18.0",
37
+ "@types/lodash": "^4.17.10",
38
+ "@types/node": "^20.19.0",
39
+ "cross-env": "^7.0.3",
40
+ "ctix": "^2.7.1",
41
+ "dependency-cruiser": "^16.3.3",
42
+ "esbuild": "^0.25.0",
43
+ "knip": "^5.23.1",
44
+ "nyc": "^17.0.0",
45
+ "pkg": "^5.8.1",
46
+ "rollup-plugin-copy": "^3.5.0",
47
+ "rollup-plugin-esbuild": "^6.1.1",
48
+ "rollup-plugin-sourcemaps": "^0.6.3",
49
+ "rollup-plugin-terser": "^7.0.2",
50
+ "rollup-plugin-typescript-paths": "^1.5.0",
51
+ "rollup-plugin-typescript2": "^0.36.0",
52
+ "source-map-support": "^0.5.21",
53
+ "typedoc": "^0.28.5",
54
+ "typedoc-github-theme": "^0.3.0",
55
+ "typescript": "^5.4.5"
56
+ },
57
+ "dependencies": {
58
+ "@anthropic-ai/sdk": "^0.39.0",
59
+ "@apidevtools/json-schema-ref-parser": "^11.6.4",
60
+ "@aws-sdk/client-bedrock-runtime": "^3.826.0",
61
+ "@aws-sdk/client-iam": "^3.826.0",
62
+ "@aws-sdk/client-lambda": "^3.826.0",
63
+ "@aws-sdk/client-s3": "^3.826.0",
64
+ "@aws-sdk/client-secrets-manager": "^3.826.0",
65
+ "@google-cloud/vertexai": "^1.7.0",
66
+ "@google/generative-ai": "^0.14.1",
67
+ "@huggingface/inference": "^2.8.0",
68
+ "@modelcontextprotocol/sdk": "^1.10.1",
69
+ "@pinecone-database/pinecone": "^3.0.0",
70
+ "@runware/sdk-js": "^1.1.36",
71
+ "@smithy/smithy-client": "^4.4.3",
72
+ "@zilliz/milvus2-sdk-node": "^2.5.11",
73
+ "acorn": "^8.14.1",
74
+ "axios": "^1.7.2",
75
+ "chokidar": "^4.0.3",
76
+ "commander": "^11.1.0",
77
+ "cookie-parser": "^1.4.7",
78
+ "cors": "^2.8.5",
79
+ "dayjs": "^1.11.11",
80
+ "dotenv": "^16.4.5",
81
+ "eventsource": "^3.0.2",
82
+ "express": "^4.21.2",
83
+ "express-async-handler": "^1.2.0",
84
+ "express-session": "^1.18.1",
85
+ "file-type": "^19.0.0",
86
+ "form-data": "^4.0.3",
87
+ "gpt-tokenizer": "^2.2.1",
88
+ "groq-sdk": "^0.6.1",
89
+ "image-size": "^1.1.1",
90
+ "ioredis": "^5.4.1",
91
+ "isbinaryfile": "^5.0.2",
92
+ "joi": "^17.13.1",
93
+ "js-yaml": "^4.1.0",
94
+ "jsonrepair": "^3.8.0",
95
+ "jsonwebtoken": "^9.0.2",
96
+ "jwks-rsa": "^3.1.0",
97
+ "lodash": "^4.17.21",
98
+ "memorystore": "^1.6.7",
99
+ "mime": "^4.0.3",
100
+ "multer": "^1.4.5-lts.1",
101
+ "mysql2": "^3.11.3",
102
+ "oauth-1.0a": "^2.2.6",
103
+ "openai": "^4.103.0",
104
+ "p-limit": "^6.1.0",
105
+ "pkce-challenge": "^5.0.0",
106
+ "qs": "^6.13.0",
107
+ "rate-limiter-flexible": "^5.0.3",
108
+ "readline-sync": "^1.4.10",
109
+ "socket.io-client": "^4.8.1",
110
+ "socks-proxy-agent": "^8.0.4",
111
+ "uuid": "^10.0.0",
112
+ "winston": "^3.13.0",
113
+ "winston-transport": "^4.7.0",
114
+ "xxhashjs": "^0.2.2",
115
+ "zip-lib": "^1.0.5"
116
+ }
117
+ }