@smythos/sre 1.7.20 → 1.7.41

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 (78) hide show
  1. package/dist/index.js +134 -89
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/Components/AgentPlugin.class.d.ts +1 -1
  4. package/dist/types/Components/DataSourceIndexer.class.d.ts +4 -12
  5. package/dist/types/Components/GenAILLM.class.d.ts +5 -5
  6. package/dist/types/Components/RAG/DataSourceCleaner.class.d.ts +4 -4
  7. package/dist/types/Components/RAG/DataSourceComponent.class.d.ts +5 -1
  8. package/dist/types/Components/index.d.ts +3 -3
  9. package/dist/types/config.d.ts +1 -0
  10. package/dist/types/helpers/Conversation.helper.d.ts +10 -13
  11. package/dist/types/helpers/TemplateString.helper.d.ts +1 -1
  12. package/dist/types/index.d.ts +4 -3
  13. package/dist/types/subsystems/IO/VectorDB.service/VectorDBConnector.d.ts +1 -0
  14. package/dist/types/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.d.ts +1 -0
  15. package/dist/types/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.d.ts +11 -4
  16. package/dist/types/subsystems/IO/VectorDB.service/embed/index.d.ts +5 -0
  17. package/dist/types/subsystems/LLMManager/LLM.helper.d.ts +19 -0
  18. package/dist/types/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.d.ts +15 -10
  19. package/dist/types/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.d.ts +35 -0
  20. package/dist/types/subsystems/Security/Account.service/AccountConnector.d.ts +2 -2
  21. package/dist/types/subsystems/Security/Vault.service/connectors/SecretsManager.class.d.ts +2 -3
  22. package/dist/types/types/LLM.types.d.ts +23 -0
  23. package/dist/types/types/VectorDB.types.d.ts +4 -0
  24. package/dist/types/utils/string.utils.d.ts +1 -0
  25. package/package.json +3 -3
  26. package/src/Components/APIEndpoint.class.ts +1 -6
  27. package/src/Components/AgentPlugin.class.ts +20 -3
  28. package/src/Components/Classifier.class.ts +79 -16
  29. package/src/Components/Component.class.ts +14 -1
  30. package/src/Components/ForEach.class.ts +34 -6
  31. package/src/Components/GenAILLM.class.ts +75 -34
  32. package/src/Components/LLMAssistant.class.ts +56 -21
  33. package/src/Components/RAG/DataSourceCleaner.class.ts +180 -0
  34. package/src/Components/RAG/DataSourceComponent.class.ts +137 -0
  35. package/src/Components/RAG/DataSourceIndexer.class.ts +260 -0
  36. package/src/Components/{DataSourceLookup.class.ts → RAG/DataSourceLookup.class.ts} +96 -3
  37. package/src/Components/ScrapflyWebScrape.class.ts +7 -0
  38. package/src/Components/ServerlessCode.class.ts +1 -4
  39. package/src/Components/index.ts +3 -3
  40. package/src/config.ts +1 -0
  41. package/src/helpers/Conversation.helper.ts +112 -26
  42. package/src/helpers/S3Cache.helper.ts +2 -1
  43. package/src/helpers/TemplateString.helper.ts +6 -5
  44. package/src/index.ts +213 -212
  45. package/src/index.ts.bak +213 -212
  46. package/src/subsystems/IO/NKV.service/connectors/NKVRedis.class.ts +3 -1
  47. package/src/subsystems/IO/VectorDB.service/VectorDBConnector.ts +1 -0
  48. package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +145 -19
  49. package/src/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.ts +67 -22
  50. package/src/subsystems/IO/VectorDB.service/embed/GoogleEmbedding.ts +1 -0
  51. package/src/subsystems/IO/VectorDB.service/embed/OpenAIEmbedding.ts +2 -1
  52. package/src/subsystems/IO/VectorDB.service/embed/index.ts +16 -0
  53. package/src/subsystems/LLMManager/LLM.helper.ts +25 -0
  54. package/src/subsystems/LLMManager/LLM.service/LLMConnector.ts +1 -1
  55. package/src/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.ts +35 -10
  56. package/src/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.ts +12 -4
  57. package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +4 -4
  58. package/src/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.ts +192 -139
  59. package/src/subsystems/LLMManager/LLM.service/connectors/Groq.class.ts +17 -5
  60. package/src/subsystems/LLMManager/LLM.service/connectors/Ollama.class.ts +18 -3
  61. package/src/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.ts +14 -5
  62. package/src/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.ts +6 -4
  63. package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts +5 -5
  64. package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +8 -3
  65. package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/utils.ts +1 -1
  66. package/src/subsystems/LLMManager/LLM.service/connectors/xAI.class.ts +9 -8
  67. package/src/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.ts +92 -1
  68. package/src/subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTel.class.ts +260 -17
  69. package/src/subsystems/Security/Account.service/AccountConnector.ts +3 -3
  70. package/src/subsystems/Security/Vault.service/connectors/SecretsManager.class.ts +8 -63
  71. package/src/types/LLM.types.ts +24 -0
  72. package/src/types/VectorDB.types.ts +4 -0
  73. package/src/utils/array.utils.ts +11 -0
  74. package/src/utils/base64.utils.ts +1 -1
  75. package/src/utils/data.utils.ts +6 -4
  76. package/src/utils/string.utils.ts +3 -192
  77. package/src/Components/DataSourceCleaner.class.ts +0 -92
  78. package/src/Components/DataSourceIndexer.class.ts +0 -181
