import { LanguageModelV1Middleware } from 'ai';

/**
 * Data structure for ingest requests
 */
type BillingProvider = 'stripe'

// Common billing fields without the meter/meters
type BillingFieldsBase = {
  customer: string
  email?: string
}

// Single meter option
type SingleMeterFields = BillingFieldsBase & {
  meter: string
  meters?: never
}

// Multiple meters option
type MultiMeterFields = BillingFieldsBase & {
  meter?: never
  meters: Record<string, string>
}

// Union type that allows either single meter or multiple meters
type BillingFields = SingleMeterFields | MultiMeterFields

interface TeerBillingConfig {
  provider: BillingProvider
  fields: BillingFields
}

// Base options for all Teer services
interface TeerBaseOptions {
  /** API key for authentication with Teer backend */
  apiKey: string
  baseURL?: string
  /** Enable debug logging */
  debug?: boolean
  /** Flush interval in ms (default: 5000) */
  flushInterval?: number
  /** Custom fetch implementation */
  customFetch?: typeof fetch
}

interface TeerBaseOptions {
  /** API key for authentication with Teer backend */
  apiKey: string
  baseURL?: string
  /** Enable debug logging */
  debug?: boolean
  /** Flush interval in ms (default: 5000) */
  flushInterval?: number
  /** Custom fetch implementation */
  customFetch?: typeof fetch
  /** API version to use */
  apiVersion?: string
}

// Optional middleware config
interface TeerMiddlewareConfig {
  /** Billing configuration */
  billing?: TeerBillingConfig
  /** Function identifier to track which function is generating responses */
  functionId?: string
  /** Trace ID to track the request */
  traceId?: string
  /** Span ID to track the request */
  spanId?: string
  /** Parent span ID to track the request */
  parentSpanId?: string
  /** Metadata to annotate tracking data with */
  metadata?: Record<string, any>
  /** Timestamp of the request */
  timestamp?: Date
}

declare class TeerAgentToolkit {
    private readonly client;
    private readonly debug;
    static readonly sdkVersion: string;
    static readonly otelVersion: string;
    static readonly namespace: string;
    static readonly baseURL: string;
    static readonly telemetryOriginVersion: string;
    constructor({ apiKey, baseURL, debug, flushInterval, customFetch }: TeerBaseOptions);
    private createTrackingMetadata;
    private track;
    /**
     * Create middleware for AI SDK
     */
    middleware(config?: TeerMiddlewareConfig): LanguageModelV1Middleware;
    private logDebug;
}

export { TeerAgentToolkit, type TeerBaseOptions, type TeerMiddlewareConfig };
