@smythos/sre 1.5.74 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +16 -10
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/types/Components/Component.class.d.ts +16 -2
- package/dist/types/helpers/AIPerformanceAnalyzer.helper.d.ts +45 -0
- package/dist/types/helpers/AIPerformanceCollector.helper.d.ts +111 -0
- package/dist/types/helpers/Conversation.helper.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.d.ts +7 -1
- package/dist/types/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.d.ts +1 -1
- package/dist/types/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.d.ts +8 -5
- package/dist/types/subsystems/IO/VectorDB.service/connectors/WeaviateVectorDB.class.d.ts +187 -0
- package/dist/types/subsystems/MemoryManager/RuntimeContext.d.ts +1 -0
- package/dist/types/subsystems/PerformanceManager/Performance.service/PerformanceConnector.d.ts +102 -0
- package/dist/types/subsystems/PerformanceManager/Performance.service/connectors/LocalPerformanceConnector.class.d.ts +100 -0
- package/dist/types/subsystems/PerformanceManager/Performance.service/index.d.ts +22 -0
- package/dist/types/subsystems/Security/Account.service/connectors/MySQLAccount.class.d.ts +19 -0
- package/dist/types/types/Performance.types.d.ts +468 -0
- package/package.json +1 -1
- package/src/Components/Component.class.ts +16 -2
- package/src/helpers/Conversation.helper.ts +9 -1
- package/src/index.ts +1 -1
- package/src/index.ts.bak +1 -1
- package/src/subsystems/IO/Storage.service/SmythFS.class.ts +3 -4
- package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +12 -1
- package/src/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.ts +4 -1
- package/src/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.ts +48 -46
- package/src/subsystems/MemoryManager/Cache.service/connectors/RAMCache.class.ts +14 -1
- package/src/subsystems/MemoryManager/RuntimeContext.ts +9 -2
- package/src/subsystems/Security/Account.service/connectors/JSONFileAccount.class.ts +6 -1
- package/src/subsystems/Security/Account.service/connectors/{AWSAccount.class.ts → MySQLAccount.class.ts} +3 -3
- package/src/subsystems/Security/Account.service/index.ts +2 -2
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import { IAgent as Agent } from '@sre/types/Agent.types';
|
|
2
|
-
export type
|
|
2
|
+
export type TComponentSchema = {
|
|
3
3
|
name: string;
|
|
4
4
|
settings?: Record<string, any>;
|
|
5
5
|
inputs?: Record<string, any>;
|
|
6
6
|
outputs?: Record<string, any>;
|
|
7
7
|
};
|
|
8
|
+
export declare enum ComponentInputType {
|
|
9
|
+
Any = "Any",
|
|
10
|
+
Binary = "Binary",
|
|
11
|
+
String = "Text",
|
|
12
|
+
Text = "Text",
|
|
13
|
+
Image = "Image",
|
|
14
|
+
Video = "Video",
|
|
15
|
+
Number = "Number",
|
|
16
|
+
Integer = "Integer",
|
|
17
|
+
Boolean = "Boolean",
|
|
18
|
+
Date = "Date",
|
|
19
|
+
Array = "Array",
|
|
20
|
+
Object = "Object"
|
|
21
|
+
}
|
|
8
22
|
export declare class Component {
|
|
9
23
|
hasReadOutput: boolean;
|
|
10
24
|
hasPostProcess: boolean;
|
|
11
25
|
alwaysActive: boolean;
|
|
12
26
|
exclusive: boolean;
|
|
13
|
-
protected schema:
|
|
27
|
+
protected schema: TComponentSchema;
|
|
14
28
|
protected configSchema: any;
|
|
15
29
|
constructor();
|
|
16
30
|
init(): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AIComponentMetrics, AIAgentPerformanceReport, AIPerformanceBottleneck } from '@sre/types/Performance.types';
|
|
2
|
+
/**
|
|
3
|
+
* Advanced AI Performance Analyzer
|
|
4
|
+
*/
|
|
5
|
+
export declare class AIPerformanceAnalyzer {
|
|
6
|
+
private behaviorAnalyzer;
|
|
7
|
+
private logger;
|
|
8
|
+
/**
|
|
9
|
+
* Generate comprehensive AI agent performance report
|
|
10
|
+
*/
|
|
11
|
+
analyzeAgentPerformance(agentId: string, agentName: string, metrics: AIComponentMetrics[], timeWindow?: {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
}): Promise<AIAgentPerformanceReport>;
|
|
15
|
+
/**
|
|
16
|
+
* Real-time bottleneck detection
|
|
17
|
+
*/
|
|
18
|
+
detectRealTimeBottleneck(metric: AIComponentMetrics): Promise<AIPerformanceBottleneck | null>;
|
|
19
|
+
private calculateSummaryStats;
|
|
20
|
+
private analyzeComponentPerformance;
|
|
21
|
+
private detectBottlenecks;
|
|
22
|
+
private generateOptimizationRecommendations;
|
|
23
|
+
private analyzeAISpecificPatterns;
|
|
24
|
+
private analyzeTrends;
|
|
25
|
+
private calculatePerformanceGrade;
|
|
26
|
+
private findCriticalPath;
|
|
27
|
+
private findParallelizationOpportunities;
|
|
28
|
+
private classifyBottleneckType;
|
|
29
|
+
private generateBottleneckDescription;
|
|
30
|
+
private identifyRootCause;
|
|
31
|
+
private calculatePerformanceImpact;
|
|
32
|
+
private generateFixSuggestion;
|
|
33
|
+
private assessImplementationComplexity;
|
|
34
|
+
private estimateResolutionTime;
|
|
35
|
+
private estimatePerformanceGain;
|
|
36
|
+
private estimateCostReduction;
|
|
37
|
+
private getPrerequisites;
|
|
38
|
+
private analyzeComponentSequences;
|
|
39
|
+
private findDuplicatePrompts;
|
|
40
|
+
private findModelDowngradeOpportunities;
|
|
41
|
+
private findCachingOpportunities;
|
|
42
|
+
private findBatchingOpportunities;
|
|
43
|
+
private calculateDataFlowEfficiency;
|
|
44
|
+
private calculateInformationLossRate;
|
|
45
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { AIComponentMetrics, AIPerformanceConfig, MetricWindow } from '@sre/types/Performance.types';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
/**
|
|
4
|
+
* Zero-overhead performance timer with AI-specific tracking
|
|
5
|
+
*/
|
|
6
|
+
export declare class AIPerformanceTimer {
|
|
7
|
+
private componentName;
|
|
8
|
+
private agentId;
|
|
9
|
+
private configHash;
|
|
10
|
+
private startTime;
|
|
11
|
+
private startMemory;
|
|
12
|
+
private checkpoints;
|
|
13
|
+
private llmMetrics;
|
|
14
|
+
constructor(componentName: string, agentId: string, configHash: string);
|
|
15
|
+
/**
|
|
16
|
+
* Add checkpoint for detailed timing analysis
|
|
17
|
+
*/
|
|
18
|
+
checkpoint(name: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Track LLM-specific metrics
|
|
21
|
+
*/
|
|
22
|
+
trackLLM(llmData: {
|
|
23
|
+
model: string;
|
|
24
|
+
promptTokens: number;
|
|
25
|
+
completionTokens: number;
|
|
26
|
+
estimatedCost: number;
|
|
27
|
+
contextUtilization?: number;
|
|
28
|
+
qualityScore?: number;
|
|
29
|
+
}): void;
|
|
30
|
+
/**
|
|
31
|
+
* Complete timing and generate comprehensive metrics
|
|
32
|
+
*/
|
|
33
|
+
finish(inputData?: any, outputData?: any, success?: boolean, errorType?: string, retryCount?: number): AIComponentMetrics;
|
|
34
|
+
private calculateDataSize;
|
|
35
|
+
private calculateComplexityScore;
|
|
36
|
+
private getObjectComplexity;
|
|
37
|
+
private calculateMemoryPressure;
|
|
38
|
+
private estimateCPUUsage;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Main AI Performance Collector - Enterprise-grade monitoring system
|
|
42
|
+
*/
|
|
43
|
+
export declare class AIPerformanceCollector extends EventEmitter {
|
|
44
|
+
private static instance;
|
|
45
|
+
private metricsBuffer;
|
|
46
|
+
private config;
|
|
47
|
+
private logger;
|
|
48
|
+
private activeTimers;
|
|
49
|
+
private eventSequence;
|
|
50
|
+
private batchBuffer;
|
|
51
|
+
private flushTimer?;
|
|
52
|
+
private constructor();
|
|
53
|
+
/**
|
|
54
|
+
* Get singleton instance with configuration
|
|
55
|
+
*/
|
|
56
|
+
static getInstance(config?: AIPerformanceConfig): AIPerformanceCollector;
|
|
57
|
+
/**
|
|
58
|
+
* Start monitoring a component execution
|
|
59
|
+
*/
|
|
60
|
+
startComponentExecution(componentName: string, agentId: string, config?: any): AIPerformanceTimer | null;
|
|
61
|
+
/**
|
|
62
|
+
* Record completed component execution
|
|
63
|
+
*/
|
|
64
|
+
recordMetrics(agentId: string, metrics: AIComponentMetrics): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get metrics for specific agent within time window
|
|
67
|
+
*/
|
|
68
|
+
getAgentMetrics(agentId: string, window?: MetricWindow): AIComponentMetrics[];
|
|
69
|
+
/**
|
|
70
|
+
* Get aggregated metrics across all agents
|
|
71
|
+
*/
|
|
72
|
+
getGlobalMetrics(window?: MetricWindow): AIComponentMetrics[];
|
|
73
|
+
/**
|
|
74
|
+
* Clear metrics for specific agent
|
|
75
|
+
*/
|
|
76
|
+
clearAgentMetrics(agentId: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get current system statistics
|
|
79
|
+
*/
|
|
80
|
+
getSystemStats(): {
|
|
81
|
+
activeTimers: number;
|
|
82
|
+
totalMetrics: number;
|
|
83
|
+
memoryUsage: number;
|
|
84
|
+
eventBufferSize: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Update configuration at runtime
|
|
88
|
+
*/
|
|
89
|
+
updateConfig(newConfig: Partial<AIPerformanceConfig>): void;
|
|
90
|
+
/**
|
|
91
|
+
* Export metrics for external monitoring systems
|
|
92
|
+
*/
|
|
93
|
+
exportMetrics(format?: 'json' | 'prometheus' | 'csv'): string;
|
|
94
|
+
private shouldMonitorComponent;
|
|
95
|
+
private shouldSample;
|
|
96
|
+
private generateConfigHash;
|
|
97
|
+
private emitEvent;
|
|
98
|
+
private setupFlushTimer;
|
|
99
|
+
private checkPerformanceThresholds;
|
|
100
|
+
private formatPrometheusMetrics;
|
|
101
|
+
private formatCSVMetrics;
|
|
102
|
+
/**
|
|
103
|
+
* Graceful shutdown
|
|
104
|
+
*/
|
|
105
|
+
private flushBatch;
|
|
106
|
+
shutdown(): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Default configuration for development
|
|
110
|
+
*/
|
|
111
|
+
export declare const DEFAULT_AI_PERFORMANCE_CONFIG: AIPerformanceConfig;
|
|
@@ -45,6 +45,7 @@ export declare class Conversation extends EventEmitter {
|
|
|
45
45
|
toolsStrategy?: (toolsConfig: any) => any;
|
|
46
46
|
agentId?: string;
|
|
47
47
|
agentVersion?: string;
|
|
48
|
+
baseUrl?: string;
|
|
48
49
|
});
|
|
49
50
|
get ready(): any;
|
|
50
51
|
prompt(message?: string | any, toolHeaders?: {}, concurrentToolCalls?: number, abortSignal?: AbortSignal): Promise<string>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -176,9 +176,9 @@ export * from './subsystems/MemoryManager/Cache.service/connectors/LocalStorageC
|
|
|
176
176
|
export * from './subsystems/MemoryManager/Cache.service/connectors/RAMCache.class';
|
|
177
177
|
export * from './subsystems/MemoryManager/Cache.service/connectors/RedisCache.class';
|
|
178
178
|
export * from './subsystems/MemoryManager/Cache.service/connectors/S3Cache.class';
|
|
179
|
-
export * from './subsystems/Security/Account.service/connectors/AWSAccount.class';
|
|
180
179
|
export * from './subsystems/Security/Account.service/connectors/DummyAccount.class';
|
|
181
180
|
export * from './subsystems/Security/Account.service/connectors/JSONFileAccount.class';
|
|
181
|
+
export * from './subsystems/Security/Account.service/connectors/MySQLAccount.class';
|
|
182
182
|
export * from './subsystems/Security/ManagedVault.service/connectors/NullManagedVault.class';
|
|
183
183
|
export * from './subsystems/Security/ManagedVault.service/connectors/SecretManagerManagedVault';
|
|
184
184
|
export * from './subsystems/Security/Vault.service/connectors/HashicorpVault.class';
|
|
@@ -15,8 +15,14 @@ export type IMilvusCredentials = {
|
|
|
15
15
|
token?: string;
|
|
16
16
|
};
|
|
17
17
|
export type MilvusConfig = {
|
|
18
|
+
/**
|
|
19
|
+
* The Milvus connection credentials
|
|
20
|
+
*/
|
|
18
21
|
credentials: IMilvusCredentials;
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The embeddings model to use
|
|
24
|
+
*/
|
|
25
|
+
embeddings?: TEmbeddings;
|
|
20
26
|
};
|
|
21
27
|
export declare class MilvusVectorDB extends VectorDBConnector {
|
|
22
28
|
protected _settings: MilvusConfig;
|
|
@@ -5,7 +5,10 @@ import { VectorDBConnector, DeleteTarget } from '../VectorDBConnector';
|
|
|
5
5
|
import { DatasourceDto, IStorageVectorDataSource, IStorageVectorNamespace, IVectorDataSourceDto, QueryOptions, VectorsResultData } from '@sre/types/VectorDB.types';
|
|
6
6
|
import { BaseEmbedding, TEmbeddings } from '../embed/BaseEmbedding';
|
|
7
7
|
export type RAMVectorDBConfig = {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The embeddings model to use
|
|
10
|
+
*/
|
|
11
|
+
embeddings?: TEmbeddings;
|
|
9
12
|
};
|
|
10
13
|
/**
|
|
11
14
|
* RAM Vector Database - stores everything in memory
|
|
@@ -20,10 +23,10 @@ export declare class RAMVectorDB extends VectorDBConnector {
|
|
|
20
23
|
name: string;
|
|
21
24
|
id: string;
|
|
22
25
|
private accountConnector;
|
|
23
|
-
private vectors;
|
|
24
|
-
private namespaces;
|
|
25
|
-
private datasources;
|
|
26
|
-
private acls;
|
|
26
|
+
private static vectors;
|
|
27
|
+
private static namespaces;
|
|
28
|
+
private static datasources;
|
|
29
|
+
private static acls;
|
|
27
30
|
embedder: BaseEmbedding;
|
|
28
31
|
constructor(_settings: RAMVectorDBConfig);
|
|
29
32
|
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { ACL } from '@sre/Security/AccessControl/ACL.class';
|
|
2
|
+
import { IAccessCandidate } from '@sre/types/ACL.types';
|
|
3
|
+
import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
|
|
4
|
+
import { VectorDBConnector, DeleteTarget } from '../VectorDBConnector';
|
|
5
|
+
import { DatasourceDto, IStorageVectorDataSource, IVectorDataSourceDto, QueryOptions, VectorsResultData } from '@sre/types/VectorDB.types';
|
|
6
|
+
import { TEmbeddings } from '../embed/BaseEmbedding';
|
|
7
|
+
export type WeaviateConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* The Weaviate instance URL
|
|
10
|
+
*/
|
|
11
|
+
url: string;
|
|
12
|
+
/**
|
|
13
|
+
* The Weaviate API key (optional for open source)
|
|
14
|
+
*/
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The class name to use for storing vectors
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The embeddings model to use
|
|
22
|
+
*/
|
|
23
|
+
embeddings: TEmbeddings;
|
|
24
|
+
/**
|
|
25
|
+
* Additional Weaviate client options
|
|
26
|
+
*/
|
|
27
|
+
clientOptions?: {
|
|
28
|
+
timeout?: number;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare class WeaviateVectorDB extends VectorDBConnector {
|
|
33
|
+
protected _settings: WeaviateConfig;
|
|
34
|
+
name: string;
|
|
35
|
+
id: string;
|
|
36
|
+
private client;
|
|
37
|
+
private className;
|
|
38
|
+
private cache;
|
|
39
|
+
private accountConnector;
|
|
40
|
+
private nkvConnector;
|
|
41
|
+
embedder: any;
|
|
42
|
+
constructor(_settings: WeaviateConfig);
|
|
43
|
+
/**
|
|
44
|
+
* @async
|
|
45
|
+
* @method getResourceACL
|
|
46
|
+
* @description Gets the ACL for a specific resource in Weaviate
|
|
47
|
+
* @param {string} resourceId - The resource identifier
|
|
48
|
+
* @param {IAccessCandidate} candidate - The access candidate
|
|
49
|
+
* @returns {Promise<ACL>} The ACL for the resource
|
|
50
|
+
* @throws {Error} If there's an error retrieving the ACL
|
|
51
|
+
*/
|
|
52
|
+
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
53
|
+
/**
|
|
54
|
+
* @async
|
|
55
|
+
* @method getACL
|
|
56
|
+
* @description Gets the ACL for a specific namespace in Weaviate
|
|
57
|
+
* @param {AccessCandidate} candidate - The access candidate
|
|
58
|
+
* @param {string} preparedNs - The prepared namespace name
|
|
59
|
+
* @returns {Promise<IACL | null>} The ACL for the namespace or null if not found
|
|
60
|
+
* @throws {Error} If there's an error retrieving the ACL
|
|
61
|
+
*/
|
|
62
|
+
private getACL;
|
|
63
|
+
/**
|
|
64
|
+
* @async
|
|
65
|
+
* @method createNamespace
|
|
66
|
+
* @description Creates a namespace in Weaviate by creating a class
|
|
67
|
+
* @param {AccessRequest} acRequest - The access request
|
|
68
|
+
* @param {string} namespace - The namespace name
|
|
69
|
+
* @param {object} metadata - Optional metadata
|
|
70
|
+
* @returns {Promise<void>}
|
|
71
|
+
* @throws {Error} If there's an error creating the namespace
|
|
72
|
+
*/
|
|
73
|
+
protected createNamespace(acRequest: AccessRequest, namespace: string, metadata?: {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* @async
|
|
78
|
+
* @method deleteNamespace
|
|
79
|
+
* @description Deletes a namespace by removing the class
|
|
80
|
+
* @param {AccessRequest} acRequest - The access request
|
|
81
|
+
* @param {string} namespace - The namespace name
|
|
82
|
+
* @returns {Promise<void>}
|
|
83
|
+
* @throws {Error} If there's an error deleting the namespace
|
|
84
|
+
*/
|
|
85
|
+
protected deleteNamespace(acRequest: AccessRequest, namespace: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* @async
|
|
88
|
+
* @method namespaceExists
|
|
89
|
+
* @description Checks if a namespace exists in Weaviate
|
|
90
|
+
* @param {AccessRequest} acRequest - The access request
|
|
91
|
+
* @param {string} namespace - The namespace name
|
|
92
|
+
* @returns {Promise<boolean>} True if namespace exists
|
|
93
|
+
* @throws {Error} If there's an error checking namespace existence
|
|
94
|
+
*/
|
|
95
|
+
protected namespaceExists(acRequest: AccessRequest, namespace: string): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* @async
|
|
98
|
+
* @method search
|
|
99
|
+
* @description Performs vector search in Weaviate
|
|
100
|
+
* @param {AccessRequest} acRequest - The access request
|
|
101
|
+
* @param {string} namespace - The namespace to search in
|
|
102
|
+
* @param {string | number[]} query - The search query (text or vector)
|
|
103
|
+
* @param {QueryOptions} options - Search options
|
|
104
|
+
* @returns {Promise<VectorsResultData>} Search results
|
|
105
|
+
* @throws {Error} If there's an error performing the search
|
|
106
|
+
*/
|
|
107
|
+
protected search(acRequest: AccessRequest, namespace: string, query: string | number[], options: QueryOptions): Promise<VectorsResultData>;
|
|
108
|
+
/**
|
|
109
|
+
* @async
|
|
110
|
+
* @method insert
|
|
111
|
+
* @description Inserts vectors into Weaviate
|
|
112
|
+
* @param {AccessRequest} acRequest - The access request
|
|
113
|
+
* @param {string} namespace - The namespace to insert into
|
|
114
|
+
* @param {IVectorDataSourceDto | IVectorDataSourceDto[]} source - The data to insert
|
|
115
|
+
* @returns {Promise<string[]>} Array of inserted IDs
|
|
116
|
+
* @throws {Error} If there's an error inserting data
|
|
117
|
+
*/
|
|
118
|
+
protected insert(acRequest: AccessRequest, namespace: string, source: IVectorDataSourceDto | IVectorDataSourceDto[]): Promise<string[]>;
|
|
119
|
+
/**
|
|
120
|
+
* @async
|
|
121
|
+
* @method delete
|
|
122
|
+
* @description Deletes vectors from Weaviate
|
|
123
|
+
* @param {AccessRequest} acRequest - The access request
|
|
124
|
+
* @param {string} namespace - The namespace to delete from
|
|
125
|
+
* @param {DeleteTarget} deleteTarget - What to delete
|
|
126
|
+
* @returns {Promise<void>}
|
|
127
|
+
* @throws {Error} If there's an error deleting data
|
|
128
|
+
*/
|
|
129
|
+
protected delete(acRequest: AccessRequest, namespace: string, deleteTarget: DeleteTarget): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* @async
|
|
132
|
+
* @method createDatasource
|
|
133
|
+
* @description Creates a datasource in Weaviate
|
|
134
|
+
* @param {AccessRequest} acRequest - The access request
|
|
135
|
+
* @param {string} namespace - The namespace
|
|
136
|
+
* @param {DatasourceDto} datasource - The datasource data
|
|
137
|
+
* @returns {Promise<IStorageVectorDataSource>} The created datasource
|
|
138
|
+
* @throws {Error} If there's an error creating the datasource
|
|
139
|
+
*/
|
|
140
|
+
protected createDatasource(acRequest: AccessRequest, namespace: string, datasource: DatasourceDto): Promise<IStorageVectorDataSource>;
|
|
141
|
+
/**
|
|
142
|
+
* @async
|
|
143
|
+
* @method deleteDatasource
|
|
144
|
+
* @description Deletes a datasource from Weaviate
|
|
145
|
+
* @param {AccessRequest} acRequest - The access request
|
|
146
|
+
* @param {string} namespace - The namespace
|
|
147
|
+
* @param {string} datasourceId - The datasource ID
|
|
148
|
+
* @returns {Promise<void>}
|
|
149
|
+
* @throws {Error} If there's an error deleting the datasource
|
|
150
|
+
*/
|
|
151
|
+
protected deleteDatasource(acRequest: AccessRequest, namespace: string, datasourceId: string): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* @async
|
|
154
|
+
* @method listDatasources
|
|
155
|
+
* @description Lists all datasources in a namespace
|
|
156
|
+
* @param {AccessRequest} acRequest - The access request
|
|
157
|
+
* @param {string} namespace - The namespace
|
|
158
|
+
* @returns {Promise<IStorageVectorDataSource[]>} Array of datasources
|
|
159
|
+
* @throws {Error} If there's an error listing datasources
|
|
160
|
+
*/
|
|
161
|
+
protected listDatasources(acRequest: AccessRequest, namespace: string): Promise<IStorageVectorDataSource[]>;
|
|
162
|
+
/**
|
|
163
|
+
* @async
|
|
164
|
+
* @method getDatasource
|
|
165
|
+
* @description Gets a specific datasource
|
|
166
|
+
* @param {AccessRequest} acRequest - The access request
|
|
167
|
+
* @param {string} namespace - The namespace
|
|
168
|
+
* @param {string} datasourceId - The datasource ID
|
|
169
|
+
* @returns {Promise<IStorageVectorDataSource | undefined>} The datasource or undefined
|
|
170
|
+
* @throws {Error} If there's an error getting the datasource
|
|
171
|
+
*/
|
|
172
|
+
protected getDatasource(acRequest: AccessRequest, namespace: string, datasourceId: string): Promise<IStorageVectorDataSource | undefined>;
|
|
173
|
+
/**
|
|
174
|
+
* @method buildWhereClause
|
|
175
|
+
* @description Builds a Weaviate where clause from filter options
|
|
176
|
+
* @param {any} filter - The filter object
|
|
177
|
+
* @returns {object} Weaviate where clause
|
|
178
|
+
*/
|
|
179
|
+
private buildWhereClause;
|
|
180
|
+
/**
|
|
181
|
+
* @async
|
|
182
|
+
* @method stop
|
|
183
|
+
* @description Stops the Weaviate connector
|
|
184
|
+
* @returns {Promise<void>}
|
|
185
|
+
*/
|
|
186
|
+
stop(): Promise<void>;
|
|
187
|
+
}
|
package/dist/types/subsystems/PerformanceManager/Performance.service/PerformanceConnector.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
|
|
6
|
+
import { AIComponentMetrics, AIAgentPerformanceReport, AIPerformanceEvent, AIPerformanceConfig, MetricWindow, ComponentBaseline, ExternalMonitoringExport } from '@sre/types/Performance.types';
|
|
7
|
+
/**
|
|
8
|
+
* Performance request interface for secure access
|
|
9
|
+
*/
|
|
10
|
+
export interface IPerformanceRequest {
|
|
11
|
+
/** Store performance metrics for an agent */
|
|
12
|
+
storeMetrics(metrics: AIComponentMetrics[]): Promise<void>;
|
|
13
|
+
/** Retrieve metrics within a time window */
|
|
14
|
+
getMetrics(timeWindow?: MetricWindow): Promise<AIComponentMetrics[]>;
|
|
15
|
+
/** Generate comprehensive performance report */
|
|
16
|
+
generateReport(): Promise<AIAgentPerformanceReport>;
|
|
17
|
+
/** Clear stored metrics */
|
|
18
|
+
clearMetrics(): Promise<void>;
|
|
19
|
+
/** Get real-time performance events */
|
|
20
|
+
getEvents(since?: number): Promise<AIPerformanceEvent[]>;
|
|
21
|
+
/** Update performance monitoring configuration */
|
|
22
|
+
updateConfig(config: Partial<AIPerformanceConfig>): Promise<void>;
|
|
23
|
+
/** Export metrics in various formats */
|
|
24
|
+
exportMetrics(format: 'json' | 'prometheus' | 'csv'): Promise<string>;
|
|
25
|
+
/** Get component performance baselines */
|
|
26
|
+
getBaselines(): Promise<ComponentBaseline[]>;
|
|
27
|
+
/** Establish baseline for specific component */
|
|
28
|
+
establishBaseline(componentName: string): Promise<ComponentBaseline>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Abstract base class for performance connectors
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class PerformanceConnector extends SecureConnector {
|
|
34
|
+
abstract id: string;
|
|
35
|
+
/**
|
|
36
|
+
* Get ACL for performance resources
|
|
37
|
+
*/
|
|
38
|
+
abstract getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
39
|
+
/**
|
|
40
|
+
* Create secure requester interface scoped to access candidate
|
|
41
|
+
*/
|
|
42
|
+
requester(candidate: AccessCandidate): IPerformanceRequest;
|
|
43
|
+
/**
|
|
44
|
+
* Store performance metrics with access control
|
|
45
|
+
*/
|
|
46
|
+
protected abstract storeMetrics(accessRequest: AccessRequest, metrics: AIComponentMetrics[]): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve metrics with time window filtering
|
|
49
|
+
*/
|
|
50
|
+
protected abstract getMetrics(accessRequest: AccessRequest, timeWindow?: MetricWindow): Promise<AIComponentMetrics[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Generate comprehensive performance report
|
|
53
|
+
*/
|
|
54
|
+
protected abstract generateReport(accessRequest: AccessRequest): Promise<AIAgentPerformanceReport>;
|
|
55
|
+
/**
|
|
56
|
+
* Clear stored metrics
|
|
57
|
+
*/
|
|
58
|
+
protected abstract clearMetrics(accessRequest: AccessRequest): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Get performance events
|
|
61
|
+
*/
|
|
62
|
+
protected abstract getEvents(accessRequest: AccessRequest, since?: number): Promise<AIPerformanceEvent[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Update monitoring configuration
|
|
65
|
+
*/
|
|
66
|
+
protected abstract updateConfig(accessRequest: AccessRequest, config: Partial<AIPerformanceConfig>): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Export metrics in various formats
|
|
69
|
+
*/
|
|
70
|
+
protected abstract exportMetrics(accessRequest: AccessRequest, format: 'json' | 'prometheus' | 'csv'): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Get component baselines
|
|
73
|
+
*/
|
|
74
|
+
protected abstract getBaselines(accessRequest: AccessRequest): Promise<ComponentBaseline[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Establish baseline for component
|
|
77
|
+
*/
|
|
78
|
+
protected abstract establishBaseline(accessRequest: AccessRequest, componentName: string): Promise<ComponentBaseline>;
|
|
79
|
+
/**
|
|
80
|
+
* Export to external monitoring systems
|
|
81
|
+
*/
|
|
82
|
+
protected exportToExternal(accessRequest: AccessRequest, exportConfig: ExternalMonitoringExport): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Perform health check on the connector
|
|
85
|
+
*/
|
|
86
|
+
healthCheck(): Promise<{
|
|
87
|
+
status: 'healthy' | 'degraded' | 'unhealthy';
|
|
88
|
+
details: Record<string, any>;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Get connector statistics
|
|
92
|
+
*/
|
|
93
|
+
getStats(): Promise<{
|
|
94
|
+
totalMetrics: number;
|
|
95
|
+
agentCount: number;
|
|
96
|
+
timeRange: {
|
|
97
|
+
start: number;
|
|
98
|
+
end: number;
|
|
99
|
+
};
|
|
100
|
+
storageSize: number;
|
|
101
|
+
}>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PerformanceConnector, IPerformanceRequest } from '../PerformanceConnector';
|
|
2
|
+
import { AIComponentMetrics, AIAgentPerformanceReport, AIPerformanceEvent, AIPerformanceConfig, MetricWindow, ComponentBaseline } from '@sre/types/Performance.types';
|
|
3
|
+
import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
|
|
4
|
+
import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class';
|
|
5
|
+
import { ACL } from '@sre/Security/AccessControl/ACL.class';
|
|
6
|
+
import { IAccessCandidate } from '@sre/types/ACL.types';
|
|
7
|
+
/**
|
|
8
|
+
* Local Performance Connector Implementation
|
|
9
|
+
*/
|
|
10
|
+
export declare class LocalPerformanceConnector extends PerformanceConnector {
|
|
11
|
+
name: string;
|
|
12
|
+
id: string;
|
|
13
|
+
private metricsIndex;
|
|
14
|
+
private config;
|
|
15
|
+
private analyzer;
|
|
16
|
+
private collector;
|
|
17
|
+
private logger;
|
|
18
|
+
private dataDir;
|
|
19
|
+
private isInitialized;
|
|
20
|
+
constructor(settings?: any);
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the connector
|
|
23
|
+
*/
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Shutdown the connector
|
|
27
|
+
*/
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Get resource ACL
|
|
31
|
+
*/
|
|
32
|
+
getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
|
|
33
|
+
/**
|
|
34
|
+
* Override requester method to implement proper access control
|
|
35
|
+
* Create secure requester interface scoped to access candidate
|
|
36
|
+
*/
|
|
37
|
+
requester(candidate: AccessCandidate): IPerformanceRequest;
|
|
38
|
+
/**
|
|
39
|
+
* Store performance metrics
|
|
40
|
+
*/
|
|
41
|
+
protected storeMetrics(accessRequest: AccessRequest, metrics: AIComponentMetrics[]): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve metrics with filtering
|
|
44
|
+
*/
|
|
45
|
+
protected getMetrics(accessRequest: AccessRequest, timeWindow?: MetricWindow): Promise<AIComponentMetrics[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Generate comprehensive performance report
|
|
48
|
+
*/
|
|
49
|
+
protected generateReport(accessRequest: AccessRequest): Promise<AIAgentPerformanceReport>;
|
|
50
|
+
/**
|
|
51
|
+
* Clear stored metrics
|
|
52
|
+
*/
|
|
53
|
+
protected clearMetrics(accessRequest: AccessRequest): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get performance events
|
|
56
|
+
*/
|
|
57
|
+
protected getEvents(accessRequest: AccessRequest, since?: number): Promise<AIPerformanceEvent[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Update monitoring configuration
|
|
60
|
+
*/
|
|
61
|
+
protected updateConfig(accessRequest: AccessRequest, config: Partial<AIPerformanceConfig>): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Export metrics in various formats
|
|
64
|
+
*/
|
|
65
|
+
protected exportMetrics(accessRequest: AccessRequest, format: 'json' | 'prometheus' | 'csv'): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Get component baselines
|
|
68
|
+
*/
|
|
69
|
+
protected getBaselines(accessRequest: AccessRequest): Promise<ComponentBaseline[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Establish baseline for component
|
|
72
|
+
*/
|
|
73
|
+
protected establishBaseline(accessRequest: AccessRequest, componentName: string): Promise<ComponentBaseline>;
|
|
74
|
+
/**
|
|
75
|
+
* Get connector statistics
|
|
76
|
+
*/
|
|
77
|
+
getStats(): Promise<{
|
|
78
|
+
totalMetrics: number;
|
|
79
|
+
agentCount: number;
|
|
80
|
+
timeRange: {
|
|
81
|
+
start: number;
|
|
82
|
+
end: number;
|
|
83
|
+
};
|
|
84
|
+
storageSize: number;
|
|
85
|
+
}>;
|
|
86
|
+
private addToIndex;
|
|
87
|
+
private enforceSizeLimits;
|
|
88
|
+
private checkRealTimeBottleneck;
|
|
89
|
+
private setupEventListeners;
|
|
90
|
+
private loadPersistedData;
|
|
91
|
+
private setupPersistence;
|
|
92
|
+
private persistData;
|
|
93
|
+
private aggregateMetrics;
|
|
94
|
+
private aggregate;
|
|
95
|
+
private percentile;
|
|
96
|
+
private mean;
|
|
97
|
+
private formatPrometheusMetrics;
|
|
98
|
+
private formatCSVMetrics;
|
|
99
|
+
private estimateStorageSize;
|
|
100
|
+
}
|