/** * Heuristic quality/coverage analyzer for sharegpt dataset JSONL files * (Dataset-uploader.md §3.1 — the `dataset_analyze` tool's core). * * Pure read-only analysis: no files are modified. The report is a plain * object the extension renders as markdown so the agent can decide whether * the dataset is worth cleaning/uploading. * * Report contents: * - total samples + malformed line count * - length distribution (p50/p95 chars per sample, rough token est chars/4) * - per-tool coverage: how many samples use each function_call tool name, * flagged when below LOW_TOOL_COVERAGE_THRESHOLD samples * - local duplicates: canonicalized-JSON hash (sorted keys), dup count * - dry-run scrub residue: per-kind redaction counts over all samples — * this is the "residue red flag": > 0 means the dataset MUST go through * `dataset_clean` before upload * - quality flags: samples with 0 tool calls, samples with an observation * longer than LONG_OBSERVATION_CHARS */ /** Tools with fewer samples than this get flagged in the coverage table. */ export declare const LOW_TOOL_COVERAGE_THRESHOLD = 20; /** Observations longer than this are flagged as oversized. */ export declare const LONG_OBSERVATION_CHARS = 8000; /** Rough token estimate divisor (chars / 4). */ export declare const TOKEN_ESTIMATE_DIVISOR = 4; export interface ToolCoverageEntry { tool: string; /** Number of samples containing at least one function_call for this tool. */ samples: number; /** True when samples < LOW_TOOL_COVERAGE_THRESHOLD. */ low: boolean; } export interface DatasetAnalysisReport { inputPath: string; totalSamples: number; malformedLines: number; lengthDistribution: { p50Chars: number; p95Chars: number; p50EstTokens: number; p95EstTokens: number; }; /** Per-tool sample coverage, sorted by samples desc, then name. */ toolCoverage: ToolCoverageEntry[]; duplicates: { total: number; unique: number; /** total - unique (samples that are exact canonicalized duplicates). */ duplicateSamples: number; }; /** * Dry-run scrub over every sample: how many redactions the scrubber WOULD * make. Any total > 0 is the residue red flag — run dataset_clean first. */ scrubResidue: { totalRedactions: number; byKind: Record; }; qualityFlags: { /** Samples with zero function_call entries. */ zeroToolCalls: number; /** Samples containing an observation longer than LONG_OBSERVATION_CHARS. */ longObservations: number; }; } export interface LoadedJsonl { samples: unknown[]; malformedLines: number; } /** * Load a JSONL file into parsed values, skipping (and counting) malformed * lines. Non-object JSON (e.g. a bare string) counts as malformed too. */ export declare function loadJsonl(inputPath: string): LoadedJsonl; /** * Total character count of a sharegpt sample: all conversation entry values * plus the system prompt (when present). Used for length distribution, * maxSampleChars filtering, and token estimates. */ export declare function sampleChars(sample: Record): number; /** Tool names used by a sample's function_call entries (unique, in order). */ export declare function sampleToolNames(sample: Record): string[]; /** * Canonicalize a JSON value: recursively sort object keys, drop undefined, * then stringify. Deterministic for duplicate detection. */ export declare function canonicalizeJson(value: unknown): string; /** * Analyze a sharegpt dataset JSONL file. Read-only; never throws on * malformed lines (they are counted instead). Throws only when the input * file itself cannot be read. * * `options.extraValues` (same opaque values `dataset_clean` scrubs with — * secret-store + .env values) extends the dry-run scrub residue counts; * values are never printed. */ export declare function analyzeDataset(inputPath: string, options?: { extraValues?: string[]; }): DatasetAnalysisReport; /** Render an analysis report as a markdown table the agent can read. */ export declare function renderAnalysisMarkdown(report: DatasetAnalysisReport): string; //# sourceMappingURL=analyzer.d.ts.map