/**
 * Public API type declarations for @browserstack/ai-sdk
 *
 * This is the ONLY types file that TypeScript consumers see.
 * Only symbols declared here appear in IDE autocomplete.
 * Everything else is hidden from suggestions but still callable at runtime.
 *
 * @module @browserstack/ai-sdk
 */

// ---------------------------------------------------------------------------
// Enums
// ---------------------------------------------------------------------------

declare enum TraceAttribute {
  SESSION_ID = "session.id",
  USER_ID = "user.id",
  TRACE_INPUT = "AIOPS_INTERNAL.trace.input",
  TRACE_OUTPUT = "AIOPS_INTERNAL.trace.output",
  TRACE_RETRIEVED_CONTEXTS = "AIOPS_INTERNAL.trace.retrieved_contexts",
}

declare enum ExperimentRunStatus {
  PENDING = "PENDING",
  RUNNING = "RUNNING",
  COMPLETED = "COMPLETED",
  FAILED = "FAILED",
  CANCELLED = "CANCELLED",
}

declare enum EvaluatorParamDataType {
  STRING = "string",
  INTEGER = "integer",
  FLOAT = "float",
  BOOLEAN = "boolean",
  STRING_ARRAY = "string[]",
  INTEGER_ARRAY = "integer[]",
  FLOAT_ARRAY = "float[]",
  BOOLEAN_ARRAY = "boolean[]",
  OBJECT = "object",
}

declare enum ComparisonDeltaDirection {
  IMPROVEMENT = "improvement",
  REGRESSION = "regression",
  NEUTRAL = "neutral",
}

declare enum ComparisonThresholdStatus {
  PASS = "pass",
  FAIL = "fail",
  MISSING_SCORE = "missing_score",
}

declare enum ComparisonStatus {
  READY = "ready",
  PENDING = "pending",
  NO_BASELINE = "no_baseline",
}

declare enum ComparisonVerdict {
  PASS = "PASS",
  REGRESSION = "REGRESSION",
}

// ---------------------------------------------------------------------------
// Config
// ---------------------------------------------------------------------------

/**
 * Customer-supplied mask function. Receives the value of a PII-bearing field
 * (input / output / metadata on traces and spans; PII-bearing OTel attributes
 * for auto-tracing) and must return the masked replacement.
 *
 * The SDK does NOT walk or transform the value before/after calling this — the
 * customer owns recursion, regex sets, and any external PII-detection library.
 *
 * Must run synchronously. If it throws, the SDK replaces the value with
 * `"[MASKED_ERROR]"` (fail-closed) so a buggy mask cannot leak data.
 */
export type CustomScrubFn = (data: unknown) => unknown;

/**
 * Configuration for the AISDK client.
 * Provide either `publicKey` + `secretKey` for full access,
 * or `writeOnlyKey` alone for write-only (untrusted environment) access.
 */
export interface AISDKConfig {
  /** Public key for authentication. Falls back to `AISDK_PUBLIC_KEY` env var. Required unless using writeOnlyKey. */
  publicKey?: string;
  /** Secret key for authentication. Falls back to `AISDK_SECRET_KEY` env var. Required unless using writeOnlyKey. */
  secretKey?: string;
  /** Write-only key for untrusted environments. Mutually exclusive with publicKey/secretKey. */
  writeOnlyKey?: string;
  /** Enable or disable the SDK. Defaults to true. */
  enabled?: boolean;
  /** Environment tag (e.g. 'production', 'staging'). */
  environment?: string;
  /** Enable file-based debug logging. Actual file logging only activates when both this flag and the remote config flag are true. Default: false. */
  fileLog?: boolean;
  /** Prefer IPv4 in DNS and bump autoSelectFamily timeout to 2000ms; mitigates VS Code PacProxyAgent IPv4-abort. Sets process-wide Node defaults. Falls back to `AISDK_RELAX_FAMILY_SELECTION` / `TESTOPS_RELAX_FAMILY_SELECTION` (`true`, case-insensitive). Default: false. */
  relaxFamilySelection?: boolean;
  mask?: CustomScrubFn;
}

/**
 * @deprecated Use `AISDKConfig` with `AISDK` instead.
 */
export interface TestOpsConfig {
  /** Public key for authentication. Falls back to `TESTOPS_PUBLIC_KEY` env var. */
  publicKey?: string;
  /** Secret key for authentication. Falls back to `TESTOPS_SECRET_KEY` env var. */
  secretKey?: string;
  /** Write-only key for untrusted environments. Mutually exclusive with publicKey/secretKey. */
  writeOnlyKey?: string;
  /** Enable or disable the SDK. Defaults to true. */
  enabled?: boolean;
  /** Environment tag (e.g. 'production', 'staging'). */
  environment?: string;
  /** Enable file-based debug logging. Actual file logging only activates when both this flag and the remote config flag are true. Default: false. */
  fileLog?: boolean;
  /** Prefer IPv4 in DNS and bump autoSelectFamily timeout to 2000ms; mitigates VS Code PacProxyAgent IPv4-abort. Sets process-wide Node defaults. Falls back to `AISDK_RELAX_FAMILY_SELECTION` / `TESTOPS_RELAX_FAMILY_SELECTION` (`true`, case-insensitive). Default: false. */
  relaxFamilySelection?: boolean;
  mask?: CustomScrubFn;
}

// ---------------------------------------------------------------------------
// Body types
// ---------------------------------------------------------------------------

export interface TraceBody {
  id?: string | null;
  timestamp?: Date | null;
  name?: string | null;
  userId?: string | null;
  input?: any;
  output?: any;
  retrievedContexts?: any;
  sessionId?: string | null;
  release?: string | null;
  version?: string | null;
  metadata?: any;
  tags?: string[] | null;
  environment?: string | null;
  public?: boolean | null;
}

export interface SpanBody {
  endTime?: Date | null;
  id?: string | null;
  traceId?: string | null;
  name?: string | null;
  startTime?: Date | null;
  metadata?: any;
  input?: any;
  output?: any;
  level?: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
  statusMessage?: string | null;
  parentObservationId?: string | null;
  version?: string | null;
  environment?: string | null;
}

export interface EventBody {
  id?: string | null;
  traceId?: string | null;
  name?: string | null;
  startTime?: Date | null;
  metadata?: any;
  input?: any;
  output?: any;
  level?: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
  statusMessage?: string | null;
  parentObservationId?: string | null;
  version?: string | null;
  environment?: string | null;
}

