perf-lens
Version:
AI-powered frontend performance optimizer
44 lines • 1.84 kB
TypeScript
import Anthropic from '@anthropic-ai/sdk';
import { type Finding } from './schema.js';
import type { AIModelConfig } from '../types/config.js';
/** Single source of truth for the default model. Override via config `ai.model`. */
export declare const DEFAULT_MODEL = "claude-opus-4-8";
export declare function thinkingFor(model: string): {
thinking: Anthropic.ThinkingConfigParam;
} | undefined;
export interface GenerationOptions {
systemPrompt?: string;
onChunk?: (chunk: string, firstChunk?: boolean) => void;
}
export interface AnalyzeOptions {
systemPrompt?: string;
/** Stable context shared across calls (e.g. Lighthouse results) — placed in the
* system prefix with cache_control so repeated batch calls hit the prompt cache. */
sharedContext?: string;
}
/**
* Thin wrapper around the Anthropic SDK. Structured outputs for code analysis,
* streaming text for prose, prompt caching on the stable system prefix, and
* usage accounting on every call. Retries are the SDK's built-in backoff.
*/
export declare class AIClient {
private client;
private config;
constructor(config: AIModelConfig & {
apiKey: string;
});
getConfig(): AIModelConfig;
private systemBlocks;
/**
* Analyzes code and returns schema-validated findings — no freeform text parsing.
*/
analyzeCode(prompt: string, options?: AnalyzeOptions): Promise<Finding[]>;
/**
* Streams a prose response (used for the Lighthouse report analysis).
* Keeps the pre-revamp `generateSuggestions` surface so call sites stay small.
*/
generateSuggestions(prompt: string, options?: GenerationOptions): Promise<string>;
/** Raw SDK client — used by the agent loop, which drives its own tool-use turns. */
get anthropic(): Anthropic;
}
//# sourceMappingURL=client.d.ts.map