# Class BaseCliAdapter`Abstract`

Abstract base class for CLI adapters. Provides common functionality for version checking, health, and error handling.

#### Hierarchy (View Summary)

- BaseCliAdapter
  - SubprocessCliAdapter
  - CodexMcpAdapter

#### Implements

- ICliAdapter

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:71

##### Index

### Constructors

constructor

### Properties

name
transport
logger
capacityTracker
initialized
lastHealthCheck?
cachedVersion?

### Accessors

capabilities

### Methods

initCapacityTracker
executeTask
getModelInfo
initialize
dispose
execute
healthCheck
getVersion
getCapacity
recordUsage
parseVersion
checkVersionCompatibility
getVersionMessage
createError
normalizeResponse
delay

## Constructors

### constructor

- new BaseCliAdapter(logger?: ILogger): BaseCliAdapter

  #### Parameters

  - `Optional` logger: ILogger

  #### Returns BaseCliAdapter

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:81

## Properties

### `Abstract` `Readonly` name

name: "claude" | "gemini" | "codex" | "opencode"

CLI name

Implementation of ICliAdapter.name

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:72

### `Abstract` `Readonly` transport

transport: CliTransport

Transport type

Implementation of ICliAdapter.transport

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:73

### `Protected` `Readonly` logger

logger: ILogger

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:75

### `Protected` capacityTracker

capacityTracker: CapacityTracker | null = null

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:76

### `Protected` initialized

initialized: boolean = false

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:77

### `Protected` `Optional` lastHealthCheck

lastHealthCheck?: HealthStatus

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:78

### `Protected` `Optional` cachedVersion

cachedVersion?: string

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:79

## Accessors

### capabilities

- get capabilities(): CliCapabilityProfile

  Gets the capability profile for this CLI.

  #### Returns CliCapabilityProfile

  Implementation of ICliAdapter.capabilities

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:96

## Methods

### `Protected` initCapacityTracker

- initCapacityTracker(): void

  Initializes the capacity tracker. Called by subclasses after name is set.

  #### Returns void

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:89

### `Abstract` executeTask

- executeTask(
  task: CliTask,
  options: Required<CliExecutionOptions>,
  ): Promise<Result<CliResponse, CliError>>

  Abstract method for executing a task. Implemented by concrete adapters.

  #### Parameters

  - task: CliTask
  - options: Required<CliExecutionOptions>

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

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:104

### `Abstract` getModelInfo

- getModelInfo(): CliModelInfo

  Abstract method for getting model info. Implemented by concrete adapters.

  #### Returns CliModelInfo

  Implementation of ICliAdapter.getModelInfo

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:113

### `Abstract` initialize

- initialize(): Promise<void>

  Abstract method for initialization. Implemented by concrete adapters.

  #### Returns Promise<void>

  Implementation of ICliAdapter.initialize

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:119

### `Abstract` dispose

- dispose(): Promise<void>

  Abstract method for cleanup. Implemented by concrete adapters.

  #### Returns Promise<void>

  Implementation of ICliAdapter.dispose

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:125

### execute

- execute(
  task: CliTask,
  options?: CliExecutionOptions,
  ): Promise<Result<CliResponse, CliError>>

  Executes a task with error handling and retries.

  Timeout priority (highest to lowest):

  1. options.timeoutMs - explicit execution option
  2. task.timeoutMs - task-level setting
  3. getTimeoutForTaskAuto() - computed from task complexity and CLI

  #### Parameters

  - task: CliTask
  - `Optional` options: CliExecutionOptions

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

  Implementation of ICliAdapter.execute

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:135

### healthCheck

- healthCheck(): Promise<HealthStatus>

  Performs a health check.

  #### Returns Promise<HealthStatus>

  Implementation of ICliAdapter.healthCheck

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:200

### getVersion

- getVersion(): Promise<string>

  Gets CLI version.

  #### Returns Promise<string>

  Implementation of ICliAdapter.getVersion

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:230

### getCapacity

- getCapacity(): Promise<CapacityStatus>

  Gets current capacity status based on tracked usage. Uses usage-based tracking since CLI subprocess execution doesn't expose HTTP rate limit headers.

  #### Returns Promise<CapacityStatus>

  #### See

  Issue #456 - Real API rate limit tracking

  Implementation of ICliAdapter.getCapacity

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:256

### `Protected` recordUsage

- recordUsage(response: CliResponse): void

  Records usage from a response for capacity tracking.

  #### Parameters

  - response: CliResponse

  #### Returns void

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:281

### `Protected` parseVersion

- parseVersion(output: string): string

  Parses version from CLI output.

  #### Parameters

  - output: string

  #### Returns string

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:290

### `Protected` checkVersionCompatibility

- checkVersionCompatibility(version: string): VersionStatus

  Checks version compatibility.

  #### Parameters

  - version: string

  #### Returns VersionStatus

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:302

### `Protected` getVersionMessage

- getVersionMessage(status: VersionStatus, version: string): string | undefined

  Gets version status message.

  #### Parameters

  - status: VersionStatus
  - version: string

  #### Returns string | undefined

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:331

### `Protected` createError

- createError(code: CliErrorCode, message: string, cause?: Error): CliError

  Creates a CLI error.

  #### Parameters

  - code: CliErrorCode
  - message: string
  - `Optional` cause: Error

  #### Returns CliError

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:349

### `Protected` normalizeResponse

- normalizeResponse(
  text: string,
  usage?: CliTokenUsage,
  extra?: Partial<CliResponse>,
  ): CliResponse

  Normalizes CLI response to common format.

  #### Parameters

  - text: string
  - `Optional` usage: CliTokenUsage
  - `Optional` extra: Partial<CliResponse>

  #### Returns CliResponse

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:364

### `Protected` delay

- delay(ms: number): Promise<void>

  Delays for the specified milliseconds.

  #### Parameters

  - ms: number

  #### Returns Promise<void>

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:379