@@ -9,7 +9,7 @@ export declare class AgentPlugin extends Component {
9
9
  _debug: string;
10
10
  Response?: undefined;
11
11
  } | {
12
- Response: string;
12
+ Response: any;
13
13
  _debug: string;
14
14
  _error?: undefined;
15
15
  }>;
@@ -6,18 +6,10 @@ export declare class DataSourceIndexer extends Component {
6
6
  protected configSchema: Joi.ObjectSchema<any>;
7
7
  constructor();
8
8
  init(): void;
9
- process(input: any, config: any, agent: Agent): Promise<{
10
- _debug: string;
11
- Success: {
12
- result: any;
13
- id: any;
14
- };
15
- _error?: undefined;
16
- } | {
17
- _debug: string;
18
- _error: any;
19
- Success?: undefined;
20
- }>;
9
+ process(input: any, config: any, agent: Agent): Promise<any>;
10
+ private processV1;
11
+ private processV2;
12
+ private transformEmbedding;
21
13
  validateInput(input: any): Joi.ValidationResult<any>;
22
14
  private addDSFromText;
23
15
  static genDsId(providedId: string, teamId: string, namespaceId: string): string;
@@ -262,19 +262,19 @@ export declare class GenAILLM extends Component {
262
262
  process(input: any, config: any, agent: Agent): Promise<{
263
263
  Reply: any;
264
264
  } | {
265
- Reply: any;
265
+ Output: any;
266
266
  _error: string;
267
267
  _debug: string;
268
- Output?: undefined;
268
+ Reply?: undefined;
269
269
  } | {
270
- Output: any;
270
+ Reply: any;
271
271
  _error: string;
272
272
  _debug: string;
273
- Reply?: undefined;
273
+ Output?: undefined;
274
274
  } | {
275
275
  _error: any;
276
276
  _debug: string;
277
- Reply?: undefined;
278
277
  Output?: undefined;
278
+ Reply?: undefined;
279
279
  }>;
280
280
  }
@@ -6,13 +6,13 @@ export declare class DataSourceCleaner extends DataSourceComponent {
6
6
  constructor();
7
7
  init(): void;
8
8
  process(input: any, config: any, agent: Agent): Promise<{
9
- _debug: string;
10
- Success: boolean;
11
- _error?: undefined;
12
- } | {
13
9
  _debug: string;
14
10
  _error: any;
15
11
  Success?: undefined;
12
+ } | {
13
+ _debug: string;
14
+ Success: boolean;
15
+ _error?: undefined;
16
16
  }>;
17
17
  processV1(input: any, config: any, agent: Agent): Promise<{
18
18
  _debug: string;
@@ -21,7 +21,11 @@ export declare class DataSourceCompError extends Error {
21
21
  }
22
22
  export declare class DataSourceComponent extends Component {
23
23
  constructor();
24
- resolveVectorDbConnector(namespace: string | NsRecord, teamId: string): Promise<VectorDBConnector>;
24
+ resolveVectorDbConnector(namespace: string | NsRecord, teamId: string): Promise<{
25
+ vecDbConnector: VectorDBConnector;
26
+ namespaceRecord: NsRecord;
27
+ }>;
28
+ private resolveNamespaceRecord;
25
29
  buildEmbeddingConfig(embedding: {
26
30
  dimensions: string;
27
31
  modelId: string;
@@ -8,9 +8,9 @@ import { FSleep } from './FSleep.class';
8
8
  import { FHash } from './FHash.class';
9
9
  import { FEncDec } from './FEncDec.class';
10
10
  import { FTimestamp } from './FTimestamp.class';
11
- import { DataSourceLookup } from './DataSourceLookup.class';
12
- import { DataSourceIndexer } from './DataSourceIndexer.class';
13
- import { DataSourceCleaner } from './DataSourceCleaner.class';
11
+ import { DataSourceLookup } from './RAG/DataSourceLookup.class';
12
+ import { DataSourceIndexer } from './RAG/DataSourceIndexer.class';
13
+ import { DataSourceCleaner } from './RAG/DataSourceCleaner.class';
14
14
  import { JSONFilter } from './JSONFilter.class';
15
15
  import { LogicAND } from './LogicAND.class';
16
16
  import { LogicOR } from './LogicOR.class';
@@ -3,6 +3,7 @@ declare const config: {
3
3
  LOG_LEVEL: string;
4
4
  LOG_FILTER: string;
5
5
  NODE_ENV: string;
6
+ ROLLOUT_RAG_V2: string;
6
7
  };
7
8
  agent: {
8
9
  ENDPOINT_PREFIX: string;
@@ -1,6 +1,6 @@
1
1
  import { LLMInference } from '@sre/LLMManager/LLM.inference';
2
2
  import { LLMContext } from '@sre/MemoryManager/LLMContext';
3
- import { ILLMContextStore, TLLMModel } from '@sre/types/LLM.types';
3
+ import { IConversationSettings, TLLMModel } from '@sre/types/LLM.types';
4
4
  import EventEmitter from 'events';
5
5
  export declare class Conversation extends EventEmitter {
6
6
  private _model;
@@ -30,7 +30,15 @@ export declare class Conversation extends EventEmitter {
30
30
  agentData: any;
31
31
  private _id;
32
32
  get id(): string;
33
+ private _toolCallCount;
34
+ private _maxToolCallsPerSession;
35
+ private _disableToolsForNextCall;
33
36
  get context(): LLMContext;
37
+ get storeId(): string;
38
+ /**
39
+ * Headers to be added to all tool call requests
40
+ */
41
+ headers: Record<string, string>;
34
42
  private _lastError;
35
43
  private _spec;
36
44
  private _customToolsDeclarations;
@@ -41,18 +49,7 @@ export declare class Conversation extends EventEmitter {
41
49
  get model(): string | TLLMModel;
42
50
  private _llmInference;
43
51
  get llmInference(): LLMInference;
44
- constructor(_model: string | TLLMModel, _specSource?: string | Record<string, any>, _settings?: {
45
- maxContextSize?: number;
46
- maxOutputTokens?: number;
47
- systemPrompt?: string;
48
- toolChoice?: string;
49
- store?: ILLMContextStore;
50
- experimentalCache?: boolean;
51
- toolsStrategy?: (toolsConfig: any) => any;
52
- agentId?: string;
53
- agentVersion?: string;
54
- baseUrl?: string;
55
- });
52
+ constructor(_model: string | TLLMModel, _specSource?: string | Record<string, any>, _settings?: IConversationSettings);
56
53
  get ready(): any;
57
54
  prompt(message?: string | any, toolHeaders?: {}, concurrentToolCalls?: number, abortSignal?: AbortSignal): Promise<string>;
58
55
  streamPrompt(message?: string | any, toolHeaders?: {}, concurrentToolCalls?: number, abortSignal?: AbortSignal): Promise<string>;
@@ -33,7 +33,7 @@ export declare class TemplateStringHelper {
33
33
  * unmatched placeholders will be left as is
34
34
  * Recursively resolves nested template variables until no more variables are found
35
35
  */
36
- parse(data: Record<string, string>, regex?: TemplateStringMatch, maxDepth?: number): this;
36
+ parse(data: Record<string, unknown>, regex?: TemplateStringMatch, maxDepth?: number): this;
37
37
  /**
38
38
  * Parses a template string by replacing placeholders with values from the provided data object, keeping the original raw values intact. This is particularly important for BinaryInput instances, as they include buffer data.
39
39
  * unmatched placeholders will be left as is
@@ -9,9 +9,6 @@ export * from './Components/Await.class';
9
9
  export * from './Components/Classifier.class';
10
10
  export * from './Components/Component.class';
11
11
  export * from './Components/ComponentHost.class';
12
- export * from './Components/DataSourceCleaner.class';
13
- export * from './Components/DataSourceIndexer.class';
14
- export * from './Components/DataSourceLookup.class';
15
12
  export * from './Components/FEncDec.class';
16
13
  export * from './Components/FHash.class';
17
14
  export * from './Components/FileStore.class';
@@ -88,6 +85,10 @@ export * from './Components/APICall/parseHeaders';
88
85
  export * from './Components/APICall/parseProxy';
89
86
  export * from './Components/APICall/parseUrl';
90
87
  export * from './Components/Image/imageSettings.config';
88
+ export * from './Components/RAG/DataSourceCleaner.class';
89
+ export * from './Components/RAG/DataSourceComponent.class';
90
+ export * from './Components/RAG/DataSourceIndexer.class';
91
+ export * from './Components/RAG/DataSourceLookup.class';
91
92
  export * from './Components/Triggers/Gmail.trigger';
92
93
  export * from './Components/Triggers/JobScheduler.trigger';
93
94
  export * from './Components/Triggers/Trigger.class';
@@ -22,6 +22,7 @@ export interface IVectorDBRequest {
22
22
  }
23
23
  export declare abstract class VectorDBConnector extends SecureConnector<IVectorDBRequest> {
24
24
  protected readonly USER_METADATA_KEY = "user_metadata";
25
+ protected readonly LEGACY_USER_METADATA_KEY = "metadata";
25
26
  abstract id: string;
26
27
  abstract getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
27
28
  requester(candidate: AccessCandidate): IVectorDBRequest;
@@ -34,6 +34,7 @@ export declare class MilvusVectorDB extends VectorDBConnector {
34
34
  embedder: BaseEmbedding;
35
35
  private SCHEMA_DEFINITION;
36
36
  private INDEX_PARAMS;
37
+ private nkvConnector;
37
38
  constructor(_settings: MilvusConfig);
38
39
  protected createNamespace(acRequest: AccessRequest, namespace: string, metadata?: {
39
40
  [key: string]: any;
@@ -7,13 +7,20 @@ import { DatasourceDto, IStorageVectorDataSource, IVectorDataSourceDto, QueryOpt
7
7
  import { BaseEmbedding, TEmbeddings } from '../embed/BaseEmbedding';
8
8
  export type PineconeConfig = {
9
9
  /**
10
- * The Pinecone API key
10
+ * The Pinecone API key [LEGACY]
11
11
  */
12
- apiKey: string;
12
+ apiKey?: string;
13
13
  /**
14
- * The Pinecone index name
14
+ * The Pinecone index name [LEGACY]
15
15
  */
16
- indexName: string;
16
+ indexName?: string;
17
+ /**
18
+ * The Pinecone credentials [New unified format]
19
+ */
20
+ credentials?: {
21
+ apiKey: string;
22
+ indexName: string;
23
+ };
17
24
  /**
18
25
  * The embeddings model to use
19
26
  */
@@ -20,5 +20,10 @@ export declare class EmbeddingsFactory {
20
20
  static create(provider?: SupportedProviders, config?: TEmbeddings & {
21
21
  model?: SupportedModels[SupportedProviders] | TLLMModel;
22
22
  }): OpenAIEmbeds | GoogleEmbeds;
23
+ static getProviderByModel(model: SupportedModels): SupportedProviders;
24
+ static getModels(): {
25
+ provider: SupportedProviders;
26
+ model: SupportedModels[SupportedProviders];
27
+ }[];
23
28
  }
24
29
  export {};
@@ -133,4 +133,23 @@ export declare class LLMHelper {
133
133
  * @returns {TLLMMessageBlock[]} The modified array of message objects.
134
134
  */
135
135
  static removeDuplicateUserMessages(messages: TLLMMessageBlock[]): TLLMMessageBlock[];
136
+ /**
137
+ * Checks if the given model is part of the Claude 4 family.
138
+ *
139
+ * @param {string} modelId - The model identifier to check.
140
+ * @returns {boolean} True if the model is Claude 4 family, false otherwise.
141
+ *
142
+ * @example
143
+ * const isClaude4 = LLMHelper.isClaude4Family('claude-sonnet-4-20250514');
144
+ * console.log(isClaude4); // true
145
+ *
146
+ * @example
147
+ * const isClaude4 = LLMHelper.isClaude4Family('claude-opus-4-5');
148
+ * console.log(isClaude4); // true
149
+ *
150
+ * @example
151
+ * const isClaude4 = LLMHelper.isClaude4Family('gpt-4-turbo');
152
+ * console.log(isClaude4); // false
153
+ */
154
+ static isClaude4Family(modelId: string): boolean;
136
155
  }
@@ -1,6 +1,6 @@
1
1
  import EventEmitter from 'events';
2
2
  import { type GenerateContentResponseUsageMetadata } from '@google/genai/node';
3
- import { TLLMMessageBlock, ToolData, TLLMToolResultMessageBlock, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse, TGoogleAIRequestBody, ILLMRequestContext, TLLMPreparedParams } from '@sre/types/LLM.types';
3
+ import { TLLMMessageBlock, ToolData, TLLMToolResultMessageBlock, APIKeySource, ILLMRequestFuncParams, TLLMChatResponse, TGoogleAIRequestBody, TLLMPreparedParams } from '@sre/types/LLM.types';
4
4
  import { LLMConnector } from '../LLMConnector';
5
5
  type UsageMetadataWithThoughtsToken = GenerateContentResponseUsageMetadata & {
6
6
  thoughtsTokenCount?: number;
@@ -26,6 +26,7 @@ export declare class GoogleAIConnector extends LLMConnector {
26
26
  sourceId: string;
27
27
  input_tokens: number;
28
28
  output_tokens: number;
29
+ output_tokens_image: number;
29
30
  input_tokens_audio: number;
30
31
  input_tokens_cache_read: number;
31
32
  input_tokens_cache_read_audio: number;
@@ -33,22 +34,26 @@ export declare class GoogleAIConnector extends LLMConnector {
33
34
  keySource: APIKeySource;
34
35
  agentId: string;
35
36
  teamId: string;
36
- inTier: string;
37
- outTier: string;
38
- crTier: string;
37
+ tier: string;
39
38
  };
40
39
  /**
41
40
  * Extract text and image tokens from Google AI usage metadata
42
41
  */
43
42
  private extractTokenCounts;
44
- protected reportImageUsage({ usage, context, numberOfImages, }: {
45
- usage: {
46
- cost?: number;
47
- usageMetadata?: UsageMetadataWithThoughtsToken;
48
- };
49
- context: ILLMRequestContext;
43
+ protected reportImageCost({ cost, context, numberOfImages }: {
44
+ cost: any;
45
+ context: any;
50
46
  numberOfImages?: number;
51
47
  }): void;
48
+ /**
49
+ * Normalizes function response values to ensure they conform to Google AI's STRUCT requirement.
50
+ * Gemini expects functionResponse.response to be a STRUCT (JSON object format), not a list or scalar.
51
+ */
52
+ private normalizeFunctionResponse;
53
+ /**
54
+ * Parses and normalizes function response values, handling string JSON and various data types.
55
+ */
56
+ private parseFunctionResponse;
52
57
  formatToolsConfig({ toolDefinitions, toolChoice }: {
53
58
  toolDefinitions: any;
54
59
  toolChoice?: string;
@@ -35,6 +35,41 @@ export declare class JSONModelsProvider extends ModelsProviderConnector {
35
35
  private getValidModels;
36
36
  private isValidSingleModel;
37
37
  private isValidModel;
38
+ /**
39
+ * Determines whether a file path should be ignored by the directory watcher.
40
+ *
41
+ * This method implements a sophisticated filtering strategy for dot-segment paths
42
+ * (paths containing directories that start with a dot, like .git, .env, .cache).
43
+ *
44
+ * **Filtering Strategy:**
45
+ * 1. Paths WITHOUT dot segments: Never ignored
46
+ * 2. Paths WITH dot segments:
47
+ * - If SMYTH_PATH is not configured: All ignored
48
+ * - If SMYTH_PATH is configured:
49
+ * - Allow the watched directory even if SMYTH_PATH contains dot-segments
50
+ * (e.g., /home/user/.smyth/models/OpenAI/default.json is allowed)
51
+ * - Ignore dot-segments INSIDE the models directory
52
+ * (e.g., /home/user/.smyth/models/.hidden/model.json is ignored)
53
+ * - Paths outside watched directory: Ignored
54
+ *
55
+ * @param filePath - The file path to check
56
+ * @param watchedDir - The absolute path of the directory being watched (models folder)
57
+ * @param smythPath - The resolved SMYTH_PATH, or null if not configured
58
+ * @returns true if the path should be ignored, false if it should be watched
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Path without dot-segment (allowed)
63
+ * shouldIgnorePath('/models/OpenAI/default.json', '/models', '/home/.smyth') // => false
64
+ *
65
+ * // Dot-segment inside models directory (ignored)
66
+ * shouldIgnorePath('/models/.git/config', '/models', '/home/.smyth') // => true
67
+ *
68
+ * // Dot-segment in parent path only (allowed)
69
+ * shouldIgnorePath('/home/.smyth/models/OpenAI/default.json', '/home/.smyth/models', '/home/.smyth') // => false
70
+ * ```
71
+ */
72
+ private shouldIgnorePath;
38
73
  private initDirWatcher;
39
74
  }
40
75
  export {};
@@ -9,7 +9,7 @@ export interface ISmythAccountRequest {
9
9
  getCandidateTeam(): Promise<string | undefined>;
10
10
  getAllTeamSettings(): Promise<KeyValueObject>;
11
11
  getAllUserSettings(): Promise<KeyValueObject>;
12
- getTeamSetting(settingKey: string): Promise<string>;
12
+ getTeamSetting(settingKey: string, group?: string): Promise<string>;
13
13
  getUserSetting(settingKey: string): Promise<string>;
14
14
  getAgentSetting(settingKey: string): Promise<string>;
15
15
  getTeam(): Promise<string>;
@@ -23,7 +23,7 @@ export declare abstract class AccountConnector extends Connector {
23
23
  abstract getCandidateTeam(candidate: IAccessCandidate): Promise<string | undefined>;
24
24
  abstract getAllTeamSettings(acRequest: AccessRequest, teamId: string): Promise<KeyValueObject>;
25
25
  abstract getAllUserSettings(acRequest: AccessRequest, accountId: string): Promise<KeyValueObject>;
26
- abstract getTeamSetting(acRequest: AccessRequest, teamId: string, settingKey: string): Promise<string>;
26
+ abstract getTeamSetting(acRequest: AccessRequest, teamId: string, settingKey: string, group?: string): Promise<string>;
27
27
  abstract getUserSetting(acRequest: AccessRequest, accountId: string, settingKey: string): Promise<string>;
28
28
  abstract getAgentSetting(acRequest: AccessRequest, agentId: string, settingKey: string): Promise<string>;
29
29
  }
@@ -14,12 +14,11 @@ export declare class SecretsManager extends VaultConnector {
14
14
  private secretsManager;
15
15
  private prefix;
16
16
  constructor(_settings: SecretsManagerConfig);
17
- protected get(acRequest: AccessRequest, secretName: string): Promise<any>;
17
+ protected get(acRequest: AccessRequest, secretName: string): Promise<string>;
18
18
  protected exists(acRequest: AccessRequest, keyId: string): Promise<boolean>;
19
19
  protected listKeys(acRequest: AccessRequest): Promise<any[]>;
20
20
  getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
21
- private getSecretByName;
22
21
  private getVaultKey;
23
22
  private getSecretById;
24
- private getSecretValue;
23
+ private extractSecretName;
25
24
  }
@@ -196,6 +196,7 @@ export type TLLMModel = {
196
196
  isCustomLLM?: boolean;
197
197
  isUserCustomLLM?: boolean;
198
198
  modelId?: string;
199
+ modelEntryName?: string;
199
200
  tokens?: number;
200
201
  completionTokens?: number;
201
202
  components?: string[];
@@ -394,10 +395,32 @@ export type TLLMInputMessage = {
394
395
  }[];
395
396
  };
396
397
  export interface ILLMContextStore {
398
+ id: string;
397
399
  save(messages: any[]): Promise<void>;
398
400
  load(count?: number): Promise<any[]>;
399
401
  getMessage(message_id: string): Promise<any[]>;
400
402
  }
403
+ /**
404
+ * Configuration options for Conversation helper
405
+ */
406
+ export interface IConversationSettings {
407
+ maxContextSize?: number;
408
+ maxOutputTokens?: number;
409
+ systemPrompt?: string;
410
+ toolChoice?: string;
411
+ store?: ILLMContextStore;
412
+ experimentalCache?: boolean;
413
+ toolsStrategy?: (toolsConfig: any) => any;
414
+ agentId?: string;
415
+ agentVersion?: string;
416
+ baseUrl?: string;
417
+ /**
418
+ * Maximum number of tool calls allowed in a single conversation session.
419
+ * Prevents infinite loops in tool calling scenarios.
420
+ * @default 100
421
+ */
422
+ maxToolCalls?: number;
423
+ }
401
424
  export declare enum APIKeySource {
402
425
  Smyth = "smyth-managed",
403
426
  User = "user-managed",
@@ -42,6 +42,10 @@ export interface IStorageVectorDataSource {
42
42
  id: string;
43
43
  candidateId: string;
44
44
  candidateRole: string;
45
+ datasourceSizeMb?: number;
46
+ createdAt?: Date;
47
+ chunkSize?: number;
48
+ chunkOverlap?: number;
45
49
  }
46
50
  export interface IStorageVectorNamespace {
47
51
  namespace: string;
@@ -22,3 +22,4 @@ export declare const kebabToCapitalize: (input: any) => any;
22
22
  * @param input
23
23
  */
24
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 calcSizeMb(text: string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smythos/sre",
3
- "version": "1.7.20",
3
+ "version": "1.7.41",
4
4
  "description": "Smyth Runtime Environment",
5
5
  "author": "Alaa-eddine KADDOURI",
6
6
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  "@pinecone-database/pinecone": "^3.0.0",
69
69
  "@runware/sdk-js": "^1.1.36",
70
70
  "@smithy/smithy-client": "^4.4.3",
71
- "@zilliz/milvus2-sdk-node": "^2.6.2",
71
+ "@zilliz/milvus2-sdk-node": "^2.6.4",
72
72
  "acorn": "^8.14.1",
73
73
  "axios": "^1.7.2",
74
74
  "chokidar": "^4.0.3",
@@ -117,7 +117,7 @@
117
117
  "scripts": {
118
118
  "gen:barrel": "ctix build",
119
119
  "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
120
- "build:jsbundle": "cross-env rollup -c",
120
+ "build:jsbundle": "cross-env NODE_OPTIONS='--max-old-space-size=8192' rollup -c",
121
121
  "build": "pnpm run build:jsbundle && pnpm run build:types",
122
122
  "test:unit": "cd ../.. && vitest run packages/core/tests/unit",
123
123
  "test:unit:watch": "cd ../.. && vitest watch packages/core/tests/unit",
@@ -246,12 +246,7 @@ async function resolveTemplateVariables(data: any, input: any, agent: Agent): Pr
246
246
  if (isKeyTemplateVar(value as string)) {
247
247
  data[key] = await parseKey(value as string, agent.teamId);
248
248
  } else if (isTemplateVar(value as string)) {
249
- // Parse using input values first, then agent variables.
250
- // This correctly resolves cases where input values reference agent variables with the same name.
251
- // Example: agent variables { user_id: "123" }, input { user_id: "{{user_id}}" }.
252
- data[key] = TemplateString(value as string)
253
- .parse(input)
254
- .parse(agent.agentVariables).result;
249
+ data[key] = TemplateString(value as string).parse(input).result;
255
250
  }
256
251
  }
257
252
 
@@ -6,6 +6,8 @@ import { TemplateString } from '@sre/helpers/TemplateString.helper';
6
6
  import { IAgent as Agent } from '@sre/types/Agent.types';
7
7
  import { Conversation } from '@sre/helpers/Conversation.helper';
8
8
  import { Component } from './Component.class';
9
+ import { LLMInference } from '@sre/LLMManager/LLM.inference';
10
+ import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
9
11
 
10
12
  export class AgentPlugin extends Component {
11
13
  protected configSchema = Joi.object({
@@ -84,16 +86,31 @@ export class AgentPlugin extends Component {
84
86
 
85
87
  const conv = new Conversation(model, subAgentId, { systemPrompt: descForModel, agentVersion: version });
86
88
 
87
- const result = await conv.prompt(prompt, {
89
+ // # Region: enhance the prompt to produce a JSON output format based on the available component outputs.
90
+ const llmInference: LLMInference = await LLMInference.getInstance(model, AccessCandidate.agent(agent.id));
91
+
92
+ // if the llm is undefined, then it means we removed the model from our system
93
+ if (!llmInference.connector) {
94
+ return {
95
+ _error: `The model '${model}' is not available. Please try a different one.`,
96
+ _debug: logger.output,
97
+ };
98
+ }
99
+ const enhancedPrompt = llmInference.connector.enhancePrompt(prompt, config);
100
+ // # End Region: prompt enhancement
101
+
102
+ const result = await conv.prompt(enhancedPrompt, {
88
103
  'X-AGENT-ID': subAgentId,
89
104
  'X-AGENT-VERSION': version,
90
105
  'X-REQUEST-TAG': reqTag, //request Tag identifies the request and tells the called agent that the call comes from internal agent
91
106
  'x-caller-session-id': agent.callerSessionId,
92
107
  });
93
108
 
94
- logger.debug(`Response:\n`, result, '\n');
109
+ const processedResponse = llmInference.connector.postProcess(result);
110
+
111
+ logger.debug(`Response:\n`, processedResponse, '\n');
95
112
 
96
- return { Response: result, _debug: logger.output };
113
+ return { Response: processedResponse, _debug: logger.output };
97
114
  } catch (error: any) {
98
115
  console.error('Error on running Agent Component: ', error);
99
116
  return { _error: `Error on running Agent Component!\n${error?.message || JSON.stringify(error)}`, _debug: logger.output };