# Class CompositeRouter

CompositeRouter implementation.

#### Implements

- ICompositeRouter

- Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:138

##### Index

### Constructors

constructor

### Methods

route
executeTask
getAvailableModelsCache
recordOutcome
recordPreference
recordDifficultyOutcome
hasMinimumPreferenceData
getZeroRouter
getLatencyTracker
getMetricsCollector
getOrchestrationObserver
getCapacityDashboard
getStats
getRoutingMemory

## Constructors

### constructor

- new CompositeRouter(
  adapters: Map<"claude" | "gemini" | "codex" | "opencode", ICliAdapter>,
  config?: Partial<CompositeRouterConfigWithPreference>,
  logger?: ILogger,
  ): CompositeRouter

  #### Parameters

  - adapters: Map<"claude" | "gemini" | "codex" | "opencode", ICliAdapter>
  - `Optional` config: Partial<CompositeRouterConfigWithPreference>
  - `Optional` logger: ILogger

  #### Returns CompositeRouter

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:201

## Methods

### route

- route(
  task: CliTask,
  ): Promise<Result<CompositeRoutingDecision, CompositeRoutingError>>

  #### Parameters

  - task: CliTask

  #### Returns Promise<Result<CompositeRoutingDecision, CompositeRoutingError>>

  Implementation of ICompositeRouter.route

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:410

### executeTask

- executeTask(
  task: CliTask,
  ): Promise<Result<CliResponse, CliError | CompositeRoutingError>>

  Unified method that routes, executes, and auto-records feedback. Use this for most cases; use route() when you need decision details without execution.

  #### Parameters

  - task: CliTask

    Task to execute

  #### Returns Promise<Result<CliResponse, CliError | CompositeRoutingError>>

  Result with CLI response or error

  Implementation of ICompositeRouter.executeTask

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:462

### getAvailableModelsCache

- getAvailableModelsCache(): AvailableModelsCache | undefined

  (#2540 PR 7) Public accessor for the wired cache (or undefined).

  #### Returns AvailableModelsCache | undefined

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:634

### recordOutcome

- recordOutcome(
  cliName: "claude" | "gemini" | "codex" | "opencode",
  task: CliTask,
  reward: number,
  ): void

  #### Parameters

  - cliName: "claude" | "gemini" | "codex" | "opencode"
  - task: CliTask
  - reward: number

  #### Returns void

  Implementation of ICompositeRouter.recordOutcome

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:756

### recordPreference

- recordPreference(
  query: string,
  strongModelPreferred: boolean,
  quality?: { strong?: number; weak?: number },
  ): void

  #### Parameters

  - query: string
  - strongModelPreferred: boolean
  - `Optional` quality: { strong?: number; weak?: number }

  #### Returns void

  Implementation of ICompositeRouter.recordPreference

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:760

### recordDifficultyOutcome

- recordDifficultyOutcome(
  task: CliTask,
  success: boolean,
  qualityScore?: number,
  ): void

  #### Parameters

  - task: CliTask
  - success: boolean
  - `Optional` qualityScore: number

  #### Returns void

  Implementation of ICompositeRouter.recordDifficultyOutcome

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:768

### hasMinimumPreferenceData

- hasMinimumPreferenceData(): boolean

  #### Returns boolean

  Implementation of ICompositeRouter.hasMinimumPreferenceData

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:772

### getZeroRouter

- getZeroRouter(): IZeroRouter | undefined

  #### Returns IZeroRouter | undefined

  Implementation of ICompositeRouter.getZeroRouter

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:787

### getLatencyTracker

- getLatencyTracker(): ILatencyTracker | undefined

  #### Returns ILatencyTracker | undefined

  Implementation of ICompositeRouter.getLatencyTracker

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:791

### getMetricsCollector

- getMetricsCollector(): IRoutingMetricsCollector | undefined

  Get the metrics collector (if configured). (Source: Issue #559 - Wire RoutingMetricsCollector to CompositeRouter)

  #### Returns IRoutingMetricsCollector | undefined

  Implementation of ICompositeRouter.getMetricsCollector

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:799

### getOrchestrationObserver

- getOrchestrationObserver(): IOrchestrationObserver | undefined

  Get the orchestration observer (if configured). (Source: Issue #587 - Wire OrchestrationObserver to CompositeRouter)

  #### Returns IOrchestrationObserver | undefined

  Implementation of ICompositeRouter.getOrchestrationObserver

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:807

### getCapacityDashboard

- getCapacityDashboard(): Promise<
  Map<"claude" | "gemini" | "codex" | "opencode", CapacityStatus>,
  >

  Get capacity status for all registered CLIs (Issue #807).

  #### Returns Promise<Map<"claude" | "gemini" | "codex" | "opencode", CapacityStatus>>

  Implementation of ICompositeRouter.getCapacityDashboard

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:814

### getStats

- getStats(): CompositeRouterStats

  #### Returns CompositeRouterStats

  Implementation of ICompositeRouter.getStats

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:818

### getRoutingMemory

- getRoutingMemory(): IRoutingMemory | undefined

  Get the routing memory instance (if enabled).

  #### Returns IRoutingMemory | undefined

  Implementation of ICompositeRouter.getRoutingMemory

  - Defined in packages/nexus-agents/src/cli-adapters/composite-router.ts:844