import { Scan } from "./scan.js"; import { type Target } from "./target.js"; import type { CreateOrGetTargetOptions, CreateScanOptions, Dataset, GeneratedObjective, Logger, LogLevel, ReconContext, SessionHandler, Topology, UpdateTargetOptions, UpdateDatasetOptions, UploadDatasetOptions } from "./types.js"; export interface LakeraRedClientOptions { apiKey: string; baseUrl: string; extraHeaders?: Record; /** * Minimum log level. Defaults to `warn` when not set. * Use `info` for phase-level progress and `debug` for worker details. */ logLevel?: LogLevel; logger?: Logger; } export declare class LakeraRedClient { private readonly baseUrl; private readonly headers; private readonly logger; constructor(options: LakeraRedClientOptions); /** * Issue a JSON request against the relay API and parse the response as `T`. * On a non-2xx status, throws ` failed: HTTP : `. * Retries transient 5xx/429 up to `maxRetries`; pass 0 for non-idempotent * calls that must not be replayed. */ private request; /** * Create a relay target by name, or return the existing one with that name, * and ensure it has a recon profile. Names are labels, not identifiers — a * repeated name resolves to the same target rather than creating a duplicate. * * - With `appContext` (or `appContextFile`): the profile is set directly and * no recon runs — `handler` is not needed. * - Without app context, when the target has no profile yet: recon runs by * relaying prompts through `handler` (relay targets have no URL to probe * directly), so `handler` is required — omitting it throws. * - Without app context, when the target already has a profile (from a prior * run or the dashboard): the existing profile is reused and no recon runs. */ createOrGetTarget(options: CreateOrGetTargetOptions, handler?: SessionHandler): Promise; /** * Fetch an existing relay target by its id. * * Read-only: unlike `createOrGetTarget`, this never creates a target or runs * recon. Use it to reuse a target created earlier (e.g. in the dashboard or * a prior run) when creating a scan. Throws if no target with that id exists * or the caller cannot access it. */ getTarget(targetId: string): Promise; /** * Update an existing target's name, recon profile, ground truth and/or * response timeout. * * `appContext` replaces the target's stored recon profile wholesale — it is * always a complete profile, matching `createOrGetTarget`. At least one field * must be provided. Returns a fresh `Target` reflecting the * updated state. Throws if the target does not exist or the caller cannot * access it. */ updateTarget(targetId: string, options: UpdateTargetOptions): Promise; /** * Re-run recon on an existing target and return the freshly-generated profile. * * Relays the recon prompts through `handler` (relay targets have no URL to * probe directly). The server persists the result by sanitizing then merging * onto the stored profile, so what it keeps can differ from this run's raw * output — a total failure is a server no-op that leaves the old profile in * place. This returns only what this run produced, or `undefined` when it * yielded nothing usable; call `getTarget` for the persisted target state. */ runRecon(targetId: string, handler: SessionHandler): Promise; private performRecon; /** * Infer the target's threat-model topology from its ground truth and assess it * against the threat-modeling catalog, replacing the stored topology. Throws if * the target has no ground truth (set it with `updateTarget`) or inference fails. */ inferTopology(targetId: string): Promise; /** * The target's stored topology, or `undefined` if none has been inferred. * Read-only: never starts inference. */ getTopology(targetId: string): Promise; /** * Generate attack objectives from the weaknesses in the target's topology and * return the ones this call produced. Pass their `key`s to `createScan`. A * weakness whose generation failed keeps its previous objective, which * `getGeneratedObjectives` still lists. Throws if the target has no topology * (call `inferTopology` first) or generation fails. */ generateObjectives(targetId: string): Promise; /** The target's generated objectives, newest first. Read-only: never generates. */ getGeneratedObjectives(targetId: string): Promise; private targetPath; private readTopology; private readGeneratedObjectives; private warnIfThreatModelStale; /** * Upload a dataset from a CSV file or a list of tests. The file uses the dataset * template's format: a header row with `conversationId` and `prompt` columns and an * optional `id` column. Throws with the first broken rows if the dataset is invalid. */ uploadDataset(options: UploadDatasetOptions): Promise; /** * The datasets this API key reaches, newest first. A key scoped to a folder lists * only that folder's datasets. */ listDatasets(): Promise; /** One dataset by id. */ getDataset(datasetId: string): Promise; /** * Rename a dataset. Scans already started keep the name they started with. Allowed * for the dataset's creator, with write access to its folder, or a folder admin. */ updateDataset(datasetId: string, options: UpdateDatasetOptions): Promise; /** * Permanently delete a dataset and its tests. Reports of past scans keep their * results. Throws while a scan using the dataset hasn't finished. Allowed for the * dataset's creator, with write access to its folder, or a folder admin. */ deleteDataset(datasetId: string): Promise; private datasetPath; createScan(options: CreateScanOptions): Promise; private createDatasetScan; } //# sourceMappingURL=client.d.ts.map