Skip to main content
@keyvaluesystems/agent-opfor-sdk is the programmatic surface — the same engine as the CLI, callable from your own code. Use it to embed red-teaming in custom tooling, gate CI on results, or build your own workflows. It’s TypeScript-first.

Install

Quickstart

Both a class-based and a functional API are available — they’re equivalent, so use whichever you prefer.

Run

Run a suite or a list of evaluators against a target.
Run specific evaluators instead of a suite with evaluators: [...]:

Targets

Strategy

Control how thorough the attack loop is.

Attack objective

Steer every evaluator’s attacks toward a specific free-text mission, instead of letting each evaluator pursue its own generic goal.

Judge hint

Steer the judge’s verdict with free-text guidance — combined with each attack’s existing judge hint rather than replacing it.

Business use case

Give the attacker extra domain/business context about the target agent.

Models

Set attacker and judge LLMs as a shorthand string or a full provider object. The judge defaults to the attacker if unset.
Provider objects accept { provider, model, apiKey, baseUrl? }apiKey is the key value, not an env var name. See providers for the full provider list.

Autonomous mode

hunt() runs the autonomous campaign programmatically — adaptive multi-turn attacks driven by an AI agent, with progress streaming.
onProgress events: line, recon_start, recon_done, thread_start, thread_turn, thread_done, finding, complete. HuntResults includes outcome, summary, recon, findings, recommendations, totalCostUsd, and report paths.

Telemetry

Enable trace-aware testing so the judge sees the target’s internal tool calls and retrievals.
For Netra, swap provider and use the netra block:
See Trace-aware testing for the full config reference.

Results

A Finding carries severity, title, description, evidence?, and a standards map. Each EvaluatorResult holds per-evaluator pass/fail counts and an attacks array with full prompt/response transcripts and verdict.
safetyScore and attackSuccessRate are severity-weighted — each attack’s contribution is scaled by its evaluator’s severity (critical = 4, high = 3, medium = 2, low = 1), so critical failures dominate the headline scores. The raw passed / failed / errors counts stay unweighted for transparency.

Reports

Gate CI on findings

Exports

Types are exported too: RunOptions, RunResults, TargetConfig, McpTargetConfig, Finding, EvaluatorResult, AttackResult, TelemetryConfig, and the Hunt* variants.