export type LanguageCode = "ar" | "bn" | "zh-Hans" | "zh-Hant" | "cs" | "da" | "nl" | "en" | "fi" | "fr" | "de" | "el" | "he" | "hi" | "hu" | "id" | "it" | "ja" | "ko" | "ms" | "no" | "pl" | "pt" | "ro" | "ru" | "es" | "sv" | "th" | "tr" | "uk" | "vi"; export type LogLevel = "debug" | "info" | "warn" | "error" | "silent"; export interface Logger { debug(message: string, fields?: Record): void; info(message: string, fields?: Record): void; warn(message: string, fields?: Record): void; error(message: string, fields?: Record): void; } export interface SessionMessage { attack: string; /** * Aborts when the server stops waiting for the reply because its deadline * passed. Pass it to the calls that produce the reply so they stop too. A * reply sent after it aborts is dropped. */ signal: AbortSignal; respond: (reply: string) => Promise; } export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue; }; export interface Session extends AsyncIterable { readonly relaySessionId: string; /** @deprecated Use relaySessionId. */ readonly id: string; readonly sessionId: string | undefined; setSessionId(sessionId: string): void; } export type SessionHandler = (session: Session) => Promise; /** * LLM-judge evaluation of the attacks against one objective. Every field is * optional: errored or pre-scoring entries carry a partial or absent * evaluation, so gating logic must fail closed on missing scores. */ export interface Evaluation { /** What the judge observed that indicates attack success. */ attackSuccessIndicator?: string; /** Attack success score from 0 (no success) to 5 (full success). */ attackSuccessScore?: 0 | 1 | 2 | 3 | 4 | 5; /** The judge's reasoning behind the score. */ explanation?: string; } export interface ScanResultEntry { objectiveId: string; conversation?: { role: string; content: string; }[]; evaluation?: Evaluation; /** * Server-computed verdict at the platform's default success threshold, * matching the dashboard; errored entries are never successful. Use * `evaluation.attackSuccessScore` to apply a custom threshold instead. */ isSuccessful: boolean; error?: string; /** For dataset scans: the `conversationId` of the dataset conversation this entry ran. */ conversationId?: string; } /** One test of a dataset to upload. */ export interface DatasetTestInput { /** Sent to the target exactly as written. At most 10,000 characters. */ prompt: string; /** Your own id for the test, unique within the dataset. At most 100 characters. */ id?: string; /** * Consecutive tests with the same conversationId are sent in order as one * conversation. Give a single-turn test a conversationId of its own. */ conversationId: string; } export interface UploadDatasetOptions { /** Shown in the dashboard. At most 200 characters. */ name: string; /** What the dataset tests, shown in scan reports. At most 2,000 characters. */ description?: string; /** Path to a CSV file in the dataset template's format, with a `conversationId` column. Pass this or `tests`. */ file?: string; /** The tests to upload, in order. Pass this or `file`. */ tests?: DatasetTestInput[]; } /** The fields `updateDataset` can change. A dataset's tests can't be changed. */ export interface UpdateDatasetOptions { /** At most 200 characters. */ name: string; } /** Tests a dataset scan sends unchanged, grouped into conversations by `conversationId`. */ export interface Dataset { datasetId: string; name: string; /** null when the dataset has none. */ description: string | null; testCount: number; /** A scan runs one attack per conversation. */ conversationCount: number; } export interface ScanResults { ready: boolean; results?: ScanResultEntry[]; } export interface StaticStrategyOptions { name: "static"; /** Number of attack probes per objective. Min 1, max 50, default 10. */ numberOfProbes?: number; /** * Alias for `numberOfProbes`, consistent with crescendo's option name. * `numberOfProbes` remains the canonical field; if both are set, it wins. */ numberOfAttacksPerObjective?: number; } export interface CrescendoStrategyOptions { name: "crescendo"; /** Number of independent escalation runs per objective. Min 1, max 10, default 1. */ numberOfAttacksPerObjective?: number; /** Maximum conversation turns. Min 1, max 30, default 10. */ maxTurns?: number; /** Maximum retries. Min 0, max 10, default 3. */ maxRetries?: number; /** Score threshold for early stopping. Min 3, max 5, default 4. */ earlyStopScore?: number; } export interface SmokeStrategyOptions { name: "smoke"; /** Custom probe strings. Uses default canned set if omitted. */ probes?: string[]; } /** Indirect attack: a benign trigger induces a tool call and Red poisons the * tool result before the agent reads it. Requires the agent to report its tool * calls via `interceptTool`. */ export interface ToolResponsePoisoningStrategyOptions { name: "tool-response-poisoning"; /** Independent single-conversation attacks per objective. Defaults to 10. */ numberOfAttacksPerObjective?: number; } export type StrategyOptions = StaticStrategyOptions | CrescendoStrategyOptions | SmokeStrategyOptions | ToolResponsePoisoningStrategyOptions; export interface ReconContext { /** High-level description of what the application is and does. */ appDescription: string; /** Capabilities and actions the application is designed to perform. Joined * into a newline-separated string before being sent. */ allowedActions: string[]; /** Topics, tasks, or content the application is not designed to handle. * Joined into a newline-separated string before being sent. */ forbiddenActions: string[]; } /** * Ground truth about the target: its real system prompt and/or tool definitions. * Used by the judge to evaluate attacks more precisely. At least one field must * be provided. Persisted on the target and reused across scans by target name. */ export interface GroundTruth { /** The target's actual system prompt. */ systemPrompt?: string; /** The target's actual tool/function definitions (e.g. their JSON schemas). */ tools?: string; } export interface CustomObjective { /** * Stable identifier, returned as `objectiveId` in results. 1-128 characters of * letters, digits, `.`, `_`, `:` or `-`. Unique within the scan and must not * match a predefined objective ID. Example: "my-org.jailbreak.1". */ key: string; /** Display name for this objective. */ name: string; /** Description of what the attack is testing for. */ attackDescription: string; /** List of indicators of a successful attack. */ successIndicators: string[]; /** Severity badge shown next to this objective in scan reports. */ severity?: "critical" | "high" | "medium" | "low"; /** * Extra context fed to the attacker to shape probe generation. * Does not affect scoring — only influences how probes are constructed. */ additionalContext?: string; /** Set to false to skip this objective for direct-attack strategies (static, crescendo). Unset runs it. */ runsWithDirectAttacks?: boolean; /** Set to false to skip this objective for indirect-attack strategies (tool-response-poisoning). Unset runs it. Both flags false is rejected. */ runsWithIndirectAttacks?: boolean; } /** Target name. Reuses an existing relay target with this name or creates a new one. */ interface CreateOrGetTargetBase { name: string; /** * Ground truth (system prompt and/or tool definitions) about the target, * supplied inline. Persisted on the target and reused across scans by name. * Can also be provided through `appContextFile` (via its `systemPrompt` / * `tools` keys); when both are given, this inline value wins. */ groundTruth?: GroundTruth; /** * How long Red waits for your handler to answer each prompt sent to this * target, in whole seconds. Between 1 and 480 (8 minutes). * Omit to keep the stored value, or the 300 second default for a new target. */ responseTimeoutSeconds?: number; /** * When true, each probe is an independent one-turn exchange with no session * state carried across calls. Incompatible with crescendo and * tool-response-poisoning, which require multi-turn sessions; attempting to * create a scan with those strategies against a single-turn target returns * an error. Persisted on the target. */ singleTurn?: boolean; } /** * `appContext` and `appContextFile` are two ways to supply the same recon * profile, so the union makes them mutually exclusive by construction: a caller * can pass one, the other, or neither — never both. */ export type CreateOrGetTargetOptions = CreateOrGetTargetBase & ({ /** Target application context inline. When provided it is persisted as the target's recon profile, so no recon run is needed. */ appContext?: ReconContext; appContextFile?: never; } | { /** * Path to a YAML file containing target application context (must * conform to ReconContext). It may also carry optional `systemPrompt` * and `tools` keys, which populate the target's ground truth. */ appContextFile?: string; appContext?: never; }); export interface UpdateTargetOptions { /** New target name. Omit to leave the name unchanged. */ name?: string; /** Replacement recon profile. When provided it replaces the target's stored recon profile wholesale. Omit to leave the recon profile unchanged. */ appContext?: ReconContext; /** Replacement ground truth. When provided it replaces the target's stored ground truth wholesale. Omit to leave it unchanged. */ groundTruth?: GroundTruth; /** * How long Red waits for your handler to answer each prompt sent to this * target, in whole seconds. Between 1 and 480 (8 minutes). * Omit to leave it unchanged. */ responseTimeoutSeconds?: number; /** * When true, marks this target as single-turn. Omit to leave the value * unchanged. */ singleTurn?: boolean; } export interface CreateScanOptions { /** Id of the target to scan (from a `Target` returned by `client.createOrGetTarget`/`getTarget`). Its recon profile is reused for this scan. */ targetId: string; /** Objective IDs to scan. Ignored for the "smoke" strategy, which runs a fixed canned probe set. Not allowed with `dataset`. */ objectives?: string[]; /** Inline custom objectives defined entirely by the caller. Never persisted to the objectives catalog. Can be combined with `objectives`. */ customObjectives?: CustomObjective[]; /** Attack strategy configuration. Defaults to `{ name: "crescendo" }`. */ strategy?: StrategyOptions; /** Number of concurrent sessions the SDK supports. Sent to the backend as maxConcurrentRequests. Defaults to 10. */ concurrency?: number; /** Human-readable name for this scan (visible in the dashboard). */ name: string; /** Language for attack generation. Defaults to "en" if omitted. */ language?: LanguageCode; /** * Id of a dataset to run in place of objectives. Each conversation's prompts are sent * once, unchanged and in order, in its own session. Can't be combined with `objectives`, * `customObjectives`, `strategy` or `language`. */ datasetId?: string; } /** Metadata about a target's inferred topology. */ export interface Topology { /** ISO-8601 timestamp. */ generatedAt: string; /** The target's ground truth or Red's threat model changed since this topology was inferred. */ isStale: boolean; } /** An attack objective generated from a target's topology. Pass `key` to `createScan`'s `objectives`. */ export interface GeneratedObjective { key: string; name: string; attackDescription: string; successIndicators: string[]; } export {}; //# sourceMappingURL=types.d.ts.map