agents / Exports / AgentFactory
Class: AgentFactory
Agent Factory for creating and managing agents Instance-based for isolated agent factory management
Table of contents
Constructors
Methods
- initialize
- createAgent
- createFromTemplate
- registerTemplate
- unregisterTemplate
- getTemplates
- getTemplate
- findTemplates
- applyTemplate
- destroyAgent
- getCreationStats
- getActiveAgents
- validateConfiguration
Constructors
constructor
• new AgentFactory(options?, lifecycleEvents?): AgentFactory
Parameters
| Name | Type |
|---|---|
options | AgentFactoryOptions |
lifecycleEvents | AgentLifecycleEvents |
Returns
Defined in
packages/agents/src/managers/agent-factory.ts:68
Methods
initialize
▸ initialize(): Promise<void>
Initialize the factory
Returns
Promise<void>
Defined in
packages/agents/src/managers/agent-factory.ts:100
createAgent
▸ createAgent(AgentClass, config, fromTemplate?): Promise<AgentInterface>
Create a new agent instance
Parameters
| Name | Type | Default value |
|---|---|---|
AgentClass | (config: AgentConfig) => AgentInterface | undefined |
config | Partial<AgentConfig> | undefined |
fromTemplate | boolean | false |
Returns
Promise<AgentInterface>
Defined in
packages/agents/src/managers/agent-factory.ts:113
createFromTemplate
▸ createFromTemplate(AgentClass, templateId, overrides?): Promise<AgentInterface>
Create agent from template
Parameters
| Name | Type |
|---|---|
AgentClass | (config: AgentConfig) => AgentInterface |
templateId | string |
overrides | Partial<AgentConfig> |
Returns
Promise<AgentInterface>
Defined in
packages/agents/src/managers/agent-factory.ts:188
registerTemplate
▸ registerTemplate(template): void
Register a template
Parameters
| Name | Type |
|---|---|
template | AgentTemplate |
Returns
void
Defined in
packages/agents/src/managers/agent-factory.ts:223
unregisterTemplate
▸ unregisterTemplate(templateId): boolean
Unregister a template
Parameters
| Name | Type |
|---|---|
templateId | string |
Returns
boolean
Defined in
packages/agents/src/managers/agent-factory.ts:230
getTemplates
▸ getTemplates(): AgentTemplate[]
Get all templates
Returns
Defined in
packages/agents/src/managers/agent-factory.ts:237
getTemplate
▸ getTemplate(templateId): undefined | AgentTemplate
Get template by ID
Parameters
| Name | Type |
|---|---|
templateId | string |
Returns
undefined | AgentTemplate
Defined in
packages/agents/src/managers/agent-factory.ts:244
findTemplates
▸ findTemplates(criteria): AgentTemplate[]
Find templates by criteria
Parameters
| Name | Type |
|---|---|
criteria | Object |
criteria.category? | string |
criteria.tags? | string[] |
criteria.provider? | string |
criteria.model? | string |
Returns
Defined in
packages/agents/src/managers/agent-factory.ts:251
applyTemplate
▸ applyTemplate(template, overrides?): TemplateApplicationResult
Apply template to configuration
Parameters
| Name | Type |
|---|---|
template | AgentTemplate |
overrides | Partial<AgentConfig> |
Returns
Defined in
packages/agents/src/managers/agent-factory.ts:263
destroyAgent
▸ destroyAgent(agentId): Promise<boolean>
Destroy an agent
Parameters
| Name | Type |
|---|---|
agentId | string |
Returns
Promise<boolean>
Defined in
packages/agents/src/managers/agent-factory.ts:270
getCreationStats
▸ getCreationStats(): AgentCreationStats
Get creation statistics
Returns
Defined in
packages/agents/src/managers/agent-factory.ts:305
getActiveAgents
▸ getActiveAgents(): Map<string, AgentInterface>
Get all active agents
Returns
Map<string, AgentInterface>
Defined in
packages/agents/src/managers/agent-factory.ts:312
validateConfiguration
▸ validateConfiguration(config): Object
Validate agent configuration
Parameters
| Name | Type |
|---|---|
config | Partial<AgentConfig> |
Returns
Object
| Name | Type |
|---|---|
isValid | boolean |
errors | string[] |