export interface GenerationBody extends SpanBody {
  completionStartTime?: Date | null;
  model?: string | null;
  modelParameters?: Record<string, string | number | boolean | string[] | null> | null;
  usage?:
    | {
        input?: number | null;
        output?: number | null;
        total?: number | null;
        unit?: "CHARACTERS" | "TOKENS" | "MILLISECONDS" | "SECONDS" | "IMAGES" | "REQUESTS";
        inputCost?: number | null;
        outputCost?: number | null;
        totalCost?: number | null;
      }
    | {
        promptTokens?: number | null;
        completionTokens?: number | null;
        totalTokens?: number | null;
      };
  usageDetails?: Record<string, number> | null;
  costDetails?: Record<string, number> | null;
  promptName?: string | null;
  promptVersion?: number | null;
}

export interface ScoreBody {
  id?: string | null;
  traceId?: string | null;
  sessionId?: string | null;
  observationId?: string | null;
  datasetRunId?: string | null;
  name: string;
  environment?: string | null;
  value: string | number;
  comment?: string | null;
  metadata?: any;
  dataType?: "NUMERIC" | "BOOLEAN" | "CATEGORICAL";
  configId?: string | null;
}

// ---------------------------------------------------------------------------
// Prompt types
// ---------------------------------------------------------------------------

export interface ChatMessage {
  role: string;
  content: string;
}

export interface TextPromptClient {
  readonly name: string;
  readonly version: number;
  readonly prompt: string;
  readonly labels: string[];
  readonly tags: string[];
  readonly config: Record<string, any>;
  readonly type: "text";
  readonly isFallback: boolean;
  readonly commitMessage?: string;
  readonly promptResponse: any;
  readonly tools: ToolList;
  readonly mcpServers: PromptMcpServerRef[];
  compile(variables?: Record<string, string>): string;
  getLangchainPrompt(): string;
}

export interface ChatPromptClient {
  readonly name: string;
  readonly version: number;
  readonly prompt: ChatMessage[];
  readonly labels: string[];
  readonly tags: string[];
  readonly config: Record<string, any>;
  readonly type: "chat";
  readonly isFallback: boolean;
  readonly commitMessage?: string;
  readonly promptResponse: any;
  readonly normalizePrompt: any;
  readonly tools: ToolList;
  readonly structuredOutput?: StructuredOutputSnapshot | null;
  readonly mcpServers: PromptMcpServerRef[];
  compile(variables?: Record<string, string>): ChatMessage[];
  getLangchainPrompt(): string;
}

/**
 * Structured-output snapshot persisted per prompt version. Mirrors the
 * server-side `StructuredOutputSnapshotSchema` (webapp/packages/shared
 * /src/features/prompts/structuredOutputSnapshot.ts).
 *
 * - `text` — plain completion (no JSON enforcement).
 * - `json_object` — OpenAI `response_format: { type: "json_object" }`.
 * - `json_schema` — full JSON Schema enforcement; `strict` toggles
 *   OpenAI/Azure native strict mode (silently dropped on providers that
 *   fall back to tool-calling).
 */
export type StructuredOutputSnapshot =
  | { output_type: "text" }
  | { output_type: "json_object" }
  | {
      output_type: "json_schema";
      name: string;
      description?: string;
      schema: Record<string, any>;
      strict: boolean;
      source: "schema" | "from_data";
      data_path?: string;
      schema_id: string | null;
    };

export interface CreateTextPromptBody {
  type: "text";
  name: string;
  prompt: string;
  labels?: string[];
  config?: Record<string, any>;
  modelParams?: Record<string, any>;
  toolList?: Record<string, any>[];
  tags?: string[];
  isActive?: boolean;
  commitMessage?: string;
}

export interface CreateChatPromptBody {
  type: "chat";
  name: string;
  prompt: ChatMessage[];
  labels?: string[];
  config?: Record<string, any>;
  modelParams?: Record<string, any>;
  toolList?: Record<string, any>[];
  tags?: string[];
  isActive?: boolean;
  commitMessage?: string;
  /**
   * Optional structured-output snapshot to attach to the new prompt version.
   * Pass `null` to clear an inherited snapshot from a previous version.
   */
  structuredOutput?: StructuredOutputSnapshot | null;
}

// ---------------------------------------------------------------------------
// Wrapper interfaces (returned by AISDK methods)
// ---------------------------------------------------------------------------

export interface TraceWrapper {
  readonly id: string;
  readonly traceId: string;
  readonly customId?: string;
  update(body: Record<string, any>): TraceWrapper;
  span(body: SpanBody): SpanWrapper;
  generation(body: GenerationBody): GenerationWrapper;
  event(body: EventBody): EventWrapper;
  score(body: ScoreBody): string;
  getTraceUrl(): string;
}

export interface SpanWrapper {
  readonly id: string;
  readonly traceId: string;
  readonly parentId?: string;
  update(body: Record<string, any>): SpanWrapper;
  end(body?: Record<string, any>): SpanWrapper;
  span(body: SpanBody): SpanWrapper;
  generation(body: GenerationBody): GenerationWrapper;
  event(body: EventBody): EventWrapper;
  score(body: ScoreBody): string;
  getTraceUrl(): string;
}

export interface GenerationWrapper {
  readonly id: string;
  readonly traceId: string;
  readonly parentId?: string;
  update(body: Record<string, any>): GenerationWrapper;
  end(body?: Record<string, any>): GenerationWrapper;
  span(body: SpanBody): SpanWrapper;
  generation(body: GenerationBody): GenerationWrapper;
  event(body: EventBody): EventWrapper;
  score(body: ScoreBody): string;
  getTraceUrl(): string;
}

export interface EventWrapper {
  readonly id: string;
  readonly traceId: string;
  readonly parentId?: string;
  span(body: SpanBody): SpanWrapper;
  generation(body: GenerationBody): GenerationWrapper;
  event(body: EventBody): EventWrapper;
  score(body: ScoreBody): string;
  getTraceUrl(): string;
}

// ---------------------------------------------------------------------------
// AISDK class
// ---------------------------------------------------------------------------

export declare class AISDK {
  /** Pass keys explicitly or set `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars. */
  constructor(config?: AISDKConfig);

  // --- Core observability methods ---

  trace(body: TraceBody): TraceWrapper;
  generateTraceId(customId: string): string;
  generation(body: GenerationBody): GenerationWrapper;
  span(body: SpanBody): SpanWrapper;
  event(body: EventBody): EventWrapper;
  score(body: ScoreBody): void;

