Vercel AI SDK tools for Darkmoon, the open source (GPL-3.0) autonomous AI penetration testing platform. Give an AI agent the ability to launch a pentest campaign, follow its progress and read the validated findings.
Darkmoon's engine, CLI, agents, and SARIF/JSON export are open source. The REST API and web dashboard are Darkmoon Pro features. These tools talk to the Darkmoon Pro REST API (through @darkmoon_ai/client), so you need a reachable Darkmoon Pro instance to use them. With the open source CLI only, use the CLI or the GitHub Action and consume the SARIF/JSON output instead.
npm install @darkmoon_ai/ai-sdk ai zodRequires ai ^7 and zod, Node 18+.
| Tool | What it does |
|---|---|
darkmoonRunPentest |
Launch an autonomous pentest campaign against an authorized target. Returns a runId immediately. Needs human approval by default. |
darkmoonGetCampaignStatus |
Status (queued, running, completed, stopped, failed), overall risk and severity counts, by campaignId or runId. |
darkmoonListCampaigns |
List campaigns, optionally filtered by status or target. |
darkmoonGetFindings |
List findings (title, severity, CVSS, category, CVE, MITRE ATT&CK id, endpoint, remediation), filterable by campaign, severity, category and status. |
import { generateText, isStepCount } from 'ai';
import { createDarkmoonTools } from '@darkmoon_ai/ai-sdk';
const tools = createDarkmoonTools({
// restrict what the model may ever attack (exact host or *.wildcard)
allowedTargets: ['staging.example.com', '*.qa.example.com'],
});
const { text } = await generateText({
model: 'openai/gpt-5-mini',
tools,
stopWhen: isStepCount(8),
prompt: 'List my Darkmoon campaigns and summarize the critical and high findings of the latest completed one.',
});
console.log(text);Configuration comes from options or environment variables:
| Option | Env var | Meaning |
|---|---|---|
pro.baseUrl |
DARKMOON_API_URL |
Base URL of your Darkmoon Pro API (with or without /api/v1). Required. |
pro.token |
DARKMOON_API_TOKEN |
Bearer token (skips login). |
pro.username / pro.password |
DARKMOON_USERNAME / DARKMOON_PASSWORD |
Login credentials, used when no token is given. |
You can also pass your own client (any object with launchCampaign, getCampaignStatus, listCampaigns, listFindings, for example a configured DarkmoonClient from @darkmoon_ai/client).
A pentest sends real attack traffic. Only test systems you own or are explicitly authorized to test.
requireApproval(defaulttrue):darkmoonRunPentestuses the AI SDKneedsApprovalflag, so your application must approve each launch.allowedTargets: when set, any target (includingtargets[]) outside the list is refused before any API call is made. Set it.- Findings are returned as compact summaries. Raw evidence (requests, responses, extracted data) is never exposed to the model, and secrets are scrubbed by
@darkmoon_ai/client. maxFindings(default 50) bounds how much a single call can return.
createDarkmoonTools(options)returns{ darkmoonRunPentest, darkmoonGetCampaignStatus, darkmoonListCampaigns, darkmoonGetFindings }, ready to pass astools.isTargetAllowed(target, allowed)andextractHost(target)are exported helpers.
npm install
npm run typecheck
npm test
npm run buildMIT, see LICENSE. Darkmoon itself is GPL-3.0 and published by ASC-IT.