@smythos/sre 1.5.73 → 1.5.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/index.js +8 -8
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/Components/Component.class.d.ts +16 -2
  4. package/dist/types/helpers/AIPerformanceAnalyzer.helper.d.ts +45 -0
  5. package/dist/types/helpers/AIPerformanceCollector.helper.d.ts +111 -0
  6. package/dist/types/helpers/Conversation.helper.d.ts +1 -0
  7. package/dist/types/index.d.ts +1 -1
  8. package/dist/types/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.d.ts +7 -1
  9. package/dist/types/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.d.ts +1 -1
  10. package/dist/types/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.d.ts +8 -5
  11. package/dist/types/subsystems/IO/VectorDB.service/connectors/WeaviateVectorDB.class.d.ts +187 -0
  12. package/dist/types/subsystems/MemoryManager/RuntimeContext.d.ts +1 -0
  13. package/dist/types/subsystems/PerformanceManager/Performance.service/PerformanceConnector.d.ts +102 -0
  14. package/dist/types/subsystems/PerformanceManager/Performance.service/connectors/LocalPerformanceConnector.class.d.ts +100 -0
  15. package/dist/types/subsystems/PerformanceManager/Performance.service/index.d.ts +22 -0
  16. package/dist/types/subsystems/Security/Account.service/connectors/MySQLAccount.class.d.ts +19 -0
  17. package/dist/types/types/Performance.types.d.ts +468 -0
  18. package/package.json +1 -1
  19. package/src/Components/Component.class.ts +16 -2
  20. package/src/helpers/Conversation.helper.ts +9 -1
  21. package/src/index.ts +194 -194
  22. package/src/index.ts.bak +194 -194
  23. package/src/subsystems/IO/Storage.service/SmythFS.class.ts +3 -4
  24. package/src/subsystems/IO/VectorDB.service/connectors/MilvusVectorDB.class.ts +12 -1
  25. package/src/subsystems/IO/VectorDB.service/connectors/PineconeVectorDB.class.ts +4 -1
  26. package/src/subsystems/IO/VectorDB.service/connectors/RAMVecrtorDB.class.ts +48 -46
  27. package/src/subsystems/LLMManager/ModelsProvider.service/connectors/JSONModelsProvider.class.ts +8 -5
  28. package/src/subsystems/MemoryManager/RuntimeContext.ts +8 -1
  29. package/src/subsystems/Security/Account.service/connectors/JSONFileAccount.class.ts +6 -1
  30. package/src/subsystems/Security/Account.service/connectors/{AWSAccount.class.ts → MySQLAccount.class.ts} +3 -3
  31. package/src/subsystems/Security/Account.service/index.ts +2 -2