  // --- Lifecycle methods ---

  flush(): Promise<void>;
  flushAsync(): Promise<void>;
  shutdown(): Promise<void>;
  shutdownAsync(): Promise<void>;

  // --- Dataset runs ---

  readonly datasetRuns: DatasetRuns;

  // --- Datasets ---

  readonly datasets: DatasetsClient;

  // --- Evals ---

  readonly evals: EvaluationExecution;

  // --- Evaluator lists ---

  readonly evalsList: EvaluatorLists;

  // --- Evaluators ---

  readonly evaluators: Evaluators;

  // --- Experiment runs ---

  readonly experimentRuns: ExperimentRuns;

  // --- Experiments ---

  readonly experiments: Experiments;

  // --- Tools ---

  readonly tools: Tool;

  // --- MCP servers ---

  readonly mcpServers: McpServers;

  // --- Prompt namespace ---

  readonly prompt: Prompt;

  // --- Evaluate namespace ---

  readonly evaluate: Evaluate;

  // --- Static members ---

  static observe: {
    init: (config?: AISDKConfig) => Promise<void>;
  };
}

// ---------------------------------------------------------------------------
// Type aliases
// ---------------------------------------------------------------------------

/**
 * @deprecated Use `AISDK` instead. `AISDKClient` will be removed in a future major version.
 */
export declare class AISDKClient extends AISDK {}

/**
 * @deprecated Use `AISDK` instead. `TestOps` will be removed in a future major version.
 */
export declare class TestOps extends AISDK {
  /** @deprecated Use `new AISDK(AISDKConfig)` with `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars instead. */
  constructor(config?: TestOpsConfig);
}

/**
 * @deprecated Use `AISDK` instead. `TestOpsClient` will be removed in a future major version.
 */
export declare class TestOpsClient extends AISDK {
  /** @deprecated Use `new AISDK(AISDKConfig)` with `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars instead. */
  constructor(config?: TestOpsConfig);
}

/**
 * @deprecated Use `Media` instead. `TestOpsMedia` will be removed in a future major version.
 */
export declare class TestOpsMedia extends Media {}

// ---------------------------------------------------------------------------
// Observe namespace
// ---------------------------------------------------------------------------

type StringOnlyTraceAttribute = TraceAttribute.SESSION_ID | TraceAttribute.USER_ID;
type TraceAttributeValue = string | number | boolean | Record<string, unknown> | unknown[];

export type ContextHandle = {
  span: any;
  previousContext: unknown;
};

export interface ObserveMiddlewareOptions {
  allowHosts?: string[];
  denyHosts?: string[];
  injectW3C?: boolean;
  injectXTraceContext?: boolean;
}

export declare const Observe: {
  init: (config?: AISDKConfig) => Promise<void>;
  setAttribute: {
    (key: TraceAttribute, value: TraceAttributeValue): void;
    <K extends string>(key: K extends StringOnlyTraceAttribute ? never : K, value: TraceAttributeValue): void;
  };
  TraceAttribute: typeof TraceAttribute;
  getBaggage: () => string;
  setBaggage: (baggageString: string) => void;
  withTrace: <T>(name: string, baggageString: string | null, fn: () => T | Promise<T>) => T | Promise<T>;
  startContext: (name: string, baggageString?: string | null) => ContextHandle;
  endContext: (handle?: ContextHandle) => void;
  middleware: (options?: ObserveMiddlewareOptions) => (req: any, res: any, next: () => void) => void;
  propagation: {
    inject: (context: any, carrier: any, setter?: any) => void;
    extract: (context: any, carrier: any, getter?: any) => any;
    getBaggage: (context: any) => any;
  };
  context: {
    active: () => any;
    with: <T>(context: any, fn: () => T) => T;
  };
  trace: {
    getTracer: (name: string, version?: string) => any;
    getActiveSpan: () => any;
    setSpan: (context: any, span: any) => any;
    setSpanContext: (context: any, spanContext: any) => any;
  };
  defaultTextMapGetter: any;
  defaultTextMapSetter: any;
  getCurrentSpan: () => SpanHandle;
  getRootSpan: () => SpanHandle;
  getLatestObservation: () => ObservationHandle;
  updateLatestObservation: (options: UpdateObservationOptions) => void;
  updateObservation: (traceId: string, spanId: string, options: UpdateObservationOptions) => Promise<boolean>;
};

export interface ObservationHandle {
  readonly traceId: string | null;
  readonly spanId: string | null;
  update(options: UpdateObservationOptions): void;
}

export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';

export interface UsageDetails {
  promptTokens?: number;
  completionTokens?: number;
  totalTokens?: number;
  cacheReadInputTokens?: number;
  cacheCreationInputTokens?: number;
  reasoningTokens?: number;
}

export interface CostDetails {
  inputCostUsd?: number;
  outputCostUsd?: number;
  totalCostUsd?: number;
}

export interface UpdateObservationOptions {
  // Span-shaped fields
  metadata?: Record<string, unknown>;
  tags?: string[];
  input?: unknown;
  output?: unknown;
  level?: LogLevel;
  statusMessage?: string;
  version?: string;
  userId?: string;
  sessionId?: string;
  // Generation-shaped fields
  model?: string;
  usageDetails?: UsageDetails;
  costDetails?: CostDetails;
  completionStartTime?: number;
  promptName?: string;
  promptVersion?: string;
}

// SpanHandle and update() accept the same field set as UpdateObservationOptions.
export type UpdateOptions = UpdateObservationOptions;

export interface SpanHandle {
  readonly traceId: string | null;
  readonly spanId: string | null;
  readonly isRecording: boolean;
  readonly permalink: string | null;
  update(options: UpdateOptions): void;
  recordException(err: Error | string): void;
}

// ---------------------------------------------------------------------------
// Top-level function exports
// ---------------------------------------------------------------------------

export declare function wrapVercelAI<T>(aiModule: T): T;

// ---------------------------------------------------------------------------
// SSR framework helpers
// ---------------------------------------------------------------------------

/**
 * Next.js config helper. Adds the SDK's auto-instrumented packages to
 * `serverExternalPackages` so SSR bundlers don't inline them — required
 * for OpenTelemetry's require/import hooks to see the real modules at
 * runtime.
 *
 * Usage in `next.config.ts`:
 *
 *   import { withAISDKNext } from "@browserstack/ai-sdk";
 *   export default withAISDKNext({});
 */
