@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.- Class
- Functional
Run
Run a suite or a list of evaluators against a target.evaluators: [...]:
Targets
- HTTP endpoint
- Stateful vs stateless
- Local script
- MCP server
Strategy
Control how thorough the attack loop is.Models
Set attacker and judge LLMs as a shorthand string or a full provider object. The judge defaults to the attacker if unset.{ provider, model, apiKeyEnv, baseUrl? }. See providers for the full list and env vars.
Autonomous mode
hunt() runs the autonomous campaign programmatically — adaptive multi-turn attacks driven by an AI agent, with progress streaming.
HuntOptions reference
HuntOptions reference
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.netra: { baseUrl, apiKeyEnv, traceSelection } block.
Results
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.
Reports
Gate CI on findings
Exports
RunOptions, RunResults, TargetConfig, McpTargetConfig, Finding, EvaluatorResult, AttackResult, TelemetryConfig, and the Hunt* variants.