@smythos/sre 1.6.14 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +15 -0
- package/dist/index.js +66 -58
- package/dist/index.js.map +1 -1
- package/dist/types/Components/APIEndpoint.class.d.ts +2 -8
- package/dist/types/Components/Component.class.d.ts +9 -0
- package/dist/types/Components/Triggers/Gmail.trigger.d.ts +0 -17
- package/dist/types/Components/Triggers/JobScheduler.trigger.d.ts +10 -0
- package/dist/types/Components/Triggers/Trigger.class.d.ts +11 -0
- package/dist/types/Components/index.d.ts +6 -0
- package/dist/types/Core/Connector.class.d.ts +1 -0
- package/dist/types/Core/ConnectorsService.d.ts +2 -0
- package/dist/types/Core/HookService.d.ts +1 -1
- package/dist/types/helpers/BinaryInput.helper.d.ts +1 -1
- package/dist/types/helpers/Conversation.helper.d.ts +2 -0
- package/dist/types/helpers/Crypto.helper.d.ts +8 -0
- package/dist/types/helpers/LocalCache.helper.d.ts +18 -0
- package/dist/types/helpers/TemplateString.helper.d.ts +2 -1
- package/dist/types/index.d.ts +13 -0
- package/dist/types/subsystems/AgentManager/Agent.class.d.ts +4 -2
- package/dist/types/subsystems/AgentManager/AgentData.service/AgentDataConnector.d.ts +13 -0
- package/dist/types/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.d.ts +1 -4
- package/dist/types/subsystems/AgentManager/Scheduler.service/Job.class.d.ts +29 -6
- package/dist/types/subsystems/AgentManager/Scheduler.service/SchedulerConnector.d.ts +11 -3
- package/dist/types/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.d.ts +31 -7
- package/dist/types/subsystems/IO/VectorDB.service/VectorDBConnector.d.ts +4 -4
- package/dist/types/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.d.ts +2 -2
- package/dist/types/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.d.ts +2 -2
- package/dist/types/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.d.ts +2 -2
- package/dist/types/subsystems/IO/VectorDB.service/embed/BaseEmbedding.d.ts +16 -9
- package/dist/types/subsystems/IO/VectorDB.service/embed/index.d.ts +4 -1
- package/dist/types/subsystems/LLMManager/LLM.inference.d.ts +36 -2
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.d.ts +2 -5
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.d.ts +3 -6
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.d.ts +7 -0
- package/dist/types/subsystems/LLMManager/LLM.service/connectors/xAI.class.d.ts +2 -5
- package/dist/types/types/Agent.types.d.ts +1 -0
- package/dist/types/types/LLM.types.d.ts +56 -36
- package/dist/types/types/SRE.types.d.ts +4 -1
- package/dist/types/types/VectorDB.types.d.ts +6 -3
- package/dist/types/utils/string.utils.d.ts +0 -4
- package/package.json +6 -2
- package/src/Components/APICall/OAuth.helper.ts +30 -35
- package/src/Components/APIEndpoint.class.ts +25 -6
- package/src/Components/Classifier.class.ts +8 -2
- package/src/Components/Component.class.ts +11 -0
- package/src/Components/GenAILLM.class.ts +11 -7
- package/src/Components/LLMAssistant.class.ts +12 -3
- package/src/Components/ScrapflyWebScrape.class.ts +8 -1
- package/src/Components/TavilyWebSearch.class.ts +4 -1
- package/src/Components/Triggers/Gmail.trigger.ts +282 -0
- package/src/Components/Triggers/JobScheduler.trigger.ts +45 -0
- package/src/Components/Triggers/README.md +3 -0
- package/src/Components/Triggers/Trigger.class.ts +101 -0
- package/src/Components/Triggers/WhatsApp.trigger.ts +219 -0
- package/src/Components/index.ts +8 -0
- package/src/Core/AgentProcess.helper.ts +4 -6
- package/src/Core/Connector.class.ts +11 -3
- package/src/Core/ConnectorsService.ts +5 -0
- package/src/Core/ExternalEventsReceiver.ts +317 -0
- package/src/Core/HookService.ts +20 -6
- package/src/Core/SmythRuntime.class.ts +20 -2
- package/src/Core/SystemEvents.ts +17 -0
- package/src/Core/boot.ts +2 -0
- package/src/helpers/BinaryInput.helper.ts +8 -8
- package/src/helpers/Conversation.helper.ts +46 -12
- package/src/helpers/Crypto.helper.ts +28 -0
- package/src/helpers/LocalCache.helper.ts +18 -0
- package/src/helpers/TemplateString.helper.ts +20 -9
- package/src/index.ts +13 -0
- package/src/index.ts.bak +13 -0
- package/src/subsystems/AGENTS.md +594 -0
- package/src/subsystems/AgentManager/Agent.class.ts +73 -21
- package/src/subsystems/AgentManager/AgentData.service/AgentDataConnector.ts +30 -6
- package/src/subsystems/AgentManager/AgentData.service/connectors/NullAgentData.class.ts +2 -2
- package/src/subsystems/AgentManager/AgentLogger.class.ts +1 -1
- package/src/subsystems/AgentManager/AgentRuntime.class.ts +34 -5
- package/src/subsystems/AgentManager/Scheduler.service/Job.class.ts +414 -0
- package/src/subsystems/AgentManager/Scheduler.service/Schedule.class.ts +200 -0
- package/src/subsystems/AgentManager/Scheduler.service/SchedulerConnector.ts +200 -0
- package/src/subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class.ts +767 -0
- package/src/subsystems/AgentManager/Scheduler.service/index.ts +11 -0
- package/src/subsystems/IO/VectorDB.service/VectorDBConnector.ts +15 -4
- package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +32 -11
- package/src/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.ts +27 -10
- package/src/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.ts +25 -9
- package/src/subsystems/IO/VectorDB.service/embed/BaseEmbedding.ts +182 -12
- package/src/subsystems/IO/VectorDB.service/embed/GoogleEmbedding.ts +1 -1
- package/src/subsystems/IO/VectorDB.service/embed/OpenAIEmbedding.ts +1 -1
- package/src/subsystems/IO/VectorDB.service/embed/index.ts +12 -2
- package/src/subsystems/LLMManager/LLM.inference.ts +76 -17
- package/src/subsystems/LLMManager/LLM.service/LLMCredentials.helper.ts +61 -2
- package/src/subsystems/LLMManager/LLM.service/connectors/Anthropic.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Bedrock.class.ts +3 -1
- package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +5 -1
- package/src/subsystems/LLMManager/LLM.service/connectors/GoogleAI.class.ts +247 -56
- package/src/subsystems/LLMManager/LLM.service/connectors/Groq.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/Ollama.class.ts +28 -21
- package/src/subsystems/LLMManager/LLM.service/connectors/Perplexity.class.ts +3 -0
- package/src/subsystems/LLMManager/LLM.service/connectors/VertexAI.class.ts +121 -33
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.ts +38 -27
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts +3 -2
- package/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +117 -20
- package/src/subsystems/LLMManager/LLM.service/connectors/xAI.class.ts +3 -0
- package/src/subsystems/LLMManager/ModelsProvider.service/ModelsProviderConnector.ts +3 -8
- package/src/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.ts +4 -1
- package/src/subsystems/MemoryManager/Cache.service/connectors/RedisCache.class.ts +12 -0
- package/src/subsystems/MemoryManager/LLMContext.ts +3 -8
- package/src/subsystems/MemoryManager/RuntimeContext.ts +10 -9
- package/src/subsystems/Security/Credentials/Credentials.class.ts +1 -0
- package/src/subsystems/Security/Credentials/ManagedOAuth2Credentials.class.ts +106 -0
- package/src/types/Agent.types.ts +1 -0
- package/src/types/LLM.types.ts +68 -40
- package/src/types/SRE.types.ts +3 -0
- package/src/types/VectorDB.types.ts +7 -3
- package/src/utils/string.utils.ts +193 -191
|
@@ -2,7 +2,7 @@ import { ACL } from '@sre/Security/AccessControl/ACL.class';
|
|
|
2
2
|
import { IAccessCandidate } from '@sre/types/ACL.types';
|
|
3
3
|
import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
|
|
4
4
|
import { VectorDBConnector, DeleteTarget } from '../VectorDBConnector';
|
|
5
|
-
import { DatasourceDto, IStorageVectorDataSource, IStorageVectorNamespace, IVectorDataSourceDto, QueryOptions, VectorsResultData } from '@sre/types/VectorDB.types';
|
|
5
|
+
import { DatasourceDto, IStorageVectorDataSource, IStorageVectorNamespace, IVectorDataSourceDto, QueryOptions, VectorDBResult, VectorsResultData } from '@sre/types/VectorDB.types';
|
|
6
6
|
import { BaseEmbedding, TEmbeddings } from '../embed/BaseEmbedding';
|
|
7
7
|
export type RAMVectorDBConfig = {
|
|
8
8
|
/**
|
|
@@ -38,7 +38,7 @@ export declare class RAMVectorDB extends VectorDBConnector {
|
|
|
38
38
|
protected listNamespaces(acRequest: AccessRequest): Promise<IStorageVectorNamespace[]>;
|
|
39
39
|
protected deleteNamespace(acRequest: AccessRequest, namespace: string): Promise<void>;
|
|
40
40
|
protected search(acRequest: AccessRequest, namespace: string, query: string | number[], options?: QueryOptions): Promise<VectorsResultData>;
|
|
41
|
-
protected insert(acRequest: AccessRequest, namespace: string, sourceWrapper: IVectorDataSourceDto | IVectorDataSourceDto[]): Promise<
|
|
41
|
+
protected insert(acRequest: AccessRequest, namespace: string, sourceWrapper: IVectorDataSourceDto | IVectorDataSourceDto[]): Promise<VectorDBResult[]>;
|
|
42
42
|
protected delete(acRequest: AccessRequest, namespace: string, deleteTarget: DeleteTarget): Promise<void>;
|
|
43
43
|
protected createDatasource(acRequest: AccessRequest, namespace: string, datasource: DatasourceDto): Promise<IStorageVectorDataSource>;
|
|
44
44
|
protected deleteDatasource(acRequest: AccessRequest, namespace: string, datasourceId: string): Promise<void>;
|
|
@@ -2,26 +2,29 @@ import { IVectorDataSourceDto, Source } from '@sre/types/VectorDB.types';
|
|
|
2
2
|
import { SupportedProviders, SupportedModels } from './index';
|
|
3
3
|
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
4
4
|
export type TEmbeddings = {
|
|
5
|
-
provider
|
|
6
|
-
model
|
|
5
|
+
provider?: SupportedProviders;
|
|
6
|
+
model?: SupportedModels[SupportedProviders];
|
|
7
7
|
credentials?: {
|
|
8
8
|
apiKey: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
dimensions?: number;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
chunkSize?: number;
|
|
13
|
+
chunkOverlap?: number;
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
stripNewLines?: boolean;
|
|
16
|
+
params?: any;
|
|
16
17
|
};
|
|
17
18
|
type SupportedSources = 'text' | 'vector' | 'url';
|
|
18
19
|
export declare abstract class BaseEmbedding {
|
|
19
20
|
model: string;
|
|
20
21
|
modelName: string;
|
|
21
22
|
chunkSize: number;
|
|
23
|
+
chunkOverlap: number;
|
|
22
24
|
stripNewLines: boolean;
|
|
23
25
|
dimensions?: number;
|
|
24
26
|
timeout?: number;
|
|
27
|
+
batchSize: number;
|
|
25
28
|
constructor(fields?: Partial<TEmbeddings>);
|
|
26
29
|
/**
|
|
27
30
|
* Embed multiple texts and return their vector representations
|
|
@@ -35,6 +38,10 @@ export declare abstract class BaseEmbedding {
|
|
|
35
38
|
* Utility method to chunk arrays into smaller batches
|
|
36
39
|
*/
|
|
37
40
|
protected chunkArr<T>(arr: T[], sizePerChunk: number): T[][];
|
|
41
|
+
chunkText(text: string, { chunkSize, chunkOverlap }: {
|
|
42
|
+
chunkSize?: number;
|
|
43
|
+
chunkOverlap?: number;
|
|
44
|
+
}): string[];
|
|
38
45
|
/**
|
|
39
46
|
* Utility method to process multiple texts based on stripNewLines setting
|
|
40
47
|
*/
|
|
@@ -48,7 +55,7 @@ export declare abstract class BaseEmbedding {
|
|
|
48
55
|
datasourceId: string;
|
|
49
56
|
datasourceLabel: string;
|
|
50
57
|
acl: string;
|
|
51
|
-
user_metadata?: string
|
|
58
|
+
user_metadata?: string | Record<string, any>;
|
|
52
59
|
};
|
|
53
60
|
id: string;
|
|
54
61
|
}[]>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OpenAIEmbeds } from './OpenAIEmbedding';
|
|
2
2
|
import { GoogleEmbeds } from './GoogleEmbedding';
|
|
3
3
|
import { TEmbeddings } from './BaseEmbedding';
|
|
4
|
+
import { TLLMModel } from '@sre/types/LLM.types';
|
|
4
5
|
declare const supportedProviders: {
|
|
5
6
|
readonly OpenAI: {
|
|
6
7
|
readonly embedder: typeof OpenAIEmbeds;
|
|
@@ -16,6 +17,8 @@ export type SupportedModels = {
|
|
|
16
17
|
[K in SupportedProviders]: (typeof supportedProviders)[K]['models'][number];
|
|
17
18
|
};
|
|
18
19
|
export declare class EmbeddingsFactory {
|
|
19
|
-
static create(provider
|
|
20
|
+
static create(provider?: SupportedProviders, config?: TEmbeddings & {
|
|
21
|
+
model?: SupportedModels[SupportedProviders] | TLLMModel;
|
|
22
|
+
}): OpenAIEmbeds | GoogleEmbeds;
|
|
20
23
|
}
|
|
21
24
|
export {};
|
|
@@ -7,6 +7,7 @@ type TPromptParams = {
|
|
|
7
7
|
contextWindow?: any[];
|
|
8
8
|
files?: any[];
|
|
9
9
|
params: TLLMParams;
|
|
10
|
+
onFallback?: (data: any) => void;
|
|
10
11
|
};
|
|
11
12
|
export declare class LLMInference {
|
|
12
13
|
private model;
|
|
@@ -16,8 +17,41 @@ export declare class LLMInference {
|
|
|
16
17
|
static getInstance(model: string | TLLMModel, candidate: AccessCandidate): Promise<LLMInference>;
|
|
17
18
|
static user(candidate: AccessCandidate): any;
|
|
18
19
|
get connector(): LLMConnector;
|
|
19
|
-
prompt({ query, contextWindow, files, params }: TPromptParams, isInFallback?: boolean): Promise<any>;
|
|
20
|
-
promptStream({ query, contextWindow, files, params }: TPromptParams, isInFallback?: boolean): Promise<any>;
|
|
20
|
+
prompt({ query, contextWindow, files, params, onFallback }: TPromptParams, isInFallback?: boolean): Promise<any>;
|
|
21
|
+
promptStream({ query, contextWindow, files, params, onFallback }: TPromptParams, isInFallback?: boolean): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a safe, minimal set of parameters when switching to a fallback LLM provider.
|
|
24
|
+
*
|
|
25
|
+
* **Why this exists:**
|
|
26
|
+
* Model settings persist in the component's configuration data, even when you switch models.
|
|
27
|
+
* This can cause issues when fallback models run with settings the user can't see or track.
|
|
28
|
+
*
|
|
29
|
+
* **Real-world scenario:**
|
|
30
|
+
* 1. User configures a GPT-5 model and sets `reasoning_effort: "high"`
|
|
31
|
+
* 2. This setting gets saved to the component's configuration
|
|
32
|
+
* 3. User switches to a custom model (e.g., for cost savings)
|
|
33
|
+
* 4. The UI now shows custom model options - GPT-5 options are hidden
|
|
34
|
+
* 5. **BUT**: `reasoning_effort: "high"` is STILL in the config data!
|
|
35
|
+
* 6. Custom model has GPT-5 as its fallback
|
|
36
|
+
* 7. Primary custom model fails → automatically switches to GPT-5 fallback
|
|
37
|
+
* 8. GPT-5 fallback runs with the hidden `reasoning_effort: "high"` setting
|
|
38
|
+
* 9. `reasoning_effort: "high"` requires a high `max_tokens` value
|
|
39
|
+
* 10. If `max_tokens` is too low → the request fails
|
|
40
|
+
*
|
|
41
|
+
* **The impact:**
|
|
42
|
+
* Users can't track response quality properly because they don't know what configuration
|
|
43
|
+
* the fallback model is using. The UI doesn't show fallback model settings, so users have
|
|
44
|
+
* no visibility into how responses are being generated.
|
|
45
|
+
*
|
|
46
|
+
* **What this function does:**
|
|
47
|
+
* Strips out provider-specific settings when falling back, using only universal parameters.
|
|
48
|
+
* This ensures predictable behavior. (Note: A more robust solution would be showing fallback
|
|
49
|
+
* configuration in the UI, but for now this handles it at the parameter level.)
|
|
50
|
+
*
|
|
51
|
+
* @param params - The full set of LLM parameters from the original request
|
|
52
|
+
* @returns A filtered parameter object with only provider-agnostic, safe parameters
|
|
53
|
+
*/
|
|
54
|
+
private getSafeFallbackParams;
|
|
21
55
|
/**
|
|
22
56
|
* Executes fallback logic for custom models when the primary model fails.
|
|
23
57
|
* This method checks if a fallback model is configured and invokes the appropriate LLM method.
|
|
@@ -69,14 +69,11 @@ export declare class PerplexityConnector extends LLMConnector {
|
|
|
69
69
|
text?: string;
|
|
70
70
|
functionCall?: {
|
|
71
71
|
name: string;
|
|
72
|
-
args: string
|
|
72
|
+
args: string | Record<string, any>;
|
|
73
73
|
};
|
|
74
74
|
functionResponse?: {
|
|
75
75
|
name: string;
|
|
76
|
-
response:
|
|
77
|
-
name: string;
|
|
78
|
-
content: string;
|
|
79
|
-
};
|
|
76
|
+
response: any;
|
|
80
77
|
};
|
|
81
78
|
}[];
|
|
82
79
|
tool_calls?: ToolData[];
|
package/dist/types/subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class OpenAIConnector extends LLMConnector {
|
|
|
14
14
|
* Determine the appropriate interface type based on context and capabilities
|
|
15
15
|
*/
|
|
16
16
|
private getInterfaceType;
|
|
17
|
-
protected getClient(
|
|
17
|
+
protected getClient(context: ILLMRequestContext): Promise<OpenAI>;
|
|
18
18
|
protected request({ acRequest, body, context }: ILLMRequestFuncParams): Promise<TLLMChatResponse>;
|
|
19
19
|
protected streamRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<EventEmitter>;
|
|
20
20
|
protected imageGenRequest({ acRequest, body, context }: ILLMRequestFuncParams): Promise<OpenAI.ImagesResponse>;
|
|
@@ -44,14 +44,11 @@ export declare class OpenAIConnector extends LLMConnector {
|
|
|
44
44
|
text?: string;
|
|
45
45
|
functionCall?: {
|
|
46
46
|
name: string;
|
|
47
|
-
args: string
|
|
47
|
+
args: string | Record<string, any>;
|
|
48
48
|
};
|
|
49
49
|
functionResponse?: {
|
|
50
50
|
name: string;
|
|
51
|
-
response:
|
|
52
|
-
name: string;
|
|
53
|
-
content: string;
|
|
54
|
-
};
|
|
51
|
+
response: any;
|
|
55
52
|
};
|
|
56
53
|
}[];
|
|
57
54
|
tool_calls?: ToolData[];
|
|
@@ -108,12 +108,19 @@ export declare class ResponsesApiInterface extends OpenAIApiInterface {
|
|
|
108
108
|
* Upload files to storage
|
|
109
109
|
*/
|
|
110
110
|
private uploadFiles;
|
|
111
|
+
/**
|
|
112
|
+
* Upload file to OpenAI Files API
|
|
113
|
+
* Similar to GoogleAI's uploadFile implementation
|
|
114
|
+
*/
|
|
115
|
+
private uploadFile;
|
|
111
116
|
/**
|
|
112
117
|
* Process image files with Responses API specific formatting
|
|
118
|
+
* Uses OpenAI Files API for uploading images
|
|
113
119
|
*/
|
|
114
120
|
private processImageData;
|
|
115
121
|
/**
|
|
116
122
|
* Process document files with Responses API specific formatting
|
|
123
|
+
* Uses OpenAI Files API for uploading documents
|
|
117
124
|
*/
|
|
118
125
|
private processDocumentData;
|
|
119
126
|
/**
|
|
@@ -104,14 +104,11 @@ export declare class xAIConnector extends LLMConnector {
|
|
|
104
104
|
text?: string;
|
|
105
105
|
functionCall?: {
|
|
106
106
|
name: string;
|
|
107
|
-
args: string
|
|
107
|
+
args: string | Record<string, any>;
|
|
108
108
|
};
|
|
109
109
|
functionResponse?: {
|
|
110
110
|
name: string;
|
|
111
|
-
response:
|
|
112
|
-
name: string;
|
|
113
|
-
content: string;
|
|
114
|
-
};
|
|
111
|
+
response: any;
|
|
115
112
|
};
|
|
116
113
|
}[];
|
|
117
114
|
tool_calls?: ToolData[];
|
|
@@ -71,7 +71,32 @@ export type TToolsInfo = {
|
|
|
71
71
|
xai: TxAIToolsInfo;
|
|
72
72
|
};
|
|
73
73
|
export type TSearchContextSize = 'low' | 'medium' | 'high';
|
|
74
|
-
|
|
74
|
+
type TLLMToolConfig = {
|
|
75
|
+
toolsConfig?: {
|
|
76
|
+
tools?: OpenAI.ChatCompletionTool[] | OpenAI.Responses.Tool[] | OpenAI.Responses.WebSearchTool[];
|
|
77
|
+
tool_choice?: TLLMToolChoice;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
type TLLMThinkingConfig = {
|
|
81
|
+
thinking?: {
|
|
82
|
+
type: 'enabled' | 'disabled';
|
|
83
|
+
budget_tokens: number;
|
|
84
|
+
};
|
|
85
|
+
maxThinkingTokens?: number;
|
|
86
|
+
};
|
|
87
|
+
type TLLMReasoningConfig = {
|
|
88
|
+
useReasoning?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Controls the level of effort the model will put into reasoning
|
|
91
|
+
* For GPT-OSS models (20B, 120B): "low" | "medium" | "high"
|
|
92
|
+
* For Qwen 3 32B: "none" | "default"
|
|
93
|
+
*/
|
|
94
|
+
reasoningEffort?: 'none' | 'default' | OpenAIReasoningEffort;
|
|
95
|
+
max_output_tokens?: number;
|
|
96
|
+
verbosity?: OpenAI.Responses.ResponseCreateParams['text']['verbosity'];
|
|
97
|
+
abortSignal?: AbortSignal;
|
|
98
|
+
};
|
|
99
|
+
type TLLMTextGenConfig = {
|
|
75
100
|
model: TLLMModel | string;
|
|
76
101
|
prompt?: string;
|
|
77
102
|
messages?: any[];
|
|
@@ -83,31 +108,16 @@ export type TLLMParams = {
|
|
|
83
108
|
frequencyPenalty?: number;
|
|
84
109
|
presencePenalty?: number;
|
|
85
110
|
responseFormat?: any;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
toolsConfig?: {
|
|
89
|
-
tools?: OpenAI.ChatCompletionTool[] | OpenAI.Responses.Tool[] | OpenAI.Responses.WebSearchTool[];
|
|
90
|
-
tool_choice?: TLLMToolChoice;
|
|
91
|
-
};
|
|
92
|
-
baseURL?: string;
|
|
93
|
-
size?: OpenAI.Images.ImageGenerateParams['size'] | OpenAI.Images.ImageEditParams['size'];
|
|
94
|
-
quality?: 'standard' | 'hd';
|
|
95
|
-
n?: number;
|
|
96
|
-
style?: 'vivid' | 'natural';
|
|
97
|
-
cache?: boolean;
|
|
98
|
-
agentId?: string;
|
|
99
|
-
teamId?: string;
|
|
100
|
-
thinking?: {
|
|
101
|
-
type: 'enabled' | 'disabled';
|
|
102
|
-
budget_tokens: number;
|
|
103
|
-
};
|
|
104
|
-
maxThinkingTokens?: number;
|
|
111
|
+
} & TLLMToolConfig & TLLMThinkingConfig & TLLMReasoningConfig;
|
|
112
|
+
type TLLMWebSearchConfig = {
|
|
105
113
|
useWebSearch?: boolean;
|
|
106
114
|
webSearchContextSize?: TSearchContextSize;
|
|
107
115
|
webSearchCity?: string;
|
|
108
116
|
webSearchCountry?: string;
|
|
109
117
|
webSearchRegion?: string;
|
|
110
118
|
webSearchTimezone?: string;
|
|
119
|
+
};
|
|
120
|
+
type TLLMSearchConfig = {
|
|
111
121
|
useSearch?: boolean;
|
|
112
122
|
searchMode?: 'auto' | 'on' | 'off';
|
|
113
123
|
returnCitations?: boolean;
|
|
@@ -124,17 +134,27 @@ export type TLLMParams = {
|
|
|
124
134
|
safeSearch?: boolean;
|
|
125
135
|
fromDate?: string;
|
|
126
136
|
toDate?: string;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
} & TLLMWebSearchConfig;
|
|
138
|
+
type TLLMMiscConfig = {
|
|
139
|
+
maxContextWindowLength?: number;
|
|
140
|
+
useContextWindow?: boolean;
|
|
141
|
+
passthrough?: boolean;
|
|
142
|
+
};
|
|
143
|
+
type TLLMRuntimeContext = {
|
|
144
|
+
modelInfo?: TCustomLLMModel;
|
|
145
|
+
files?: BinaryInput[];
|
|
146
|
+
baseURL?: string;
|
|
147
|
+
cache?: boolean;
|
|
148
|
+
agentId?: string;
|
|
149
|
+
teamId?: string;
|
|
150
|
+
};
|
|
151
|
+
type TLLMImageGenConfig = {
|
|
152
|
+
size?: OpenAI.Images.ImageGenerateParams['size'] | OpenAI.Images.ImageEditParams['size'];
|
|
153
|
+
quality?: 'standard' | 'hd';
|
|
154
|
+
n?: number;
|
|
155
|
+
style?: 'vivid' | 'natural';
|
|
137
156
|
};
|
|
157
|
+
export type TLLMParams = TLLMTextGenConfig & TLLMSearchConfig & TLLMImageGenConfig & TLLMMiscConfig & TLLMRuntimeContext;
|
|
138
158
|
export type TLLMPreparedParams = TLLMParams & {
|
|
139
159
|
body: any;
|
|
140
160
|
modelEntryName?: string;
|
|
@@ -341,14 +361,11 @@ export type TLLMMessageBlock = {
|
|
|
341
361
|
text?: string;
|
|
342
362
|
functionCall?: {
|
|
343
363
|
name: string;
|
|
344
|
-
args: string
|
|
364
|
+
args: string | Record<string, any>;
|
|
345
365
|
};
|
|
346
366
|
functionResponse?: {
|
|
347
367
|
name: string;
|
|
348
|
-
response:
|
|
349
|
-
name: string;
|
|
350
|
-
content: string;
|
|
351
|
-
};
|
|
368
|
+
response: any;
|
|
352
369
|
};
|
|
353
370
|
}[];
|
|
354
371
|
tool_calls?: ToolData[];
|
|
@@ -425,7 +442,9 @@ export declare enum TLLMEvent {
|
|
|
425
442
|
/** Tokens usage information */
|
|
426
443
|
Usage = "usage",
|
|
427
444
|
/** Interrupted : emitted when the response is interrupted before completion */
|
|
428
|
-
Interrupted = "interrupted"
|
|
445
|
+
Interrupted = "interrupted",
|
|
446
|
+
/** Fallback : emitted when the response is using a fallback model */
|
|
447
|
+
Fallback = "fallback"
|
|
429
448
|
}
|
|
430
449
|
export interface ILLMRequestContext {
|
|
431
450
|
modelEntryName: string;
|
|
@@ -481,3 +500,4 @@ export interface TGoogleAIRequestBody {
|
|
|
481
500
|
toolConfig?: any;
|
|
482
501
|
}
|
|
483
502
|
export type TLLMRequestBody = TOpenAIRequestBody | TAnthropicRequestBody | TGoogleAIRequestBody | ConverseCommandInput;
|
|
503
|
+
export {};
|
|
@@ -13,6 +13,7 @@ import { LogService } from '@sre/IO/Log.service';
|
|
|
13
13
|
import { ComponentService } from '@sre/AgentManager/Component.service';
|
|
14
14
|
import { ModelsProviderService } from '@sre/LLMManager/ModelsProvider.service';
|
|
15
15
|
import { CodeService } from '@sre/ComputeManager/Code.service';
|
|
16
|
+
import { SchedulerService } from '@sre/AgentManager/Scheduler.service';
|
|
16
17
|
export type TServiceRegistry = {
|
|
17
18
|
Storage?: StorageService;
|
|
18
19
|
VectorDB?: VectorDBService;
|
|
@@ -29,6 +30,7 @@ export type TServiceRegistry = {
|
|
|
29
30
|
Component?: ComponentService;
|
|
30
31
|
ModelsProvider?: ModelsProviderService;
|
|
31
32
|
Code?: CodeService;
|
|
33
|
+
Scheduler?: SchedulerService;
|
|
32
34
|
};
|
|
33
35
|
export declare enum TConnectorService {
|
|
34
36
|
Storage = "Storage",
|
|
@@ -45,7 +47,8 @@ export declare enum TConnectorService {
|
|
|
45
47
|
Log = "Log",
|
|
46
48
|
Component = "Component",
|
|
47
49
|
ModelsProvider = "ModelsProvider",
|
|
48
|
-
Code = "Code"
|
|
50
|
+
Code = "Code",
|
|
51
|
+
Scheduler = "Scheduler"
|
|
49
52
|
}
|
|
50
53
|
export type SREConnectorConfig = {
|
|
51
54
|
Connector: string;
|
|
@@ -3,16 +3,17 @@ export type VectorDBMetadata = {
|
|
|
3
3
|
datasourceId: string;
|
|
4
4
|
datasourceLabel: string;
|
|
5
5
|
acl: string;
|
|
6
|
-
user_metadata?: string
|
|
6
|
+
user_metadata?: string | Record<string, any>;
|
|
7
7
|
text?: string;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
9
|
+
export type VectorDBResult = {
|
|
10
10
|
id: string;
|
|
11
11
|
score?: number;
|
|
12
12
|
values: number[];
|
|
13
13
|
text: string;
|
|
14
14
|
metadata?: Record<string, any>;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export type VectorsResultData = VectorDBResult[];
|
|
16
17
|
export interface NsKnownMetadata {
|
|
17
18
|
isOnCustomStorage?: boolean;
|
|
18
19
|
[key: string]: any;
|
|
@@ -37,6 +38,7 @@ export interface IStorageVectorDataSource {
|
|
|
37
38
|
metadata: string;
|
|
38
39
|
text?: string;
|
|
39
40
|
vectorIds: string[];
|
|
41
|
+
vectorInfo?: VectorDBResult[];
|
|
40
42
|
id: string;
|
|
41
43
|
candidateId: string;
|
|
42
44
|
candidateRole: string;
|
|
@@ -65,4 +67,5 @@ export interface DatasourceDto {
|
|
|
65
67
|
chunkOverlap?: number;
|
|
66
68
|
label?: string;
|
|
67
69
|
id?: string;
|
|
70
|
+
returnFullVectorInfo?: boolean;
|
|
68
71
|
}
|
|
@@ -22,7 +22,3 @@ 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 chunkText(text: string, { chunkSize, chunkOverlap, }?: {
|
|
26
|
-
chunkSize?: number;
|
|
27
|
-
chunkOverlap?: number;
|
|
28
|
-
}): string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smythos/sre",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Smyth Runtime Environment",
|
|
5
5
|
"author": "Alaa-eddine KADDOURI",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@types/express": "^4.17.23",
|
|
32
32
|
"@types/lodash": "^4.17.10",
|
|
33
33
|
"@types/node": "^20.19.0",
|
|
34
|
+
"@types/ws": "^8.18.1",
|
|
34
35
|
"cross-env": "^7.0.3",
|
|
35
36
|
"ctix": "^2.7.1",
|
|
36
37
|
"dependency-cruiser": "^16.3.3",
|
|
@@ -59,11 +60,12 @@
|
|
|
59
60
|
"@pinecone-database/pinecone": "^3.0.0",
|
|
60
61
|
"@runware/sdk-js": "^1.1.36",
|
|
61
62
|
"@smithy/smithy-client": "^4.4.3",
|
|
62
|
-
"@zilliz/milvus2-sdk-node": "^2.
|
|
63
|
+
"@zilliz/milvus2-sdk-node": "^2.6.2",
|
|
63
64
|
"acorn": "^8.14.1",
|
|
64
65
|
"axios": "^1.7.2",
|
|
65
66
|
"chokidar": "^4.0.3",
|
|
66
67
|
"dayjs": "^1.11.11",
|
|
68
|
+
"domutils": "^3.2.2",
|
|
67
69
|
"dotenv": "^16.4.5",
|
|
68
70
|
"eventsource": "^3.0.2",
|
|
69
71
|
"express": "^4.21.2",
|
|
@@ -71,6 +73,7 @@
|
|
|
71
73
|
"form-data": "^4.0.3",
|
|
72
74
|
"gpt-tokenizer": "^2.2.1",
|
|
73
75
|
"groq-sdk": "^0.6.1",
|
|
76
|
+
"htmlparser2": "^10.0.0",
|
|
74
77
|
"image-size": "^1.1.1",
|
|
75
78
|
"ioredis": "^5.4.1",
|
|
76
79
|
"isbinaryfile": "^5.0.2",
|
|
@@ -90,6 +93,7 @@
|
|
|
90
93
|
"socks-proxy-agent": "^8.0.4",
|
|
91
94
|
"winston": "^3.13.0",
|
|
92
95
|
"winston-transport": "^4.7.0",
|
|
96
|
+
"ws": "^8.18.3",
|
|
93
97
|
"xxhashjs": "^0.2.2",
|
|
94
98
|
"zip-lib": "^1.1.2"
|
|
95
99
|
},
|
|
@@ -7,8 +7,9 @@ import axios, { AxiosRequestConfig } from 'axios';
|
|
|
7
7
|
import { Logger } from '@sre/helpers/Log.helper';
|
|
8
8
|
import { ConnectorService } from '@sre/Core/ConnectorsService';
|
|
9
9
|
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
10
|
-
import { TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
10
|
+
import { Match, TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
11
11
|
import { SystemEvents } from '@sre/Core/SystemEvents';
|
|
12
|
+
import { cloneDeep } from 'lodash';
|
|
12
13
|
|
|
13
14
|
const console = Logger('OAuth.helper');
|
|
14
15
|
let managedVault: any;
|
|
@@ -49,11 +50,9 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
49
50
|
|
|
50
51
|
// Headers might be an object or array of objects
|
|
51
52
|
if (Array.isArray(headers)) {
|
|
52
|
-
const contentTypeHeader = headers.find(h =>
|
|
53
|
-
Object.keys(h).some(k => k.toLowerCase() === 'content-type')
|
|
54
|
-
);
|
|
53
|
+
const contentTypeHeader = headers.find((h) => Object.keys(h).some((k) => k.toLowerCase() === 'content-type'));
|
|
55
54
|
if (contentTypeHeader) {
|
|
56
|
-
const key = Object.keys(contentTypeHeader).find(k => k.toLowerCase() === 'content-type');
|
|
55
|
+
const key = Object.keys(contentTypeHeader).find((k) => k.toLowerCase() === 'content-type');
|
|
57
56
|
contentType = contentTypeHeader[key];
|
|
58
57
|
}
|
|
59
58
|
} else {
|
|
@@ -83,9 +82,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
83
82
|
console.debug('OAuth1: Including form parameters in signature:', Object.keys(formParams));
|
|
84
83
|
additionalParams = { ...additionalParams, ...formParams };
|
|
85
84
|
}
|
|
86
|
-
} else if (contentType.includes(REQUEST_CONTENT_TYPES.json) ||
|
|
87
|
-
contentType.includes('application/') ||
|
|
88
|
-
contentType.includes('text/')) {
|
|
85
|
+
} else if (contentType.includes(REQUEST_CONTENT_TYPES.json) || contentType.includes('application/') || contentType.includes('text/')) {
|
|
89
86
|
// For JSON and other non-form data, use oauth_body_hash
|
|
90
87
|
if (reqConfig.data && method !== 'GET' && method !== 'HEAD') {
|
|
91
88
|
let bodyString = '';
|
|
@@ -110,8 +107,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
110
107
|
// Only include string values, exclude Files/Blobs
|
|
111
108
|
if (typeof value === 'string') {
|
|
112
109
|
additionalParams[key] = value;
|
|
113
|
-
} else if (typeof value === 'object' && value !== null &&
|
|
114
|
-
('size' in value || 'type' in value)) {
|
|
110
|
+
} else if (typeof value === 'object' && value !== null && ('size' in value || 'type' in value)) {
|
|
115
111
|
// Skip binary data (Files, Blobs, etc.)
|
|
116
112
|
continue;
|
|
117
113
|
} else {
|
|
@@ -123,8 +119,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
123
119
|
} else if (!contentType && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
|
|
124
120
|
// No content type specified but has data
|
|
125
121
|
if (reqConfig.data) {
|
|
126
|
-
const bodyString = typeof reqConfig.data === 'string' ?
|
|
127
|
-
reqConfig.data : JSON.stringify(reqConfig.data);
|
|
122
|
+
const bodyString = typeof reqConfig.data === 'string' ? reqConfig.data : JSON.stringify(reqConfig.data);
|
|
128
123
|
const hash = crypto.createHash('sha1').update(bodyString).digest('base64');
|
|
129
124
|
additionalParams['oauth_body_hash'] = hash;
|
|
130
125
|
}
|
|
@@ -165,9 +160,10 @@ export const buildOAuth1Header = (url, method, oauth1Credentials, additionalPara
|
|
|
165
160
|
data: additionalParams, // Parameters should be in data field for oauth-1.0a library
|
|
166
161
|
};
|
|
167
162
|
|
|
168
|
-
const token =
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
const token =
|
|
164
|
+
oauth1Credentials.token && oauth1Credentials.token !== ''
|
|
165
|
+
? { key: oauth1Credentials.token, secret: oauth1Credentials.tokenSecret || '' }
|
|
166
|
+
: null;
|
|
171
167
|
|
|
172
168
|
const signedRequest = oauth.authorize(requestData, token);
|
|
173
169
|
return oauth.toHeader(signedRequest);
|
|
@@ -190,24 +186,25 @@ export const retrieveOAuthTokens = async (agent, config) => {
|
|
|
190
186
|
// Check if it's new structure (has auth_data and auth_settings) or old structure
|
|
191
187
|
const isNewStructure = tokensData.auth_data !== undefined && tokensData.auth_settings !== undefined;
|
|
192
188
|
|
|
189
|
+
//* Resolve vault keys inside auth_data
|
|
190
|
+
if (isNewStructure) {
|
|
191
|
+
await Promise.all(
|
|
192
|
+
Object.keys(tokensData.auth_settings).map(async (key) => {
|
|
193
|
+
if (typeof tokensData.auth_settings[key] !== 'string') return;
|
|
194
|
+
tokensData.auth_settings[key] = await TemplateString(tokensData.auth_settings[key]).parseTeamKeysAsync(agent.teamId)
|
|
195
|
+
.asyncResult;
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
193
200
|
// Extract tokens based on structure
|
|
194
|
-
const primaryToken = isNewStructure
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const secondaryToken = isNewStructure
|
|
198
|
-
? tokensData.auth_data?.secondary
|
|
199
|
-
: tokensData.secondary;
|
|
200
|
-
const expiresIn = isNewStructure
|
|
201
|
-
? tokensData.auth_data?.expires_in
|
|
202
|
-
: tokensData.expires_in;
|
|
201
|
+
const primaryToken = isNewStructure ? tokensData.auth_data?.primary : tokensData.primary;
|
|
202
|
+
const secondaryToken = isNewStructure ? tokensData.auth_data?.secondary : tokensData.secondary;
|
|
203
|
+
const expiresIn = isNewStructure ? tokensData.auth_data?.expires_in : tokensData.expires_in;
|
|
203
204
|
|
|
204
205
|
// Extract settings based on structure
|
|
205
|
-
const type = isNewStructure
|
|
206
|
-
|
|
207
|
-
: (tokensData.type || tokensData.oauth_info?.type);
|
|
208
|
-
const service = isNewStructure
|
|
209
|
-
? tokensData.auth_settings?.service
|
|
210
|
-
: tokensData.oauth_info?.service;
|
|
206
|
+
const type = isNewStructure ? tokensData.auth_settings?.type : tokensData.type || tokensData.oauth_info?.type;
|
|
207
|
+
const service = isNewStructure ? tokensData.auth_settings?.service : tokensData.oauth_info?.service;
|
|
211
208
|
|
|
212
209
|
// Add warning logs for OAuth2
|
|
213
210
|
if (type === 'oauth2' && service !== 'oauth2_client_credentials') {
|
|
@@ -353,8 +350,6 @@ const getKeyIdsFromTemplateVars = (str: string): string[] => {
|
|
|
353
350
|
};
|
|
354
351
|
|
|
355
352
|
async function getClientCredentialToken(tokensData, logger, keyId, oauthTokens, config, agent, isNewStructure = false) {
|
|
356
|
-
|
|
357
|
-
|
|
358
353
|
const logAndThrowError = (message) => {
|
|
359
354
|
logger.debug(message);
|
|
360
355
|
throw new Error(message);
|
|
@@ -399,7 +394,7 @@ async function getClientCredentialToken(tokensData, logger, keyId, oauthTokens,
|
|
|
399
394
|
auth_data: {
|
|
400
395
|
...(tokensData?.auth_data || {}),
|
|
401
396
|
primary: newAccessToken,
|
|
402
|
-
expires_in: expirationTimestamp.toString()
|
|
397
|
+
expires_in: expirationTimestamp.toString(),
|
|
403
398
|
},
|
|
404
399
|
auth_settings: {
|
|
405
400
|
...(tokensData?.auth_settings || {}),
|
|
@@ -416,7 +411,7 @@ async function getClientCredentialToken(tokensData, logger, keyId, oauthTokens,
|
|
|
416
411
|
updatedData = {
|
|
417
412
|
...tokensData,
|
|
418
413
|
primary: newAccessToken,
|
|
419
|
-
expires_in: expirationTimestamp.toString()
|
|
414
|
+
expires_in: expirationTimestamp.toString(),
|
|
420
415
|
};
|
|
421
416
|
// Ensure required fields are present for old structure
|
|
422
417
|
if (!updatedData.type) updatedData.type = 'oauth2';
|
|
@@ -428,7 +423,7 @@ async function getClientCredentialToken(tokensData, logger, keyId, oauthTokens,
|
|
|
428
423
|
service: 'oauth2_client_credentials',
|
|
429
424
|
tokenURL,
|
|
430
425
|
clientID,
|
|
431
|
-
clientSecret
|
|
426
|
+
clientSecret,
|
|
432
427
|
};
|
|
433
428
|
}
|
|
434
429
|
}
|