export declare function withAISDKNext<T extends { serverExternalPackages?: string[] }>(
  userConfig?: T
): T;

/**
 * Vite plugin (SvelteKit / Astro / any Vite-based SSR). Adds the SDK's
 * auto-instrumented packages to `ssr.external` so Vite/Rollup don't inline
 * them — required for OpenTelemetry's require/import hooks to see the real
 * modules at runtime.
 *
 * Usage in `vite.config.ts`:
 *
 *   import { withAISDKVite } from "@browserstack/ai-sdk";
 *   export default defineConfig({ plugins: [withAISDKVite(), sveltekit()] });
 */
export declare function withAISDKVite(): {
  name: string;
  enforce?: "pre" | "post";
  config: (config: any) => any;
};

// ---------------------------------------------------------------------------
// Decorators, factory functions, and utilities are available at runtime
// but intentionally excluded from this type declaration file.
// They are not part of the public API surface.
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// Class declarations
// ---------------------------------------------------------------------------

export interface DatasetRuns {
  create(datasetName: string, options?: { name?: string; description?: string; metadata?: string; tag?: string }): Promise<DatasetRunResponse>;
  create(params: CreateWithPromptRequest): Promise<DatasetRunResponse>;
  /** @deprecated Use `create(params: CreateWithPromptRequest)` instead. */
  createWithPrompt(params: CreateWithPromptRequest): Promise<DatasetRunResponse>;
  createItems(datasetName: string, datasetRunId: string, items: CreateDatasetRunItemRequest[]): Promise<CreateDatasetRunItemsResponse>;
  getRunByTag(datasetName: string, tagName: string): Promise<GetDatasetRunByTagResponse>;
  getRunTags(datasetName: string, datasetRunId: string, page?: number, limit?: number): Promise<GetDatasetRunTagsResponse>;
  list(datasetName: string, page?: number, limit?: number, name?: string, type?: string): Promise<ListDatasetRunsResponse>;
  listItems(datasetName: string, datasetRunId: string, page?: number, limit?: number): Promise<ListDatasetRunItemsResponse>;
}

export interface Datasets {}

export interface DatasetsClient {
  create(name: string, description?: string, metadata?: Record<string, any>, kind?: DatasetKind): Promise<DatasetResponse>;
  createItems(params: CreateItemsRequest, options?: CreateItemsOptions): Promise<CreateDatasetItemsResponse>;
  getTags(datasetName: string): Promise<GetDatasetTagsResponse>;
  list(page?: number, limit?: number, name?: string, kind?: DatasetKind): Promise<ListDatasetsResponse>;
}

export interface RunEvaluationExperimentRequest {
  name: string;
  datasetId: string;
  evaluatorListId: string;
  description?: string;
  concurrency?: number;
  datasetVersion?: number | null;
}

export interface EvaluationDatasets {
  create(name: string, description?: string, metadata?: Record<string, any>): Promise<DatasetResponse>;
  list(page?: number, limit?: number, name?: string): Promise<ListDatasetsResponse>;
  createItems(params: CreateItemsRequest, options?: CreateItemsOptions): Promise<CreateDatasetItemsResponse>;
  runExperiment(params: RunEvaluationExperimentRequest): Promise<ExperimentResponse>;
}

export interface EvaluationDatasetsClient {
  create(name: string, description?: string, metadata?: Record<string, any>): Promise<DatasetResponse>;
  list(page?: number, limit?: number, name?: string): Promise<ListDatasetsResponse>;
  createItems(params: CreateItemsRequest, options?: CreateItemsOptions): Promise<CreateDatasetItemsResponse>;
  runExperiment(params: RunEvaluationExperimentRequest): Promise<ExperimentResponse>;
}

export declare class Evaluate {
  /** Pass keys explicitly or set `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars. */
  constructor(publicKey?: string, secretKey?: string);
  readonly dataset: {
    create(name: string, description?: string, metadata?: Record<string, any>, kind?: DatasetKind): Promise<DatasetResponse>;
    list(page?: number, limit?: number, name?: string, kind?: DatasetKind): Promise<ListDatasetsResponse>;
    getTags(datasetName: string): Promise<GetDatasetTagsResponse>;
    createItems(params: CreateItemsRequest, options?: CreateItemsOptions): Promise<CreateDatasetItemsResponse>;
  };
  readonly evaluationDataset: {
    create(name: string, description?: string, metadata?: Record<string, any>): Promise<DatasetResponse>;
    list(page?: number, limit?: number, name?: string): Promise<ListDatasetsResponse>;
    createItems(params: CreateItemsRequest, options?: CreateItemsOptions): Promise<CreateDatasetItemsResponse>;
    runExperiment(params: RunEvaluationExperimentRequest): Promise<ExperimentResponse>;
  };
  readonly datasetRun: {
    create(datasetName: string, options?: { name?: string; description?: string; metadata?: string; tag?: string }): Promise<DatasetRunResponse>;
    create(params: CreateWithPromptRequest): Promise<DatasetRunResponse>;
    /** @deprecated Use `create(params: CreateWithPromptRequest)` instead. */
    createWithPrompt(params: CreateWithPromptRequest): Promise<DatasetRunResponse>;
    list(datasetName: string, page?: number, limit?: number, name?: string, type?: string): Promise<ListDatasetRunsResponse>;
    listItems(datasetName: string, datasetRunId: string, page?: number, limit?: number): Promise<ListDatasetRunItemsResponse>;
    createItems(datasetName: string, datasetRunId: string, items: CreateDatasetRunItemRequest[]): Promise<CreateDatasetRunItemsResponse>;
    getRunByTag(datasetName: string, tagName: string): Promise<GetDatasetRunByTagResponse>;
    getRunTags(datasetName: string, datasetRunId: string, page?: number, limit?: number): Promise<GetDatasetRunTagsResponse>;
  };
  readonly evaluationExecution: {
    evaluate(requestData: EvaluationExecutionRequest): Promise<EvaluationExecutionResponse>;
  };
  readonly evaluator: {
    create(options: CreateEvaluatorOptions): Promise<EvaluatorResponseBase>;
    get(evaluatorId: string): Promise<EnrichedEvaluatorResponse>;
    list(options?: ListEvaluatorsOptions): Promise<ListEvaluatorsResponse>;
    update(evaluatorId: string, options: UpdateEvaluatorOptions): Promise<EvaluatorResponseBase>;
    listVersions(evaluatorId: string, options: ListVersionsOptions): Promise<ListVersionsResponse>;
    setLabels(evaluatorId: string, labels: string[]): Promise<SetLabelsResponse>;
  };
  readonly evaluatorList: {
    create(requestData: CreateEvaluatorListRequest): Promise<CreateEvaluatorListResponse>;
    list(limit?: number, page?: number, orderBy?: { column?: string; order?: "ASC" | "DESC" }): Promise<ListEvaluatorListsResponse>;
    get(evaluatorListId: string): Promise<EvaluatorListResponse>;
    delete(evaluatorListId: string): Promise<EvaluatorListResponse>;
  };
  readonly experiment: {
    create(requestData: CreateExperimentWithTagRequest): Promise<ExperimentResponse>;
    create(requestData: CreateExperimentWithPromptRequest): Promise<ExperimentResponse>;
    list(limit?: number, page?: number): Promise<ListExperimentsResponse>;
    find(experimentId: string): Promise<ExperimentResponse>;
    find(opts: { id?: string; name?: string }): Promise<ExperimentResponse | null>;
    delete(experimentId: string): Promise<ExperimentResponse>;
  };
  readonly experimentRun: {
    create(experimentId: string, llmColumnName?: string, concurrency?: number, runConfig?: Record<string, any>, metadata?: Record<string, any>): Promise<ExperimentRunResponse>;
    list(experimentId?: string, page?: number, limit?: number): Promise<ListExperimentRunsResponse>;
    find(experimentRunId: string): Promise<ExperimentRunResponse>;
    delete(experimentRunId: string): Promise<ExperimentRunResponse>;
    update(experimentRunId: string, updateData: UpdateExperimentRunRequest): Promise<ExperimentRunResponse>;
    subscribe(experimentRunId: string, timeout?: number, pollInterval?: number): Promise<ExperimentRunSubscriptionResult>;
    compare(experimentRunId: string): Promise<ExperimentRunComparisonResponse>;
  };
}

