nexus-agents - v2.80.0
    Preparing search index...

    Class BaseAdapterAbstract

    Abstract base class for model adapters.

    Provides default implementations for common adapter functionality while leaving the core API interaction methods abstract for provider-specific implementations.

    class ClaudeAdapter extends BaseAdapter {
    constructor(config: ClaudeAdapterConfig) {
    super({
    providerId: 'anthropic',
    modelId: config.modelId,
    capabilities: [ModelCapability.COMPLETION, ModelCapability.STREAMING],
    apiKey: config.apiKey,
    });
    }

    async complete(request: CompletionRequest): Promise<Result<CompletionResponse, ModelError>> {
    this.logRequest(request);
    // Provider-specific implementation...
    }

    async *stream(request: CompletionRequest): AsyncIterable<StreamChunk> {
    this.logRequest(request);
    // Provider-specific streaming implementation...
    }
    }

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    providerId: string

    Provider identifier (e.g., 'anthropic', 'openai')

    modelId: string

    Model identifier (e.g., 'claude-sonnet-4', 'gpt-4o')

    capabilities: readonly ModelCapability[]

    Capabilities this model supports

    logger: ILogger

    Logger for request/response logging

    Configuration for the adapter

    Methods

    • Count tokens in text using the unified TokenEstimator.

      This provides a reasonable estimate for most use cases. Concrete adapters may override this with provider-specific tokenizers.

      Parameters

      • text: string

        Text to count tokens for

      Returns Promise<number>

      Approximate token count

    • Transform a provider-specific error into a standardized ModelError.

      Maps common error patterns to appropriate error codes:

      • Rate limiting (429, quota exceeded)
      • Timeouts (ETIMEDOUT, ESOCKETTIMEDOUT)
      • Authentication (401, 403)
      • Model unavailable (503, 502)

      Parameters

      • error: unknown

        The original error from the provider

      Returns ModelError

      A standardized ModelError