<!--
 ⚠️  AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 This file is automatically generated by scripts/docs-generator.js
 To make changes, edit the source TypeScript files or update the generator script
-->

[agents](../../) / [Exports](../modules) / AgentFactory

# Class: AgentFactory

Agent Factory for creating and managing agents
Instance-based for isolated agent factory management

## Table of contents

### Constructors

- [constructor](AgentFactory#constructor)

### Methods

- [initialize](AgentFactory#initialize)
- [createAgent](AgentFactory#createagent)
- [createFromTemplate](AgentFactory#createfromtemplate)
- [registerTemplate](AgentFactory#registertemplate)
- [unregisterTemplate](AgentFactory#unregistertemplate)
- [getTemplates](AgentFactory#gettemplates)
- [getTemplate](AgentFactory#gettemplate)
- [findTemplates](AgentFactory#findtemplates)
- [applyTemplate](AgentFactory#applytemplate)
- [destroyAgent](AgentFactory#destroyagent)
- [getCreationStats](AgentFactory#getcreationstats)
- [getActiveAgents](AgentFactory#getactiveagents)
- [validateConfiguration](AgentFactory#validateconfiguration)

## Constructors

### constructor

• **new AgentFactory**(`options?`, `lifecycleEvents?`): [`AgentFactory`](AgentFactory)

#### Parameters

| Name              | Type                                                           |
| :---------------- | :------------------------------------------------------------- |
| `options`         | [`IAgentFactoryOptions`](../interfaces/IAgentFactoryOptions)   |
| `lifecycleEvents` | [`IAgentLifecycleEvents`](../interfaces/IAgentLifecycleEvents) |

#### Returns

[`AgentFactory`](AgentFactory)

#### Defined in

[packages/agents/src/managers/agent-factory.ts:68](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L68)

## Methods

### initialize

▸ **initialize**(): `Promise`\<`void`\>

Initialize the factory

#### Returns

`Promise`\<`void`\>

#### Defined in

[packages/agents/src/managers/agent-factory.ts:100](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L100)

---

### createAgent

▸ **createAgent**(`AgentClass`, `config`, `fromTemplate?`): `Promise`\<`IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\>\>

Create a new agent instance

#### Parameters

| Name           | Type                                                                                                                                                                                                                  | Default value |
| :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ |
| `AgentClass`   | (`config`: [`IAgentConfig`](../interfaces/IAgentConfig)) => `IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\> | `undefined`   |
| `config`       | `Partial`\<[`IAgentConfig`](../interfaces/IAgentConfig)\>                                                                                                                                                             | `undefined`   |
| `fromTemplate` | `boolean`                                                                                                                                                                                                             | `false`       |

#### Returns

`Promise`\<`IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\>\>

#### Defined in

[packages/agents/src/managers/agent-factory.ts:113](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L113)

---

### createFromTemplate

▸ **createFromTemplate**(`AgentClass`, `templateId`, `overrides?`): `Promise`\<`IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\>\>

Create agent from template

#### Parameters

| Name         | Type                                                                                                                                                                                                                  |
| :----------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AgentClass` | (`config`: [`IAgentConfig`](../interfaces/IAgentConfig)) => `IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\> |
| `templateId` | `string`                                                                                                                                                                                                              |
| `overrides`  | `Partial`\<[`IAgentConfig`](../interfaces/IAgentConfig)\>                                                                                                                                                             |

#### Returns

`Promise`\<`IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\>\>

#### Defined in

[packages/agents/src/managers/agent-factory.ts:192](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L192)

---

### registerTemplate

▸ **registerTemplate**(`template`): `void`

Register a template

#### Parameters

| Name       | Type                                             |
| :--------- | :----------------------------------------------- |
| `template` | [`IAgentTemplate`](../interfaces/IAgentTemplate) |

#### Returns

`void`

#### Defined in

[packages/agents/src/managers/agent-factory.ts:227](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L227)

---

### unregisterTemplate

▸ **unregisterTemplate**(`templateId`): `boolean`

Unregister a template

#### Parameters

| Name         | Type     |
| :----------- | :------- |
| `templateId` | `string` |

#### Returns

`boolean`

#### Defined in

[packages/agents/src/managers/agent-factory.ts:234](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L234)

---

### getTemplates

▸ **getTemplates**(): [`IAgentTemplate`](../interfaces/IAgentTemplate)[]

Get all templates

#### Returns

[`IAgentTemplate`](../interfaces/IAgentTemplate)[]

#### Defined in

[packages/agents/src/managers/agent-factory.ts:241](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L241)

---

### getTemplate

▸ **getTemplate**(`templateId`): `undefined` \| [`IAgentTemplate`](../interfaces/IAgentTemplate)

Get template by ID

#### Parameters

| Name         | Type     |
| :----------- | :------- |
| `templateId` | `string` |

#### Returns

`undefined` \| [`IAgentTemplate`](../interfaces/IAgentTemplate)

#### Defined in

[packages/agents/src/managers/agent-factory.ts:248](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L248)

---

### findTemplates

▸ **findTemplates**(`criteria`): [`IAgentTemplate`](../interfaces/IAgentTemplate)[]

Find templates by criteria

#### Parameters

| Name                 | Type       |
| :------------------- | :--------- |
| `criteria`           | `Object`   |
| `criteria.category?` | `string`   |
| `criteria.tags?`     | `string`[] |
| `criteria.provider?` | `string`   |
| `criteria.model?`    | `string`   |

#### Returns

[`IAgentTemplate`](../interfaces/IAgentTemplate)[]

#### Defined in

[packages/agents/src/managers/agent-factory.ts:255](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L255)

---

### applyTemplate

▸ **applyTemplate**(`template`, `overrides?`): [`ITemplateApplicationResult`](../interfaces/ITemplateApplicationResult)

Apply template to configuration

#### Parameters

| Name        | Type                                                      |
| :---------- | :-------------------------------------------------------- |
| `template`  | [`IAgentTemplate`](../interfaces/IAgentTemplate)          |
| `overrides` | `Partial`\<[`IAgentConfig`](../interfaces/IAgentConfig)\> |

#### Returns

[`ITemplateApplicationResult`](../interfaces/ITemplateApplicationResult)

#### Defined in

[packages/agents/src/managers/agent-factory.ts:267](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L267)

---

### 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:274](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L274)

---

### getCreationStats

▸ **getCreationStats**(): [`IAgentCreationStats`](../interfaces/IAgentCreationStats)

Get creation statistics

#### Returns

[`IAgentCreationStats`](../interfaces/IAgentCreationStats)

#### Defined in

[packages/agents/src/managers/agent-factory.ts:313](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L313)

---

### getActiveAgents

▸ **getActiveAgents**(): `Map`\<`string`, `IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\>\>

Get all active agents

#### Returns

`Map`\<`string`, `IAgent`\<[`IAgentConfig`](../interfaces/IAgentConfig), [`IRunOptions`](../interfaces/IRunOptions), [`TUniversalMessage`](../modules#tuniversalmessage)\>\>

#### Defined in

[packages/agents/src/managers/agent-factory.ts:320](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L320)

---

### validateConfiguration

▸ **validateConfiguration**(`config`): `Object`

Validate agent configuration

#### Parameters

| Name     | Type                                                      |
| :------- | :-------------------------------------------------------- |
| `config` | `Partial`\<[`IAgentConfig`](../interfaces/IAgentConfig)\> |

#### Returns

`Object`

| Name      | Type       |
| :-------- | :--------- |
| `isValid` | `boolean`  |
| `errors`  | `string`[] |

#### Defined in

[packages/agents/src/managers/agent-factory.ts:327](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/managers/agent-factory.ts#L327)