export interface EvaluationExecution {
  evaluate(requestData: EvaluationExecutionRequest): Promise<EvaluationExecutionResponse>;
}

export interface EvaluationExecutionError extends Error {
  readonly statusCode?: number;
  readonly response?: any;
}

export interface EvaluatorLists {
  create(requestData: CreateEvaluatorListRequest): Promise<CreateEvaluatorListResponse>;
  delete(evaluatorListId: string): Promise<EvaluatorListResponse>;
  get(evaluatorListId: string): Promise<EvaluatorListResponse>;
  list(limit?: number, page?: number, orderBy?: { column?: string; order?: "ASC" | "DESC" }): Promise<ListEvaluatorListsResponse>;
}

export interface Evaluators {
  create(options: CreateEvaluatorOptions): Promise<EvaluatorResponseBase>;
  get(evaluatorId: string): Promise<EnrichedEvaluatorResponse>;
  list(options?: ListEvaluatorsOptions): Promise<ListEvaluatorsResponse>;
  listVersions(evaluatorId: string, options: ListVersionsOptions): Promise<ListVersionsResponse>;
  setLabels(evaluatorId: string, labels: string[]): Promise<SetLabelsResponse>;
  update(evaluatorId: string, options: UpdateEvaluatorOptions): Promise<EvaluatorResponseBase>;
}

export interface ExperimentRuns {
  create(experimentId: string, llmColumnName?: string, concurrency?: number, runConfig?: Record<string, any>, metadata?: Record<string, any>): Promise<ExperimentRunResponse>;
  delete(experimentRunId: string): Promise<ExperimentRunResponse>;
  find(experimentRunId: string): Promise<ExperimentRunResponse>;
  list(experimentId?: string, page?: number, limit?: number): Promise<ListExperimentRunsResponse>;
  subscribe(experimentRunId: string, timeout?: number, pollInterval?: number): Promise<ExperimentRunSubscriptionResult>;
  update(experimentRunId: string, updateData: UpdateExperimentRunRequest): Promise<ExperimentRunResponse>;
  /**
   * Fetch a server-computed "compare this run vs its baseline" payload.
   * The backend resolves the baseline (most-recent COMPLETED run for the
   * same experiment, excluding this one) and computes per-evaluator
   * deltas, threshold pass/fail, and a pre-rendered PR-comment markdown.
   * Returns status='pending' when scores are still aggregating; retry.
   */
  compare(experimentRunId: string): Promise<ExperimentRunComparisonResponse>;
}

export interface Experiments {
  create(requestData: CreateExperimentWithTagRequest): Promise<ExperimentResponse>;
  create(requestData: CreateExperimentWithPromptRequest): Promise<ExperimentResponse>;
  delete(experimentId: string): Promise<ExperimentResponse>;
  /**
   * Find an experiment by id (legacy: throws on 404) or by name lookup
   * (returns null when no match). Pass a string for id, or an object
   * with `id` or `name`.
   */
  find(experimentId: string): Promise<ExperimentResponse>;
  find(opts: { id?: string; name?: string }): Promise<ExperimentResponse | null>;
  list(limit?: number, page?: number): Promise<ListExperimentsResponse>;
}

export type MediaContentType = "image/png" | "image/jpeg" | "image/jpg" | "image/webp" | "image/gif" | "image/svg+xml" | "image/tiff" | "image/bmp" | "audio/mpeg" | "audio/mp3" | "audio/wav" | "audio/ogg" | "audio/oga" | "audio/aac" | "audio/mp4" | "audio/flac" | "video/mp4" | "video/webm" | "text/plain" | "text/html" | "text/css" | "text/csv" | "application/pdf" | "application/msword" | "application/vnd.ms-excel" | "application/zip" | "application/json" | "application/xml" | "application/octet-stream";

export declare class Media {
  constructor(options?: { contentType?: MediaContentType; base64DataUri?: string; contentBytes?: Buffer | Uint8Array; filePath?: string; unsignedUrl?: string; data?: Buffer | Uint8Array; url?: string });
  readonly contentLength?: number;
  readonly contentSha256Hash?: string;
  readonly obj?: object;
  readonly unsignedUrl?: string;
  toJSON(): string;
  static parseReferenceString(referenceString: string): { mediaId: string; source: string; contentType: string };
}

