agentic-qe 2.6.0 → 2.6.2
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.md +156 -0
- package/README.md +222 -159
- package/dist/agents/BaseAgent.d.ts +19 -0
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +41 -1
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.d.ts +14 -0
- package/dist/agents/CodeIntelligenceAgent.d.ts.map +1 -1
- package/dist/agents/CodeIntelligenceAgent.js +66 -0
- package/dist/agents/CodeIntelligenceAgent.js.map +1 -1
- package/dist/agents/CoverageAnalyzerAgent.d.ts +8 -0
- package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
- package/dist/agents/CoverageAnalyzerAgent.js +65 -1
- package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
- package/dist/agents/TestGeneratorAgent.d.ts +2 -2
- package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
- package/dist/agents/TestGeneratorAgent.js +16 -6
- package/dist/agents/TestGeneratorAgent.js.map +1 -1
- package/dist/agents/adapters/AgentLLMAdapter.d.ts +127 -0
- package/dist/agents/adapters/AgentLLMAdapter.d.ts.map +1 -0
- package/dist/agents/adapters/AgentLLMAdapter.js +366 -0
- package/dist/agents/adapters/AgentLLMAdapter.js.map +1 -0
- package/dist/agents/adapters/index.d.ts +1 -0
- package/dist/agents/adapters/index.d.ts.map +1 -1
- package/dist/agents/adapters/index.js +5 -1
- package/dist/agents/adapters/index.js.map +1 -1
- package/dist/agents/interfaces/IAgentLLM.d.ts +257 -0
- package/dist/agents/interfaces/IAgentLLM.d.ts.map +1 -0
- package/dist/agents/interfaces/IAgentLLM.js +39 -0
- package/dist/agents/interfaces/IAgentLLM.js.map +1 -0
- package/dist/agents/interfaces/index.d.ts +10 -0
- package/dist/agents/interfaces/index.d.ts.map +1 -0
- package/dist/agents/interfaces/index.js +14 -0
- package/dist/agents/interfaces/index.js.map +1 -0
- package/dist/agents/n8n/N8nBaseAgent.d.ts +18 -0
- package/dist/agents/n8n/N8nBaseAgent.d.ts.map +1 -1
- package/dist/agents/n8n/N8nBaseAgent.js +80 -0
- package/dist/agents/n8n/N8nBaseAgent.js.map +1 -1
- package/dist/agents/pool/AgentPool.d.ts +112 -0
- package/dist/agents/pool/AgentPool.d.ts.map +1 -0
- package/dist/agents/pool/AgentPool.js +573 -0
- package/dist/agents/pool/AgentPool.js.map +1 -0
- package/dist/agents/pool/QEAgentPoolFactory.d.ts +118 -0
- package/dist/agents/pool/QEAgentPoolFactory.d.ts.map +1 -0
- package/dist/agents/pool/QEAgentPoolFactory.js +251 -0
- package/dist/agents/pool/QEAgentPoolFactory.js.map +1 -0
- package/dist/agents/pool/index.d.ts +34 -0
- package/dist/agents/pool/index.d.ts.map +1 -0
- package/dist/agents/pool/index.js +44 -0
- package/dist/agents/pool/index.js.map +1 -0
- package/dist/agents/pool/types.d.ts +227 -0
- package/dist/agents/pool/types.d.ts.map +1 -0
- package/dist/agents/pool/types.js +28 -0
- package/dist/agents/pool/types.js.map +1 -0
- package/dist/cli/commands/providers.d.ts +50 -0
- package/dist/cli/commands/providers.d.ts.map +1 -0
- package/dist/cli/commands/providers.js +403 -0
- package/dist/cli/commands/providers.js.map +1 -0
- package/dist/cli/index.js +62 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/code-intelligence/indexing/FileWatcher.d.ts.map +1 -1
- package/dist/code-intelligence/indexing/FileWatcher.js +11 -8
- package/dist/code-intelligence/indexing/FileWatcher.js.map +1 -1
- package/dist/config/ConfigLoader.d.ts +85 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +420 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/config/ProviderConfig.d.ts +153 -0
- package/dist/config/ProviderConfig.d.ts.map +1 -0
- package/dist/config/ProviderConfig.js +155 -0
- package/dist/config/ProviderConfig.js.map +1 -0
- package/dist/config/index.d.ts +35 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +45 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/mcp/handlers/agent-spawn.d.ts +71 -5
- package/dist/mcp/handlers/agent-spawn.d.ts.map +1 -1
- package/dist/mcp/handlers/agent-spawn.js +336 -110
- package/dist/mcp/handlers/agent-spawn.js.map +1 -1
- package/dist/mcp/handlers/fleet-init.d.ts +24 -0
- package/dist/mcp/handlers/fleet-init.d.ts.map +1 -1
- package/dist/mcp/handlers/fleet-init.js +56 -4
- package/dist/mcp/handlers/fleet-init.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/memory/HNSWPatternStore.d.ts.map +1 -1
- package/dist/memory/HNSWPatternStore.js +23 -0
- package/dist/memory/HNSWPatternStore.js.map +1 -1
- package/dist/memory/RuVectorPatternStore.d.ts +5 -0
- package/dist/memory/RuVectorPatternStore.d.ts.map +1 -1
- package/dist/memory/RuVectorPatternStore.js +11 -0
- package/dist/memory/RuVectorPatternStore.js.map +1 -1
- package/dist/plugins/BasePlugin.d.ts +111 -0
- package/dist/plugins/BasePlugin.d.ts.map +1 -0
- package/dist/plugins/BasePlugin.js +154 -0
- package/dist/plugins/BasePlugin.js.map +1 -0
- package/dist/plugins/PluginManager.d.ts +145 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -0
- package/dist/plugins/PluginManager.js +862 -0
- package/dist/plugins/PluginManager.js.map +1 -0
- package/dist/plugins/adapters/McpToolsPlugin.d.ts +98 -0
- package/dist/plugins/adapters/McpToolsPlugin.d.ts.map +1 -0
- package/dist/plugins/adapters/McpToolsPlugin.js +518 -0
- package/dist/plugins/adapters/McpToolsPlugin.js.map +1 -0
- package/dist/plugins/adapters/PlaywrightPlugin.d.ts +63 -0
- package/dist/plugins/adapters/PlaywrightPlugin.d.ts.map +1 -0
- package/dist/plugins/adapters/PlaywrightPlugin.js +451 -0
- package/dist/plugins/adapters/PlaywrightPlugin.js.map +1 -0
- package/dist/plugins/adapters/VitestPlugin.d.ts +74 -0
- package/dist/plugins/adapters/VitestPlugin.d.ts.map +1 -0
- package/dist/plugins/adapters/VitestPlugin.js +589 -0
- package/dist/plugins/adapters/VitestPlugin.js.map +1 -0
- package/dist/plugins/adapters/index.d.ts +8 -0
- package/dist/plugins/adapters/index.d.ts.map +1 -0
- package/dist/plugins/adapters/index.js +17 -0
- package/dist/plugins/adapters/index.js.map +1 -0
- package/dist/plugins/index.d.ts +32 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +48 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/types.d.ts +528 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +61 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/providers/CostOptimizationStrategies.d.ts +297 -0
- package/dist/providers/CostOptimizationStrategies.d.ts.map +1 -0
- package/dist/providers/CostOptimizationStrategies.js +831 -0
- package/dist/providers/CostOptimizationStrategies.js.map +1 -0
- package/dist/providers/HybridRouter.d.ts +142 -5
- package/dist/providers/HybridRouter.d.ts.map +1 -1
- package/dist/providers/HybridRouter.js +472 -6
- package/dist/providers/HybridRouter.js.map +1 -1
- package/dist/providers/HybridRouterComplexityIntegration.d.ts +169 -0
- package/dist/providers/HybridRouterComplexityIntegration.d.ts.map +1 -0
- package/dist/providers/HybridRouterComplexityIntegration.js +319 -0
- package/dist/providers/HybridRouterComplexityIntegration.js.map +1 -0
- package/dist/providers/HybridRouterModelSelection.d.ts +106 -0
- package/dist/providers/HybridRouterModelSelection.d.ts.map +1 -0
- package/dist/providers/HybridRouterModelSelection.js +420 -0
- package/dist/providers/HybridRouterModelSelection.js.map +1 -0
- package/dist/providers/LLMProviderFactory.d.ts +23 -9
- package/dist/providers/LLMProviderFactory.d.ts.map +1 -1
- package/dist/providers/LLMProviderFactory.js +54 -11
- package/dist/providers/LLMProviderFactory.js.map +1 -1
- package/dist/providers/OllamaProvider.d.ts +122 -0
- package/dist/providers/OllamaProvider.d.ts.map +1 -0
- package/dist/providers/OllamaProvider.js +425 -0
- package/dist/providers/OllamaProvider.js.map +1 -0
- package/dist/providers/index.d.ts +6 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +17 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/routing/ComplexityClassifier.d.ts +266 -0
- package/dist/routing/ComplexityClassifier.d.ts.map +1 -0
- package/dist/routing/ComplexityClassifier.js +567 -0
- package/dist/routing/ComplexityClassifier.js.map +1 -0
- package/dist/routing/ModelCapabilityRegistry.d.ts +98 -0
- package/dist/routing/ModelCapabilityRegistry.d.ts.map +1 -0
- package/dist/routing/ModelCapabilityRegistry.js +216 -0
- package/dist/routing/ModelCapabilityRegistry.js.map +1 -0
- package/dist/routing/index.d.ts +13 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +24 -0
- package/dist/routing/index.js.map +1 -0
- package/docs/reference/model-capability-registry.md +402 -0
- package/docs/reference/provider-config-schema.md +608 -0
- package/package.json +21 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QE Agent Pool Factory
|
|
3
|
+
* Phase 3 D1: Memory Pooling for 16x Agent Spawn Speedup
|
|
4
|
+
*
|
|
5
|
+
* Bridges the AgentPool with the existing QE agent creation system.
|
|
6
|
+
* Provides a factory implementation that creates poolable agents.
|
|
7
|
+
*/
|
|
8
|
+
import { QEAgentType } from '../../types';
|
|
9
|
+
import { BaseAgent } from '../BaseAgent';
|
|
10
|
+
import { AgentFactory, AgentPool } from './AgentPool';
|
|
11
|
+
import { IResettableAgent, AgentPoolConfig, AgentTypePoolConfig } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper that makes BaseAgent poolable
|
|
14
|
+
*/
|
|
15
|
+
export declare class PoolableAgent implements IResettableAgent {
|
|
16
|
+
private readonly agent;
|
|
17
|
+
private healthy;
|
|
18
|
+
constructor(agent: BaseAgent);
|
|
19
|
+
/**
|
|
20
|
+
* Get the underlying BaseAgent
|
|
21
|
+
*/
|
|
22
|
+
getBaseAgent(): BaseAgent;
|
|
23
|
+
/**
|
|
24
|
+
* Reset agent state for reuse
|
|
25
|
+
*/
|
|
26
|
+
reset(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if agent is healthy
|
|
29
|
+
*/
|
|
30
|
+
isHealthy(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get agent ID
|
|
33
|
+
*/
|
|
34
|
+
getId(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get agent type
|
|
37
|
+
*/
|
|
38
|
+
getType(): QEAgentType;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for the pool factory
|
|
42
|
+
*/
|
|
43
|
+
export interface PoolFactoryConfig {
|
|
44
|
+
/** Enable learning for agents */
|
|
45
|
+
enableLearning?: boolean;
|
|
46
|
+
/** Enable debug logging */
|
|
47
|
+
debug?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Agent creator function type
|
|
51
|
+
* This allows the caller to provide their own agent creation logic
|
|
52
|
+
*/
|
|
53
|
+
export type AgentCreator = (type: QEAgentType) => Promise<BaseAgent>;
|
|
54
|
+
/**
|
|
55
|
+
* Factory for creating poolable QE agents
|
|
56
|
+
*
|
|
57
|
+
* Uses a provided creator function to decouple from QEAgentFactory dependencies
|
|
58
|
+
*/
|
|
59
|
+
export declare class QEAgentPoolFactory implements AgentFactory<PoolableAgent> {
|
|
60
|
+
private readonly creator;
|
|
61
|
+
private readonly config;
|
|
62
|
+
constructor(creator: AgentCreator, config?: PoolFactoryConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Create a new poolable agent (constructor only, no initialization)
|
|
65
|
+
*/
|
|
66
|
+
create(type: QEAgentType): Promise<PoolableAgent>;
|
|
67
|
+
/**
|
|
68
|
+
* Initialize an agent (heavy async operations)
|
|
69
|
+
*/
|
|
70
|
+
initialize(agent: PoolableAgent): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Dispose an agent
|
|
73
|
+
*/
|
|
74
|
+
dispose(agent: PoolableAgent): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Default pool configuration optimized for QE workloads
|
|
78
|
+
*/
|
|
79
|
+
export declare const DEFAULT_QE_POOL_CONFIG: Partial<AgentPoolConfig>;
|
|
80
|
+
/**
|
|
81
|
+
* Type-specific pool configurations
|
|
82
|
+
*/
|
|
83
|
+
export declare const QE_TYPE_CONFIGS: Map<QEAgentType, AgentTypePoolConfig>;
|
|
84
|
+
/**
|
|
85
|
+
* Create a configured QE agent pool
|
|
86
|
+
*
|
|
87
|
+
* @param creator - Function to create agents
|
|
88
|
+
* @param factoryConfig - Factory configuration
|
|
89
|
+
* @param poolConfig - Pool configuration
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* import { QEAgentFactory } from '../index';
|
|
94
|
+
*
|
|
95
|
+
* // Setup factory with your dependencies
|
|
96
|
+
* const qeFactory = new QEAgentFactory({ eventBus, memoryStore, context });
|
|
97
|
+
*
|
|
98
|
+
* // Create pool with custom creator
|
|
99
|
+
* const pool = await createQEAgentPool(
|
|
100
|
+
* (type) => qeFactory.createAgent(type),
|
|
101
|
+
* { enableLearning: true },
|
|
102
|
+
* { debug: true }
|
|
103
|
+
* );
|
|
104
|
+
*
|
|
105
|
+
* await pool.warmup();
|
|
106
|
+
*
|
|
107
|
+
* const { agent, meta } = await pool.acquire(QEAgentType.TEST_GENERATOR);
|
|
108
|
+
* const baseAgent = agent.getBaseAgent();
|
|
109
|
+
* // Use baseAgent...
|
|
110
|
+
* await pool.release(meta.poolId);
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function createQEAgentPool(creator: AgentCreator, factoryConfig?: PoolFactoryConfig, poolConfig?: Partial<AgentPoolConfig>): Promise<AgentPool<PoolableAgent>>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the BaseAgent from a pooled agent
|
|
116
|
+
*/
|
|
117
|
+
export declare function unwrapPooledAgent(poolable: PoolableAgent): BaseAgent;
|
|
118
|
+
//# sourceMappingURL=QEAgentPoolFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QEAgentPoolFactory.d.ts","sourceRoot":"","sources":["../../../src/agents/pool/QEAgentPoolFactory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEjF;;GAEG;AACH,qBAAa,aAAc,YAAW,gBAAgB;IACpD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,OAAO,CAAQ;gBAEX,KAAK,EAAE,SAAS;IAI5B;;OAEG;IACH,YAAY,IAAI,SAAS;IAIzB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB5B;;OAEG;IACH,SAAS,IAAI,OAAO;IAapB;;OAEG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,OAAO,IAAI,WAAW;CAGvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAErE;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,YAAY,CAAC,aAAa,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,GAAE,iBAAsB;IAKjE;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAKvD;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CASnD;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,CAAC,eAAe,CAa3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,GAAG,CAAC,WAAW,EAAE,mBAAmB,CA6DhE,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,YAAY,EACrB,aAAa,GAAE,iBAAsB,EACrC,UAAU,GAAE,OAAO,CAAC,eAAe,CAAM,GACxC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAenC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,CAEpE"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* QE Agent Pool Factory
|
|
4
|
+
* Phase 3 D1: Memory Pooling for 16x Agent Spawn Speedup
|
|
5
|
+
*
|
|
6
|
+
* Bridges the AgentPool with the existing QE agent creation system.
|
|
7
|
+
* Provides a factory implementation that creates poolable agents.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.QE_TYPE_CONFIGS = exports.DEFAULT_QE_POOL_CONFIG = exports.QEAgentPoolFactory = exports.PoolableAgent = void 0;
|
|
11
|
+
exports.createQEAgentPool = createQEAgentPool;
|
|
12
|
+
exports.unwrapPooledAgent = unwrapPooledAgent;
|
|
13
|
+
const types_1 = require("../../types");
|
|
14
|
+
const AgentPool_1 = require("./AgentPool");
|
|
15
|
+
/**
|
|
16
|
+
* Wrapper that makes BaseAgent poolable
|
|
17
|
+
*/
|
|
18
|
+
class PoolableAgent {
|
|
19
|
+
constructor(agent) {
|
|
20
|
+
this.healthy = true;
|
|
21
|
+
this.agent = agent;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the underlying BaseAgent
|
|
25
|
+
*/
|
|
26
|
+
getBaseAgent() {
|
|
27
|
+
return this.agent;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reset agent state for reuse
|
|
31
|
+
*/
|
|
32
|
+
async reset() {
|
|
33
|
+
try {
|
|
34
|
+
// Clear current task using type assertion to access protected member
|
|
35
|
+
this.agent.currentTask = undefined;
|
|
36
|
+
// Reset performance metrics (keep accumulated stats but clear current)
|
|
37
|
+
if (this.agent.performanceMetrics) {
|
|
38
|
+
this.agent.performanceMetrics.lastTaskDuration = 0;
|
|
39
|
+
}
|
|
40
|
+
// Clear any pending events
|
|
41
|
+
this.agent.removeAllListeners();
|
|
42
|
+
// Re-setup event handlers if available
|
|
43
|
+
if (typeof this.agent.setupEventHandlers === 'function') {
|
|
44
|
+
this.agent.setupEventHandlers();
|
|
45
|
+
}
|
|
46
|
+
this.healthy = true;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.healthy = false;
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if agent is healthy
|
|
55
|
+
*/
|
|
56
|
+
isHealthy() {
|
|
57
|
+
if (!this.healthy)
|
|
58
|
+
return false;
|
|
59
|
+
try {
|
|
60
|
+
// Check lifecycle status - getStatus() returns an object with .status
|
|
61
|
+
const statusObj = this.agent.getStatus();
|
|
62
|
+
const status = statusObj.status;
|
|
63
|
+
return status !== types_1.AgentStatus.ERROR && status !== types_1.AgentStatus.TERMINATED;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get agent ID
|
|
71
|
+
*/
|
|
72
|
+
getId() {
|
|
73
|
+
return this.agent.getAgentId().id;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get agent type
|
|
77
|
+
*/
|
|
78
|
+
getType() {
|
|
79
|
+
return this.agent.getAgentId().type;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.PoolableAgent = PoolableAgent;
|
|
83
|
+
/**
|
|
84
|
+
* Factory for creating poolable QE agents
|
|
85
|
+
*
|
|
86
|
+
* Uses a provided creator function to decouple from QEAgentFactory dependencies
|
|
87
|
+
*/
|
|
88
|
+
class QEAgentPoolFactory {
|
|
89
|
+
constructor(creator, config = {}) {
|
|
90
|
+
this.creator = creator;
|
|
91
|
+
this.config = config;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a new poolable agent (constructor only, no initialization)
|
|
95
|
+
*/
|
|
96
|
+
async create(type) {
|
|
97
|
+
const agent = await this.creator(type);
|
|
98
|
+
return new PoolableAgent(agent);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Initialize an agent (heavy async operations)
|
|
102
|
+
*/
|
|
103
|
+
async initialize(agent) {
|
|
104
|
+
await agent.getBaseAgent().initialize();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Dispose an agent
|
|
108
|
+
*/
|
|
109
|
+
async dispose(agent) {
|
|
110
|
+
try {
|
|
111
|
+
await agent.getBaseAgent().terminate();
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (this.config.debug) {
|
|
115
|
+
console.warn(`Error disposing agent ${agent.getId()}:`, error);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.QEAgentPoolFactory = QEAgentPoolFactory;
|
|
121
|
+
/**
|
|
122
|
+
* Default pool configuration optimized for QE workloads
|
|
123
|
+
*/
|
|
124
|
+
exports.DEFAULT_QE_POOL_CONFIG = {
|
|
125
|
+
debug: false,
|
|
126
|
+
globalMaxAgents: 50,
|
|
127
|
+
warmupStrategy: 'lazy',
|
|
128
|
+
healthCheckIntervalMs: 60000,
|
|
129
|
+
defaultConfig: {
|
|
130
|
+
minSize: 1,
|
|
131
|
+
maxSize: 5,
|
|
132
|
+
warmupCount: 1,
|
|
133
|
+
preInitialize: false,
|
|
134
|
+
idleTtlMs: 300000, // 5 minutes
|
|
135
|
+
growthIncrement: 1,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Type-specific pool configurations
|
|
140
|
+
*/
|
|
141
|
+
exports.QE_TYPE_CONFIGS = new Map([
|
|
142
|
+
[
|
|
143
|
+
types_1.QEAgentType.TEST_GENERATOR,
|
|
144
|
+
{
|
|
145
|
+
type: types_1.QEAgentType.TEST_GENERATOR,
|
|
146
|
+
minSize: 2,
|
|
147
|
+
maxSize: 8,
|
|
148
|
+
warmupCount: 2,
|
|
149
|
+
preInitialize: true, // Pre-init for fast response
|
|
150
|
+
idleTtlMs: 600000, // 10 minutes (high demand)
|
|
151
|
+
growthIncrement: 2,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
[
|
|
155
|
+
types_1.QEAgentType.COVERAGE_ANALYZER,
|
|
156
|
+
{
|
|
157
|
+
type: types_1.QEAgentType.COVERAGE_ANALYZER,
|
|
158
|
+
minSize: 1,
|
|
159
|
+
maxSize: 4,
|
|
160
|
+
warmupCount: 1,
|
|
161
|
+
preInitialize: true,
|
|
162
|
+
idleTtlMs: 300000,
|
|
163
|
+
growthIncrement: 1,
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
types_1.QEAgentType.QUALITY_GATE,
|
|
168
|
+
{
|
|
169
|
+
type: types_1.QEAgentType.QUALITY_GATE,
|
|
170
|
+
minSize: 1,
|
|
171
|
+
maxSize: 3,
|
|
172
|
+
warmupCount: 1,
|
|
173
|
+
preInitialize: true, // Fast response needed for gates
|
|
174
|
+
idleTtlMs: 180000, // 3 minutes
|
|
175
|
+
growthIncrement: 1,
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
[
|
|
179
|
+
types_1.QEAgentType.PERFORMANCE_TESTER,
|
|
180
|
+
{
|
|
181
|
+
type: types_1.QEAgentType.PERFORMANCE_TESTER,
|
|
182
|
+
minSize: 1,
|
|
183
|
+
maxSize: 4,
|
|
184
|
+
warmupCount: 0, // Heavy resource, lazy create
|
|
185
|
+
preInitialize: false,
|
|
186
|
+
idleTtlMs: 120000, // 2 minutes (resource intensive)
|
|
187
|
+
growthIncrement: 1,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
types_1.QEAgentType.SECURITY_SCANNER,
|
|
192
|
+
{
|
|
193
|
+
type: types_1.QEAgentType.SECURITY_SCANNER,
|
|
194
|
+
minSize: 1,
|
|
195
|
+
maxSize: 3,
|
|
196
|
+
warmupCount: 1,
|
|
197
|
+
preInitialize: false,
|
|
198
|
+
idleTtlMs: 300000,
|
|
199
|
+
growthIncrement: 1,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
]);
|
|
203
|
+
/**
|
|
204
|
+
* Create a configured QE agent pool
|
|
205
|
+
*
|
|
206
|
+
* @param creator - Function to create agents
|
|
207
|
+
* @param factoryConfig - Factory configuration
|
|
208
|
+
* @param poolConfig - Pool configuration
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* import { QEAgentFactory } from '../index';
|
|
213
|
+
*
|
|
214
|
+
* // Setup factory with your dependencies
|
|
215
|
+
* const qeFactory = new QEAgentFactory({ eventBus, memoryStore, context });
|
|
216
|
+
*
|
|
217
|
+
* // Create pool with custom creator
|
|
218
|
+
* const pool = await createQEAgentPool(
|
|
219
|
+
* (type) => qeFactory.createAgent(type),
|
|
220
|
+
* { enableLearning: true },
|
|
221
|
+
* { debug: true }
|
|
222
|
+
* );
|
|
223
|
+
*
|
|
224
|
+
* await pool.warmup();
|
|
225
|
+
*
|
|
226
|
+
* const { agent, meta } = await pool.acquire(QEAgentType.TEST_GENERATOR);
|
|
227
|
+
* const baseAgent = agent.getBaseAgent();
|
|
228
|
+
* // Use baseAgent...
|
|
229
|
+
* await pool.release(meta.poolId);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
async function createQEAgentPool(creator, factoryConfig = {}, poolConfig = {}) {
|
|
233
|
+
const factory = new QEAgentPoolFactory(creator, factoryConfig);
|
|
234
|
+
const config = {
|
|
235
|
+
...exports.DEFAULT_QE_POOL_CONFIG,
|
|
236
|
+
...poolConfig,
|
|
237
|
+
typeConfigs: new Map([
|
|
238
|
+
...exports.QE_TYPE_CONFIGS,
|
|
239
|
+
...(poolConfig.typeConfigs || new Map()),
|
|
240
|
+
]),
|
|
241
|
+
};
|
|
242
|
+
const pool = new AgentPool_1.AgentPool(factory, config);
|
|
243
|
+
return pool;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the BaseAgent from a pooled agent
|
|
247
|
+
*/
|
|
248
|
+
function unwrapPooledAgent(poolable) {
|
|
249
|
+
return poolable.getBaseAgent();
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=QEAgentPoolFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QEAgentPoolFactory.js","sourceRoot":"","sources":["../../../src/agents/pool/QEAgentPoolFactory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAgQH,8CAmBC;AAKD,8CAEC;AA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CAAiC;YACpD,eAAe,EAAE,CAAC;SACnB;KACF;IACD;QACE,mBAAW,CAAC,gBAAgB;QAC5B;YACE,IAAI,EAAE,mBAAW,CAAC,gBAAgB;YAClC,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,KAAK;YACpB,SAAS,EAAE,MAAM;YACjB,eAAe,EAAE,CAAC;SACnB;KACF;CACF,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACI,KAAK,UAAU,iBAAiB,CACrC,OAAqB,EACrB,gBAAmC,EAAE,EACrC,aAAuC,EAAE;IAEzC,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE/D,MAAM,MAAM,GAA6B;QACvC,GAAG,8BAAsB;QACzB,GAAG,UAAU;QACb,WAAW,EAAE,IAAI,GAAG,CAAC;YACnB,GAAG,uBAAe;YAClB,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI,IAAI,GAAG,EAAE,CAAC;SACzC,CAAC;KACH,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,qBAAS,CAAgB,OAAO,EAAE,MAAM,CAAC,CAAC;IAE3D,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,QAAuB;IACvD,OAAO,QAAQ,CAAC,YAAY,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Pool Module
|
|
3
|
+
* Phase 3 D1: Memory Pooling for 16x Agent Spawn Speedup
|
|
4
|
+
*
|
|
5
|
+
* Provides pre-allocated agent pooling for fast acquisition.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AgentPool, createQEAgentFactory } from './pool';
|
|
10
|
+
*
|
|
11
|
+
* const factory = createQEAgentFactory(memoryStore, config);
|
|
12
|
+
* const pool = new AgentPool(factory, {
|
|
13
|
+
* typeConfigs: new Map([
|
|
14
|
+
* ['test-generator', { minSize: 3, maxSize: 10, warmupCount: 3 }],
|
|
15
|
+
* ]),
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Warmup during startup
|
|
19
|
+
* await pool.warmup();
|
|
20
|
+
*
|
|
21
|
+
* // Fast acquisition (<6ms target)
|
|
22
|
+
* const { agent, meta } = await pool.acquire('test-generator');
|
|
23
|
+
*
|
|
24
|
+
* // Use agent
|
|
25
|
+
* await agent.executeTask(task);
|
|
26
|
+
*
|
|
27
|
+
* // Return to pool
|
|
28
|
+
* await pool.release(meta.poolId);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export { AgentPool, AgentFactory } from './AgentPool';
|
|
32
|
+
export { AgentPoolConfig, AgentTypePoolConfig, PooledAgentState, PooledAgentMeta, PoolStats, TypePoolStats, AcquireOptions, ReleaseOptions, AcquireResult, PoolEvents, IResettableAgent, ExpansionPolicy, } from './types';
|
|
33
|
+
export { QEAgentPoolFactory, createQEAgentPool, unwrapPooledAgent, PoolableAgent, PoolFactoryConfig, AgentCreator, } from './QEAgentPoolFactory';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/pool/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAEL,eAAe,EACf,mBAAmB,EAGnB,gBAAgB,EAChB,eAAe,EAGf,SAAS,EACT,aAAa,EAGb,cAAc,EACd,cAAc,EACd,aAAa,EAGb,UAAU,EAGV,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Pool Module
|
|
4
|
+
* Phase 3 D1: Memory Pooling for 16x Agent Spawn Speedup
|
|
5
|
+
*
|
|
6
|
+
* Provides pre-allocated agent pooling for fast acquisition.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { AgentPool, createQEAgentFactory } from './pool';
|
|
11
|
+
*
|
|
12
|
+
* const factory = createQEAgentFactory(memoryStore, config);
|
|
13
|
+
* const pool = new AgentPool(factory, {
|
|
14
|
+
* typeConfigs: new Map([
|
|
15
|
+
* ['test-generator', { minSize: 3, maxSize: 10, warmupCount: 3 }],
|
|
16
|
+
* ]),
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Warmup during startup
|
|
20
|
+
* await pool.warmup();
|
|
21
|
+
*
|
|
22
|
+
* // Fast acquisition (<6ms target)
|
|
23
|
+
* const { agent, meta } = await pool.acquire('test-generator');
|
|
24
|
+
*
|
|
25
|
+
* // Use agent
|
|
26
|
+
* await agent.executeTask(task);
|
|
27
|
+
*
|
|
28
|
+
* // Return to pool
|
|
29
|
+
* await pool.release(meta.poolId);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.PoolableAgent = exports.unwrapPooledAgent = exports.createQEAgentPool = exports.QEAgentPoolFactory = exports.PooledAgentState = exports.AgentPool = void 0;
|
|
34
|
+
var AgentPool_1 = require("./AgentPool");
|
|
35
|
+
Object.defineProperty(exports, "AgentPool", { enumerable: true, get: function () { return AgentPool_1.AgentPool; } });
|
|
36
|
+
var types_1 = require("./types");
|
|
37
|
+
// State and metadata
|
|
38
|
+
Object.defineProperty(exports, "PooledAgentState", { enumerable: true, get: function () { return types_1.PooledAgentState; } });
|
|
39
|
+
var QEAgentPoolFactory_1 = require("./QEAgentPoolFactory");
|
|
40
|
+
Object.defineProperty(exports, "QEAgentPoolFactory", { enumerable: true, get: function () { return QEAgentPoolFactory_1.QEAgentPoolFactory; } });
|
|
41
|
+
Object.defineProperty(exports, "createQEAgentPool", { enumerable: true, get: function () { return QEAgentPoolFactory_1.createQEAgentPool; } });
|
|
42
|
+
Object.defineProperty(exports, "unwrapPooledAgent", { enumerable: true, get: function () { return QEAgentPoolFactory_1.unwrapPooledAgent; } });
|
|
43
|
+
Object.defineProperty(exports, "PoolableAgent", { enumerable: true, get: function () { return QEAgentPoolFactory_1.PoolableAgent; } });
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/pool/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAEH,yCAAsD;AAA7C,sGAAA,SAAS,OAAA;AAElB,iCAwBiB;AAnBf,qBAAqB;AACrB,yGAAA,gBAAgB,OAAA;AAoBlB,2DAO8B;AAN5B,wHAAA,kBAAkB,OAAA;AAClB,uHAAA,iBAAiB,OAAA;AACjB,uHAAA,iBAAiB,OAAA;AACjB,mHAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Pool Types
|
|
3
|
+
* Phase 3 D1: Memory Pooling for 16x Agent Spawn Speedup
|
|
4
|
+
*
|
|
5
|
+
* Target: Reduce spawn time from ~50-100ms to ~3-6ms
|
|
6
|
+
*/
|
|
7
|
+
import { QEAgentType } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Pool configuration for a specific agent type
|
|
10
|
+
*/
|
|
11
|
+
export interface AgentTypePoolConfig {
|
|
12
|
+
/** Agent type identifier */
|
|
13
|
+
type: QEAgentType;
|
|
14
|
+
/** Minimum number of agents to keep warm in pool */
|
|
15
|
+
minSize: number;
|
|
16
|
+
/** Maximum pool size (prevents memory bloat) */
|
|
17
|
+
maxSize: number;
|
|
18
|
+
/** Number of agents to pre-warm during startup */
|
|
19
|
+
warmupCount: number;
|
|
20
|
+
/** Whether to pre-initialize agents (run initialize() during warmup) */
|
|
21
|
+
preInitialize: boolean;
|
|
22
|
+
/** Time-to-live for idle agents in ms (0 = no expiration) */
|
|
23
|
+
idleTtlMs: number;
|
|
24
|
+
/** Growth increment when pool is exhausted */
|
|
25
|
+
growthIncrement: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Overall pool configuration
|
|
29
|
+
*/
|
|
30
|
+
export interface AgentPoolConfig {
|
|
31
|
+
/** Per-type pool configurations */
|
|
32
|
+
typeConfigs: Map<QEAgentType, AgentTypePoolConfig>;
|
|
33
|
+
/** Default config for types without specific configuration */
|
|
34
|
+
defaultConfig: Omit<AgentTypePoolConfig, 'type'>;
|
|
35
|
+
/** Enable debug logging */
|
|
36
|
+
debug: boolean;
|
|
37
|
+
/** Maximum total agents across all pools */
|
|
38
|
+
globalMaxAgents: number;
|
|
39
|
+
/** Warmup strategy: 'eager' (all at once) or 'lazy' (on first request) */
|
|
40
|
+
warmupStrategy: 'eager' | 'lazy';
|
|
41
|
+
/** Health check interval in ms (0 = disabled) */
|
|
42
|
+
healthCheckIntervalMs: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* State of a pooled agent
|
|
46
|
+
*/
|
|
47
|
+
export declare enum PooledAgentState {
|
|
48
|
+
/** Agent is available for acquisition */
|
|
49
|
+
AVAILABLE = "available",
|
|
50
|
+
/** Agent is currently in use */
|
|
51
|
+
IN_USE = "in_use",
|
|
52
|
+
/** Agent is being initialized */
|
|
53
|
+
INITIALIZING = "initializing",
|
|
54
|
+
/** Agent is being reset for reuse */
|
|
55
|
+
RESETTING = "resetting",
|
|
56
|
+
/** Agent has an error and needs recovery */
|
|
57
|
+
ERROR = "error",
|
|
58
|
+
/** Agent is marked for removal */
|
|
59
|
+
DISPOSING = "disposing"
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Metadata for a pooled agent
|
|
63
|
+
*/
|
|
64
|
+
export interface PooledAgentMeta {
|
|
65
|
+
/** Unique pool-assigned ID */
|
|
66
|
+
poolId: string;
|
|
67
|
+
/** Agent type */
|
|
68
|
+
type: QEAgentType;
|
|
69
|
+
/** Current state in pool */
|
|
70
|
+
state: PooledAgentState;
|
|
71
|
+
/** When the agent was created */
|
|
72
|
+
createdAt: number;
|
|
73
|
+
/** When the agent was last acquired */
|
|
74
|
+
lastAcquiredAt: number | null;
|
|
75
|
+
/** When the agent was last released */
|
|
76
|
+
lastReleasedAt: number | null;
|
|
77
|
+
/** Number of times this agent has been reused */
|
|
78
|
+
reuseCount: number;
|
|
79
|
+
/** Total time spent in use (ms) */
|
|
80
|
+
totalUseTimeMs: number;
|
|
81
|
+
/** Whether agent has been initialized */
|
|
82
|
+
isInitialized: boolean;
|
|
83
|
+
/** Last error if any */
|
|
84
|
+
lastError: Error | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Pool statistics for monitoring
|
|
88
|
+
*/
|
|
89
|
+
export interface PoolStats {
|
|
90
|
+
/** Total agents across all types */
|
|
91
|
+
totalAgents: number;
|
|
92
|
+
/** Available agents ready for use */
|
|
93
|
+
availableAgents: number;
|
|
94
|
+
/** Agents currently in use */
|
|
95
|
+
inUseAgents: number;
|
|
96
|
+
/** Agents being initialized */
|
|
97
|
+
initializingAgents: number;
|
|
98
|
+
/** Per-type breakdown */
|
|
99
|
+
byType: Map<QEAgentType, TypePoolStats>;
|
|
100
|
+
/** Average acquisition time (ms) */
|
|
101
|
+
avgAcquisitionTimeMs: number;
|
|
102
|
+
/** Cache hit rate (acquisitions from pool vs new creates) */
|
|
103
|
+
hitRate: number;
|
|
104
|
+
/** Total acquisitions since startup */
|
|
105
|
+
totalAcquisitions: number;
|
|
106
|
+
/** Total pool misses (had to create new) */
|
|
107
|
+
totalMisses: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Per-type pool statistics
|
|
111
|
+
*/
|
|
112
|
+
export interface TypePoolStats {
|
|
113
|
+
type: QEAgentType;
|
|
114
|
+
total: number;
|
|
115
|
+
available: number;
|
|
116
|
+
inUse: number;
|
|
117
|
+
minSize: number;
|
|
118
|
+
maxSize: number;
|
|
119
|
+
avgReuseCount: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Options for acquiring an agent from the pool
|
|
123
|
+
*/
|
|
124
|
+
export interface AcquireOptions {
|
|
125
|
+
/** Timeout for acquisition in ms (default: 5000) */
|
|
126
|
+
timeoutMs?: number;
|
|
127
|
+
/** Whether to wait for an agent if none available (default: true) */
|
|
128
|
+
waitIfUnavailable?: boolean;
|
|
129
|
+
/** Priority level for acquisition (higher = first in queue) */
|
|
130
|
+
priority?: number;
|
|
131
|
+
/** Custom capabilities required (filters available agents) */
|
|
132
|
+
requiredCapabilities?: string[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Options for releasing an agent back to the pool
|
|
136
|
+
*/
|
|
137
|
+
export interface ReleaseOptions {
|
|
138
|
+
/** Whether to reset agent state (default: true) */
|
|
139
|
+
reset?: boolean;
|
|
140
|
+
/** Mark agent as having an error (will be recovered or disposed) */
|
|
141
|
+
hasError?: boolean;
|
|
142
|
+
/** Force disposal instead of returning to pool */
|
|
143
|
+
dispose?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Pool expansion policy
|
|
147
|
+
*/
|
|
148
|
+
export type ExpansionPolicy = 'none' | 'linear' | 'exponential' | 'adaptive';
|
|
149
|
+
/**
|
|
150
|
+
* Result of an acquire operation
|
|
151
|
+
*/
|
|
152
|
+
export interface AcquireResult<T> {
|
|
153
|
+
/** The acquired agent */
|
|
154
|
+
agent: T;
|
|
155
|
+
/** Pool metadata for this agent */
|
|
156
|
+
meta: PooledAgentMeta;
|
|
157
|
+
/** Whether this was a cache hit (from pool) or miss (newly created) */
|
|
158
|
+
fromPool: boolean;
|
|
159
|
+
/** Time taken to acquire in ms */
|
|
160
|
+
acquisitionTimeMs: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Events emitted by the pool
|
|
164
|
+
*/
|
|
165
|
+
export interface PoolEvents {
|
|
166
|
+
'agent:acquired': {
|
|
167
|
+
poolId: string;
|
|
168
|
+
type: QEAgentType;
|
|
169
|
+
fromPool: boolean;
|
|
170
|
+
};
|
|
171
|
+
'agent:released': {
|
|
172
|
+
poolId: string;
|
|
173
|
+
type: QEAgentType;
|
|
174
|
+
};
|
|
175
|
+
'agent:created': {
|
|
176
|
+
poolId: string;
|
|
177
|
+
type: QEAgentType;
|
|
178
|
+
};
|
|
179
|
+
'agent:disposed': {
|
|
180
|
+
poolId: string;
|
|
181
|
+
type: QEAgentType;
|
|
182
|
+
reason: string;
|
|
183
|
+
};
|
|
184
|
+
'agent:error': {
|
|
185
|
+
poolId: string;
|
|
186
|
+
type: QEAgentType;
|
|
187
|
+
error: Error;
|
|
188
|
+
};
|
|
189
|
+
'pool:exhausted': {
|
|
190
|
+
type: QEAgentType;
|
|
191
|
+
waitingCount: number;
|
|
192
|
+
};
|
|
193
|
+
'pool:expanded': {
|
|
194
|
+
type: QEAgentType;
|
|
195
|
+
newSize: number;
|
|
196
|
+
};
|
|
197
|
+
'pool:warmed': {
|
|
198
|
+
type: QEAgentType;
|
|
199
|
+
count: number;
|
|
200
|
+
};
|
|
201
|
+
'pool:healthCheck': {
|
|
202
|
+
stats: PoolStats;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Interface for resettable agents (agents that can be reused)
|
|
207
|
+
*/
|
|
208
|
+
export interface IResettableAgent {
|
|
209
|
+
/**
|
|
210
|
+
* Reset agent state for reuse
|
|
211
|
+
* Called when agent is returned to pool
|
|
212
|
+
*/
|
|
213
|
+
reset(): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Check if agent is healthy and can be reused
|
|
216
|
+
*/
|
|
217
|
+
isHealthy(): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Get agent's unique identifier
|
|
220
|
+
*/
|
|
221
|
+
getId(): string;
|
|
222
|
+
/**
|
|
223
|
+
* Get agent type
|
|
224
|
+
*/
|
|
225
|
+
getType(): QEAgentType;
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=types.d.ts.map
|