/** * Chunked dataset upload to the team dataset vault (Dataset-uploader.md §3.2 — * the `dataset_upload` tool's core). * * Loads a (cleaned) sharegpt JSONL, validates each line, groups it into * batches of `batchSize` and calls the backend MCP tool * `upload_dataset_samples` (JSON-RPC tools/call, Bearer auth) per batch, * then sums the per-batch `DatasetUploadResult` ({accepted, duplicates, * rejected}). * * Auth/URL resolution mirrors `aexol-mcp.ts`: `~/.spectral/config.json` * (`readConfig()`), token = `teamApiKey || userJwt`, URL via `getApiUrl()`, * and a single `ensureAuthenticated()` OAuth retry on 401/403. * * projectId: the Studio binding (`.aexol/aexol.jsonc`) supplies a single * batch-level projectId for ALL batches — the exporter does not persist * per-sample project provenance in the JSONL, so per-project grouping is not * possible without exporter rework (documented in the result notes). * * Testability: the backend call lives behind `callBackendTool`, overridable * per-call (`options.callBackendTool`) or via `setCallBackendToolForTesting` * (module-level), so tests can stub the network entirely. */ export declare const DEFAULT_BATCH_SIZE = 50; /** Backend MCP tool that ingests one batch of samples. */ export declare const BACKEND_UPLOAD_TOOL = "upload_dataset_samples"; /** Backend MCP tool returning vault stats (best-effort, post-upload). */ export declare const BACKEND_VAULT_STATS_TOOL = "dataset_vault_stats"; export declare const DATASET_FORMAT = "sharegpt"; /** * Backend tool call abstraction. Returns the parsed JSON payload of the * tool's first content item (the raw content items when only text was * returned). */ export type CallBackendTool = (tool: string, args: Record) => Promise; export interface UploadDatasetOptions { /** Path to the (cleaned) sharegpt JSONL file. */ inputPath: string; /** Team id; defaults to the Studio binding's teamId, then omitted (backend resolves from the token). */ teamId?: string | null; /** Samples per backend call. Default 50. */ batchSize?: number; /** When true, only parse + validate; no network call is made. */ dryRun?: boolean; /** Working directory for Studio binding lookup. Default: process.cwd(). */ cwd?: string; /** Test injection: overrides the module-level and default backend call. */ callBackendTool?: CallBackendTool; } export interface UploadBatchResult { projectId: string | null; /** Number of samples in this batch. */ sent: number; accepted: number; duplicates: number; rejected: number; } export interface UploadDatasetResult { inputPath: string; dryRun: boolean; totalLines: number; validSamples: number; invalidLines: number; batchSize: number; teamId: string | null; projectId: string | null; batches: UploadBatchResult[]; totals: { accepted: number; duplicates: number; rejected: number; }; /** Valid sample count that WOULD be uploaded (equals validSamples in dry-run). */ wouldUpload: number; /** Vault stats returned by the backend (absent on failure or dry-run). */ vaultStats?: unknown; /** * Pre-upload residue warning: pattern-only dry-run scrub (NO extraValues) * over the file contents. Present when any redactions would be made — * counts only, never values. */ residueWarning?: { totalRedactions: number; kinds: string[]; }; /** Human-readable notes (e.g. binding state, per-project grouping). */ notes: string[]; } /** * Test hook: override the backend call for the whole module. Pass null to * restore the real implementation. Prefer `options.callBackendTool` for * per-call injection; this exists so tests that drive code through other * entry points (e.g. the extension index) can stub the network too. */ export declare function setCallBackendToolForTesting(fn: CallBackendTool | null): void; /** * Upload a dataset JSONL to the team vault in chunks. * * dryRun: parse + validate only — no backend call, `wouldUpload` carries the * count, totals stay zero. */ export declare function uploadDataset(options: UploadDatasetOptions): Promise; /** Render an upload result as a markdown summary for the agent. */ export declare function renderUploadMarkdown(result: UploadDatasetResult): string; //# sourceMappingURL=upload.d.ts.map