export declare class Prompt {
  /** Pass keys explicitly or set `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars. */
  constructor(publicKey?: string, secretKey?: string);
  create(body: ExtendedCreateChatPromptBodyWithPlaceholders): Promise<ChatPromptClient>;
  create(body: ExtendedCreateTextPromptBody): Promise<TextPromptClient>;
  create(body: ExtendedCreateChatPromptBody): Promise<ChatPromptClient>;
  create(body: ExtendedCreateChatPromptBodyMultimodal): Promise<PromptClient>;
  get(name: string, version?: number, options?: { label?: string; cacheTtlSeconds?: number; fallback?: string; maxRetries?: number; type?: "text"; fetchTimeoutMs?: number }): Promise<TextPromptClient>;
  get(name: string, version?: number, options?: { label?: string; cacheTtlSeconds?: number; fallback?: ChatMessage[]; maxRetries?: number; type: "chat"; fetchTimeoutMs?: number }): Promise<ChatPromptClient>;
  update(body: { name: string; version: number; newLabels: string[] }): Promise<any>;
}

export interface ProviderToolResult {
  compile(options?: ToolCompileOptions): CompiledTool;
  toData(): Record<string, unknown>;
}

export declare class Tool {
  /** Pass keys explicitly or set `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars. */
  constructor(publicKey?: string, secretKey?: string);
  readonly baseUrl: any;
  readonly publicKey: any;
  readonly secretKey: any;
  create(options: CreateToolOptions): Promise<ToolInstance>;
  get(name: string, provider?: string, options?: { version?: number; label?: string; cacheTtlSeconds?: number }): Promise<ProviderToolResult>;
  list(limit?: number, cursor?: string, label?: string): Promise<ListToolsResponse>;
  update(options: UpdateToolOptions): Promise<ToolInstance>;
}

export interface ToolInstance {
  readonly id: string;
  readonly name: string;
  readonly description?: string;
  readonly parameters: ToolParameters;
  readonly version: number;
  readonly labels: string[];
  readonly commitMessage?: string;
  readonly createdAt: string;
  readonly updatedAt: string;
  readonly isRunnable?: boolean;
  readonly sampleOutput?: Record<string, unknown> | null;
  compile(options?: ToolCompileOptions): CompiledTool;
  toData(): LlmTool;
  toString(): string;
}

export interface ToolList {
  readonly length: number;
  compile(options?: ToolCompileOptions): CompiledTool[];
}

// ---------------------------------------------------------------------------
// MCP Server Registry
// ---------------------------------------------------------------------------

export type McpAuthConfigInput =
  | { kind: 'none' }
  | { kind: 'bearer'; token: string }
  | { kind: 'header'; headers: Array<{ name: string; value: string }> }
  | { kind: 'query_param'; paramName: string; value: string }
  | { kind: 'oauth' };

export type McpServerStatus = 'ACTIVE' | 'NEEDS_REAUTH' | 'BROKEN';

export type McpAuthType =
  | 'NONE'
  | 'BEARER'
  | 'HEADER'
  | 'QUERY_PARAM'
  | 'OAUTH';

export interface McpServer {
  id: string;
  name: string;
  url: string;
  authType: McpAuthType;
  status: McpServerStatus;
  createdAt: string;
  updatedAt: string;
  authConfigRedacted?: unknown;
  oauthIdentity?: {
    authenticatedBy: string | null;
    authenticatedAt: string | null;
  } | null;
  lastHealthCheckAt?: string | null;
  lastHealthError?: string | null;
}

export interface CreateMcpServerOptions {
  name: string;
  url: string;
  authConfig: McpAuthConfigInput;
}

export interface UpdateMcpServerOptions {
  id: string;
  name?: string;
  url?: string;
  authConfig?: McpAuthConfigInput;
}

export interface ListMcpServersResponse {
  data: McpServer[];
}

export type McpServerAttachmentInput =
  | { serverName: string; serverId?: string; disabledTools?: string[] }
  | { serverId: string; serverName?: string; disabledTools?: string[] };

export interface PromptMcpServerRef {
  serverId: string;
  serverName: string;
  url: string;
  disabledTools: string[];
}

export declare class McpServers {
  /** Pass keys explicitly or set `AISDK_PUBLIC_KEY` / `AISDK_SECRET_KEY` env vars. */
  constructor(publicKey?: string, secretKey?: string);
  list(): Promise<ListMcpServersResponse>;
  get(options: { id: string } | { name: string }): Promise<McpServer>;
  create(options: CreateMcpServerOptions): Promise<McpServer>;
  update(options: UpdateMcpServerOptions): Promise<McpServer>;
  delete(options: { id: string }): Promise<void>;
  revokeOAuth(options: { id: string }): Promise<McpServer>;
}

// ---------------------------------------------------------------------------
// SDK Types & Interfaces
// ---------------------------------------------------------------------------

export interface CreateCodeEvaluatorOptions {
  name: string;
  code: string;
  language?: string;
  [key: string]: any;
}

export interface CreateDatasetRunItemRequest {
  id?: string;
  input?: any;
  output?: any;
  expectedOutput?: any;
  metadata?: any;
  sourceTraceId?: string;
  sourceObservationId?: string;
  status?: string;
  traceId?: string;
  observationId?: string;
}

export interface CreateDatasetRunItemsResponse {
  success: boolean;
  itemCount: number;
}

export interface CreateEvaluatorListRequest {
  name: string;
  evaluators: any[];
  [key: string]: any;
}

export interface CreateEvaluatorListResponse {
  id: string;
  [key: string]: any;
}

export interface CreateExperimentRunRequest {
  experimentId: string;
  [key: string]: any;
}

export interface CreateExperimentWithPromptRequest {
  name: string;
  description?: string;
  promptId?: string;
  apiRecordId?: string;
  datasetId: string;
  datasetVersion?: number | null;
  evaluatorListId: string;
  concurrency?: number;
}

export interface CreateExperimentWithTagRequest {
  name: string;
  description?: string;
  datasetRunTagId: string;
  evaluatorListId: string;
  concurrency?: number;
}

export interface CreateLLMCustomEvaluatorOptions {
  name: string;
  prompt: string;
  model?: string;
  /**
   * AIOPS-1881: per-evaluator opt-in to strict variable validation.
   * Default `false` (lenient — empty-string substitution on missing
   * `{{var}}` references). Only meaningful for `llm_custom`.
   */
  strictVariables?: boolean;
  [key: string]: any;
}

export interface CreateToolOptions {
  name: string;
  description: string;
  parameters?: ToolParameters;
  strict?: boolean;
  sampleOutput?: Record<string, unknown> | null;
  isRunnable?: boolean;
  labels?: string[];
  commitMessage?: string | null;
}

