@smythos/sre 1.7.11 → 1.7.16
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/dist/index.js +48 -48
- package/dist/index.js.map +1 -1
- package/dist/types/Components/APICall/OAuth.helper.d.ts +1 -1
- package/dist/types/Core/ConnectorsService.d.ts +3 -1
- package/dist/types/Core/HookService.d.ts +18 -0
- package/dist/types/helpers/Conversation.helper.d.ts +3 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/subsystems/ObservabilityManager/Log.service/LogConnector.d.ts +2 -1
- package/dist/types/subsystems/ObservabilityManager/Log.service/connectors/OTel/OTel.class.d.ts +59 -0
- package/dist/types/subsystems/ObservabilityManager/Log.service/connectors/OTel/OTelContextRegistry.d.ts +16 -0
- package/dist/types/subsystems/ObservabilityManager/Telemetry.service/TelemetryConnector.d.ts +13 -0
- package/dist/types/subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTel.class.d.ts +59 -0
- package/dist/types/subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTelContextRegistry.d.ts +16 -0
- package/dist/types/subsystems/ObservabilityManager/Telemetry.service/index.d.ts +4 -0
- package/dist/types/types/LLM.types.d.ts +3 -1
- package/dist/types/types/SRE.types.d.ts +5 -2
- package/package.json +9 -1
- package/src/Components/APICall/OAuth.helper.ts +24 -25
- package/src/Components/APICall/mimeTypeCategories.ts +16 -1
- package/src/Components/Component.class.ts +3 -1
- package/src/Core/ConnectorsService.ts +5 -1
- package/src/Core/HookService.ts +104 -12
- package/src/Core/boot.ts +3 -1
- package/src/helpers/Conversation.helper.ts +42 -15
- package/src/index.ts +7 -3
- package/src/index.ts.bak +7 -3
- package/src/subsystems/AgentManager/Agent.class.ts +9 -8
- package/src/subsystems/AgentManager/AgentRuntime.class.ts +4 -4
- package/src/subsystems/AgentManager/OSResourceMonitor.ts +69 -8
- package/src/subsystems/LLMManager/LLM.service/connectors/Echo.class.ts +1 -1
- package/src/subsystems/{IO → ObservabilityManager}/Log.service/LogConnector.ts +5 -1
- package/src/subsystems/{IO → ObservabilityManager}/Log.service/connectors/ConsoleLog.class.ts +3 -3
- package/src/subsystems/{IO → ObservabilityManager}/Log.service/index.ts +1 -2
- package/src/subsystems/ObservabilityManager/Telemetry.service/TelemetryConnector.ts +23 -0
- package/src/subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTel.class.ts +759 -0
- package/src/subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTelContextRegistry.ts +35 -0
- package/src/subsystems/ObservabilityManager/Telemetry.service/index.ts +12 -0
- package/src/types/LLM.types.ts +2 -0
- package/src/types/SRE.types.ts +4 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import OAuth from 'oauth-1.0a';
|
|
2
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import OAuth from 'oauth-1.0a';
|
|
3
3
|
export declare function extractAdditionalParamsForOAuth1(reqConfig?: AxiosRequestConfig): {};
|
|
4
4
|
export declare const buildOAuth1Header: (url: any, method: any, oauth1Credentials: any, additionalParams?: {}) => OAuth.Header;
|
|
5
5
|
export declare const retrieveOAuthTokens: (agent: any, config: any) => Promise<{
|
|
@@ -3,7 +3,7 @@ import { ComponentConnector } from '@sre/AgentManager/Component.service/Componen
|
|
|
3
3
|
import { SchedulerConnector } from '@sre/AgentManager/Scheduler.service/SchedulerConnector';
|
|
4
4
|
import { CodeConnector } from '@sre/ComputeManager/Code.service/CodeConnector';
|
|
5
5
|
import { CLIConnector } from '@sre/IO/CLI.service/CLIConnector';
|
|
6
|
-
import { LogConnector } from '@sre/
|
|
6
|
+
import { LogConnector } from '@sre/ObservabilityManager/Log.service/LogConnector';
|
|
7
7
|
import { NKVConnector } from '@sre/IO/NKV.service/NKVConnector';
|
|
8
8
|
import { RouterConnector } from '@sre/IO/Router.service/RouterConnector';
|
|
9
9
|
import { StorageConnector } from '@sre/IO/Storage.service/StorageConnector';
|
|
@@ -14,6 +14,7 @@ import { CacheConnector } from '@sre/MemoryManager/Cache.service/CacheConnector'
|
|
|
14
14
|
import { AccountConnector } from '@sre/Security/Account.service/AccountConnector';
|
|
15
15
|
import { ManagedVaultConnector } from '@sre/Security/ManagedVault.service/ManagedVaultConnector';
|
|
16
16
|
import { VaultConnector } from '@sre/Security/Vault.service/VaultConnector';
|
|
17
|
+
import { TelemetryConnector } from '@sre/ObservabilityManager/Telemetry.service/TelemetryConnector';
|
|
17
18
|
import { TConnectorService, TServiceRegistry } from '@sre/types/SRE.types';
|
|
18
19
|
export declare class ConnectorService {
|
|
19
20
|
static get Connectors(): any;
|
|
@@ -59,6 +60,7 @@ export declare class ConnectorService {
|
|
|
59
60
|
static getRouterConnector(name?: string): RouterConnector;
|
|
60
61
|
static getCodeConnector(name?: string): CodeConnector;
|
|
61
62
|
static getSchedulerConnector(name?: string): SchedulerConnector;
|
|
63
|
+
static getTelemetryConnector(name?: string): TelemetryConnector;
|
|
62
64
|
}
|
|
63
65
|
export declare abstract class ConnectorServiceProvider {
|
|
64
66
|
abstract register(): any;
|
|
@@ -31,8 +31,26 @@ export declare class HookService {
|
|
|
31
31
|
* @param hookName The name of the hook to trigger
|
|
32
32
|
*/
|
|
33
33
|
export declare function hook(hookName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
34
|
+
/**
|
|
35
|
+
* Class decorator that automatically applies hookAsync to ALL child class methods
|
|
36
|
+
* that override parent methods decorated with hookAsync
|
|
37
|
+
*
|
|
38
|
+
* Usage:
|
|
39
|
+
* @hookableClass
|
|
40
|
+
* export class Component {
|
|
41
|
+
* @hookAsync('Component.process')
|
|
42
|
+
* async process(...) { ... }
|
|
43
|
+
*
|
|
44
|
+
* @hookAsync('Component.postProcess')
|
|
45
|
+
* async postProcess(...) { ... }
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
48
|
+
export declare function hookableClass<T extends {
|
|
49
|
+
new (...args: any[]): {};
|
|
50
|
+
}>(constructor: T): T;
|
|
34
51
|
/**
|
|
35
52
|
* Decorator function that executes registered hooks asynchronously before and after the decorated method
|
|
53
|
+
* Automatically stores metadata for hookableClass decorator to enable automatic child class wrapping
|
|
36
54
|
* @param hookName The name of the hook to trigger
|
|
37
55
|
*/
|
|
38
56
|
export declare function hookAsync(hookName: string, customContext?: Record<string, any> | ((instance: any) => Record<string, any>)): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -6,6 +6,7 @@ export declare class Conversation extends EventEmitter {
|
|
|
6
6
|
private _specSource?;
|
|
7
7
|
private _settings?;
|
|
8
8
|
private _agentId;
|
|
9
|
+
get agentId(): string;
|
|
9
10
|
private _systemPrompt;
|
|
10
11
|
private userDefinedSystemPrompt;
|
|
11
12
|
toolChoice: string;
|
|
@@ -26,6 +27,8 @@ export declare class Conversation extends EventEmitter {
|
|
|
26
27
|
private _teamId;
|
|
27
28
|
private _agentVersion;
|
|
28
29
|
agentData: any;
|
|
30
|
+
private _id;
|
|
31
|
+
get id(): string;
|
|
29
32
|
get context(): LLMContext;
|
|
30
33
|
private _lastError;
|
|
31
34
|
private _spec;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -124,8 +124,6 @@ export * from './subsystems/ComputeManager/Code.service/CodeConnector';
|
|
|
124
124
|
export * from './subsystems/ComputeManager/Code.service/index';
|
|
125
125
|
export * from './subsystems/IO/CLI.service/CLIConnector';
|
|
126
126
|
export * from './subsystems/IO/CLI.service/index';
|
|
127
|
-
export * from './subsystems/IO/Log.service/index';
|
|
128
|
-
export * from './subsystems/IO/Log.service/LogConnector';
|
|
129
127
|
export * from './subsystems/IO/NKV.service/index';
|
|
130
128
|
export * from './subsystems/IO/NKV.service/NKVConnector';
|
|
131
129
|
export * from './subsystems/IO/Router.service/index';
|
|
@@ -143,6 +141,10 @@ export * from './subsystems/LLMManager/ModelsProvider.service/ModelsProviderConn
|
|
|
143
141
|
export * from './subsystems/MemoryManager/Cache.service/CacheConnector';
|
|
144
142
|
export * from './subsystems/MemoryManager/Cache.service/index';
|
|
145
143
|
export * from './subsystems/MemoryManager/LLMMemory.service/LLMMemoryConnector';
|
|
144
|
+
export * from './subsystems/ObservabilityManager/Log.service/index';
|
|
145
|
+
export * from './subsystems/ObservabilityManager/Log.service/LogConnector';
|
|
146
|
+
export * from './subsystems/ObservabilityManager/Telemetry.service/index';
|
|
147
|
+
export * from './subsystems/ObservabilityManager/Telemetry.service/TelemetryConnector';
|
|
146
148
|
export * from './subsystems/Security/AccessControl/AccessCandidate.class';
|
|
147
149
|
export * from './subsystems/Security/AccessControl/AccessRequest.class';
|
|
148
150
|
export * from './subsystems/Security/AccessControl/ACL.class';
|
|
@@ -161,7 +163,6 @@ export * from './subsystems/AgentManager/AgentData.service/connectors/NullAgentD
|
|
|
161
163
|
export * from './subsystems/AgentManager/Component.service/connectors/LocalComponentConnector.class';
|
|
162
164
|
export * from './subsystems/AgentManager/Scheduler.service/connectors/LocalScheduler.class';
|
|
163
165
|
export * from './subsystems/ComputeManager/Code.service/connectors/AWSLambdaCode.class';
|
|
164
|
-
export * from './subsystems/IO/Log.service/connectors/ConsoleLog.class';
|
|
165
166
|
export * from './subsystems/IO/NKV.service/connectors/NKVLocalStorage.class';
|
|
166
167
|
export * from './subsystems/IO/NKV.service/connectors/NKVRAM.class';
|
|
167
168
|
export * from './subsystems/IO/NKV.service/connectors/NKVRedis.class';
|
|
@@ -190,6 +191,7 @@ export * from './subsystems/MemoryManager/Cache.service/connectors/LocalStorageC
|
|
|
190
191
|
export * from './subsystems/MemoryManager/Cache.service/connectors/RAMCache.class';
|
|
191
192
|
export * from './subsystems/MemoryManager/Cache.service/connectors/RedisCache.class';
|
|
192
193
|
export * from './subsystems/MemoryManager/Cache.service/connectors/S3Cache.class';
|
|
194
|
+
export * from './subsystems/ObservabilityManager/Log.service/connectors/ConsoleLog.class';
|
|
193
195
|
export * from './subsystems/Security/Account.service/connectors/DummyAccount.class';
|
|
194
196
|
export * from './subsystems/Security/Account.service/connectors/JSONFileAccount.class';
|
|
195
197
|
export * from './subsystems/Security/Account.service/connectors/MySQLAccount.class';
|
|
@@ -201,5 +203,7 @@ export * from './subsystems/Security/Vault.service/connectors/NullVault.class';
|
|
|
201
203
|
export * from './subsystems/Security/Vault.service/connectors/SecretsManager.class';
|
|
202
204
|
export * from './subsystems/LLMManager/LLM.service/connectors/openai/OpenAIConnector.class';
|
|
203
205
|
export * from './subsystems/LLMManager/LLM.service/connectors/openai/types';
|
|
206
|
+
export * from './subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTel.class';
|
|
207
|
+
export * from './subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTelContextRegistry';
|
|
204
208
|
export * from './subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants';
|
|
205
209
|
export * from './subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/utils';
|
|
@@ -10,8 +10,9 @@ export interface ILogRequest {
|
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class LogConnector extends SecureConnector {
|
|
12
12
|
abstract id: string;
|
|
13
|
-
|
|
13
|
+
constructor();
|
|
14
14
|
requester(candidate: AccessCandidate): ILogRequest;
|
|
15
|
+
abstract getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
15
16
|
protected abstract log(acRequest: AccessRequest, logData: AgentCallLog, callId?: string): Promise<any>;
|
|
16
17
|
protected abstract logTask(acRequest: AccessRequest, tasks: number, isUsingTestDomain: boolean): Promise<void>;
|
|
17
18
|
}
|
package/dist/types/subsystems/ObservabilityManager/Log.service/connectors/OTel/OTel.class.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
|
|
2
|
+
import { ACL } from '@sre/Security/AccessControl/ACL.class';
|
|
3
|
+
import { IAccessCandidate } from '@sre/types/ACL.types';
|
|
4
|
+
import { LogConnector } from '../../LogConnector';
|
|
5
|
+
import { AgentCallLog } from '@sre/types/AgentLogger.types';
|
|
6
|
+
export type OTelLogConfig = {
|
|
7
|
+
endpoint: string;
|
|
8
|
+
headers: Record<string, string>;
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
serviceVersion?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum size (in bytes) for full output in logs.
|
|
13
|
+
* Outputs larger than this will be truncated with a note.
|
|
14
|
+
* Default: 256KB (262144 bytes) - Safe for all backends (Loki, Elasticsearch, etc.)
|
|
15
|
+
*
|
|
16
|
+
* Common values:
|
|
17
|
+
* - 256KB (262144) - Recommended, works with all backends
|
|
18
|
+
* - 512KB (524288) - Works with most backends
|
|
19
|
+
* - 1MB (1048576) - Only for backends that support it (CloudWatch, Datadog)
|
|
20
|
+
*/
|
|
21
|
+
maxOutputSize?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Only log full output on errors. Success cases will only log size/preview.
|
|
24
|
+
* Default: false (log full output for both success and errors)
|
|
25
|
+
*/
|
|
26
|
+
fullOutputOnErrorOnly?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Fields to redact from outputs (e.g., ['password', 'token', 'apiKey'])
|
|
29
|
+
* These will be replaced with '[REDACTED]' in logs
|
|
30
|
+
*/
|
|
31
|
+
redactFields?: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare class OTelLog extends LogConnector {
|
|
34
|
+
protected _settings: OTelLogConfig;
|
|
35
|
+
name: string;
|
|
36
|
+
id: string;
|
|
37
|
+
private tracer;
|
|
38
|
+
private logger;
|
|
39
|
+
private tracerProvider;
|
|
40
|
+
private loggerProvider;
|
|
41
|
+
constructor(_settings: OTelLogConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Cleanup and shutdown exporters
|
|
44
|
+
*/
|
|
45
|
+
stop(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Redact sensitive fields from an object
|
|
48
|
+
*/
|
|
49
|
+
private redactSensitiveData;
|
|
50
|
+
/**
|
|
51
|
+
* Safely format output for logging with size limits and redaction
|
|
52
|
+
*/
|
|
53
|
+
private formatOutputForLog;
|
|
54
|
+
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
55
|
+
protected log(acRequest: AccessRequest, logData: AgentCallLog, callId?: string): Promise<any>;
|
|
56
|
+
protected logTask(acRequest: AccessRequest, tasks: number, isUsingTestDomain: boolean): Promise<void>;
|
|
57
|
+
private prepareComponentData;
|
|
58
|
+
protected setupHooks(): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Span } from '@opentelemetry/api';
|
|
2
|
+
interface ProcessContext {
|
|
3
|
+
processId: string;
|
|
4
|
+
agentId: string;
|
|
5
|
+
rootSpan: Span;
|
|
6
|
+
currentSpan?: Span;
|
|
7
|
+
}
|
|
8
|
+
export declare class OTelContextRegistry {
|
|
9
|
+
private static registry;
|
|
10
|
+
static key(agentId: string, processId: string): string;
|
|
11
|
+
static startProcess(agentId: string, processId: string, span: Span): void;
|
|
12
|
+
static get(agentId: string, processId: string): ProcessContext;
|
|
13
|
+
static update(agentId: string, processId: string, ctx: Partial<ProcessContext>): void;
|
|
14
|
+
static endProcess(agentId: string, processId: string): void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SecureConnector } from '@sre/Security/SecureConnector.class';
|
|
2
|
+
import { IAccessCandidate } from '@sre/types/ACL.types';
|
|
3
|
+
import { ACL } from '@sre/Security/AccessControl/ACL.class';
|
|
4
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
5
|
+
export interface ITelemetryRequest {
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class TelemetryConnector extends SecureConnector {
|
|
8
|
+
abstract id: string;
|
|
9
|
+
constructor();
|
|
10
|
+
requester(candidate: AccessCandidate): ITelemetryRequest;
|
|
11
|
+
abstract getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
12
|
+
protected abstract setupHooks(): Promise<void>;
|
|
13
|
+
}
|
package/dist/types/subsystems/ObservabilityManager/Telemetry.service/connectors/OTel/OTel.class.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
|
|
2
|
+
import { ACL } from '@sre/Security/AccessControl/ACL.class';
|
|
3
|
+
import { IAccessCandidate } from '@sre/types/ACL.types';
|
|
4
|
+
import { TelemetryConnector } from '../../TelemetryConnector';
|
|
5
|
+
import { AgentCallLog } from '@sre/types/AgentLogger.types';
|
|
6
|
+
export type OTelLogConfig = {
|
|
7
|
+
endpoint: string;
|
|
8
|
+
headers: Record<string, string>;
|
|
9
|
+
serviceName?: string;
|
|
10
|
+
serviceVersion?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum size (in bytes) for full output in logs.
|
|
13
|
+
* Outputs larger than this will be truncated with a note.
|
|
14
|
+
* Default: 256KB (262144 bytes) - Safe for all backends (Loki, Elasticsearch, etc.)
|
|
15
|
+
*
|
|
16
|
+
* Common values:
|
|
17
|
+
* - 256KB (262144) - Recommended, works with all backends
|
|
18
|
+
* - 512KB (524288) - Works with most backends
|
|
19
|
+
* - 1MB (1048576) - Only for backends that support it (CloudWatch, Datadog)
|
|
20
|
+
*/
|
|
21
|
+
maxOutputSize?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Only log full output on errors. Success cases will only log size/preview.
|
|
24
|
+
* Default: false (log full output for both success and errors)
|
|
25
|
+
*/
|
|
26
|
+
fullOutputOnErrorOnly?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Fields to redact from outputs (e.g., ['password', 'token', 'apiKey'])
|
|
29
|
+
* These will be replaced with '[REDACTED]' in logs
|
|
30
|
+
*/
|
|
31
|
+
redactFields?: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare class OTel extends TelemetryConnector {
|
|
34
|
+
protected _settings: OTelLogConfig;
|
|
35
|
+
name: string;
|
|
36
|
+
id: string;
|
|
37
|
+
private tracer;
|
|
38
|
+
private logger;
|
|
39
|
+
private tracerProvider;
|
|
40
|
+
private loggerProvider;
|
|
41
|
+
constructor(_settings: OTelLogConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Cleanup and shutdown exporters
|
|
44
|
+
*/
|
|
45
|
+
stop(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Redact sensitive fields from an object
|
|
48
|
+
*/
|
|
49
|
+
private redactSensitiveData;
|
|
50
|
+
/**
|
|
51
|
+
* Safely format output for logging with size limits and redaction
|
|
52
|
+
*/
|
|
53
|
+
private formatOutputForLog;
|
|
54
|
+
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
55
|
+
protected log(acRequest: AccessRequest, logData: AgentCallLog, callId?: string): Promise<any>;
|
|
56
|
+
protected logTask(acRequest: AccessRequest, tasks: number, isUsingTestDomain: boolean): Promise<void>;
|
|
57
|
+
private prepareComponentData;
|
|
58
|
+
protected setupHooks(): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Span } from '@opentelemetry/api';
|
|
2
|
+
interface ProcessContext {
|
|
3
|
+
processId: string;
|
|
4
|
+
agentId: string;
|
|
5
|
+
rootSpan: Span;
|
|
6
|
+
currentSpan?: Span;
|
|
7
|
+
}
|
|
8
|
+
export declare class OTelContextRegistry {
|
|
9
|
+
private static registry;
|
|
10
|
+
static key(agentId: string, processId: string): string;
|
|
11
|
+
static startProcess(agentId: string, processId: string, span: Span): void;
|
|
12
|
+
static get(agentId: string, processId: string): ProcessContext;
|
|
13
|
+
static update(agentId: string, processId: string, ctx: Partial<ProcessContext>): void;
|
|
14
|
+
static endProcess(agentId: string, processId: string): void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -444,7 +444,9 @@ export declare enum TLLMEvent {
|
|
|
444
444
|
/** Interrupted : emitted when the response is interrupted before completion */
|
|
445
445
|
Interrupted = "interrupted",
|
|
446
446
|
/** Fallback : emitted when the response is using a fallback model */
|
|
447
|
-
Fallback = "fallback"
|
|
447
|
+
Fallback = "fallback",
|
|
448
|
+
/** Requested : emitted when a request is sent to the LLM */
|
|
449
|
+
Requested = "requested"
|
|
448
450
|
}
|
|
449
451
|
export interface ILLMRequestContext {
|
|
450
452
|
modelEntryName: string;
|
|
@@ -9,11 +9,12 @@ import { AccountService } from '@sre/Security/Account.service';
|
|
|
9
9
|
import { VaultService } from '@sre/Security/Vault.service';
|
|
10
10
|
import { RouterService } from '@sre/IO/Router.service';
|
|
11
11
|
import { ManagedVaultService } from '@sre/Security/ManagedVault.service';
|
|
12
|
-
import { LogService } from '@sre/
|
|
12
|
+
import { LogService } from '@sre/ObservabilityManager/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
16
|
import { SchedulerService } from '@sre/AgentManager/Scheduler.service';
|
|
17
|
+
import { TelemetryService } from '@sre/ObservabilityManager/Telemetry.service';
|
|
17
18
|
export type TServiceRegistry = {
|
|
18
19
|
Storage?: StorageService;
|
|
19
20
|
VectorDB?: VectorDBService;
|
|
@@ -31,6 +32,7 @@ export type TServiceRegistry = {
|
|
|
31
32
|
ModelsProvider?: ModelsProviderService;
|
|
32
33
|
Code?: CodeService;
|
|
33
34
|
Scheduler?: SchedulerService;
|
|
35
|
+
Telemetry?: TelemetryService;
|
|
34
36
|
};
|
|
35
37
|
export declare enum TConnectorService {
|
|
36
38
|
Storage = "Storage",
|
|
@@ -48,7 +50,8 @@ export declare enum TConnectorService {
|
|
|
48
50
|
Component = "Component",
|
|
49
51
|
ModelsProvider = "ModelsProvider",
|
|
50
52
|
Code = "Code",
|
|
51
|
-
Scheduler = "Scheduler"
|
|
53
|
+
Scheduler = "Scheduler",
|
|
54
|
+
Telemetry = "Telemetry"
|
|
52
55
|
}
|
|
53
56
|
export type SREConnectorConfig = {
|
|
54
57
|
Connector: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smythos/sre",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.16",
|
|
4
4
|
"description": "Smyth Runtime Environment",
|
|
5
5
|
"author": "Alaa-eddine KADDOURI",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,6 +57,14 @@
|
|
|
57
57
|
"@google/genai": "^1.10.0",
|
|
58
58
|
"@huggingface/inference": "^2.8.0",
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.17.4",
|
|
60
|
+
"@opentelemetry/api": "^1.9.0",
|
|
61
|
+
"@opentelemetry/api-logs": "^0.208.0",
|
|
62
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.208.0",
|
|
63
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
|
|
64
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
65
|
+
"@opentelemetry/sdk-logs": "^0.208.0",
|
|
66
|
+
"@opentelemetry/sdk-trace-node": "^2.2.0",
|
|
67
|
+
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
60
68
|
"@pinecone-database/pinecone": "^3.0.0",
|
|
61
69
|
"@runware/sdk-js": "^1.1.36",
|
|
62
70
|
"@smithy/smithy-client": "^4.4.3",
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
// helper.ts
|
|
2
|
+
import { ConnectorService } from '@sre/Core/ConnectorsService';
|
|
3
|
+
import { SystemEvents } from '@sre/Core/SystemEvents';
|
|
4
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
5
|
+
import { REQUEST_CONTENT_TYPES } from '@sre/constants';
|
|
6
|
+
import { Logger } from '@sre/helpers/Log.helper';
|
|
7
|
+
import { TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
8
|
+
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
9
|
import crypto from 'crypto';
|
|
3
10
|
import OAuth from 'oauth-1.0a';
|
|
4
11
|
import AccessTokenManager from './AccessTokenManager';
|
|
5
|
-
import { REQUEST_CONTENT_TYPES } from '@sre/constants';
|
|
6
|
-
import axios, { AxiosRequestConfig } from 'axios';
|
|
7
|
-
import { Logger } from '@sre/helpers/Log.helper';
|
|
8
|
-
import { ConnectorService } from '@sre/Core/ConnectorsService';
|
|
9
|
-
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
10
|
-
import { Match, TemplateString } from '@sre/helpers/TemplateString.helper';
|
|
11
|
-
import { SystemEvents } from '@sre/Core/SystemEvents';
|
|
12
|
-
import { cloneDeep } from 'lodash';
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const logger = Logger('OAuth.helper');
|
|
15
14
|
let managedVault: any;
|
|
16
15
|
|
|
17
16
|
SystemEvents.on('SRE:Booted', () => {
|
|
18
17
|
try {
|
|
19
18
|
managedVault = ConnectorService.getManagedVaultConnector();
|
|
20
19
|
} catch (error) {
|
|
21
|
-
|
|
20
|
+
logger.warn('Could not find a compatible ManagedVault connector, OAuth APICalls will not work');
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
|
|
@@ -27,7 +26,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
27
26
|
|
|
28
27
|
// Validate URL doesn't contain unresolved template variables
|
|
29
28
|
if (reqConfig.url && (reqConfig.url.includes('{{') || reqConfig.url.includes('${{'))) {
|
|
30
|
-
|
|
29
|
+
logger.warn('Warning: URL contains unresolved template variables for OAuth1 signature:', reqConfig.url);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
// Parse URL parameters
|
|
@@ -38,10 +37,10 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
38
37
|
|
|
39
38
|
// Log if we have query parameters for debugging
|
|
40
39
|
if (searchParams.toString()) {
|
|
41
|
-
|
|
40
|
+
logger.debug('OAuth1: Found query parameters:', Object.keys(additionalParams));
|
|
42
41
|
}
|
|
43
42
|
} catch (error) {
|
|
44
|
-
|
|
43
|
+
logger.warn('Failed to parse URL for OAuth1 parameters:', error);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
// Get the content type, handling different header formats
|
|
@@ -69,7 +68,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
69
68
|
if (typeof reqConfig.data === 'string') {
|
|
70
69
|
// Check for unresolved template variables in form data
|
|
71
70
|
if (reqConfig.data.includes('{{') || reqConfig.data.includes('${{')) {
|
|
72
|
-
|
|
71
|
+
logger.warn('Warning: Form data contains unresolved template variables for OAuth1 signature');
|
|
73
72
|
}
|
|
74
73
|
const formData = new URLSearchParams(reqConfig.data);
|
|
75
74
|
formParams = Object.fromEntries(formData.entries());
|
|
@@ -79,7 +78,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
79
78
|
// Handle plain object
|
|
80
79
|
formParams = reqConfig.data;
|
|
81
80
|
}
|
|
82
|
-
|
|
81
|
+
logger.debug('OAuth1: Including form parameters in signature:', Object.keys(formParams));
|
|
83
82
|
additionalParams = { ...additionalParams, ...formParams };
|
|
84
83
|
}
|
|
85
84
|
} else if (contentType.includes(REQUEST_CONTENT_TYPES.json) || contentType.includes('application/') || contentType.includes('text/')) {
|
|
@@ -93,11 +92,11 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
93
92
|
}
|
|
94
93
|
// Check for unresolved template variables
|
|
95
94
|
if (bodyString.includes('{{') || bodyString.includes('${{')) {
|
|
96
|
-
|
|
95
|
+
logger.warn('Warning: Request body contains unresolved template variables for OAuth1 signature');
|
|
97
96
|
}
|
|
98
97
|
const hash = crypto.createHash('sha1').update(bodyString).digest('base64');
|
|
99
98
|
additionalParams['oauth_body_hash'] = hash;
|
|
100
|
-
|
|
99
|
+
logger.debug('OAuth1: Added oauth_body_hash for', contentType);
|
|
101
100
|
}
|
|
102
101
|
} else if (contentType.includes(REQUEST_CONTENT_TYPES.multipartFormData)) {
|
|
103
102
|
// For multipart form data, only include text fields
|
|
@@ -125,7 +124,7 @@ export function extractAdditionalParamsForOAuth1(reqConfig: AxiosRequestConfig =
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
logger.debug('OAuth1: Total parameters for signature:', Object.keys(additionalParams).length);
|
|
129
128
|
return additionalParams;
|
|
130
129
|
}
|
|
131
130
|
|
|
@@ -148,9 +147,9 @@ export const buildOAuth1Header = (url, method, oauth1Credentials, additionalPara
|
|
|
148
147
|
const urlObj = new URL(url);
|
|
149
148
|
// Remove query parameters from URL for signature base
|
|
150
149
|
baseUrl = `${urlObj.protocol}//${urlObj.host}${urlObj.pathname}`;
|
|
151
|
-
|
|
150
|
+
logger.debug('OAuth1: Base URL for signature:', baseUrl);
|
|
152
151
|
} catch (error) {
|
|
153
|
-
|
|
152
|
+
logger.warn('Failed to parse URL for OAuth1 signature:', error);
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
// Include additional parameters in the request data
|
|
@@ -209,10 +208,10 @@ export const retrieveOAuthTokens = async (agent, config) => {
|
|
|
209
208
|
// Add warning logs for OAuth2
|
|
210
209
|
if (type === 'oauth2' && service !== 'oauth2_client_credentials') {
|
|
211
210
|
if (!secondaryToken) {
|
|
212
|
-
|
|
211
|
+
logger.warn('Warning: refresh_token is missing for OAuth2');
|
|
213
212
|
}
|
|
214
213
|
if (!expiresIn) {
|
|
215
|
-
|
|
214
|
+
logger.warn('Warning: expires_in is missing for OAuth2.');
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
|
|
@@ -262,7 +261,7 @@ export const retrieveOAuthTokens = async (agent, config) => {
|
|
|
262
261
|
throw new Error(`Failed to parse retrieved tokens: ${error}`);
|
|
263
262
|
}
|
|
264
263
|
} catch (error) {
|
|
265
|
-
|
|
264
|
+
logger.error('Error retrieving OAuth tokens:', error);
|
|
266
265
|
throw error; // rethrow for potential handling by the calling code
|
|
267
266
|
}
|
|
268
267
|
};
|
|
@@ -375,7 +374,7 @@ async function getClientCredentialToken(tokensData, logger, keyId, oauthTokens,
|
|
|
375
374
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
376
375
|
});
|
|
377
376
|
|
|
378
|
-
|
|
377
|
+
logger.log('Access token refreshed successfully.');
|
|
379
378
|
logger.debug('Access token refreshed successfully.');
|
|
380
379
|
|
|
381
380
|
const newAccessToken = response.data.access_token;
|
|
@@ -432,7 +431,7 @@ async function getClientCredentialToken(tokensData, logger, keyId, oauthTokens,
|
|
|
432
431
|
|
|
433
432
|
return newAccessToken;
|
|
434
433
|
} else {
|
|
435
|
-
|
|
434
|
+
logger.log('Access token value is still valid.');
|
|
436
435
|
logger.debug('Access token value is still valid.');
|
|
437
436
|
return oauthTokens.primaryToken;
|
|
438
437
|
}
|
|
@@ -28,7 +28,22 @@ const mimeTypeCategories = {
|
|
|
28
28
|
'font/woff2',
|
|
29
29
|
'model/',
|
|
30
30
|
],
|
|
31
|
-
json: [
|
|
31
|
+
json: [
|
|
32
|
+
'application/json',
|
|
33
|
+
'application/ld+json',
|
|
34
|
+
'application/geo+json',
|
|
35
|
+
'application/graphql',
|
|
36
|
+
'application/vnd.api+json',
|
|
37
|
+
'application/json-patch+json',
|
|
38
|
+
'application/merge-patch+json',
|
|
39
|
+
'application/problem+json',
|
|
40
|
+
'application/hal+json',
|
|
41
|
+
'application/vnd.collection+json',
|
|
42
|
+
'application/json-seq',
|
|
43
|
+
'application/csp-report',
|
|
44
|
+
'application/manifest+json',
|
|
45
|
+
'application/cloudevents+json',
|
|
46
|
+
],
|
|
32
47
|
text: [
|
|
33
48
|
'text/', //all starting with text/
|
|
34
49
|
'application/xml',
|
|
@@ -2,7 +2,7 @@ import Joi from 'joi';
|
|
|
2
2
|
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
3
3
|
import { Logger } from '@sre/helpers/Log.helper';
|
|
4
4
|
import { performTypeInference } from '@sre/helpers/TypeChecker.helper';
|
|
5
|
-
import { hookAsync } from '@sre/Core/HookService';
|
|
5
|
+
import { hookableClass, hookAsync } from '@sre/Core/HookService';
|
|
6
6
|
|
|
7
7
|
export type TComponentSchema = {
|
|
8
8
|
name: string;
|
|
@@ -25,6 +25,8 @@ export enum ComponentInputType {
|
|
|
25
25
|
Array = 'Array',
|
|
26
26
|
Object = 'Object',
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
@hookableClass
|
|
28
30
|
export class Component {
|
|
29
31
|
public hasReadOutput = false;
|
|
30
32
|
public hasPostProcess = true;
|
|
@@ -3,7 +3,7 @@ import { ComponentConnector } from '@sre/AgentManager/Component.service/Componen
|
|
|
3
3
|
import { SchedulerConnector } from '@sre/AgentManager/Scheduler.service/SchedulerConnector';
|
|
4
4
|
import { CodeConnector } from '@sre/ComputeManager/Code.service/CodeConnector';
|
|
5
5
|
import { CLIConnector } from '@sre/IO/CLI.service/CLIConnector';
|
|
6
|
-
import { LogConnector } from '@sre/
|
|
6
|
+
import { LogConnector } from '@sre/ObservabilityManager/Log.service/LogConnector';
|
|
7
7
|
import { NKVConnector } from '@sre/IO/NKV.service/NKVConnector';
|
|
8
8
|
import { RouterConnector } from '@sre/IO/Router.service/RouterConnector';
|
|
9
9
|
import { StorageConnector } from '@sre/IO/Storage.service/StorageConnector';
|
|
@@ -14,6 +14,7 @@ import { CacheConnector } from '@sre/MemoryManager/Cache.service/CacheConnector'
|
|
|
14
14
|
import { AccountConnector } from '@sre/Security/Account.service/AccountConnector';
|
|
15
15
|
import { ManagedVaultConnector } from '@sre/Security/ManagedVault.service/ManagedVaultConnector';
|
|
16
16
|
import { VaultConnector } from '@sre/Security/Vault.service/VaultConnector';
|
|
17
|
+
import { TelemetryConnector } from '@sre/ObservabilityManager/Telemetry.service/TelemetryConnector';
|
|
17
18
|
import { TConnectorService, TServiceRegistry } from '@sre/types/SRE.types';
|
|
18
19
|
import { isSubclassOf, printStackTrace } from '@sre/utils';
|
|
19
20
|
import { Logger } from '../helpers/Log.helper';
|
|
@@ -220,6 +221,9 @@ export class ConnectorService {
|
|
|
220
221
|
static getSchedulerConnector(name?: string): SchedulerConnector {
|
|
221
222
|
return ConnectorService.getInstance<SchedulerConnector>(TConnectorService.Scheduler, name);
|
|
222
223
|
}
|
|
224
|
+
static getTelemetryConnector(name?: string): TelemetryConnector {
|
|
225
|
+
return ConnectorService.getInstance<TelemetryConnector>(TConnectorService.Telemetry, name);
|
|
226
|
+
}
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
export abstract class ConnectorServiceProvider {
|