# Class Orchestrator

Agents exports - Agent framework, Orchestrator, Experts Split from index.ts for file size compliance (Issue #285)

#### Hierarchy (View Summary)

- BaseAgent
  - Orchestrator

- Defined in packages/nexus-agents/src/agents/tech-lead.ts:192

##### Index

### Constructors

constructor

### Properties

id
role
capabilities
stateMachine
budgetTracker
adapter
logger
config
sharedState
history
systemPrompt
temperature
maxTokens
eventBus
emitMessageEvents

### Accessors

state

### Methods

initialize
execute
handleMessage
cleanup
hasCapability
transformError
complete
addToHistory
getHistory
clearHistory
getPruningMetrics
addContextItem
isContextPruningEnabled
isMemoryEnabled
getMemoryState
getRelevantMemories
flushMemory
recordLearning
recordPattern
recordResolution
findResolutionForError
getTaskLearnings
getTopExecutionPatterns
setExpertAgents
executeTask
buildPrompt
analyzeTask
decomposeTask
selectExperts
synthesizeResults
getCollaborationHelper
getOptions

## Constructors

### constructor

- new Orchestrator(
  options?: Partial<BaseAgentOptions> & OrchestratorExtendedOptions & {
  techLeadOptions?: OrchestratorOptions;
  },
  ): Orchestrator

  #### Parameters

  - options: Partial<BaseAgentOptions> & OrchestratorExtendedOptions & {
    techLeadOptions?: OrchestratorOptions;
    } = {}

  #### Returns Orchestrator

  Overrides BaseAgent.constructor

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:198

## Properties

### `Readonly` id

id: string

Unique agent identifier

Inherited from BaseAgent.id

- Defined in packages/nexus-agents/src/agents/base-agent.ts:94

### `Readonly` role

role: AgentRole

Agent role

Inherited from BaseAgent.role

- Defined in packages/nexus-agents/src/agents/base-agent.ts:95

### `Readonly` capabilities

capabilities: readonly AgentCapability[]

Agent capabilities

Inherited from BaseAgent.capabilities

- Defined in packages/nexus-agents/src/agents/base-agent.ts:96

### `Protected` `Readonly` stateMachine

stateMachine: AgentStateMachine

Inherited from BaseAgent.stateMachine

- Defined in packages/nexus-agents/src/agents/base-agent.ts:97

### `Protected` `Readonly` budgetTracker

budgetTracker: ITokenBudgetTracker

Inherited from BaseAgent.budgetTracker

- Defined in packages/nexus-agents/src/agents/base-agent.ts:98

### `Protected` adapter

adapter: IModelAdapter | undefined

Inherited from BaseAgent.adapter

- Defined in packages/nexus-agents/src/agents/base-agent.ts:99

### `Protected` `Readonly` logger

logger: ILogger

Inherited from BaseAgent.logger

- Defined in packages/nexus-agents/src/agents/base-agent.ts:100

### `Protected` config

config: AgentConfig | undefined

Inherited from BaseAgent.config

- Defined in packages/nexus-agents/src/agents/base-agent.ts:101

### `Protected` sharedState

sharedState: Record<string, unknown> = {}

Inherited from BaseAgent.sharedState

- Defined in packages/nexus-agents/src/agents/base-agent.ts:102

### `Protected` history

history: Message[] = []

Inherited from BaseAgent.history

- Defined in packages/nexus-agents/src/agents/base-agent.ts:103

### `Protected` `Readonly` systemPrompt

systemPrompt: string | undefined

Inherited from BaseAgent.systemPrompt

- Defined in packages/nexus-agents/src/agents/base-agent.ts:104

### `Protected` `Readonly` temperature

temperature: number

Inherited from BaseAgent.temperature

- Defined in packages/nexus-agents/src/agents/base-agent.ts:105

### `Protected` `Readonly` maxTokens

maxTokens: number

Inherited from BaseAgent.maxTokens

- Defined in packages/nexus-agents/src/agents/base-agent.ts:106

### `Protected` `Readonly` eventBus

eventBus: IEventBus

Inherited from BaseAgent.eventBus

- Defined in packages/nexus-agents/src/agents/base-agent.ts:107

### `Protected` `Readonly` emitMessageEvents

emitMessageEvents: boolean

Inherited from BaseAgent.emitMessageEvents

- Defined in packages/nexus-agents/src/agents/base-agent.ts:108

## Accessors

### state

- get state(): AgentState

  Current state

  #### Returns AgentState

  Inherited from BaseAgent.state

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:169

## Methods

### initialize

- initialize(ctx: AgentContext): Promise<Result<void, AgentError>>

  Initialize the agent with context.

  #### Parameters

  - ctx: AgentContext

    Agent context

  #### Returns Promise<Result<void, AgentError>>

  Result with void or AgentError

  Inherited from BaseAgent.initialize

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:198

### execute

- execute(task: Task): Promise<Result<TaskResult, AgentError>>

  Execute a task.

  #### Parameters

  - task: Task

    Task to execute

  #### Returns Promise<Result<TaskResult, AgentError>>

  Result with TaskResult or AgentError

  Inherited from BaseAgent.execute

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:211

### handleMessage

- handleMessage(msg: AgentMessage): Promise<Result<AgentResponse, AgentError>>

  Handle an inter-agent message.

  #### Parameters

  - msg: AgentMessage

    Message to handle

  #### Returns Promise<Result<AgentResponse, AgentError>>

  Result with AgentResponse or AgentError

  Inherited from BaseAgent.handleMessage

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:243

### cleanup

- cleanup(): Promise<void>

  Cleanup agent resources.

  #### Returns Promise<void>

  Inherited from BaseAgent.cleanup

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:258

### hasCapability

- hasCapability(capability: AgentCapability): boolean

  #### Parameters

  - capability: AgentCapability

  #### Returns boolean

  Inherited from BaseAgent.hasCapability

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:274

### `Protected` transformError

- transformError(error: unknown, taskId: string): AgentError

  #### Parameters

  - error: unknown
  - taskId: string

  #### Returns AgentError

  Inherited from BaseAgent.transformError

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:281

### `Protected` complete

- complete(
  request: CompletionRequest,
  ): Promise<Result<CompletionResponse, AgentError>>

  #### Parameters

  - request: CompletionRequest

  #### Returns Promise<Result<CompletionResponse, AgentError>>

  Inherited from BaseAgent.complete

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:285

### `Protected` addToHistory

- addToHistory(message: Message): void

  #### Parameters

  - message: Message

  #### Returns void

  Inherited from BaseAgent.addToHistory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:307

### `Protected` getHistory

- getHistory(): Message[]

  #### Returns Message[]

  Inherited from BaseAgent.getHistory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:310

### `Protected` clearHistory

- clearHistory(): void

  #### Returns void

  Inherited from BaseAgent.clearHistory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:313

### getPruningMetrics

- getPruningMetrics(): Readonly<ContextPruningMetrics>

  #### Returns Readonly<ContextPruningMetrics>

  Inherited from BaseAgent.getPruningMetrics

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:316

### `Protected` addContextItem

- addContextItem(
  content: string,
  priority?: 20 | 60 | 80 | 100 | 40,
  category?: "system" | "task" | "active",
  ): Promise<void>

  #### Parameters

  - content: string
  - `Optional` priority: 20 | 60 | 80 | 100 | 40
  - `Optional` category: "system" | "task" | "active"

  #### Returns Promise<void>

  Inherited from BaseAgent.addContextItem

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:320

### isContextPruningEnabled

- isContextPruningEnabled(): boolean

  #### Returns boolean

  Inherited from BaseAgent.isContextPruningEnabled

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:334

### isMemoryEnabled

- isMemoryEnabled(): boolean

  #### Returns boolean

  Inherited from BaseAgent.isMemoryEnabled

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:337

### getMemoryState

- getMemoryState(): Readonly<AgentMemoryState> | null

  #### Returns Readonly<AgentMemoryState> | null

  Inherited from BaseAgent.getMemoryState

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:340

### getRelevantMemories

- getRelevantMemories(): readonly TypedMemoryEntry<MemoryType>[]

  #### Returns readonly TypedMemoryEntry<MemoryType>[]

  Inherited from BaseAgent.getRelevantMemories

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:343

### flushMemory

- flushMemory(): Promise<Result<void, AgentMemoryError>>

  #### Returns Promise<Result<void, AgentMemoryError>>

  Inherited from BaseAgent.flushMemory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:347

### `Protected` recordLearning

- recordLearning(learning: Omit<TaskLearning, "id" | "learnedAt">): void

  #### Parameters

  - learning: Omit<TaskLearning, "id" | "learnedAt">

  #### Returns void

  Inherited from BaseAgent.recordLearning

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:360

### `Protected` recordPattern

- recordPattern(
  p: Omit<ExecutionPattern, "id" | "lastSeen" | "occurrences">,
  ): void

  #### Parameters

  - p: Omit<ExecutionPattern, "id" | "lastSeen" | "occurrences">

  #### Returns void

  Inherited from BaseAgent.recordPattern

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:363

### `Protected` recordResolution

- recordResolution(r: Omit<ErrorResolution, "resolvedAt">): void

  #### Parameters

  - r: Omit<ErrorResolution, "resolvedAt">

  #### Returns void

  Inherited from BaseAgent.recordResolution

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:366

### `Protected` findResolutionForError

- findResolutionForError(errorMessage: string): ErrorResolution | undefined

  #### Parameters

  - errorMessage: string

  #### Returns ErrorResolution | undefined

  Inherited from BaseAgent.findResolutionForError

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:369

### `Protected` getTaskLearnings

- getTaskLearnings(taskType: string): readonly TaskLearning[]

  #### Parameters

  - taskType: string

  #### Returns readonly TaskLearning[]

  Inherited from BaseAgent.getTaskLearnings

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:372

### `Protected` getTopExecutionPatterns

- getTopExecutionPatterns(limit?: number): readonly ExecutionPattern[]

  #### Parameters

  - limit: number = 10

  #### Returns readonly ExecutionPattern[]

  Inherited from BaseAgent.getTopExecutionPatterns

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:375

### setExpertAgents

- setExpertAgents(agents: Map<string, IAgent>): void

  Set expert agents for collaboration (Issue #488). Call this to provide agents that can participate in collaborative synthesis.

  #### Parameters

  - agents: Map<string, IAgent>

  #### Returns void

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:231

### `Protected` executeTask

- executeTask(task: Task): Promise<Result<TaskResult, AgentError>>

  Execute a task by analyzing, decomposing (if needed), and coordinating.

  #### Parameters

  - task: Task

  #### Returns Promise<Result<TaskResult, AgentError>>

  Overrides BaseAgent.executeTask

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:240

### `Protected` buildPrompt

- buildPrompt(task: Task): Message[]

  Build prompt messages for task execution.

  #### Parameters

  - task: Task

  #### Returns Message[]

  Overrides BaseAgent.buildPrompt

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:282

### analyzeTask

- analyzeTask(task: Task): Promise<Result<TaskAnalysis, AgentError>>

  Analyze a task to understand its complexity and requirements.

  #### Parameters

  - task: Task

  #### Returns Promise<Result<TaskAnalysis, AgentError>>

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:287

### decomposeTask

- decomposeTask(
  task: Task,
  analysis: TaskAnalysis,
  ): Promise<Result<SubTask[], AgentError>>

  Decompose a task into subtasks.

  #### Parameters

  - task: Task
  - analysis: TaskAnalysis

  #### Returns Promise<Result<SubTask[], AgentError>>

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:318

### selectExperts

- selectExperts(subtasks: SubTask[]): ExpertAssignment[]

  Select appropriate expert agents for each subtask.

  #### Parameters

  - subtasks: SubTask[]

  #### Returns ExpertAssignment[]

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:357

### synthesizeResults

- synthesizeResults(
  results: TaskResult[],
  originalTask?: Task,
  ): Promise<Result<SynthesizedResult, AgentError>>

  Synthesize results from multiple experts into a cohesive output.

  Uses collaboration protocols for complex multi-expert synthesis (Issue #488) when enough experts and task complexity warrant it.

  #### Parameters

  - results: TaskResult[]

    Results to synthesize

  - `Optional` originalTask: Task

    Optional original task for context in collaborative synthesis

  #### Returns Promise<Result<SynthesizedResult, AgentError>>

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:370

### getCollaborationHelper

- getCollaborationHelper(): OrchestratorCollaborationHelper

  Get the collaboration helper for external use.

  #### Returns OrchestratorCollaborationHelper

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:468

### getOptions

- getOptions(): Readonly<Required<OrchestratorOptions>>

  Get the Orchestrator options.

  #### Returns Readonly<Required<OrchestratorOptions>>

  - Defined in packages/nexus-agents/src/agents/tech-lead.ts:473