export interface DatasetRunItemResponse {
  id: string;
  datasetRunId: string;
  datasetItemId: string;
  traceId: string;
  observationId?: string;
  [key: string]: any;
}

export interface DatasetRunResponse {
  id: string;
  name: string;
  datasetId: string;
  datasetName: string;
  [key: string]: any;
}

export interface EnrichedEvaluatorResponse {
  id: string;
  name: string;
  /**
   * AIOPS-1881: current strict-variables setting for USER_PROMPT
   * evaluators. Absent on partner / code / built-in templates.
   */
  strictVariables?: boolean;
  [key: string]: any;
}

export interface EvaluationExecutionRequest {
  evaluators: Array<{
    metricName: string;
    displayName?: string;
    family?: string;
    runtimeProvider?: string;
    internalName?: string;
    params?: Record<string, any>;
  }>;
  provider?: string;
  model?: string;
  data: {
    input?: string;
    output?: string;
    context?: string[];
    expectedOutput?: string;
    retrievedContexts?: string[];
    referenceContexts?: string[];
    rubrics?: Record<string, any>;
  };
  concurrency?: number;
}

export interface EvaluationExecutionResponse {
  success: boolean;
  results: Array<{
    evaluator: string;
    success: boolean;
    score: number | null;
    reasoning: string | null;
    error: string | null;
    metadata?: Record<string, any>;
  }>;
  jobId: string;
  timestamp: string;
  error?: string;
}

export interface EvaluatorConfigResponse {
  id: string;
  [key: string]: any;
}

export interface EvaluatorListResponse {
  id: string;
  name: string;
  evaluators: any[];
  [key: string]: any;
}

export interface EvaluatorModelParams {
  provider: string;
  model: string;
  [key: string]: any;
}

export interface EvaluatorParamResponse {
  name: string;
  dataType: string;
  [key: string]: any;
}

export interface EvaluatorResponseBase {
  id: string;
  name: string;
  /**
   * AIOPS-1881: current strict-variables setting for USER_PROMPT
   * evaluators. Absent on partner / code / built-in templates.
   */
  strictVariables?: boolean;
  [key: string]: any;
}

export interface EvaluatorSummary {
  id: string;
  name: string;
  [key: string]: any;
}

export interface EvaluatorThreshold {
  metric: string;
  value: number;
  [key: string]: any;
}

export interface ExperimentResponse {
  id: string;
  name: string;
  [key: string]: any;
}

export interface ExperimentRunResponse {
  id: string;
  experimentId: string;
  status: ExperimentRunStatus;
  /**
   * Canonical TestAI UI URL for this run. Provided by the backend so
   * clients don't have to construct it from projectId/experimentId/runId
   * (route changes won't break consumers). May be null when the backend
   * can't determine its public web URL.
   */
  uiUrl?: string | null;
  [key: string]: any;
}

export interface ExperimentRunComparisonEvaluator {
  name: string;
  currentScore: number | null;
  baselineScore: number | null;
  delta: number | null;
  deltaDirection: ComparisonDeltaDirection | null;
  threshold: { value: number; criteria: string } | null;
  thresholdStatus: ComparisonThresholdStatus | null;
}

export interface ExperimentRunComparisonResponse {
  status: ComparisonStatus;
  markdown?: string;
  current: {
    runId: string;
    runUiUrl: string | null;
    rowCount: number;
  };
  baseline: {
    runId: string;
    runUiUrl: string | null;
    rowCount: number;
  } | null;
  evaluators: ExperimentRunComparisonEvaluator[];
  summary: {
    verdict: ComparisonVerdict;
    failureCount: number;
    improvedCount: number;
    regressedCount: number;
  };
}

export interface ExperimentRunSubscriptionResult {
  finalStatus: 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'TIMEOUT';
  experimentRunData: ExperimentRunResponse;
}

export interface GetDatasetRunByTagResponse extends DatasetRunResponse {}

export interface GetDatasetRunTagsResponse {
  data: Array<Record<string, any>>;
  meta: Record<string, any>;
}

export interface GetDatasetTagsResponse {
  tags: string[];
  [key: string]: any;
}

export interface ListDatasetRunItemsResponse {
  data: any[];
  meta: { page: number; limit: number; totalItems: number; totalPages: number };
}

export interface ListDatasetRunsResponse {
  data: any[];
  meta: { page: number; limit: number; totalItems: number; totalPages: number };
}

export interface ListEvaluatorListsQuery {
  limit?: number;
  page?: number;
  orderBy?: { column?: string; order?: "ASC" | "DESC" };
}

export interface ListEvaluatorListsResponse {
  evaluators: EvaluatorListResponse[];
  totalCount: number;
}

export interface ListEvaluatorsOptions {
  page?: number;
  limit?: number;
  [key: string]: any;
}

export interface ListEvaluatorsResponse {
  evaluators: EnrichedEvaluatorResponse[];
  totalCount: number;
}

export interface ListExperimentRunsResponse {
  experimentRuns: ExperimentRunResponse[];
  totalCount: number;
}

export interface ListExperimentsResponse {
  experiments: ExperimentResponse[];
  totalCount: number;
}

export interface ListToolsResponse {
  data: LlmTool[];
  meta: {
    nextCursor: string | null;
    totalCount: number;
  };
}

export interface ListVersionsOptions {
  page?: number;
  limit?: number;
  [key: string]: any;
}

export interface ListVersionsResponse {
  versions: EnrichedEvaluatorResponse[];
  nextCursor?: string;
}

export interface LlmTool {
  name: string;
  description?: string;
  parameters?: Record<string, any>;
  [key: string]: any;
}

export interface LlmToolInput {
  name: string;
  [key: string]: any;
}

export interface ModelParams {
  provider: string;
  model: string;
  adapter: "anthropic" | "openai" | "atla" | "azure" | "bedrock" | "google-vertex-ai" | "google-ai-studio";
  temperature?: number;
  max_tokens?: number;
  max_completion_tokens?: number;
  top_p?: number;
  top_k?: number;
  stop_sequences?: string[];
  tool_choice?: "auto" | "none" | "required";
  reasoning_enabled?: boolean;
  use_cache?: boolean;
  frequency_penalty?: number;
  presence_penalty?: number;
}

export interface SetLabelsResponse {
  [key: string]: any;
}

// ChatPromptClient and TextPromptClient already include tools

export interface SDKMetadata {
  resourceAttributes: {
    'telemetry.sdk.version': string;
    'telemetry.sdk.name': string;
  };
}

