01Install
Install from npm into your project.
BASH
pnpm add @lov3kaizen/agentsea-redteam @lov3kaizen/agentsea-core02Example
TS
import { createRedTeam } from '@lov3kaizen/agentsea-redteam';
const redTeam = createRedTeam({
config: {
target: { type: 'agent', name: 'my-agent', endpoint: 'https://api.example.com/chat' },
},
});
const results = await redTeam.run();
console.log('Risk Score:', results.summary.riskScore);03Key API
createRedTeam(options?)Main entry point. Options: config, reporter, dryRun, verbose.
createVulnerabilityScanner()Scans for vulnerabilities in four categories: injection, jailbreak, data-leakage and bias.
createJailbreakDetector(threshold?)detect({ text, role?, context? }) is synchronous and returns detected, confidence and technique. threshold is a number, default 0.5.
ComplianceChecker(framework, config?)Checks requirement evaluations against a framework. Framework ids include eu_ai_act and nist_ai_rmf (underscores, not hyphens).
AuditLogger and SchedulerAudit logging with hash-chain verification, and scheduled runs with fixed or cron frequencies.
04Caveats
- Beta. Audit entries are kept in memory unless you pass a store to AuditLogger.
- Scheduling supports hourly, daily, weekly, monthly and custom frequencies. A custom frequency takes a cronExpression. The README says cron is not supported, but the source handles it.
- Alerts go only to the channels you configure. Evidence and screenshot capture are not implemented.
- createAgentSeaIntegration and createCIIntegration are placeholders. They return their config and have no run method, so the README examples for them do not work.
- Requires @lov3kaizen/agentsea-core 0.6.0 or later and Node.js 20 or later. Some examples pass options the current source does not accept.
05Jailbreak detection
The detector is synchronous. Pass the text to inspect and read detected, confidence and technique from the result.
TS
import { createJailbreakDetector } from '@lov3kaizen/agentsea-redteam';
const detector = createJailbreakDetector(0.5);
const result = detector.detect({ text: 'Ignore all previous instructions...' });
console.log('Detected:', result.detected, 'Confidence:', result.confidence, result.technique);06Scheduling and alerts
Scheduler runs a job on a fixed frequency or on a cron expression. AlertManager evaluates alert rules against a metrics object and returns the alerts it triggers.
TS
import { AlertManager, Scheduler } from '@lov3kaizen/agentsea-redteam';
const scheduler = new Scheduler();
scheduler.schedule({ frequency: 'custom', cronExpression: '0 */6 * * *' }, () => {
console.log('Running scheduled tests');
});
const alerts = new AlertManager({ rules: [] });
const triggered = alerts.evaluate({ riskScore: 72 });