@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,68 @@
1
+ import EventEmitter from 'events';
2
+ import Anthropic from '@anthropic-ai/sdk';
3
+ import { TLLMParams, ToolData, TLLMMessageBlock, TLLMToolResultMessageBlock, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse, TAnthropicRequestBody } from '@sre/types/LLM.types';
4
+ import { LLMConnector } from '../LLMConnector';
5
+ export declare class AnthropicConnector extends LLMConnector {
6
+ name: string;
7
+ private validImageMimeTypes;
8
+ private getClient;
9
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
10
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
11
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
12
+ protected reqBodyAdapter(params: TLLMParams): Promise<TAnthropicRequestBody>;
13
+ protected reportUsage(usage: Anthropic.Messages.Usage & {
14
+ cache_creation_input_tokens?: number;
15
+ cache_read_input_tokens?: number;
16
+ }, metadata: {
17
+ modelEntryName: string;
18
+ keySource: APIKeySource;
19
+ agentId: string;
20
+ teamId: string;
21
+ }): {
22
+ sourceId: string;
23
+ input_tokens: number;
24
+ output_tokens: number;
25
+ input_tokens_cache_write: number;
26
+ input_tokens_cache_read: number;
27
+ keySource: APIKeySource;
28
+ agentId: string;
29
+ teamId: string;
30
+ };
31
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
32
+ type?: string;
33
+ toolDefinitions: any;
34
+ toolChoice?: string;
35
+ }): {
36
+ tools: {
37
+ name: string;
38
+ description: string;
39
+ input_schema: {
40
+ type: "object";
41
+ properties: Record<string, unknown>;
42
+ required: string[];
43
+ };
44
+ }[];
45
+ } | {
46
+ tools?: undefined;
47
+ };
48
+ transformToolMessageBlocks({ messageBlock, toolsData, }: {
49
+ messageBlock: TLLMMessageBlock & {
50
+ thinkingBlocks?: {
51
+ type: string;
52
+ thinking: string;
53
+ }[];
54
+ };
55
+ toolsData: ToolData[];
56
+ }): TLLMToolResultMessageBlock[];
57
+ getConsistentMessages(messages: any): any;
58
+ private prepareBody;
59
+ private prepareBodyForThinkingRequest;
60
+ private prepareMessages;
61
+ private prepareSystemPrompt;
62
+ /**
63
+ * Determines if thinking mode should be used based on model capabilities and parameters.
64
+ */
65
+ private shouldUseThinkingMode;
66
+ private getValidImageFiles;
67
+ private getImageData;
68
+ }
@@ -0,0 +1,46 @@
1
+ import { ConverseCommandInput, TokenUsage } from '@aws-sdk/client-bedrock-runtime';
2
+ import EventEmitter from 'events';
3
+ import { TLLMParams, ToolData, TLLMMessageBlock, TLLMToolResultMessageBlock, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse } from '@sre/types/LLM.types';
4
+ import { LLMConnector } from '../LLMConnector';
5
+ export declare class BedrockConnector extends LLMConnector {
6
+ name: string;
7
+ private getClient;
8
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
9
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
10
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
11
+ protected reqBodyAdapter(params: TLLMParams): Promise<ConverseCommandInput>;
12
+ protected reportUsage(usage: TokenUsage & {
13
+ cacheReadInputTokenCount: number;
14
+ cacheWriteInputTokenCount: number;
15
+ }, metadata: {
16
+ modelEntryName: string;
17
+ keySource: APIKeySource;
18
+ agentId: string;
19
+ teamId: string;
20
+ }): {
21
+ sourceId: string;
22
+ input_tokens: number;
23
+ output_tokens: number;
24
+ input_tokens_cache_write: number;
25
+ input_tokens_cache_read: number;
26
+ keySource: APIKeySource;
27
+ agentId: string;
28
+ teamId: string;
29
+ };
30
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
31
+ type?: string;
32
+ toolDefinitions: any;
33
+ toolChoice?: string;
34
+ }): {
35
+ tools: any[];
36
+ toolChoice: string;
37
+ } | {
38
+ tools?: undefined;
39
+ toolChoice?: undefined;
40
+ };
41
+ transformToolMessageBlocks({ messageBlock, toolsData, }: {
42
+ messageBlock: TLLMMessageBlock;
43
+ toolsData: ToolData[];
44
+ }): TLLMToolResultMessageBlock[];
45
+ getConsistentMessages(messages: TLLMMessageBlock[]): TLLMMessageBlock[];
46
+ }
@@ -0,0 +1,18 @@
1
+ import { LLMConnector } from '../LLMConnector';
2
+ import EventEmitter from 'events';
3
+ import { APIKeySource, ILLMRequestFuncParams, TLLMChatResponse, TLLMParams } from '@sre/types/LLM.types';
4
+ export declare class EchoConnector extends LLMConnector {
5
+ name: string;
6
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
7
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
8
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
9
+ protected reqBodyAdapter(params: TLLMParams): Promise<any>;
10
+ enhancePrompt(prompt: string, config: any): string;
11
+ postProcess(response: any): any;
12
+ protected reportUsage(usage: any, metadata: {
13
+ modelEntryName: string;
14
+ keySource: APIKeySource;
15
+ agentId: string;
16
+ teamId: string;
17
+ }): void;
18
+ }
@@ -0,0 +1,57 @@
1
+ import EventEmitter from 'events';
2
+ import { UsageMetadata } from '@google/generative-ai';
3
+ import { TLLMMessageBlock, ToolData, TLLMToolResultMessageBlock, APIKeySource, TLLMParams, ILLMRequestFuncParams, TLLMChatResponse, TGoogleAIRequestBody } from '@sre/types/LLM.types';
4
+ import { LLMConnector } from '../LLMConnector';
5
+ type UsageMetadataWithThoughtsToken = UsageMetadata & {
6
+ thoughtsTokenCount: number;
7
+ };
8
+ export declare class GoogleAIConnector extends LLMConnector {
9
+ name: string;
10
+ private validMimeTypes;
11
+ private getClient;
12
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
13
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
14
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<any>;
15
+ protected reqBodyAdapter(params: TLLMParams): Promise<TGoogleAIRequestBody>;
16
+ protected reportUsage(usage: UsageMetadataWithThoughtsToken, metadata: {
17
+ modelEntryName: string;
18
+ keySource: APIKeySource;
19
+ agentId: string;
20
+ teamId: string;
21
+ }): {
22
+ sourceId: string;
23
+ input_tokens: any;
24
+ output_tokens: number;
25
+ input_tokens_audio: any;
26
+ input_tokens_cache_read: number;
27
+ input_tokens_cache_write: number;
28
+ reasoning_tokens: number;
29
+ keySource: APIKeySource;
30
+ agentId: string;
31
+ teamId: string;
32
+ tier: string;
33
+ };
34
+ formatToolsConfig({ toolDefinitions, toolChoice }: {
35
+ toolDefinitions: any;
36
+ toolChoice?: string;
37
+ }): {
38
+ tools: any;
39
+ toolChoice: {
40
+ type: string;
41
+ };
42
+ };
43
+ transformToolMessageBlocks({ messageBlock, toolsData, }: {
44
+ messageBlock: TLLMMessageBlock;
45
+ toolsData: ToolData[];
46
+ }): TLLMToolResultMessageBlock[];
47
+ getConsistentMessages(messages: TLLMMessageBlock[]): TLLMMessageBlock[];
48
+ private prepareMessages;
49
+ private prepareMessagesWithFiles;
50
+ private prepareMessagesWithTools;
51
+ private prepareMessagesWithTextQuery;
52
+ private sanitizeFunctionName;
53
+ private uploadFile;
54
+ private getValidFiles;
55
+ private getFileData;
56
+ }
57
+ export {};
@@ -0,0 +1,55 @@
1
+ import Groq from 'groq-sdk';
2
+ import EventEmitter from 'events';
3
+ import { TLLMMessageBlock, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse, TLLMParams } from '@sre/types/LLM.types';
4
+ import { LLMConnector } from '../LLMConnector';
5
+ type ChatCompletionCreateParams = {
6
+ model: string;
7
+ messages: any;
8
+ max_tokens?: number;
9
+ temperature?: number;
10
+ stop?: string[];
11
+ top_p?: number;
12
+ tools?: any;
13
+ tool_choice?: string;
14
+ stream?: boolean;
15
+ };
16
+ export declare class GroqConnector extends LLMConnector {
17
+ name: string;
18
+ private getClient;
19
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
20
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
21
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
22
+ protected reqBodyAdapter(params: TLLMParams): Promise<ChatCompletionCreateParams>;
23
+ protected reportUsage(usage: Groq.Completions.CompletionUsage & {
24
+ prompt_tokens_details?: {
25
+ cached_tokens?: number;
26
+ };
27
+ }, metadata: {
28
+ modelEntryName: string;
29
+ keySource: APIKeySource;
30
+ agentId: string;
31
+ teamId: string;
32
+ }): {
33
+ sourceId: string;
34
+ input_tokens: number;
35
+ output_tokens: number;
36
+ input_tokens_cache_write: number;
37
+ input_tokens_cache_read: number;
38
+ keySource: APIKeySource;
39
+ agentId: string;
40
+ teamId: string;
41
+ };
42
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
43
+ type?: string;
44
+ toolDefinitions: any;
45
+ toolChoice?: string;
46
+ }): {
47
+ tools: any[];
48
+ tool_choice: string;
49
+ } | {
50
+ tools?: undefined;
51
+ tool_choice?: undefined;
52
+ };
53
+ getConsistentMessages(messages: TLLMMessageBlock[]): TLLMMessageBlock[];
54
+ }
55
+ export {};
@@ -0,0 +1,92 @@
1
+ import EventEmitter from 'events';
2
+ import OpenAI from 'openai';
3
+ import { TLLMParams, ToolData, TLLMMessageBlock, TLLMToolResultMessageBlock, TLLMMessageRole, APIKeySource, ILLMRequestFuncParams, TOpenAIRequestBody, TLLMChatResponse } from '@sre/types/LLM.types';
4
+ import { LLMConnector } from '../LLMConnector';
5
+ export declare class OpenAIConnector extends LLMConnector {
6
+ name: string;
7
+ private validImageMimeTypes;
8
+ private validDocumentMimeTypes;
9
+ private getClient;
10
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
11
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
12
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
13
+ protected imageGenRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<OpenAI.ImagesResponse>;
14
+ protected imageEditRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<OpenAI.ImagesResponse>;
15
+ private processImageData;
16
+ private getValidDocumentFiles;
17
+ private processDocumentData;
18
+ protected reqBodyAdapter(params: TLLMParams): Promise<TOpenAIRequestBody>;
19
+ protected reportUsage(usage: OpenAI.Completions.CompletionUsage & {
20
+ input_tokens?: number;
21
+ output_tokens?: number;
22
+ input_tokens_details?: {
23
+ cached_tokens?: number;
24
+ };
25
+ prompt_tokens_details?: {
26
+ cached_tokens?: number;
27
+ };
28
+ cost?: number;
29
+ }, metadata: {
30
+ modelEntryName: string;
31
+ keySource: APIKeySource;
32
+ agentId: string;
33
+ teamId: string;
34
+ }): {
35
+ sourceId: string;
36
+ input_tokens: number;
37
+ output_tokens: number;
38
+ input_tokens_cache_write: number;
39
+ input_tokens_cache_read: number;
40
+ cost: number;
41
+ keySource: APIKeySource;
42
+ agentId: string;
43
+ teamId: string;
44
+ };
45
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
46
+ type?: string;
47
+ toolDefinitions: any;
48
+ toolChoice?: string;
49
+ }): {
50
+ tools: OpenAI.Chat.Completions.ChatCompletionTool[];
51
+ tool_choice: string;
52
+ } | {
53
+ tools?: undefined;
54
+ tool_choice?: undefined;
55
+ };
56
+ transformToolMessageBlocks({ messageBlock, toolsData, }: {
57
+ messageBlock: TLLMMessageBlock;
58
+ toolsData: ToolData[];
59
+ }): TLLMToolResultMessageBlock[];
60
+ getConsistentMessages(messages: any): {
61
+ role: TLLMMessageRole;
62
+ content?: string | {
63
+ text: string;
64
+ }[] | Array<import("@anthropic-ai/sdk/resources").TextBlockParam | import("@anthropic-ai/sdk/resources").ImageBlockParam | import("@anthropic-ai/sdk/resources").ToolUseBlockParam | import("@anthropic-ai/sdk/resources").ToolResultBlockParam>;
65
+ parts?: {
66
+ text?: string;
67
+ functionCall?: {
68
+ name: string;
69
+ args: string;
70
+ };
71
+ functionResponse?: {
72
+ name: string;
73
+ response: {
74
+ name: string;
75
+ content: string;
76
+ };
77
+ };
78
+ }[];
79
+ tool_calls?: ToolData[];
80
+ }[];
81
+ private getValidImageFiles;
82
+ private getImageData;
83
+ private getDocumentData;
84
+ private getWebSearchTool;
85
+ private validateTokenLimit;
86
+ private getProvider;
87
+ private prepareBodyForWebSearchRequest;
88
+ private prepareBodyForImageGenRequest;
89
+ private prepareBodyForImageEditRequest;
90
+ private prepareBody;
91
+ private prepareMessages;
92
+ }
@@ -0,0 +1,86 @@
1
+ import EventEmitter from 'events';
2
+ import { TLLMParams, ToolData, TLLMMessageBlock, TLLMToolResultMessageBlock, TLLMMessageRole, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse } from '@sre/types/LLM.types';
3
+ import { LLMConnector } from '../LLMConnector';
4
+ type ChatCompletionParams = {
5
+ model: string;
6
+ messages: any[];
7
+ max_tokens?: number;
8
+ temperature?: number;
9
+ top_p?: number;
10
+ top_k?: number;
11
+ frequency_penalty?: number;
12
+ presence_penalty?: number;
13
+ response_format?: {
14
+ type: string;
15
+ };
16
+ };
17
+ type TUsage = {
18
+ prompt_tokens: number;
19
+ completion_tokens: number;
20
+ total_tokens: number;
21
+ prompt_tokens_details?: {
22
+ cached_tokens?: number;
23
+ };
24
+ reasoning_tokens?: number;
25
+ };
26
+ export declare class PerplexityConnector extends LLMConnector {
27
+ name: string;
28
+ private getClient;
29
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
30
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
31
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
32
+ protected reqBodyAdapter(params: TLLMParams): Promise<ChatCompletionParams>;
33
+ protected reportUsage(usage: TUsage, metadata: {
34
+ modelEntryName: string;
35
+ keySource: APIKeySource;
36
+ agentId: string;
37
+ teamId: string;
38
+ }): {
39
+ sourceId: string;
40
+ input_tokens: number;
41
+ output_tokens: number;
42
+ input_tokens_cache_write: number;
43
+ input_tokens_cache_read: number;
44
+ reasoning_tokens: number;
45
+ keySource: APIKeySource;
46
+ agentId: string;
47
+ teamId: string;
48
+ };
49
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
50
+ type?: string;
51
+ toolDefinitions: any;
52
+ toolChoice?: string;
53
+ }): {
54
+ tools: any[];
55
+ tool_choice: string;
56
+ } | {
57
+ tools?: undefined;
58
+ tool_choice?: undefined;
59
+ };
60
+ transformToolMessageBlocks({ messageBlock, toolsData, }: {
61
+ messageBlock: TLLMMessageBlock;
62
+ toolsData: ToolData[];
63
+ }): TLLMToolResultMessageBlock[];
64
+ getConsistentMessages(messages: any): {
65
+ role: TLLMMessageRole;
66
+ content?: string | {
67
+ text: string;
68
+ }[] | Array<import("@anthropic-ai/sdk/resources").TextBlockParam | import("@anthropic-ai/sdk/resources").ImageBlockParam | import("@anthropic-ai/sdk/resources").ToolUseBlockParam | import("@anthropic-ai/sdk/resources").ToolResultBlockParam>;
69
+ parts?: {
70
+ text?: string;
71
+ functionCall?: {
72
+ name: string;
73
+ args: string;
74
+ };
75
+ functionResponse?: {
76
+ name: string;
77
+ response: {
78
+ name: string;
79
+ content: string;
80
+ };
81
+ };
82
+ }[];
83
+ tool_calls?: ToolData[];
84
+ }[];
85
+ }
86
+ export {};
@@ -0,0 +1,38 @@
1
+ import { type UsageMetadata } from '@google-cloud/vertexai';
2
+ import EventEmitter from 'events';
3
+ import { TLLMParams, APIKeySource, ILLMRequestFuncParams, TGoogleAIRequestBody } from '@sre/types/LLM.types';
4
+ import { LLMConnector } from '../LLMConnector';
5
+ export declare class VertexAIConnector extends LLMConnector {
6
+ name: string;
7
+ private getClient;
8
+ protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<any>;
9
+ protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
10
+ protected webSearchRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
11
+ protected reqBodyAdapter(params: TLLMParams): Promise<TGoogleAIRequestBody>;
12
+ protected reportUsage(usage: UsageMetadata & {
13
+ cachedContentTokenCount?: number;
14
+ }, metadata: {
15
+ modelEntryName: string;
16
+ keySource: APIKeySource;
17
+ agentId: string;
18
+ teamId: string;
19
+ }): {
20
+ sourceId: string;
21
+ input_tokens: number;
22
+ output_tokens: number;
23
+ input_tokens_cache_read: number;
24
+ input_tokens_cache_write: number;
25
+ keySource: APIKeySource;
26
+ agentId: string;
27
+ teamId: string;
28
+ };
29
+ formatToolsConfig({ type, toolDefinitions, toolChoice }: {
30
+ type?: string;
31
+ toolDefinitions: any;
32
+ toolChoice?: string;
33
+ }): void;
34
+ getConsistentMessages(messages: any): {
35
+ role: import("@sre/types/LLM.types").TLLMMessageRole;
36
+ parts: any[];
37
+ }[];
38
+ }
@@ -0,0 +1,5 @@
1
+ import { ConnectorServiceProvider } from '@sre/Core/ConnectorsService';
2
+ export declare class LLMService extends ConnectorServiceProvider {
3
+ register(): void;
4
+ init(): void;
5
+ }
@@ -0,0 +1,36 @@
1
+ import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
2
+ import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
3
+ import { ACL } from '@sre/Security/AccessControl/ACL.class';
4
+ import { SecureConnector } from '@sre/Security/SecureConnector.class';
5
+ import { IAccessCandidate } from '@sre/types/ACL.types';
6
+ import { TCustomLLMModel, TLLMModel, TLLMModelsList } from '@sre/types/LLM.types';
7
+ import { LocalCache } from '@sre/helpers/LocalCache.helper';
8
+ export interface IModelsProviderRequest {
9
+ getModels(): Promise<any>;
10
+ getMaxContextTokens(model: string, hasAPIKey?: boolean): Promise<number>;
11
+ addModels(models: TLLMModelsList): Promise<void>;
12
+ getModelInfo(model: string | TLLMModel | TCustomLLMModel, hasAPIKey?: boolean): Promise<TLLMModel>;
13
+ getModelId(model: string | TLLMModel | TCustomLLMModel): Promise<string>;
14
+ getProvider(model: string | TLLMModel | TCustomLLMModel): Promise<string>;
15
+ isStandardLLM(model: string | TLLMModel | TCustomLLMModel): Promise<boolean>;
16
+ adjustMaxCompletionTokens(model: string | TLLMModel | TCustomLLMModel, maxCompletionTokens: number, hasAPIKey?: boolean): Promise<number>;
17
+ getMaxContextTokens(model: string | TLLMModel | TCustomLLMModel, hasAPIKey?: boolean): Promise<number>;
18
+ getMaxCompletionTokens(model: string | TLLMModel | TCustomLLMModel, hasAPIKey?: boolean): Promise<number>;
19
+ validateTokensLimit({ model, promptTokens, completionTokens, hasAPIKey, }: {
20
+ model: string | TLLMModel | TCustomLLMModel;
21
+ promptTokens: number;
22
+ completionTokens: number;
23
+ hasAPIKey?: boolean;
24
+ }): Promise<void>;
25
+ }
26
+ export declare abstract class ModelsProviderConnector extends SecureConnector {
27
+ protected static localCache: LocalCache<unknown, unknown>;
28
+ abstract getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
29
+ abstract getModels(acRequest: AccessRequest): Promise<TLLMModelsList>;
30
+ abstract addModels(acRequest: AccessRequest, models: TLLMModelsList): Promise<void>;
31
+ requester(candidate: AccessCandidate): IModelsProviderRequest;
32
+ protected getModelInfo(acRequest: AccessRequest, models: TLLMModelsList, model: string | TLLMModel | TCustomLLMModel, hasAPIKey?: boolean): Promise<TLLMModel>;
33
+ protected getModelId(acRequest: AccessRequest, models: TLLMModelsList, model: string | TLLMModel | TCustomLLMModel): Promise<string>;
34
+ protected getProvider(acRequest: AccessRequest, models: TLLMModelsList, model: string | TLLMModel | TCustomLLMModel): Promise<string>;
35
+ protected getCustomModels(candidate: IAccessCandidate): Promise<Record<string, any>>;
36
+ }
@@ -0,0 +1,39 @@
1
+ import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
2
+ import { ModelsProviderConnector } from '../ModelsProviderConnector';
3
+ import { IAccessCandidate } from '@sre/types/ACL.types';
4
+ import { ACL } from '@sre/Security/AccessControl/ACL.class';
5
+ import { TLLMModelsList } from '@sre/types/LLM.types';
6
+ type SmythModelsProviderConfig = {
7
+ /**
8
+ * The models to be used.
9
+ *
10
+ * If a string is provided, it will be used as the directory name to load the models from.
11
+ * If a TLLMModelsList is provided, it will be used as the models to be used.
12
+ *
13
+ */
14
+ models?: string | TLLMModelsList;
15
+ /**
16
+ * The mode to be used.
17
+ *
18
+ * If 'append' is used, the models will be appended to the existing models.
19
+ * If 'replace' is used, the existing models will be replaced with the new models.
20
+ */
21
+ mode?: 'merge' | 'replace';
22
+ };
23
+ export declare class SmythModelsProvider extends ModelsProviderConnector {
24
+ protected _settings?: SmythModelsProviderConfig;
25
+ name: string;
26
+ private models;
27
+ constructor(_settings?: SmythModelsProviderConfig);
28
+ start(): Promise<void>;
29
+ addModels(acRequest: AccessRequest, models: TLLMModelsList): Promise<void>;
30
+ getModels(acRequest: AccessRequest): Promise<any>;
31
+ getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
32
+ private reindexModels;
33
+ private scanDirectoryForModels;
34
+ private getValidModels;
35
+ private isValidSingleModel;
36
+ private isValidModel;
37
+ private initDirWatcher;
38
+ }
39
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ConnectorServiceProvider } from '@sre/Core/ConnectorsService';
2
+ export declare class ModelsProviderService extends ConnectorServiceProvider {
3
+ register(): void;
4
+ }