@@ -0,0 +1,22 @@
1
+ import { ConnectorServiceProvider } from '../../../Core/ConnectorsService';
2
+ /**
3
+ * Performance Service Provider
4
+ */
5
+ export declare class PerformanceService extends ConnectorServiceProvider {
6
+ private logger;
7
+ /**
8
+ * Register all available performance connectors
9
+ */
10
+ register(): void;
11
+ /**
12
+ * Initialize performance service
13
+ */
14
+ init(): void;
15
+ /**
16
+ * Auto-configure performance monitoring based on environment
17
+ */
18
+ private autoConfigurePerformanceMonitoring;
19
+ }
20
+ export { LocalPerformanceConnector } from './connectors/LocalPerformanceConnector.class';
21
+ export { PerformanceConnector } from './PerformanceConnector';
22
+ export type { IPerformanceRequest } from './PerformanceConnector';
@@ -0,0 +1,19 @@
1
+ import { ACL } from '@sre/Security/AccessControl/ACL.class';
2
+ import { AccessRequest } from '@sre/Security/AccessControl/AccessRequest.class';
3
+ import { IAccessCandidate } from '@sre/types/ACL.types';
4
+ import { AccountConnector } from '../AccountConnector';
5
+ import { KeyValueObject } from '@sre/types/Common.types';
6
+ export declare class MySQLAccount extends AccountConnector {
7
+ protected _settings: any;
8
+ name: string;
9
+ private pool;
10
+ constructor(_settings: any);
11
+ isTeamMember(team: string, candidate: IAccessCandidate): Promise<boolean>;
12
+ getCandidateTeam(candidate: IAccessCandidate): Promise<string | undefined>;
13
+ getAllTeamSettings(acRequest: AccessRequest, teamId: string): Promise<KeyValueObject[]>;
14
+ getTeamSetting(acRequest: AccessRequest, teamId: string, settingKey: string): Promise<string>;
15
+ getResourceACL(resourceId: string, candidate: IAccessCandidate): Promise<ACL>;
16
+ getAllUserSettings(acRequest: AccessRequest, accountId: string): Promise<KeyValueObject[]>;
17
+ getUserSetting(acRequest: AccessRequest, accountId: string, settingKey: string): Promise<string>;
18
+ getAgentSetting(acRequest: AccessRequest, agentId: string, settingKey: string): Promise<string>;
19
+ }
@@ -0,0 +1,468 @@
1
+ export interface AIComponentMetrics {
2
+ /** Component identifier */
3
+ componentName: string;
4
+ /** Agent executing this component */
5
+ agentId: string;
6
+ /** Execution timing breakdown */
7
+ timing: {
8
+ /** Total execution time (ms) */
9
+ total: number;
10
+ /** Time spent on input processing (ms) */
11
+ inputProcessing: number;
12
+ /** Time spent on core logic (ms) */
13
+ coreProcessing: number;
14
+ /** Time spent on output processing (ms) */
15
+ outputProcessing: number;
16
+ /** Queue wait time (ms) */
17
+ queueTime: number;
18
+ };
19
+ /** Memory usage analytics */
20
+ memory: {
21
+ /** Peak memory usage during execution (bytes) */
22
+ peak: number;
23
+ /** Memory delta from start to finish (bytes) */
24
+ delta: number;
25
+ /** Memory pressure level (0-1) */
26
+ pressure: number;
27
+ };
28
+ /** Data flow metrics */
29
+ dataFlow: {
30
+ /** Input data size (bytes) */
31
+ inputSize: number;
32
+ /** Output data size (bytes) */
33
+ outputSize: number;
34
+ /** Data transformation ratio */
35
+ transformationRatio: number;
36
+ /** Data complexity score (0-1) */
37
+ complexityScore: number;
38
+ };
39
+ /** LLM-specific metrics (if applicable) */
40
+ llm?: {
41
+ /** Model used for this execution */
42
+ model: string;
43
+ /** Token usage breakdown */
44
+ tokens: {
45
+ prompt: number;
46
+ completion: number;
47
+ total: number;
48
+ };
49
+ /** Estimated cost in USD */
50
+ estimatedCost: number;
51
+ /** Context window utilization (0-1) */
52
+ contextUtilization: number;
53
+ /** Response quality score (0-1) */
54
+ qualityScore?: number;
55
+ };
56
+ /** Execution result metadata */
57
+ execution: {
58
+ /** Execution timestamp */
59
+ timestamp: number;
60
+ /** Success/failure status */
61
+ success: boolean;
62
+ /** Error type if failed */
63
+ errorType?: string;
64
+ /** Retry count */
65
+ retryCount: number;
66
+ /** Component configuration hash */
67
+ configHash: string;
68
+ };
69
+ /** Performance impact factors */
70
+ impact: {
71
+ /** CPU usage percentage during execution */
72
+ cpuUsage: number;
73
+ /** I/O operations count */
74
+ ioOperations: number;
75
+ /** Network requests made */
76
+ networkRequests: number;
77
+ /** Cache hit/miss status */
78
+ cacheStatus: 'hit' | 'miss' | 'n/a';
79
+ };
80
+ }
81
+ /**
82
+ * Comprehensive AI agent performance report
83
+ */
84
+ export interface AIAgentPerformanceReport {
85
+ /** Report metadata */
86
+ metadata: {
87
+ agentId: string;
88
+ agentName: string;
89
+ reportId: string;
90
+ generatedAt: number;
91
+ analysisWindow: {
92
+ start: number;
93
+ end: number;
94
+ duration?: number;
95
+ };
96
+ version: string;
97
+ };
98
+ /** Executive summary */
99
+ summary: {
100
+ /** Total execution time across all components */
101
+ totalExecutionTime: number;
102
+ /** Total LLM costs */
103
+ totalLLMCosts: number;
104
+ /** Success rate percentage */
105
+ successRate: number;
106
+ /** Performance grade (A-F) */
107
+ performanceGrade: 'A' | 'B' | 'C' | 'D' | 'F';
108
+ /** Key performance indicators */
109
+ kpis: {
110
+ throughput: number;
111
+ latency: number;
112
+ efficiency: number;
113
+ reliability: number;
114
+ };
115
+ };
116
+ /** Detailed component analysis */
117
+ components: {
118
+ /** Individual component metrics */
119
+ metrics: AIComponentMetrics[];
120
+ /** Component ranking by performance */
121
+ ranking: Array<{
122
+ componentName: string;
123
+ score: number;
124
+ rank: number;
125
+ }>;
126
+ /** Component dependency graph analysis */
127
+ dependencies: {
128
+ criticalPath: string[];
129
+ parallelizationOpportunities: string[][];
130
+ bottleneckComponents: string[];
131
+ };
132
+ };
133
+ /** AI-specific insights */
134
+ aiInsights: {
135
+ /** LLM usage optimization opportunities */
136
+ llmOptimization: {
137
+ modelDowngradeOpportunities: Array<{
138
+ component: string;
139
+ currentModel: string;
140
+ suggestedModel: string;
141
+ potentialSavings: number;
142
+ }>;
143
+ cachingOpportunities: Array<{
144
+ component: string;
145
+ repetitionRate: number;
146
+ potentialSavings: number;
147
+ }>;
148
+ batchingOpportunities: Array<{
149
+ components: string[];
150
+ batchSize: number;
151
+ potentialSavings: number;
152
+ }>;
153
+ };
154
+ /** Semantic analysis of component interactions */
155
+ semanticAnalysis: {
156
+ componentAffinity: Record<string, number>;
157
+ dataFlowEfficiency: number;
158
+ informationLossRate: number;
159
+ };
160
+ };
161
+ /** Performance bottlenecks with AI context */
162
+ bottlenecks: AIPerformanceBottleneck[];
163
+ /** Intelligent optimization recommendations */
164
+ recommendations: AIOptimizationRecommendation[];
165
+ /** Trend analysis and predictions */
166
+ trends: {
167
+ /** Performance trends over time */
168
+ performanceTrend: 'improving' | 'stable' | 'degrading';
169
+ /** Cost trends */
170
+ costTrend: 'improving' | 'stable' | 'degrading';
171
+ /** Predicted future performance */
172
+ predictions: Array<{
173
+ metric: string;
174
+ futureValue: number;
175
+ confidence: number;
176
+ timeframe: number;
177
+ }>;
178
+ };
179
+ }
180
+ /**
181
+ * AI-aware performance bottleneck
182
+ */
183
+ export interface AIPerformanceBottleneck {
184
+ /** Bottleneck identification */
185
+ id: string;
186
+ type: AIBottleneckType;
187
+ severity: BottleneckSeverity;
188
+ /** Component(s) affected */
189
+ affectedComponents: string[];
190
+ /** Detailed analysis */
191
+ analysis: {
192
+ description: string;
193
+ rootCause: string;
194
+ impactAssessment: {
195
+ performanceImpact: number;
196
+ costImpact: number;
197
+ userExperienceImpact: 'low' | 'medium' | 'high';
198
+ };
199
+ };
200
+ /** AI-specific context */
201
+ aiContext?: {
202
+ modelInefficiency?: {
203
+ model: string;
204
+ taskComplexity: number;
205
+ overProvisioningScore: number;
206
+ };
207
+ semanticBottleneck?: {
208
+ informationLoss: number;
209
+ contextFragmentation: number;
210
+ semanticDrift: number;
211
+ };
212
+ };
213
+ /** Resolution guidance */
214
+ resolution: {
215
+ suggestedFix: string;
216
+ implementationComplexity: 'low' | 'medium' | 'high';
217
+ estimatedResolutionTime: number;
218
+ expectedImprovement: {
219
+ performanceGain: number;
220
+ costReduction: number;
221
+ };
222
+ prerequisites: string[];
223
+ };
224
+ /** Confidence and validation */
225
+ confidence: number;
226
+ validatedBy?: 'static_analysis' | 'runtime_profiling' | 'ml_prediction';
227
+ }
228
+ /**
229
+ * AI-driven optimization recommendation
230
+ */
231
+ export interface AIOptimizationRecommendation {
232
+ /** Recommendation metadata */
233
+ id: string;
234
+ type: AIOptimizationType;
235
+ priority: OptimizationPriority;
236
+ category: 'performance' | 'cost' | 'reliability' | 'scalability';
237
+ /** Target components */
238
+ targetComponents: string[];
239
+ /** Recommendation details */
240
+ recommendation: {
241
+ title: string;
242
+ description: string;
243
+ technicalDetails: string;
244
+ implementation: {
245
+ steps: string[];
246
+ codeExamples: Array<{
247
+ language: string;
248
+ code: string;
249
+ description: string;
250
+ }>;
251
+ configuration: Record<string, any>;
252
+ };
253
+ };
254
+ /** Impact analysis */
255
+ impact: {
256
+ performance: {
257
+ latencyImprovement: number;
258
+ throughputImprovement: number;
259
+ memoryReduction: number;
260
+ };
261
+ cost: {
262
+ operationalSavings: number;
263
+ infrastructureSavings: number;
264
+ llmCostReduction: number;
265
+ };
266
+ reliability: {
267
+ errorReduction: number;
268
+ uptimeImprovement: number;
269
+ };
270
+ };
271
+ /** Implementation guidance */
272
+ implementation: {
273
+ effort: ImplementationEffort;
274
+ timeline: string;
275
+ risks: Array<{
276
+ description: string;
277
+ probability: number;
278
+ impact: 'low' | 'medium' | 'high';
279
+ mitigation: string;
280
+ }>;
281
+ rollbackStrategy: string;
282
+ };
283
+ /** AI-generated insights */
284
+ aiGenerated: {
285
+ confidence: number;
286
+ reasoning: string;
287
+ similarCases: number;
288
+ validationMethod: string;
289
+ };
290
+ }
291
+ /**
292
+ * Real-time performance monitoring configuration
293
+ */
294
+ export interface AIPerformanceConfig {
295
+ /** Global monitoring settings */
296
+ global: {
297
+ enabled: boolean;
298
+ samplingRate: number;
299
+ bufferSize: number;
300
+ flushInterval: number;
301
+ };
302
+ /** Component-specific settings */
303
+ components: {
304
+ whitelist: string[];
305
+ blacklist: string[];
306
+ customSamplingRates: Record<string, number>;
307
+ };
308
+ /** LLM monitoring settings */
309
+ llm: {
310
+ trackTokenUsage: boolean;
311
+ trackCosts: boolean;
312
+ trackQuality: boolean;
313
+ costThresholds: {
314
+ warning: number;
315
+ critical: number;
316
+ };
317
+ };
318
+ /** Alert configuration */
319
+ alerts: {
320
+ enabled: boolean;
321
+ thresholds: {
322
+ latencyP95: number;
323
+ errorRate: number;
324
+ memoryUsage: number;
325
+ costPerOperation: number;
326
+ };
327
+ channels: Array<{
328
+ type: 'console' | 'file' | 'webhook';
329
+ config: Record<string, any>;
330
+ }>;
331
+ };
332
+ /** Advanced features */
333
+ advanced: {
334
+ enablePredictiveAnalysis: boolean;
335
+ enableAutoOptimization: boolean;
336
+ enableSemanticAnalysis: boolean;
337
+ retentionDays: number;
338
+ compressionEnabled: boolean;
339
+ };
340
+ }
341
+ /**
342
+ * Performance event for real-time streaming
343
+ */
344
+ export interface AIPerformanceEvent {
345
+ /** Event metadata */
346
+ id: string;
347
+ timestamp: number;
348
+ type: AIPerformanceEventType;
349
+ source: {
350
+ agentId: string;
351
+ componentName: string;
352
+ sessionId?: string;
353
+ };
354
+ /** Event payload */
355
+ payload: {
356
+ metric?: AIComponentMetrics;
357
+ bottleneck?: AIPerformanceBottleneck;
358
+ recommendation?: AIOptimizationRecommendation;
359
+ alert?: {
360
+ level: 'info' | 'warning' | 'error' | 'critical';
361
+ message: string;
362
+ context: Record<string, any>;
363
+ };
364
+ };
365
+ /** Event processing metadata */
366
+ processing: {
367
+ latency: number;
368
+ batchId?: string;
369
+ sequenceNumber: number;
370
+ };
371
+ }
372
+ export declare enum AIBottleneckType {
373
+ LLM_OVERPROVISIONING = "llm_overprovisioning",
374
+ CONTEXT_FRAGMENTATION = "context_fragmentation",
375
+ SEMANTIC_BOTTLENECK = "semantic_bottleneck",
376
+ TOKEN_INEFFICIENCY = "token_inefficiency",
377
+ MODEL_MISMATCH = "model_mismatch",
378
+ CACHING_MISS = "caching_miss",
379
+ SEQUENTIAL_DEPENDENCY = "sequential_dependency",
380
+ MEMORY_PRESSURE = "memory_pressure",
381
+ IO_CONTENTION = "io_contention",
382
+ NETWORK_LATENCY = "network_latency"
383
+ }
384
+ export declare enum BottleneckSeverity {
385
+ LOW = "low",
386
+ MEDIUM = "medium",
387
+ HIGH = "high",
388
+ CRITICAL = "critical"
389
+ }
390
+ export declare enum AIOptimizationType {
391
+ LLM_MODEL_OPTIMIZATION = "llm_model_optimization",
392
+ SEMANTIC_CACHING = "semantic_caching",
393
+ CONTEXT_COMPRESSION = "context_compression",
394
+ PARALLEL_PROCESSING = "parallel_processing",
395
+ BATCH_OPTIMIZATION = "batch_optimization",
396
+ MEMORY_POOLING = "memory_pooling",
397
+ PREDICTIVE_LOADING = "predictive_loading",
398
+ ADAPTIVE_SAMPLING = "adaptive_sampling",
399
+ COST_OPTIMIZATION = "cost_optimization",
400
+ QUALITY_IMPROVEMENT = "quality_improvement"
401
+ }
402
+ export declare enum OptimizationPriority {
403
+ LOW = "low",
404
+ MEDIUM = "medium",
405
+ HIGH = "high",
406
+ CRITICAL = "critical"
407
+ }
408
+ export declare enum ImplementationEffort {
409
+ MINIMAL = "minimal",// < 1 day
410
+ LOW = "low",// 1-3 days
411
+ MEDIUM = "medium",// 1-2 weeks
412
+ HIGH = "high",// 2-4 weeks
413
+ EXTENSIVE = "extensive"
414
+ }
415
+ export declare enum AIPerformanceEventType {
416
+ COMPONENT_START = "component_start",
417
+ COMPONENT_END = "component_end",
418
+ BOTTLENECK_DETECTED = "bottleneck_detected",
419
+ OPTIMIZATION_SUGGESTED = "optimization_suggested",
420
+ THRESHOLD_EXCEEDED = "threshold_exceeded",
421
+ ANOMALY_DETECTED = "anomaly_detected",
422
+ TREND_CHANGE = "trend_change"
423
+ }
424
+ /**
425
+ * Performance metric aggregation window
426
+ */
427
+ export interface MetricWindow {
428
+ start: number;
429
+ end: number;
430
+ granularity: '1m' | '5m' | '15m' | '1h' | '1d';
431
+ aggregation: 'avg' | 'sum' | 'min' | 'max' | 'p95' | 'p99';
432
+ }
433
+ /**
434
+ * Component performance baseline
435
+ */
436
+ export interface ComponentBaseline {
437
+ componentName: string;
438
+ baseline: {
439
+ latency: {
440
+ p50: number;
441
+ p95: number;
442
+ p99: number;
443
+ };
444
+ memoryUsage: {
445
+ avg: number;
446
+ peak: number;
447
+ };
448
+ successRate: number;
449
+ costPerOperation: number;
450
+ };
451
+ established: number;
452
+ sampleSize: number;
453
+ confidence: number;
454
+ }
455
+ /**
456
+ * Export interface for external monitoring integration
457
+ */
458
+ export interface ExternalMonitoringExport {
459
+ format: 'prometheus' | 'datadog' | 'newrelic' | 'cloudwatch' | 'grafana';
460
+ endpoint?: string;
461
+ credentials?: Record<string, string>;
462
+ tags?: Record<string, string>;
463
+ filters?: {
464
+ components?: string[];
465
+ metrics?: string[];
466
+ severity?: BottleneckSeverity[];
467
+ };
468
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smythos/sre",
3
- "version": "1.5.73",
3
+ "version": "1.5.75",
4
4
  "description": "Smyth Runtime Environment",
5
5
  "author": "Alaa-eddine KADDOURI",
6
6
  "license": "MIT",
@@ -4,19 +4,33 @@ import { Logger } from '@sre/helpers/Log.helper';
4
4
  import { performTypeInference } from '@sre/helpers/TypeChecker.helper';
5
5
  import { hookAsync } from '@sre/Core/HookService';
6
6
 
7
- export type ComponentSchema = {
7
+ export type TComponentSchema = {
8
8
  name: string;
9
9
  settings?: Record<string, any>;
10
10
  inputs?: Record<string, any>;
11
11
  outputs?: Record<string, any>;
12
12
  };
13
13
 
14
+ export enum ComponentInputType {
15
+ Any = 'Any',
16
+ Binary = 'Binary',
17
+ String = 'Text',
18
+ Text = 'Text',
19
+ Image = 'Image',
20
+ Video = 'Video',
21
+ Number = 'Number',
22
+ Integer = 'Integer',
23
+ Boolean = 'Boolean',
24
+ Date = 'Date',
25
+ Array = 'Array',
26
+ Object = 'Object',
27
+ }
14
28
  export class Component {
15
29
  public hasReadOutput = false;
16
30
  public hasPostProcess = true;
17
31
  public alwaysActive = false; //for components like readable memories
18
32
  public exclusive = false; //for components like writable memories : when exclusive components are active, they are processed in a run cycle bofore other components
19
- protected schema: ComponentSchema = {
33
+ protected schema: TComponentSchema = {
20
34
  name: 'Component',
21
35
  settings: {},
22
36
  inputs: {},
@@ -121,6 +121,7 @@ export class Conversation extends EventEmitter {
121
121
  toolsStrategy?: (toolsConfig) => any;
122
122
  agentId?: string;
123
123
  agentVersion?: string;
124
+ baseUrl?: string;
124
125
  }
125
126
  ) {
126
127
  //TODO: handle loading previous session (messages)
@@ -150,6 +151,8 @@ export class Conversation extends EventEmitter {
150
151
  this._llmContextStore = _settings.store;
151
152
  }
152
153
 
154
+ this._baseUrl = _settings?.baseUrl;
155
+
153
156
  this._agentVersion = _settings?.agentVersion;
154
157
 
155
158
  (async () => {
@@ -1006,7 +1009,12 @@ export class Conversation extends EventEmitter {
1006
1009
  return map;
1007
1010
  }, {});
1008
1011
 
1009
- const spec = await agentDataConnector.getOpenAPIJSON(agentData, 'http://localhost/', this._agentVersion, true).catch((error) => null);
1012
+ let baseUrl = this._baseUrl || 'http://localhost/';
1013
+ if (baseUrl && !baseUrl.endsWith('/')) {
1014
+ baseUrl += '/';
1015
+ }
1016
+
1017
+ const spec = await agentDataConnector.getOpenAPIJSON(agentData, baseUrl, this._agentVersion, true).catch((error) => null);
1010
1018
  return this.patchSpec(spec);
1011
1019
  }
1012
1020