@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
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # Smyth Runtime Environment (SRE) Core
2
+
3
+ This package contains the **Smyth Runtime Environment (SRE)**, the core of SmythOS. It is responsible for low-level agent orchestration, secure resource management, and providing the foundational services upon which all higher-level agent functionalities are built.
4
+
5
+ This document provides a technical deep-dive into the SRE's architecture, you only need to read this if you are interested in the internals of SmythOS or if you are planning to [contribute](../../CONTRIBUTING.md) to the SmythOS codebase.
6
+ For building applications and agents on top of SmythOS, please refer to the developer-friendly **[@smythos/sdk](../sdk)** package.
7
+
8
+ ---
9
+
10
+ ## 🏗️ Core Architecture
11
+
12
+ SRE is designed with a philosophy inspired by operating system kernels, establishing a clear separation between the core runtime and the pluggable **Connectors** that interface with external services and infrastructure.
13
+
14
+ ### The SRE Lifecycle & Initialization
15
+
16
+ The SRE is a singleton that gets initialized via the `SRE.init()` method. This critical step bootstraps the entire environment based on the provided configuration. The `sre.ready()` method then ensures all configured connectors are initialized and operational.
17
+
18
+ An SRE initialization looks like this:
19
+
20
+ ```typescript
21
+ import { SRE } from '@smythos/sre';
22
+
23
+ // 1. SRE.init() loads the configuration for each subsystem
24
+ const sre = SRE.init({
25
+ Vault: { Connector: 'JSONFileVault', Settings: { file: 'vault.json' } },
26
+ Cache: { Connector: 'RAM' },
27
+ Storage: { Connector: 'Local' },
28
+ Log: { Connector: 'ConsoleLog' },
29
+ });
30
+
31
+ // 2. sre.ready() asynchronously initializes all configured connectors
32
+ await sre.ready();
33
+
34
+ console.log('SRE is operational.');
35
+ ```
36
+
37
+ ### 🛡️ Security Model: The Candidate & ACL System
38
+
39
+ Security is a foundational, non-negotiable aspect of SRE. Every operation that accesses a resource is governed by the **Candidate/ACL system**. An **Access Candidate** is an object representing the entity (e.g., an agent, a user, an internal process) requesting access.
40
+
41
+ Connectors use the candidate to scope and isolate resources, preventing data leakage between tenants.
42
+
43
+ ```typescript
44
+ // Internally, when an agent requests a resource, this happens:
45
+
46
+ // 1. An Access Candidate is created for the specific agent
47
+ const candidate = AccessCandidate.agent(agentId);
48
+
49
+ // 2. A handle to the underlying storage connector is retrieved
50
+ const storageConnector = ConnectorService.getStorageConnector();
51
+
52
+ // 3. The connector is scoped to the candidate's context
53
+ // The resulting `storage` object is now a sandboxed view for that agent
54
+ const storage = storageConnector.user(candidate);
55
+
56
+ // 4. This write operation is now isolated. Another agent writing to 'data.json'
57
+ // will write to a completely different, isolated location.
58
+ await storage.write('data.json', content);
59
+ ```
60
+
61
+ This design ensures that multi-tenancy and security are enforced at the lowest level of the runtime.
62
+
63
+ ### Subsystem Deep Dive
64
+
65
+ SRE's functionality is partitioned into several discrete subsystems.
66
+
67
+ #### 🤖 Agent Manager
68
+
69
+ The heart of agent execution. It manages the entire agent lifecycle (start, stop, pause), monitors performance, and orchestrates the complex workflows defined within an agent's components.
70
+
71
+ #### 💾 Memory Manager
72
+
73
+ Provides intelligent state and context management for agents. It includes:
74
+
75
+ - **Cache Service**: A multi-tiered caching system (RAM, Redis) for fast data retrieval.
76
+ - **Runtime Context**: Manages an agent's state during execution.
77
+ - **LLM Context**: Manages conversation history and context windows for LLMs.
78
+
79
+ #### 🛡️ Security Manager
80
+
81
+ Handles all security-related primitives.
82
+
83
+ - **Vault Service**: Provides a secure connector-based interface for storing and retrieving secrets (e.g., from HashiCorp Vault, AWS Secrets Manager, or a local JSON file).
84
+ - **Account Management**: Manages identity and authentication.
85
+ - **Access Control**: Implements the granular Candidate/ACL permission system.
86
+
87
+ #### 📥 IO Subsystem
88
+
89
+ The gateway to the outside world. It provides a set of unified connector interfaces for all input/output operations.
90
+
91
+ | Service | Purpose | Example Connectors |
92
+ | ------------ | -------------------------- | -------------------- |
93
+ | **Storage** | File & data persistence | `Local`, `S3` |
94
+ | **VectorDB** | Vector storage & retrieval | `Pinecone`, `Chroma` |
95
+ | **Log** | Activity & debug logging | `Console` |
96
+ | **NKV** | Key-value storage | `Redis`, `RAM` |
97
+
98
+ #### 🧠 LLM Manager
99
+
100
+ A powerful abstraction layer for over 8 different LLM providers. It handles API variations between providers and offers features like smart inference, response caching, and unified usage tracking.
101
+
102
+ ---
103
+
104
+ <details>
105
+ <summary>💻 Code Standards & Best Practices</summary>
106
+
107
+ ### Folder Structure
108
+
109
+ - **/subsystems**: Contains the core service definitions and connector interfaces for all major subsystems (IO, AgentManager, MemoryManager, etc.).
110
+ - **/Components**: SmythOS Agent Components.
111
+ - **/utils**: Contains utility functions. Functions in this folder should not depend on other packages of the project outside of /utils/\*. These functions are reusable throughout the code.
112
+ - **/helpers**: Contains general helper classes/objects/structures. Unlike utils, helpers export an object that exposes a collection of functions specific to a given task.
113
+ - **/types**: This folder contains SmythOS-specific type declarations.
114
+
115
+ ### Naming Standards
116
+
117
+ #### File Naming
118
+
119
+ Use the following extensions for specific code roles to maintain consistency across the codebase:
120
+
121
+ - `.service.ts` for top-level services
122
+ - `.class.ts` for classes and connectors
123
+ - `.utils.ts` for utility collections
124
+ - `.helper.ts` for task-specific helpers
125
+ - `.handler.ts` for event handlers
126
+ - `.mw.ts` for middlewares
127
+
128
+ #### Declaration Naming
129
+
130
+ - **Constants**: Uppercase with underscores (e.g., `MAX_RETRIES`).
131
+ - **Enums and Types**: Start with `T` (e.g., `TAccessLevel`).
132
+ - **Interfaces**: Start with `I` (e.g., `IStorageConnector`).
133
+ - **Classes**: Use PascalCase without a prefix (e.g., `MyAgent`).
134
+
135
+ </details>