@pga-ai/core 0.4.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/README.md +278 -0
- package/dist/PGA.d.ts +156 -0
- package/dist/PGA.d.ts.map +1 -0
- package/dist/PGA.js +636 -0
- package/dist/PGA.js.map +1 -0
- package/dist/advanced-ai/ModelRouter.d.ts +82 -0
- package/dist/advanced-ai/ModelRouter.d.ts.map +1 -0
- package/dist/advanced-ai/ModelRouter.js +280 -0
- package/dist/advanced-ai/ModelRouter.js.map +1 -0
- package/dist/advanced-ai/ThinkingEngine.d.ts +50 -0
- package/dist/advanced-ai/ThinkingEngine.d.ts.map +1 -0
- package/dist/advanced-ai/ThinkingEngine.js +179 -0
- package/dist/advanced-ai/ThinkingEngine.js.map +1 -0
- package/dist/core/ContextMemory.d.ts +56 -0
- package/dist/core/ContextMemory.d.ts.map +1 -0
- package/dist/core/ContextMemory.js +253 -0
- package/dist/core/ContextMemory.js.map +1 -0
- package/dist/core/DNAProfile.d.ts +19 -0
- package/dist/core/DNAProfile.d.ts.map +1 -0
- package/dist/core/DNAProfile.js +141 -0
- package/dist/core/DNAProfile.js.map +1 -0
- package/dist/core/FitnessTracker.d.ts +13 -0
- package/dist/core/FitnessTracker.d.ts.map +1 -0
- package/dist/core/FitnessTracker.js +101 -0
- package/dist/core/FitnessTracker.js.map +1 -0
- package/dist/core/GenomeKernel.d.ts +57 -0
- package/dist/core/GenomeKernel.d.ts.map +1 -0
- package/dist/core/GenomeKernel.js +305 -0
- package/dist/core/GenomeKernel.js.map +1 -0
- package/dist/core/GenomeManager.d.ts +21 -0
- package/dist/core/GenomeManager.d.ts.map +1 -0
- package/dist/core/GenomeManager.js +123 -0
- package/dist/core/GenomeManager.js.map +1 -0
- package/dist/core/LearningAnnouncer.d.ts +16 -0
- package/dist/core/LearningAnnouncer.d.ts.map +1 -0
- package/dist/core/LearningAnnouncer.js +176 -0
- package/dist/core/LearningAnnouncer.js.map +1 -0
- package/dist/core/ProactiveSuggestions.d.ts +25 -0
- package/dist/core/ProactiveSuggestions.d.ts.map +1 -0
- package/dist/core/ProactiveSuggestions.js +238 -0
- package/dist/core/ProactiveSuggestions.js.map +1 -0
- package/dist/core/PromptAssembler.d.ts +12 -0
- package/dist/core/PromptAssembler.d.ts.map +1 -0
- package/dist/core/PromptAssembler.js +74 -0
- package/dist/core/PromptAssembler.js.map +1 -0
- package/dist/enterprise/AuthManager.d.ts +71 -0
- package/dist/enterprise/AuthManager.d.ts.map +1 -0
- package/dist/enterprise/AuthManager.js +216 -0
- package/dist/enterprise/AuthManager.js.map +1 -0
- package/dist/enterprise/RateLimiter.d.ts +48 -0
- package/dist/enterprise/RateLimiter.d.ts.map +1 -0
- package/dist/enterprise/RateLimiter.js +193 -0
- package/dist/enterprise/RateLimiter.js.map +1 -0
- package/dist/evaluation/BenchmarkSuites.d.ts +27 -0
- package/dist/evaluation/BenchmarkSuites.d.ts.map +1 -0
- package/dist/evaluation/BenchmarkSuites.js +69 -0
- package/dist/evaluation/BenchmarkSuites.js.map +1 -0
- package/dist/evaluation/CalibrationManager.d.ts +66 -0
- package/dist/evaluation/CalibrationManager.d.ts.map +1 -0
- package/dist/evaluation/CalibrationManager.js +117 -0
- package/dist/evaluation/CalibrationManager.js.map +1 -0
- package/dist/evaluation/Evaluator.d.ts +79 -0
- package/dist/evaluation/Evaluator.d.ts.map +1 -0
- package/dist/evaluation/Evaluator.js +359 -0
- package/dist/evaluation/Evaluator.js.map +1 -0
- package/dist/evaluation/EvolutionGuardrails.d.ts +29 -0
- package/dist/evaluation/EvolutionGuardrails.d.ts.map +1 -0
- package/dist/evaluation/EvolutionGuardrails.js +166 -0
- package/dist/evaluation/EvolutionGuardrails.js.map +1 -0
- package/dist/evaluation/SandboxSuites.d.ts +26 -0
- package/dist/evaluation/SandboxSuites.d.ts.map +1 -0
- package/dist/evaluation/SandboxSuites.js +252 -0
- package/dist/evaluation/SandboxSuites.js.map +1 -0
- package/dist/evaluation/SemanticJudge.d.ts +21 -0
- package/dist/evaluation/SemanticJudge.d.ts.map +1 -0
- package/dist/evaluation/SemanticJudge.js +139 -0
- package/dist/evaluation/SemanticJudge.js.map +1 -0
- package/dist/evaluation/fixtures/core-coding-v1.json +68 -0
- package/dist/evaluation/fixtures/core-general-v1.json +68 -0
- package/dist/evolution/CanaryDeployment.d.ts +77 -0
- package/dist/evolution/CanaryDeployment.d.ts.map +1 -0
- package/dist/evolution/CanaryDeployment.js +261 -0
- package/dist/evolution/CanaryDeployment.js.map +1 -0
- package/dist/evolution/DriftAnalyzer.d.ts +63 -0
- package/dist/evolution/DriftAnalyzer.d.ts.map +1 -0
- package/dist/evolution/DriftAnalyzer.js +283 -0
- package/dist/evolution/DriftAnalyzer.js.map +1 -0
- package/dist/evolution/FitnessCalculator.d.ts +47 -0
- package/dist/evolution/FitnessCalculator.d.ts.map +1 -0
- package/dist/evolution/FitnessCalculator.js +177 -0
- package/dist/evolution/FitnessCalculator.js.map +1 -0
- package/dist/evolution/MutationOperator.d.ts +76 -0
- package/dist/evolution/MutationOperator.d.ts.map +1 -0
- package/dist/evolution/MutationOperator.js +267 -0
- package/dist/evolution/MutationOperator.js.map +1 -0
- package/dist/evolution/PromotionGate.d.ts +45 -0
- package/dist/evolution/PromotionGate.d.ts.map +1 -0
- package/dist/evolution/PromotionGate.js +248 -0
- package/dist/evolution/PromotionGate.js.map +1 -0
- package/dist/evolution/boost/EvolutionBoostEngine.d.ts +69 -0
- package/dist/evolution/boost/EvolutionBoostEngine.d.ts.map +1 -0
- package/dist/evolution/boost/EvolutionBoostEngine.js +185 -0
- package/dist/evolution/boost/EvolutionBoostEngine.js.map +1 -0
- package/dist/evolution/boost/GeneticRecombinator.d.ts +26 -0
- package/dist/evolution/boost/GeneticRecombinator.d.ts.map +1 -0
- package/dist/evolution/boost/GeneticRecombinator.js +179 -0
- package/dist/evolution/boost/GeneticRecombinator.js.map +1 -0
- package/dist/evolution/boost/MetaEvolutionEngine.d.ts +48 -0
- package/dist/evolution/boost/MetaEvolutionEngine.d.ts.map +1 -0
- package/dist/evolution/boost/MetaEvolutionEngine.js +193 -0
- package/dist/evolution/boost/MetaEvolutionEngine.js.map +1 -0
- package/dist/evolution/boost/ParallelEvolutionEngine.d.ts +44 -0
- package/dist/evolution/boost/ParallelEvolutionEngine.d.ts.map +1 -0
- package/dist/evolution/boost/ParallelEvolutionEngine.js +135 -0
- package/dist/evolution/boost/ParallelEvolutionEngine.js.map +1 -0
- package/dist/evolution/boost/ParetoOptimizer.d.ts +42 -0
- package/dist/evolution/boost/ParetoOptimizer.d.ts.map +1 -0
- package/dist/evolution/boost/ParetoOptimizer.js +167 -0
- package/dist/evolution/boost/ParetoOptimizer.js.map +1 -0
- package/dist/evolution/boost/operators/BreakthroughOperator.d.ts +22 -0
- package/dist/evolution/boost/operators/BreakthroughOperator.d.ts.map +1 -0
- package/dist/evolution/boost/operators/BreakthroughOperator.js +217 -0
- package/dist/evolution/boost/operators/BreakthroughOperator.js.map +1 -0
- package/dist/evolution/boost/operators/CrossoverMutationOperator.d.ts +26 -0
- package/dist/evolution/boost/operators/CrossoverMutationOperator.d.ts.map +1 -0
- package/dist/evolution/boost/operators/CrossoverMutationOperator.js +160 -0
- package/dist/evolution/boost/operators/CrossoverMutationOperator.js.map +1 -0
- package/dist/evolution/boost/operators/PatternExtractionOperator.d.ts +24 -0
- package/dist/evolution/boost/operators/PatternExtractionOperator.d.ts.map +1 -0
- package/dist/evolution/boost/operators/PatternExtractionOperator.js +212 -0
- package/dist/evolution/boost/operators/PatternExtractionOperator.js.map +1 -0
- package/dist/evolution/boost/operators/SemanticRestructuringOperator.d.ts +19 -0
- package/dist/evolution/boost/operators/SemanticRestructuringOperator.d.ts.map +1 -0
- package/dist/evolution/boost/operators/SemanticRestructuringOperator.js +106 -0
- package/dist/evolution/boost/operators/SemanticRestructuringOperator.js.map +1 -0
- package/dist/gene-bank/CognitiveGene.d.ts +799 -0
- package/dist/gene-bank/CognitiveGene.d.ts.map +1 -0
- package/dist/gene-bank/CognitiveGene.js +128 -0
- package/dist/gene-bank/CognitiveGene.js.map +1 -0
- package/dist/gene-bank/GeneAdopter.d.ts +75 -0
- package/dist/gene-bank/GeneAdopter.d.ts.map +1 -0
- package/dist/gene-bank/GeneAdopter.js +271 -0
- package/dist/gene-bank/GeneAdopter.js.map +1 -0
- package/dist/gene-bank/GeneBank.d.ts +124 -0
- package/dist/gene-bank/GeneBank.d.ts.map +1 -0
- package/dist/gene-bank/GeneBank.js +261 -0
- package/dist/gene-bank/GeneBank.js.map +1 -0
- package/dist/gene-bank/GeneExtractor.d.ts +59 -0
- package/dist/gene-bank/GeneExtractor.d.ts.map +1 -0
- package/dist/gene-bank/GeneExtractor.js +311 -0
- package/dist/gene-bank/GeneExtractor.js.map +1 -0
- package/dist/gene-bank/GeneMatcher.d.ts +82 -0
- package/dist/gene-bank/GeneMatcher.d.ts.map +1 -0
- package/dist/gene-bank/GeneMatcher.js +215 -0
- package/dist/gene-bank/GeneMatcher.js.map +1 -0
- package/dist/gene-bank/PGAIntegration.d.ts +53 -0
- package/dist/gene-bank/PGAIntegration.d.ts.map +1 -0
- package/dist/gene-bank/PGAIntegration.js +139 -0
- package/dist/gene-bank/PGAIntegration.js.map +1 -0
- package/dist/gene-bank/SandboxTester.d.ts +92 -0
- package/dist/gene-bank/SandboxTester.d.ts.map +1 -0
- package/dist/gene-bank/SandboxTester.js +262 -0
- package/dist/gene-bank/SandboxTester.js.map +1 -0
- package/dist/gene-bank/adapters/InMemoryGeneStorage.d.ts +21 -0
- package/dist/gene-bank/adapters/InMemoryGeneStorage.d.ts.map +1 -0
- package/dist/gene-bank/adapters/InMemoryGeneStorage.js +115 -0
- package/dist/gene-bank/adapters/InMemoryGeneStorage.js.map +1 -0
- package/dist/gene-bank/adapters/PostgresGeneStorage.d.ts +21 -0
- package/dist/gene-bank/adapters/PostgresGeneStorage.d.ts.map +1 -0
- package/dist/gene-bank/adapters/PostgresGeneStorage.js +272 -0
- package/dist/gene-bank/adapters/PostgresGeneStorage.js.map +1 -0
- package/dist/gene-bank/index.d.ts +7 -0
- package/dist/gene-bank/index.d.ts.map +1 -0
- package/dist/gene-bank/index.js +7 -0
- package/dist/gene-bank/index.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/LLMAdapter.d.ts +31 -0
- package/dist/interfaces/LLMAdapter.d.ts.map +1 -0
- package/dist/interfaces/LLMAdapter.js +2 -0
- package/dist/interfaces/LLMAdapter.js.map +1 -0
- package/dist/interfaces/StorageAdapter.d.ts +49 -0
- package/dist/interfaces/StorageAdapter.d.ts.map +1 -0
- package/dist/interfaces/StorageAdapter.js +2 -0
- package/dist/interfaces/StorageAdapter.js.map +1 -0
- package/dist/memory/LayeredMemory.d.ts +112 -0
- package/dist/memory/LayeredMemory.d.ts.map +1 -0
- package/dist/memory/LayeredMemory.js +405 -0
- package/dist/memory/LayeredMemory.js.map +1 -0
- package/dist/memory-compaction/MemoryCompactor.d.ts +18 -0
- package/dist/memory-compaction/MemoryCompactor.d.ts.map +1 -0
- package/dist/memory-compaction/MemoryCompactor.js +156 -0
- package/dist/memory-compaction/MemoryCompactor.js.map +1 -0
- package/dist/memory-compaction/index.d.ts +6 -0
- package/dist/memory-compaction/index.d.ts.map +1 -0
- package/dist/memory-compaction/index.js +5 -0
- package/dist/memory-compaction/index.js.map +1 -0
- package/dist/memory-compaction/strategies/BaseStrategy.d.ts +9 -0
- package/dist/memory-compaction/strategies/BaseStrategy.d.ts.map +1 -0
- package/dist/memory-compaction/strategies/BaseStrategy.js +50 -0
- package/dist/memory-compaction/strategies/BaseStrategy.js.map +1 -0
- package/dist/memory-compaction/strategies/ImportanceBasedStrategy.d.ts +9 -0
- package/dist/memory-compaction/strategies/ImportanceBasedStrategy.d.ts.map +1 -0
- package/dist/memory-compaction/strategies/ImportanceBasedStrategy.js +101 -0
- package/dist/memory-compaction/strategies/ImportanceBasedStrategy.js.map +1 -0
- package/dist/memory-compaction/strategies/SlidingWindowStrategy.d.ts +9 -0
- package/dist/memory-compaction/strategies/SlidingWindowStrategy.d.ts.map +1 -0
- package/dist/memory-compaction/strategies/SlidingWindowStrategy.js +87 -0
- package/dist/memory-compaction/strategies/SlidingWindowStrategy.js.map +1 -0
- package/dist/memory-compaction/types.d.ts +78 -0
- package/dist/memory-compaction/types.d.ts.map +1 -0
- package/dist/memory-compaction/types.js +2 -0
- package/dist/memory-compaction/types.js.map +1 -0
- package/dist/monitoring/AlertWebhooks.d.ts +57 -0
- package/dist/monitoring/AlertWebhooks.d.ts.map +1 -0
- package/dist/monitoring/AlertWebhooks.js +205 -0
- package/dist/monitoring/AlertWebhooks.js.map +1 -0
- package/dist/monitoring/MetricsCollector.d.ts +120 -0
- package/dist/monitoring/MetricsCollector.d.ts.map +1 -0
- package/dist/monitoring/MetricsCollector.js +274 -0
- package/dist/monitoring/MetricsCollector.js.map +1 -0
- package/dist/monitoring/MonitoringDashboard.d.ts +38 -0
- package/dist/monitoring/MonitoringDashboard.d.ts.map +1 -0
- package/dist/monitoring/MonitoringDashboard.js +271 -0
- package/dist/monitoring/MonitoringDashboard.js.map +1 -0
- package/dist/plugins/PluginManager.d.ts +61 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -0
- package/dist/plugins/PluginManager.js +154 -0
- package/dist/plugins/PluginManager.js.map +1 -0
- package/dist/rag/RAGEngine.d.ts +54 -0
- package/dist/rag/RAGEngine.d.ts.map +1 -0
- package/dist/rag/RAGEngine.js +162 -0
- package/dist/rag/RAGEngine.js.map +1 -0
- package/dist/rag/VectorStoreAdapter.d.ts +40 -0
- package/dist/rag/VectorStoreAdapter.d.ts.map +1 -0
- package/dist/rag/VectorStoreAdapter.js +106 -0
- package/dist/rag/VectorStoreAdapter.js.map +1 -0
- package/dist/realtime/EventEmitter.d.ts +86 -0
- package/dist/realtime/EventEmitter.d.ts.map +1 -0
- package/dist/realtime/EventEmitter.js +173 -0
- package/dist/realtime/EventEmitter.js.map +1 -0
- package/dist/realtime/StreamingManager.d.ts +26 -0
- package/dist/realtime/StreamingManager.d.ts.map +1 -0
- package/dist/realtime/StreamingManager.js +175 -0
- package/dist/realtime/StreamingManager.js.map +1 -0
- package/dist/reasoning/ReasoningEngine.d.ts +57 -0
- package/dist/reasoning/ReasoningEngine.d.ts.map +1 -0
- package/dist/reasoning/ReasoningEngine.js +316 -0
- package/dist/reasoning/ReasoningEngine.js.map +1 -0
- package/dist/resilience/CircuitBreaker.d.ts +41 -0
- package/dist/resilience/CircuitBreaker.d.ts.map +1 -0
- package/dist/resilience/CircuitBreaker.js +108 -0
- package/dist/resilience/CircuitBreaker.js.map +1 -0
- package/dist/resilience/RetryManager.d.ts +14 -0
- package/dist/resilience/RetryManager.d.ts.map +1 -0
- package/dist/resilience/RetryManager.js +35 -0
- package/dist/resilience/RetryManager.js.map +1 -0
- package/dist/types/GenomeV2.d.ts +226 -0
- package/dist/types/GenomeV2.d.ts.map +1 -0
- package/dist/types/GenomeV2.js +2 -0
- package/dist/types/GenomeV2.js.map +1 -0
- package/dist/types/index.d.ts +205 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export class AuthManager {
|
|
2
|
+
config;
|
|
3
|
+
users = new Map();
|
|
4
|
+
rolePermissions = new Map();
|
|
5
|
+
static DEFAULT_ROLE_PERMISSIONS = new Map([
|
|
6
|
+
['admin', ['admin:all']],
|
|
7
|
+
[
|
|
8
|
+
'developer',
|
|
9
|
+
[
|
|
10
|
+
'genome:read',
|
|
11
|
+
'genome:write',
|
|
12
|
+
'genome:evolve',
|
|
13
|
+
'chat:send',
|
|
14
|
+
'chat:read',
|
|
15
|
+
'metrics:read',
|
|
16
|
+
],
|
|
17
|
+
],
|
|
18
|
+
['viewer', ['genome:read', 'chat:read', 'metrics:read']],
|
|
19
|
+
['user', ['chat:send', 'chat:read', 'genome:read']],
|
|
20
|
+
]);
|
|
21
|
+
constructor(config = {}) {
|
|
22
|
+
this.config = {
|
|
23
|
+
defaultRole: config.defaultRole || 'user',
|
|
24
|
+
enableMultiTenancy: config.enableMultiTenancy ?? false,
|
|
25
|
+
requireTenantId: config.requireTenantId ?? false,
|
|
26
|
+
policies: config.policies || [],
|
|
27
|
+
};
|
|
28
|
+
this.rolePermissions = new Map(AuthManager.DEFAULT_ROLE_PERMISSIONS);
|
|
29
|
+
}
|
|
30
|
+
createUser(data) {
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const user = {
|
|
33
|
+
id: data.id,
|
|
34
|
+
email: data.email,
|
|
35
|
+
roles: data.roles || [this.config.defaultRole],
|
|
36
|
+
permissions: data.permissions || [],
|
|
37
|
+
tenantId: data.tenantId,
|
|
38
|
+
metadata: data.metadata,
|
|
39
|
+
createdAt: now,
|
|
40
|
+
updatedAt: now,
|
|
41
|
+
};
|
|
42
|
+
if (this.config.requireTenantId && !user.tenantId) {
|
|
43
|
+
throw new Error('Tenant ID is required');
|
|
44
|
+
}
|
|
45
|
+
this.users.set(user.id, user);
|
|
46
|
+
return user;
|
|
47
|
+
}
|
|
48
|
+
getUser(userId) {
|
|
49
|
+
return this.users.get(userId);
|
|
50
|
+
}
|
|
51
|
+
updateUser(userId, updates) {
|
|
52
|
+
const user = this.users.get(userId);
|
|
53
|
+
if (!user) {
|
|
54
|
+
throw new Error(`User not found: ${userId}`);
|
|
55
|
+
}
|
|
56
|
+
Object.assign(user, updates, { updatedAt: new Date() });
|
|
57
|
+
return user;
|
|
58
|
+
}
|
|
59
|
+
deleteUser(userId) {
|
|
60
|
+
return this.users.delete(userId);
|
|
61
|
+
}
|
|
62
|
+
addRole(userId, role) {
|
|
63
|
+
const user = this.getUser(userId);
|
|
64
|
+
if (!user) {
|
|
65
|
+
throw new Error(`User not found: ${userId}`);
|
|
66
|
+
}
|
|
67
|
+
if (!user.roles.includes(role)) {
|
|
68
|
+
user.roles.push(role);
|
|
69
|
+
user.updatedAt = new Date();
|
|
70
|
+
}
|
|
71
|
+
return user;
|
|
72
|
+
}
|
|
73
|
+
removeRole(userId, role) {
|
|
74
|
+
const user = this.getUser(userId);
|
|
75
|
+
if (!user) {
|
|
76
|
+
throw new Error(`User not found: ${userId}`);
|
|
77
|
+
}
|
|
78
|
+
user.roles = user.roles.filter((r) => r !== role);
|
|
79
|
+
user.updatedAt = new Date();
|
|
80
|
+
return user;
|
|
81
|
+
}
|
|
82
|
+
addPermission(userId, permission) {
|
|
83
|
+
const user = this.getUser(userId);
|
|
84
|
+
if (!user) {
|
|
85
|
+
throw new Error(`User not found: ${userId}`);
|
|
86
|
+
}
|
|
87
|
+
if (!user.permissions.includes(permission)) {
|
|
88
|
+
user.permissions.push(permission);
|
|
89
|
+
user.updatedAt = new Date();
|
|
90
|
+
}
|
|
91
|
+
return user;
|
|
92
|
+
}
|
|
93
|
+
removePermission(userId, permission) {
|
|
94
|
+
const user = this.getUser(userId);
|
|
95
|
+
if (!user) {
|
|
96
|
+
throw new Error(`User not found: ${userId}`);
|
|
97
|
+
}
|
|
98
|
+
user.permissions = user.permissions.filter((p) => p !== permission);
|
|
99
|
+
user.updatedAt = new Date();
|
|
100
|
+
return user;
|
|
101
|
+
}
|
|
102
|
+
async hasPermission(userId, permission, resource) {
|
|
103
|
+
const user = this.getUser(userId);
|
|
104
|
+
if (!user) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (user.roles.includes('admin')) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
if (user.permissions.includes(permission)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
for (const role of user.roles) {
|
|
114
|
+
const permissions = this.rolePermissions.get(role) || [];
|
|
115
|
+
if (permissions.includes(permission) || permissions.includes('admin:all')) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const context = {
|
|
120
|
+
userId: user.id,
|
|
121
|
+
roles: user.roles,
|
|
122
|
+
permissions: user.permissions,
|
|
123
|
+
tenantId: user.tenantId,
|
|
124
|
+
metadata: user.metadata,
|
|
125
|
+
};
|
|
126
|
+
const allowed = await this.checkPolicies(context, permission, resource);
|
|
127
|
+
return allowed;
|
|
128
|
+
}
|
|
129
|
+
async checkPolicies(context, permission, resource) {
|
|
130
|
+
let allowed = false;
|
|
131
|
+
for (const policy of this.config.policies) {
|
|
132
|
+
if (!policy.actions.includes(permission)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (policy.resources && resource) {
|
|
136
|
+
const matches = policy.resources.some((pattern) => this.matchResourcePattern(pattern, resource));
|
|
137
|
+
if (!matches) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (policy.conditions) {
|
|
142
|
+
const conditionsMet = await Promise.all(policy.conditions.map((condition) => condition(context)));
|
|
143
|
+
if (!conditionsMet.every((met) => met)) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (policy.effect === 'allow') {
|
|
148
|
+
allowed = true;
|
|
149
|
+
}
|
|
150
|
+
else if (policy.effect === 'deny') {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return allowed;
|
|
155
|
+
}
|
|
156
|
+
matchResourcePattern(pattern, resource) {
|
|
157
|
+
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$');
|
|
158
|
+
return regex.test(resource);
|
|
159
|
+
}
|
|
160
|
+
async authorize(userId, permission, resource) {
|
|
161
|
+
const allowed = await this.hasPermission(userId, permission, resource);
|
|
162
|
+
if (!allowed) {
|
|
163
|
+
throw new Error(`User ${userId} is not authorized for permission: ${permission}${resource ? ` on resource: ${resource}` : ''}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
createContext(userId) {
|
|
167
|
+
const user = this.getUser(userId);
|
|
168
|
+
if (!user) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
userId: user.id,
|
|
173
|
+
roles: user.roles,
|
|
174
|
+
permissions: user.permissions,
|
|
175
|
+
tenantId: user.tenantId,
|
|
176
|
+
metadata: user.metadata,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
defineRole(role, permissions) {
|
|
180
|
+
this.rolePermissions.set(role, permissions);
|
|
181
|
+
}
|
|
182
|
+
addPolicy(policy) {
|
|
183
|
+
this.config.policies.push(policy);
|
|
184
|
+
}
|
|
185
|
+
removePolicy(name) {
|
|
186
|
+
this.config.policies = this.config.policies.filter((p) => p.name !== name);
|
|
187
|
+
}
|
|
188
|
+
getUsersByTenant(tenantId) {
|
|
189
|
+
return Array.from(this.users.values()).filter((u) => u.tenantId === tenantId);
|
|
190
|
+
}
|
|
191
|
+
getUsersByRole(role) {
|
|
192
|
+
return Array.from(this.users.values()).filter((u) => u.roles.includes(role));
|
|
193
|
+
}
|
|
194
|
+
getStats() {
|
|
195
|
+
const users = Array.from(this.users.values());
|
|
196
|
+
const usersByRole = {};
|
|
197
|
+
for (const user of users) {
|
|
198
|
+
for (const role of user.roles) {
|
|
199
|
+
usersByRole[role] = (usersByRole[role] || 0) + 1;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const usersByTenant = {};
|
|
203
|
+
for (const user of users) {
|
|
204
|
+
if (user.tenantId) {
|
|
205
|
+
usersByTenant[user.tenantId] =
|
|
206
|
+
(usersByTenant[user.tenantId] || 0) + 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
totalUsers: users.length,
|
|
211
|
+
usersByRole: usersByRole,
|
|
212
|
+
usersByTenant,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=AuthManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthManager.js","sourceR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C;oBACxB,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAChD,CAAC;QACL,CAAC;QAED,OAAO;YACH,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,WAAW,EAAE,WAAmC;YAChD,aAAa;SAChB,CAAC;IACN,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface RateLimitConfig {
|
|
2
|
+
maxRequests: number;
|
|
3
|
+
windowMs: number;
|
|
4
|
+
algorithm?: 'token-bucket' | 'sliding-window' | 'fixed-window';
|
|
5
|
+
keyGenerator?: (context: RateLimitContext) => string;
|
|
6
|
+
onLimitExceeded?: 'reject' | 'queue' | 'callback';
|
|
7
|
+
onLimitExceededCallback?: (context: RateLimitContext) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface RateLimitContext {
|
|
10
|
+
userId?: string;
|
|
11
|
+
genomeId?: string;
|
|
12
|
+
operation?: string;
|
|
13
|
+
ip?: string;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface RateLimitResult {
|
|
17
|
+
allowed: boolean;
|
|
18
|
+
remaining: number;
|
|
19
|
+
resetAt: Date;
|
|
20
|
+
retryAfter?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class RateLimiter {
|
|
23
|
+
private config;
|
|
24
|
+
private records;
|
|
25
|
+
private tokenBuckets;
|
|
26
|
+
constructor(config: RateLimitConfig);
|
|
27
|
+
check(context: RateLimitContext): Promise<RateLimitResult>;
|
|
28
|
+
private checkTokenBucket;
|
|
29
|
+
private checkSlidingWindow;
|
|
30
|
+
private checkFixedWindow;
|
|
31
|
+
private defaultKeyGenerator;
|
|
32
|
+
reset(key: string): void;
|
|
33
|
+
resetAll(): void;
|
|
34
|
+
getUsage(key: string): {
|
|
35
|
+
count: number;
|
|
36
|
+
remaining: number;
|
|
37
|
+
};
|
|
38
|
+
private cleanup;
|
|
39
|
+
getStats(): {
|
|
40
|
+
totalKeys: number;
|
|
41
|
+
algorithm: string;
|
|
42
|
+
config: {
|
|
43
|
+
maxRequests: number;
|
|
44
|
+
windowMs: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=RateLimiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RateLimiter.d.ts","sourceRoot":"","sources":["../../src/enterprise/RateLimiter.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAI5B,WAAW,EAAE,MAAM,CAAC;IAKpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,SAAS,CAAC,EAAE,cAAc,GAAG,gBAAgB,GAAG,cAAc,CAAC;IAK/D,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC;IAMrD,eAAe,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;IAKlD,uBAAuB,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAYD,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAEZ;IACF,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,YAAY,CAAkE;gBAE1E,MAAM,EAAE,eAAe;IAiB7B,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBhE,OAAO,CAAC,gBAAgB;IAgDxB,OAAO,CAAC,kBAAkB;IA4C1B,OAAO,CAAC,gBAAgB;IA0CxB,OAAO,CAAC,mBAAmB;IAc3B,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQxB,QAAQ,IAAI,IAAI;IAQhB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IA4C3D,OAAO,CAAC,OAAO;IAyBf,QAAQ,IAAI;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE;YACJ,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC;SACpB,CAAC;KACL;CAaJ"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export class RateLimiter {
|
|
2
|
+
config;
|
|
3
|
+
records = new Map();
|
|
4
|
+
tokenBuckets = new Map();
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = {
|
|
7
|
+
maxRequests: config.maxRequests,
|
|
8
|
+
windowMs: config.windowMs,
|
|
9
|
+
algorithm: config.algorithm || 'sliding-window',
|
|
10
|
+
keyGenerator: config.keyGenerator || this.defaultKeyGenerator,
|
|
11
|
+
onLimitExceeded: config.onLimitExceeded || 'reject',
|
|
12
|
+
onLimitExceededCallback: config.onLimitExceededCallback,
|
|
13
|
+
};
|
|
14
|
+
setInterval(() => this.cleanup(), this.config.windowMs);
|
|
15
|
+
}
|
|
16
|
+
async check(context) {
|
|
17
|
+
const key = this.config.keyGenerator(context);
|
|
18
|
+
if (this.config.algorithm === 'token-bucket') {
|
|
19
|
+
return this.checkTokenBucket(key);
|
|
20
|
+
}
|
|
21
|
+
else if (this.config.algorithm === 'sliding-window') {
|
|
22
|
+
return this.checkSlidingWindow(key);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return this.checkFixedWindow(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
checkTokenBucket(key) {
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
let bucket = this.tokenBuckets.get(key);
|
|
31
|
+
if (!bucket) {
|
|
32
|
+
bucket = {
|
|
33
|
+
tokens: this.config.maxRequests,
|
|
34
|
+
lastRefill: now,
|
|
35
|
+
};
|
|
36
|
+
this.tokenBuckets.set(key, bucket);
|
|
37
|
+
}
|
|
38
|
+
const elapsed = now - bucket.lastRefill;
|
|
39
|
+
const refillRate = this.config.maxRequests / this.config.windowMs;
|
|
40
|
+
const tokensToAdd = Math.floor(elapsed * refillRate);
|
|
41
|
+
bucket.tokens = Math.min(this.config.maxRequests, bucket.tokens + tokensToAdd);
|
|
42
|
+
bucket.lastRefill = now;
|
|
43
|
+
if (bucket.tokens >= 1) {
|
|
44
|
+
bucket.tokens -= 1;
|
|
45
|
+
return {
|
|
46
|
+
allowed: true,
|
|
47
|
+
remaining: Math.floor(bucket.tokens),
|
|
48
|
+
resetAt: new Date(now + this.config.windowMs),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const timeToNextToken = (1 - bucket.tokens) / refillRate;
|
|
52
|
+
return {
|
|
53
|
+
allowed: false,
|
|
54
|
+
remaining: 0,
|
|
55
|
+
resetAt: new Date(now + this.config.windowMs),
|
|
56
|
+
retryAfter: Math.ceil(timeToNextToken),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
checkSlidingWindow(key) {
|
|
60
|
+
const now = Date.now();
|
|
61
|
+
const windowStart = now - this.config.windowMs;
|
|
62
|
+
let records = this.records.get(key) || [];
|
|
63
|
+
records = records.filter((r) => r.timestamp > windowStart);
|
|
64
|
+
const count = records.reduce((sum, r) => sum + r.count, 0);
|
|
65
|
+
if (count < this.config.maxRequests) {
|
|
66
|
+
records.push({ timestamp: now, count: 1 });
|
|
67
|
+
this.records.set(key, records);
|
|
68
|
+
return {
|
|
69
|
+
allowed: true,
|
|
70
|
+
remaining: this.config.maxRequests - count - 1,
|
|
71
|
+
resetAt: new Date(now + this.config.windowMs),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const oldestRequest = records[0];
|
|
75
|
+
const retryAfter = oldestRequest
|
|
76
|
+
? oldestRequest.timestamp + this.config.windowMs - now
|
|
77
|
+
: this.config.windowMs;
|
|
78
|
+
return {
|
|
79
|
+
allowed: false,
|
|
80
|
+
remaining: 0,
|
|
81
|
+
resetAt: new Date(oldestRequest.timestamp + this.config.windowMs),
|
|
82
|
+
retryAfter: Math.max(0, retryAfter),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
checkFixedWindow(key) {
|
|
86
|
+
const now = Date.now();
|
|
87
|
+
const windowStart = Math.floor(now / this.config.windowMs) * this.config.windowMs;
|
|
88
|
+
let records = this.records.get(key) || [];
|
|
89
|
+
records = records.filter((r) => r.timestamp >= windowStart);
|
|
90
|
+
const count = records.reduce((sum, r) => sum + r.count, 0);
|
|
91
|
+
if (count < this.config.maxRequests) {
|
|
92
|
+
const existingRecord = records.find((r) => r.timestamp === windowStart);
|
|
93
|
+
if (existingRecord) {
|
|
94
|
+
existingRecord.count += 1;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
records.push({ timestamp: windowStart, count: 1 });
|
|
98
|
+
}
|
|
99
|
+
this.records.set(key, records);
|
|
100
|
+
return {
|
|
101
|
+
allowed: true,
|
|
102
|
+
remaining: this.config.maxRequests - count - 1,
|
|
103
|
+
resetAt: new Date(windowStart + this.config.windowMs),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
allowed: false,
|
|
108
|
+
remaining: 0,
|
|
109
|
+
resetAt: new Date(windowStart + this.config.windowMs),
|
|
110
|
+
retryAfter: windowStart + this.config.windowMs - now,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
defaultKeyGenerator(context) {
|
|
114
|
+
const parts = [];
|
|
115
|
+
if (context.userId)
|
|
116
|
+
parts.push(`user:${context.userId}`);
|
|
117
|
+
if (context.genomeId)
|
|
118
|
+
parts.push(`genome:${context.genomeId}`);
|
|
119
|
+
if (context.operation)
|
|
120
|
+
parts.push(`op:${context.operation}`);
|
|
121
|
+
if (context.ip)
|
|
122
|
+
parts.push(`ip:${context.ip}`);
|
|
123
|
+
return parts.length > 0 ? parts.join(':') : 'global';
|
|
124
|
+
}
|
|
125
|
+
reset(key) {
|
|
126
|
+
this.records.delete(key);
|
|
127
|
+
this.tokenBuckets.delete(key);
|
|
128
|
+
}
|
|
129
|
+
resetAll() {
|
|
130
|
+
this.records.clear();
|
|
131
|
+
this.tokenBuckets.clear();
|
|
132
|
+
}
|
|
133
|
+
getUsage(key) {
|
|
134
|
+
if (this.config.algorithm === 'token-bucket') {
|
|
135
|
+
const bucket = this.tokenBuckets.get(key);
|
|
136
|
+
if (!bucket) {
|
|
137
|
+
return { count: 0, remaining: this.config.maxRequests };
|
|
138
|
+
}
|
|
139
|
+
const now = Date.now();
|
|
140
|
+
const elapsed = now - bucket.lastRefill;
|
|
141
|
+
const refillRate = this.config.maxRequests / this.config.windowMs;
|
|
142
|
+
const tokensToAdd = Math.floor(elapsed * refillRate);
|
|
143
|
+
const currentTokens = Math.min(this.config.maxRequests, bucket.tokens + tokensToAdd);
|
|
144
|
+
return {
|
|
145
|
+
count: this.config.maxRequests - Math.floor(currentTokens),
|
|
146
|
+
remaining: Math.floor(currentTokens),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const now = Date.now();
|
|
150
|
+
const windowStart = this.config.algorithm === 'fixed-window'
|
|
151
|
+
? Math.floor(now / this.config.windowMs) * this.config.windowMs
|
|
152
|
+
: now - this.config.windowMs;
|
|
153
|
+
const records = this.records.get(key) || [];
|
|
154
|
+
const count = records
|
|
155
|
+
.filter((r) => r.timestamp > windowStart)
|
|
156
|
+
.reduce((sum, r) => sum + r.count, 0);
|
|
157
|
+
return {
|
|
158
|
+
count,
|
|
159
|
+
remaining: Math.max(0, this.config.maxRequests - count),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
cleanup() {
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
const cutoff = now - this.config.windowMs * 2;
|
|
165
|
+
for (const [key, records] of this.records.entries()) {
|
|
166
|
+
const filtered = records.filter((r) => r.timestamp > cutoff);
|
|
167
|
+
if (filtered.length === 0) {
|
|
168
|
+
this.records.delete(key);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this.records.set(key, filtered);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
for (const [key, bucket] of this.tokenBuckets.entries()) {
|
|
175
|
+
if (bucket.lastRefill < cutoff) {
|
|
176
|
+
this.tokenBuckets.delete(key);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
getStats() {
|
|
181
|
+
return {
|
|
182
|
+
totalKeys: this.config.algorithm === 'token-bucket'
|
|
183
|
+
? this.tokenBuckets.size
|
|
184
|
+
: this.records.size,
|
|
185
|
+
algorithm: this.config.algorithm,
|
|
186
|
+
config: {
|
|
187
|
+
maxRequests: this.config.maxRequests,
|
|
188
|
+
windowMs: this.config.windowMs,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=RateLimiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RateLimiter.js","sourceRoot":"","sources":["../../src/enterprise/RateLimiter.ts"],"names":[],"mappings":"AAkEA,MAAM,OAAO,WAAW;IACZ,MAAM,CAEZ;IACM,OAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;IAClD,YAAY,GAAwD,IAAI,GAAG,EAAE,CAAC;IAEtF,YAAY,MAAuB;QAC/B,IAAI,CAAC,MAAM,GAAG;YACV,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QA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AAC,CAAC;YAClC,CAAC;QACL,CAAC;IACL,CAAC;IAKD,QAAQ;QAQJ,OAAO;YACH,SAAS,EACL,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,cAAc;gBACpC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI;gBACxB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;YAC3B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,MAAM,EAAE;gBACJ,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBACpC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;aACjC;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EvaluationTask } from './Evaluator.js';
|
|
2
|
+
export interface BenchmarkSuiteMetadata {
|
|
3
|
+
id: string;
|
|
4
|
+
version: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
changedAt: string;
|
|
8
|
+
changelog: string[];
|
|
9
|
+
frozen: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface BenchmarkSuite {
|
|
12
|
+
metadata: BenchmarkSuiteMetadata;
|
|
13
|
+
tasks: EvaluationTask[];
|
|
14
|
+
}
|
|
15
|
+
export declare const CORE_GENERAL_V1: BenchmarkSuite;
|
|
16
|
+
export declare const CORE_CODING_V1: BenchmarkSuite;
|
|
17
|
+
export declare const PGA_SPECIFIC_V1: BenchmarkSuite;
|
|
18
|
+
export declare const BENCHMARK_SUITES: {
|
|
19
|
+
readonly 'core-general-v1': BenchmarkSuite;
|
|
20
|
+
readonly 'core-coding-v1': BenchmarkSuite;
|
|
21
|
+
readonly 'pga-specific-v1': BenchmarkSuite;
|
|
22
|
+
};
|
|
23
|
+
export type BenchmarkSuiteId = keyof typeof BENCHMARK_SUITES;
|
|
24
|
+
export declare function getBenchmarkSuite(suiteId: BenchmarkSuiteId): BenchmarkSuite;
|
|
25
|
+
export declare function getAvailableSuites(): BenchmarkSuiteId[];
|
|
26
|
+
export declare function validateSuiteFrozen(suiteId: BenchmarkSuiteId): boolean;
|
|
27
|
+
//# sourceMappingURL=BenchmarkSuites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BenchmarkSuites.d.ts","sourceRoot":"","sources":["../../src/evaluation/BenchmarkSuites.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQrD,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,EAAE,cAAc,EAAE,CAAC;CAC3B;AAKD,eAAO,MAAM,eAAe,EAAE,cAAuD,CAAC;AAKtF,eAAO,MAAM,cAAc,EAAE,cAAsD,CAAC;AAIpF,eAAO,MAAM,eAAe,EAAE,cA6C7B,CAAC;AAIF,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAO7D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAM3E;AAKD,wBAAgB,kBAAkB,IAAI,gBAAgB,EAAE,CAEvD;AAKD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAEtE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import coreGeneralV1Fixture from './fixtures/core-general-v1.json';
|
|
2
|
+
import coreCodingV1Fixture from './fixtures/core-coding-v1.json';
|
|
3
|
+
export const CORE_GENERAL_V1 = coreGeneralV1Fixture;
|
|
4
|
+
export const CORE_CODING_V1 = coreCodingV1Fixture;
|
|
5
|
+
export const PGA_SPECIFIC_V1 = {
|
|
6
|
+
metadata: {
|
|
7
|
+
id: 'pga-specific-v1',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
owner: 'Luis Alfredo Velasquez Duran',
|
|
10
|
+
createdAt: '2026-02-27',
|
|
11
|
+
changedAt: '2026-02-27',
|
|
12
|
+
changelog: ['Initial release - PGA-specific knowledge'],
|
|
13
|
+
frozen: true,
|
|
14
|
+
},
|
|
15
|
+
tasks: [
|
|
16
|
+
{
|
|
17
|
+
id: 'pga-architecture',
|
|
18
|
+
name: 'PGA Architecture',
|
|
19
|
+
description: 'Test understanding of PGA architecture',
|
|
20
|
+
userMessage: 'Explain the three-layer architecture of PGA',
|
|
21
|
+
expectedOutcome: {
|
|
22
|
+
keywords: ['layer0', 'layer1', 'layer2', 'immutable', 'mutation'],
|
|
23
|
+
minLength: 100,
|
|
24
|
+
},
|
|
25
|
+
difficulty: 'easy',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'pga-evolution',
|
|
29
|
+
name: 'Evolution Mechanism',
|
|
30
|
+
description: 'Test understanding of evolution process',
|
|
31
|
+
userMessage: 'How does PGA evolve prompts?',
|
|
32
|
+
expectedOutcome: {
|
|
33
|
+
keywords: ['fitness', 'mutation', 'selection', 'genome'],
|
|
34
|
+
minLength: 100,
|
|
35
|
+
},
|
|
36
|
+
difficulty: 'medium',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'pga-userdna',
|
|
40
|
+
name: 'User DNA Concept',
|
|
41
|
+
description: 'Test understanding of user DNA',
|
|
42
|
+
userMessage: 'What is User DNA in PGA?',
|
|
43
|
+
expectedOutcome: {
|
|
44
|
+
keywords: ['user', 'preferences', 'traits', 'cognitive'],
|
|
45
|
+
minLength: 80,
|
|
46
|
+
},
|
|
47
|
+
difficulty: 'medium',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
export const BENCHMARK_SUITES = {
|
|
52
|
+
'core-general-v1': CORE_GENERAL_V1,
|
|
53
|
+
'core-coding-v1': CORE_CODING_V1,
|
|
54
|
+
'pga-specific-v1': PGA_SPECIFIC_V1,
|
|
55
|
+
};
|
|
56
|
+
export function getBenchmarkSuite(suiteId) {
|
|
57
|
+
const suite = BENCHMARK_SUITES[suiteId];
|
|
58
|
+
if (!suite) {
|
|
59
|
+
throw new Error(`Unknown benchmark suite: ${suiteId}`);
|
|
60
|
+
}
|
|
61
|
+
return suite;
|
|
62
|
+
}
|
|
63
|
+
export function getAvailableSuites() {
|
|
64
|
+
return Object.keys(BENCHMARK_SUITES);
|
|
65
|
+
}
|
|
66
|
+
export function validateSuiteFrozen(suiteId) {
|
|
67
|
+
return getBenchmarkSuite(suiteId).metadata.frozen;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=BenchmarkSuites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BenchmarkSuites.js","sourceRoot":"","sources":["../../src/evaluation/BenchmarkSuites.ts"],"names":[],"mappings":"AAgBA,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,mBAAmB,MAAM,gCAAgC,CAAC;AAsBjE,MAAM,CAAC,MAAM,eAAe,GAAmB,oBAAsC,CAAC;AAKtF,MAAM,CAAC,MAAM,cAAc,GAAmB,mBAAqC,CAAC;AAIpF,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC3C,QAAQ,EAAE;QACN,EAAE,EAAE,iBAAiB;QACrB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,8BAA8B;QACrC,SAAS,EAAE,YAAY;QACvB,SAAS,EAAE,YAAY;QACvB,SAAS,EAAE,CAAC,0CAA0C,CAAC;QACvD,MAAM,EAAE,IAAI;KACf;IACD,KAAK,EAAE;QACH;YACI,EAAE,EAAE,kBAAkB;YACtB,IAAI,E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AAC;AAC/D,CAAC;AAKD,MAAM,UAAU,mBAAmB,CAAC,OAAyB;IACzD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { StorageAdapter } from '../interfaces/StorageAdapter.js';
|
|
2
|
+
export interface CalibrationPoint {
|
|
3
|
+
timestamp: Date;
|
|
4
|
+
context: {
|
|
5
|
+
layer?: 0 | 1 | 2;
|
|
6
|
+
operator?: string;
|
|
7
|
+
taskType?: string;
|
|
8
|
+
};
|
|
9
|
+
threshold: number;
|
|
10
|
+
metrics: {
|
|
11
|
+
totalCandidates: number;
|
|
12
|
+
passedSandbox: number;
|
|
13
|
+
deployedSuccessfully: number;
|
|
14
|
+
rolledBack: number;
|
|
15
|
+
};
|
|
16
|
+
performance: {
|
|
17
|
+
falsePositiveRate: number;
|
|
18
|
+
falseNegativeRate: number;
|
|
19
|
+
optimalThreshold: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface CalibrationHistory {
|
|
23
|
+
context: {
|
|
24
|
+
layer?: 0 | 1 | 2;
|
|
25
|
+
operator?: string;
|
|
26
|
+
taskType?: string;
|
|
27
|
+
};
|
|
28
|
+
points: CalibrationPoint[];
|
|
29
|
+
currentThreshold: number;
|
|
30
|
+
recommendedThreshold: number;
|
|
31
|
+
confidence: number;
|
|
32
|
+
}
|
|
33
|
+
export declare class CalibrationManager {
|
|
34
|
+
private storage;
|
|
35
|
+
private cache;
|
|
36
|
+
constructor(storage: StorageAdapter);
|
|
37
|
+
getCalibratedThreshold(context: {
|
|
38
|
+
layer?: 0 | 1 | 2;
|
|
39
|
+
operator?: string;
|
|
40
|
+
taskType?: string;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
threshold: number;
|
|
43
|
+
confidence: number;
|
|
44
|
+
source: 'calibrated' | 'default' | 'cached';
|
|
45
|
+
}>;
|
|
46
|
+
recordCalibrationPoint(context: {
|
|
47
|
+
layer?: 0 | 1 | 2;
|
|
48
|
+
operator?: string;
|
|
49
|
+
taskType?: string;
|
|
50
|
+
}, metrics: {
|
|
51
|
+
totalCandidates: number;
|
|
52
|
+
passedSandbox: number;
|
|
53
|
+
deployedSuccessfully: number;
|
|
54
|
+
rolledBack: number;
|
|
55
|
+
}, currentThreshold: number): Promise<void>;
|
|
56
|
+
private calculateOptimalThreshold;
|
|
57
|
+
private loadCalibrationHistory;
|
|
58
|
+
private getContextKey;
|
|
59
|
+
private getDefaultThreshold;
|
|
60
|
+
getCalibrationReport(context?: {
|
|
61
|
+
layer?: 0 | 1 | 2;
|
|
62
|
+
operator?: string;
|
|
63
|
+
taskType?: string;
|
|
64
|
+
}): Promise<string>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=CalibrationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalibrationManager.d.ts","sourceRoot":"","sources":["../../src/evaluation/CalibrationManager.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAItE,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE;QACL,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,WAAW,EAAE;QACT,iBAAiB,EAAE,MAAM,CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,MAAM,CAAC;KAC5B,CAAC;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