Files
proffesor-for-testing__agen…/docs/implementation/specs/SPEC-043-A-llm-provider-adapters.md
Profa 2253d05618 feat: flatten project structure — archive v2, promote v3 to root
Remove the nested v3/ subdirectory by moving all active source code,
tests, configs, and assets directly to the project root. Archive v2/
(dead code, 847MB) to v2-archive.tar.gz.

Key changes:
- Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/
- Move v3/tsconfig.json, v3/vitest.config.ts to root
- Merge v3/package.json into root package.json (ESM, scripts, deps, exports)
- Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/
- Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes
- Fix all init installer path resolution (3-level-up → 2-level-up)
- Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe"
- Update settings.json ADR/DDD directories to docs/implementation/
- Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks)
- Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces
- Update 15 guidance shards: v3/src/ → src/ path references
- Fix sync interfaces: remove v3/ and v2/ path references
- Fix test path calculations (process.cwd() + '..' no longer needed)
- Fix flaky perf test threshold (500ms → 1000ms for CI environments)
- Fix complexity-analyzer test to match ADR-051 keyword-based eligibility

Build passes, 17,901 tests pass, CLI and MCP bundles verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:35:41 +00:00

3.7 KiB

SPEC-043-A: LLM Provider Adapters

Field Value
Specification ID SPEC-043-A
Parent ADR ADR-043
Version 1.0
Status Implemented
Last Updated 2026-01-15
Author Architecture Team

Overview

This specification defines the provider adapter implementations for the HybridRouter system, covering all 7 supported LLM providers with their configuration interfaces and capability flags.


Provider Implementations

Provider Interface Extension

interface LLMProvider {
  // Existing (ADR-011)
  generate(params: GenerateParams): Promise<LLMResponse>;
  embed(texts: string[]): Promise<number[][]>;
  healthCheck(): Promise<boolean>;

  // New capability flags
  supportsStreaming: boolean;
  supportsTools: boolean;
  supportsMCP: boolean;

  // Capability validation
  validateCapabilities(features: string[]): boolean;
}

Supported Providers

Provider SDK Key Features
Anthropic Claude @anthropic-ai/sdk Native, MCP support
OpenAI openai GPT-4, tools
Ollama axios Local inference
OpenRouter axios 100+ models, unified API
Gemini @google/genai Gemini Pro/Ultra/Flash
Azure OpenAI @azure/openai Enterprise, Azure AD
AWS Bedrock @aws-sdk/client-bedrock IAM, Claude on AWS

Provider Configuration Interfaces

// OpenRouter configuration
interface OpenRouterConfig {
  apiKey: string;
  baseUrl?: string;  // default: https://openrouter.ai/api/v1
  defaultModel?: string;
  siteUrl?: string;  // For rankings
  siteName?: string;
}

// Gemini configuration
interface GeminiConfig {
  apiKey: string;
  projectId?: string;
  location?: string;  // default: us-central1
  defaultModel?: string;  // default: gemini-pro
}

// Azure OpenAI configuration
interface AzureOpenAIConfig {
  endpoint: string;  // e.g., https://myinstance.openai.azure.com
  apiKey?: string;
  useAzureAD?: boolean;
  deploymentName: string;
  apiVersion?: string;  // default: 2024-02-01
}

// AWS Bedrock configuration
interface BedrockConfig {
  region: string;
  accessKeyId?: string;
  secretAccessKey?: string;
  sessionToken?: string;
  useIAMRole?: boolean;  // For EC2/Lambda
  defaultModel?: string;  // default: anthropic.claude-3-sonnet-20240229-v1:0
}

// ONNX Local configuration
interface ONNXConfig {
  modelPath: string;
  executionProvider?: 'cpu' | 'cuda' | 'coreml';
  numThreads?: number;
  quantized?: boolean;
}

Implementation Files

File LOC Description
src/shared/llm/providers/openrouter.ts 200 OpenRouter adapter
src/shared/llm/providers/gemini.ts 180 Google Gemini adapter
src/shared/llm/providers/azure-openai.ts 220 Azure OpenAI adapter
src/shared/llm/providers/bedrock.ts 350 AWS Bedrock with SigV4 signing
src/shared/llm/interfaces.ts - All config interfaces

Validation Rules

Rule ID Description Severity
SPEC-043-A-001 Provider config must include required auth fields Error
SPEC-043-A-002 Capability validation must return boolean Error
SPEC-043-A-003 All providers must implement healthCheck() Error

Changelog

Version Date Author Changes
1.0 2026-01-15 Architecture Team Initial specification

References