export interface ToolCompileOptions {
  strings?: Record<string, string | number | boolean>;
  objects?: Record<string, unknown>;
}

export interface UpdateEvaluatorOptions {
  name?: string;
  /**
   * AIOPS-1881: toggle strict variable validation on the evaluator
   * template. Omit to leave unchanged; pass `true`/`false` to set.
   * Server ignores the flag for non-USER_PROMPT evaluators.
   */
  strictVariables?: boolean;
  [key: string]: any;
}

export interface UpdateExperimentRunRequest {
  [key: string]: any;
}

export interface UpdateToolOptions {
  name: string;
  [key: string]: any;
}

// ---------------------------------------------------------------------------
// Dataset types
// ---------------------------------------------------------------------------

export type DatasetKind = "REGULAR" | "EVALUATION";

export interface DatasetResponse {
  id: string;
  name: string;
  kind?: DatasetKind;
  [key: string]: any;
}

export interface ListDatasetsResponse {
  data: any[];
  meta: { page: number; limit: number; totalItems: number; totalPages: number };
}

export interface CreateItemsRequest {
  datasetName: string;
  items: any[];
  [key: string]: any;
}

export interface CreateItemsOptions {
  [key: string]: any;
}

export interface CreateDatasetItemsResponse {
  items: any[];
  [key: string]: any;
}

export interface CreateEvaluatorOptions {
  name: string;
  [key: string]: any;
}

export interface ArchiveEvaluatorResponse {
  [key: string]: any;
}

export interface CreateWithPromptRequest {
  name: string;
  promptName: string;
  promptVersion?: string;
  description?: string;
  metadata?: Record<string, any>;
}

// ---------------------------------------------------------------------------
// Decorator config type
// ---------------------------------------------------------------------------

export interface DecoratorConfig {
  name?: string;
  [key: string]: any;
}

// ---------------------------------------------------------------------------
// Compiled tool type
// ---------------------------------------------------------------------------

export interface CompiledTool {
  [key: string]: any;
}

// ---------------------------------------------------------------------------
// Tool parameter type
// ---------------------------------------------------------------------------

export interface ToolParameters {
  [key: string]: any;
}

// Content part types

export interface TextContentPart {
  type: 'text';
  text: string;
}

export interface ImageContentPart {
  type: 'input_image';
  image_url: string | { url: string };
}

export interface DocumentContentPart {
  type: 'document';
  source: { type: 'url'; url: string };
}

export type MessageContentPart = TextContentPart | ImageContentPart | DocumentContentPart;

// Message types

export interface SimpleChatMessage {
  role: string;
  content: string;
  cache_control?: { type: "ephemeral"; ttl?: "5m" | "1h" };
}

export interface UserMessage {
  type: 'user';
  role: 'user';
  content: string | MessageContentPart[];
  cache_control?: { type: "ephemeral"; ttl?: "5m" | "1h" };
}

export interface PlaceholderMessage {
  type: 'placeholder';
  name: string;
}

export type PromptMessage = SimpleChatMessage | UserMessage | PlaceholderMessage;

// Extended prompt body types

export interface ExtendedCreateTextPromptBody extends CreateTextPromptBody {
  modelParams?: ModelParams;
  toolList?: ToolRef[];
  mcpServers?: McpServerAttachmentInput[];
}

export interface ExtendedCreateChatPromptBody extends CreateChatPromptBody {
  modelParams?: ModelParams;
  toolList?: ToolRef[];
  mcpServers?: McpServerAttachmentInput[];
}

export interface ExtendedCreateChatPromptBodyWithPlaceholders {
  type: 'chat';
  name: string;
  prompt: (ChatMessage | PlaceholderMessage)[];
  labels?: string[];
  config?: Record<string, any>;
  modelParams?: ModelParams;
  toolList?: ToolRef[];
  mcpServers?: McpServerAttachmentInput[];
  tags?: string[];
  isActive?: boolean;
  commitMessage?: string;
  structuredOutput?: StructuredOutputSnapshot | null;
}

export interface ExtendedCreateChatPromptBodyMultimodal {
  type: 'chat';
  name: string;
  prompt: PromptMessage[];
  labels?: string[];
  config?: Record<string, any>;
  modelParams?: ModelParams;
  toolList?: ToolRef[];
  mcpServers?: McpServerAttachmentInput[];
  tags?: string[];
  isActive?: boolean;
  commitMessage?: string;
  structuredOutput?: StructuredOutputSnapshot | null;
}

export type ExtendedCreatePromptBody =
  | ExtendedCreateTextPromptBody
  | ExtendedCreateChatPromptBodyMultimodal
  | ExtendedCreateChatPromptBodyWithPlaceholders
  | ExtendedCreateChatPromptBody;

export type CreateChatPromptBodyWithPlaceholders = ExtendedCreateChatPromptBodyWithPlaceholders;

// Generation body

export interface ExtendedGenerationBody extends GenerationBody {
  [key: string]: any;
}

// Agent/config types

export interface AISDKAgent {
  httpAgent?: any;
  httpsAgent?: any;
}

export interface AISDKPublicConfig {
  writeOnlyKey: string;
  [key: string]: any;
}

// Prompt client types

export type PromptClient = TextPromptClient | ChatPromptClient;
export type AISDKParent = any;
export type PromptRecord = any;

// Usage types

export interface ExtendedUsage {
  input?: number | null;
  output?: number | null;
  total?: number | null;
  unit?: "CHARACTERS" | "TOKENS" | "MILLISECONDS" | "SECONDS" | "IMAGES" | "REQUESTS";
  inputCost?: number | null;
  outputCost?: number | null;
  totalCost?: number | null;
  promptTokens?: number | null;
  completionTokens?: number | null;
  totalTokens?: number | null;
  serviceTier?: string;
}

export interface ExtendedUsageDetails {
  [key: string]: number;
}

// Tool ref

export interface ToolRef {
  name: string;
  version?: number;
  label?: string;
  [key: string]: any;
}

// Evaluator enums/types

export type EvaluatorType = "llm_custom" | "code";
export type EvaluatorScope = "GLOBAL" | "PROJECT";
export type CodeLanguage = "javascript" | "python";
export type ThresholdSelection = "greater_than" | "smaller_than";

export interface ScoreRangePrompt {
  [key: string]: any;
}

// Response types

export interface CreateEvaluatorResponse extends EvaluatorResponseBase {}
export interface UpdateEvaluatorResponse extends EvaluatorResponseBase {}
