--discover. When --discover is enabled, swarm runs the complete pipeline: source analysis, SAST, discovery/spidering, AI planning, native scanning, and triage — making it the unified replacement for the former agent pipeline command.
Note:Swarm automatically enables warm session pooling for ACP agent backends, reusing subprocesses across the plan and triage phases for faster execution. Whenvigolium agent pipelineis now an alias forvigolium agent swarm --discover. Existing pipeline invocations continue to work unchanged.
--source is provided, swarm runs a consolidated 4-call source analysis in 2 waves: a single explore call reads the codebase and documents routes, auth flows, and vulnerability sinks, then three calls run in parallel — format-routes, format-session, and extensions — to produce structured output. When --code-audit is enabled (on by default when --source is provided), a deep AI security code audit identifies business logic flaws, data flow vulnerabilities, and framework misconfigurations that static analysis misses. This is followed by a native SAST phase (ast-grep + secret detection) and a SAST review sub-agent to validate all findings — before the master agent plans the attack. When --discover is enabled, native discovery+spidering expands the attack surface further.
Architecture Overview
--source is provided, code-audit runs by default when --source is provided (disable with --code-audit=false), SAST runs when --source is provided, and discovery runs when --discover is enabled.
Detailed Data Flow
Component Interaction
Batched Master Agent (>5 inputs)
When the swarm receives more than 5 input records, the master agent is called in batches:CLI Usage
Supported Input Types
Inputs are auto-detected from their content:| Type | Example | Detection |
|---|---|---|
| URL | https://example.com/api/users | Starts with http:// or https:// |
| Curl | curl -X POST https://... | Starts with curl |
| Raw HTTP | POST /api HTTP/1.1\r\n... | Starts with HTTP method + path |
| Burp XML | <?xml...><items>...</items> | Starts with <?xml or <items |
| Record UUID | 550e8400-e29b-... | Matches UUID format (8-4-4-4-12 hex) |
Flags
| Flag | Default | Description |
|---|---|---|
-t, --target | — | Target URL (required when --source is used) |
--input | — | Raw input (curl command, raw HTTP, Burp XML). Use - for stdin |
--record-uuid | — | HTTP record UUID from database |
--source | — | Path to application source code for route discovery |
--files | — | Specific source files to include (relative to --source) |
--vuln-type | — | Vulnerability type focus (e.g., sqli, xss, ssrf) |
--focus | — | Focus area hint for the agent (e.g., API injection, auth bypass). Broader than --vuln-type |
-m, --modules | — | Explicit module names to include alongside agent selections |
--max-iterations | 3 | Maximum triage-rescan iterations (hidden alias: --max-rescan-rounds) |
--code-audit | true (when --source) | Enable AI security code audit phase (requires --source). Enabled by default when --source is provided; disable with --code-audit=false |
--skip-sast | false | Skip native SAST tools (ast-grep, osv-scanner, semgrep) when --source is provided |
--start-from | — | Resume from a specific phase (native-normalize, source-analysis, code-audit, native-sast, native-discover, plan, native-extension, native-scan, triage). Legacy names without native- prefix are also accepted |
--skip | — | Skip specific phases (repeatable, e.g., --skip discovery --skip spidering) |
--agent | from config | Agent backend to use |
--agent-acp-cmd | — | Custom ACP agent command (e.g., traecli acp), overrides --agent |
--swarm-duration | 12h | Maximum swarm duration |
--profile | — | Scanning profile to use |
--dry-run | false | Render prompts without executing |
--instruction | — | Custom instruction to guide the agent (appended to all prompts) |
--instruction-file | — | Path to a file containing custom instructions |
--show-prompt | false | Print rendered prompts to stderr before executing |
--source-analysis-only | false | Run only the source analysis phase and exit |
--discover | false | Run discovery+spidering before master agent planning |
--batch-concurrency | 0 (auto) | Max parallel master agent batches (0 = scales with CPU count) |
--max-master-retries | 3 | Max master agent retries on JSON parse failure |
--sub-agent-concurrency | 3 | Max parallel source analysis sub-agents |
--custom-slash-command | — | Slash command available inside the ACP session (repeatable, e.g. /security-review). Auto-detected from the agent’s global config (e.g. ~/.claude/commands/) |
--custom-agent | — | Custom agent the swarm can invoke via vigolium agent query --agent=X (repeatable, e.g. @my-sqli-specialist) |
--max-commands | 50 | Max terminal commands per ACP session (only applies when --custom-slash-command or --custom-agent is set) |
--target, --input, --record-uuid, or --source. Multiple inputs can be combined (e.g., --target + --input) for flows that require multiple requests (like login + protected endpoint).
When --source is provided, SAST analysis is automatically enabled (no extra flag needed). The SAST phase runs ast-grep route extraction and secret detection, then a SAST review sub-agent validates findings and generates targeted extensions.
Custom Slash Commands & Custom Agents
Swarm supports two mechanisms for extending the ACP agent’s capabilities during a run: custom slash commands (/command) and custom agents (@agent). Both enable terminal capability in the ACP session (via CreateTerminal), allowing the agent to execute commands mid-response.
Custom Slash Commands
Custom slash commands make Claude Code-native/ commands available inside the ACP session. These are prompt files that the agent can invoke by name (e.g., /security-review).
How it works:
- You specify
--custom-slash-command /security-reviewon the CLI - Vigolium auto-detects the agent type (e.g., Claude Code) and finds the command file in the agent’s global config directory (e.g.,
~/.claude/commands/security-review.md) - Before the ACP session starts, vigolium symlinks the command file into the session CWD’s
.claude/commands/directory SettingSourcesis adjusted so Claude Code loads the commands- The agent sees
/security-reviewas a native slash command - After the swarm run, symlinks and created directories are cleaned up
vigolium-configs.yaml:
Custom Agents
Custom agents (@agent) allow the ACP agent to invoke other agent backends (defined in agent.backends) via the terminal during a swarm session. The agent runs them as vigolium agent query --agent=<name> --prompt "...".
@ prefix is stripped when resolving the agent backend name. The agent receives prompt context about available custom agents and can invoke them via terminal during the plan and triage phases.
Terminal Capability
When either--custom-slash-command or --custom-agent is specified, swarm enables terminal capability in ACP sessions:
- The
CreateTerminalACP method becomes active (normally stubbed in swarm mode) vigoliumis always in the terminal allowlist (so custom agents can be invoked viavigolium agent query)- A
--max-commandslimit (default: 50) prevents runaway terminal usage - Terminal is enabled for all AI phases (plan, triage, source analysis, code audit, SAST review)
Phase Overview
Phases prefixed withnative- are executed by native Go code without AI agent involvement.
--source is provided (disable with --code-audit=false). The triage->rescan loop (phases 5-6) repeats until the agent sets verdict to "done", there are no follow-ups, or --max-iterations is reached.
Step-by-Step Flow
Phase 1: native-normalize
Input strings are converted toHttpRequestResponse objects using deterministic format detection (no AI needed):
- URL ->
httpmsg.GetRawRequestFromURL()generates a GET request - Curl -> Parsed using the existing
curl.ParseSingleCommand()parser (handles-X,-H,-d,-F,-b,-u,--url) - Raw HTTP -> Parsed directly via
httpmsg.ParseRawRequest() - Burp XML -> Streaming XML decoder extracts
<item>elements with base64-encoded request/response - Record UUID -> Fetched from the
http_recordsdatabase table
"agent-swarm".
Phase 1.5: Source Analysis (AI — Consolidated 4-Call)
When--source is provided, source analysis runs in 4 LLM calls across 2 waves:
| Wave | Call | Template | Output | Runs |
|---|---|---|---|---|
| 1 | Explore | swarm-source-explore | Plain-text notes (routes + auth + sinks) | Sequential (first) |
| 2 | Format Routes | swarm-source-format-routes | http_records[] (JSONL) | Parallel |
| 2 | Format Session | swarm-source-format-session | session_config (JSON) | Parallel |
| 2 | Extensions | swarm-source-extensions | extensions[] (JS code blocks) | Parallel |
- Wave 1 — Explore: A single agent reads the entire codebase once and documents all HTTP routes, authentication flows, and vulnerability sinks as plain-text notes with labeled sections (routes + auth/session).
- Wave 2 — Format + Extensions (3 calls in parallel):
- Format Routes converts the route notes into structured JSONL http_records. It reuses the warm ACP session from explore (retains codebase context).
- Format Session converts the auth/session notes into a session_config JSON with login flows and token extraction rules.
- Extensions generates targeted JS scanner extensions from the explore notes. It receives the notes via prompt append (no source code access needed — the explore notes contain all the sink details).
SourceAnalysisCallback converts the agent’s session config into an auth-config.yaml file in the session directory. This auth config is then used by subsequent phases (SAST, discovery, scan) for authenticated analysis.
Extension handling: Source-analysis extensions are held and later merged with plan extensions (Phase 2) via mergeExtensionsTracked(). On filename collision: identical code is dropped as a duplicate; different code triggers a rename with -2, -3 suffix. The merge result includes a renames map tracking original->new filenames.
Phase 1.55: code-audit (AI — On by Default with —source)
When--source is provided, the code audit phase is enabled by default (disable with --code-audit=false). An AI agent performs a deep security code review focusing on vulnerabilities that static analysis tools miss:
- Business logic flaws — IDOR, race conditions, privilege escalation, workflow bypasses, mass assignment
- Authentication/authorization gaps — missing auth middleware, JWT weaknesses, OAuth misconfigurations
- Data flow vulnerabilities — second-order injection, SSTI, unsafe deserialization, path traversal
- Framework misconfigurations — CORS, CSRF, debug endpoints, verbose error messages
- Cryptographic misuse — weak algorithms, hardcoded keys, timing-unsafe comparisons
--source.
Findings are saved directly to the database with module_type="agent" and module_id="agent-swarm-code-audit". These findings are:
- Included in the SAST review phase for validation alongside SAST findings
- Included in the triage phase for final verification
- Visible in the findings table alongside all other scan findings
swarm-code-audit.md
Phase 1.6: native-sast (Native — No AI)
When--source is provided, the native SAST phase runs automatically:
- ast-grep — Extracts routes from source code using AST patterns, ingests them into the database with parameterized path resolution and concurrent probing
- Kingfisher — Detects hardcoded secrets, API keys, and credentials
- Third-party tools — semgrep, osv-scanner, CodeQL (when available on the system)
module_type="sast". Auth config from source analysis is applied for authenticated SAST analysis.
Phase 1.6.1: SAST Review (AI Sub-Agent)
After SAST completes, a review sub-agent (swarm-sast-review template) evaluates both SAST findings and code-audit findings (if --code-audit was enabled):
- Validate routes — Cross-references SAST findings with discovered routes, adds new/corrected routes
- Assess quality — Classifies each finding as high/medium/low confidence
- Generate extensions — Creates targeted JS extensions (prefixed
agent-sast-*, taggedsast-verified) to dynamically verify high/medium confidence SAST findings
SourceAnalysisResult — validated routes merge into input records, extensions merge with source-analysis extensions.
Phase 1.7: native-discover (Native — No AI)
When--discover is enabled, native discovery + spidering runs before the master agent:
- Deparos crawling (link extraction, form discovery)
- JavaScript analysis (jsscan)
- Spidering (dynamic page exploration)
Phase 2: Plan (AI Checkpoint — Master Agent)
The plan phase consists of two sequential AI calls orchestrated byrunMasterAgent():
- Plan agent (
agent-swarm-plantemplate) — analyzes HTTP records and generates aSwarmPlanwith module selections, focus areas, and determines if custom extensions are needed - Extension agent (
agent-swarm-extensionstemplate) — if the plan indicatesneeds_extensions: true, generates custom JS scanner extensions based on the plan
agent-swarm-plan prompt template with:
| Variable | Content |
|---|---|
TargetURL | Extracted from the first normalized record |
Hostname | Derived from target URL |
ModuleList | JSON of all available active/passive scanner modules |
Extra.RequestContext | Full HTTP request/response pairs (responses truncated at 4KB) |
Extra.VulnType | User-specified vulnerability focus (if any) |
Extra.Focus | User-specified focus area hint (if any) |
needs_extensions is true, the extension agent is called next to generate custom JS extensions, quick checks, and snippets:
module_tags(required) — scanner module tags to activate (e.g.,sqli,xss,ssrf)module_ids— specific module IDs to includeneeds_extensions— whether the extension agent should generate custom extensionsneeds_extensions_reason— rationale for why custom extensions are neededextensions— custom JavaScript scanner extensions for payloads the built-in modules won’t coverquick_checks— declarative payload-and-match checks (auto-converted to full JS extensions)snippets— shorthand extensions (scan function body only; runner wraps in scaffold)focus_areas— human-readable description of attack focusnotes— strategy summary
--modules are merged with agent selections. The plan agent retries up to --max-master-retries (default 3) on JSON parse failure, with error feedback appended to the retry prompt.
Phase 3: native-extension (Write Generated Code)
Extensions from all sources (source analysis, SAST review, plan agent) are merged and written to the session extensions directory. Quick checks and snippets are first converted to full JS modules:QuickChecks->GenerateQuickCheckExtensions()-> full ActiveModule scaffoldSnippets->GenerateSnippetExtensions()-> full ActiveModule scaffold- Extensions -> validated with
ValidateExtensionSyntax(), invalid ones repaired viaRepairExtensionsWithLLM()
Phase 4: native-scan (Native — No AI)
The audit phase runs with:- All built-in modules enabled by default (
opts.Modules = ["all"],opts.PassiveModules = ["all"]) - Plus the generated extensions loaded from the session extensions directory
- Plus any user-specified modules from
--modules - Heuristics check disabled (
"none") during swarm scans
Phase 5: Triage (AI Checkpoint)
The triage agent reviews all findings — both extension-generated and built-in module findings. Extension findings receive the most scrutiny since they were generated by custom AI-written scanners, but built-in module findings are also reviewed for false positives. The agent returns a TriageResult with confirmed findings, false positives, and optional follow-up scan recommendations.Phase 6: native-rescan (Conditional Loop)
If the triage verdict is"rescan" and follow-ups are recommended, a targeted rescan runs with the suggested modules. The triage->rescan loop continues up to --max-iterations times.
Database Tracking
Every swarm run creates anagent_runs database record with:
- Run UUID (
agt-...prefix) - Input, input type, target URL
- Status, current phase, timing
- Attack plan and triage results (JSON)
- Finding and record counts
- Error message (on failure)
Server API
Endpoint:POST /api/agent/run/swarm
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
input | string | Yes* | Single input (URL, curl, raw HTTP, Burp XML, or record UUID) |
inputs | string[] | Yes* | Multiple inputs (for auth flows). Merged with input |
http_request_base64 | string | No | Base64-encoded raw HTTP request. Ingested into DB and its UUID is used as input |
http_response_base64 | string | No | Base64-encoded raw HTTP response. Attached to the request above |
url | string | No | URL hint for parsing the base64 request (used when the raw request lacks a full URL) |
vuln_type | string | No | Vulnerability type focus (e.g., sqli, xss) |
focus | string | No | Focus area hint for the agent (e.g., API injection, auth bypass). Broader than vuln_type |
instruction | string | No | Custom instruction appended to all agent prompts |
module_names | string[] | No | Explicit module IDs to include |
scanning_phase | string | No | Scan phase to run (default audit) |
max_iterations | int | No | Max triage-rescan rounds (default 3) |
agent | string | No | Agent backend name |
project_uuid | string | No | Project UUID for data scoping |
scan_uuid | string | No | Scan UUID to attach findings to |
stream | bool | No | Enable SSE streaming |
timeout | string | No | Go duration string (default 15m) |
dry_run | bool | No | Render prompts without executing |
code_audit | bool | No | Enable AI security code audit phase |
input, inputs, or http_request_base64 must be provided.
Response modes:
- Streaming (SSE): Real-time events with phase transitions, agent output chunks, and final result
- Async (202): Returns
run_idfor status polling viaGET /api/agent/status/:id
| Event | Description |
|---|---|
phase | Phase transition ({"type":"phase","phase":"native-normalize"}) |
chunk | Real-time text from the agent |
done | Swarm completed ({"type":"done","swarm_result":{...}}) |
error | Swarm failed |
curl Examples
Extension Generation Detail
The swarm plan can include three types of agent-generated scanning logic. All three are converted to full JavaScript extensions before the scan phase:Extension Lifecycle
Extensions can originate from three sources. They are merged by filename (plan wins on collision) before writing to disk:Output Schemas
SwarmPlan (Phase 2)
SwarmResult (Final)
TriageResult (Phase 5)
Comparison: Swarm vs Autopilot
| Aspect | Swarm | Autopilot |
|---|---|---|
| Scope | Single request/endpoint, or full target with --discover | Entire target |
| Input | URL, curl, raw HTTP, Burp XML, DB record | Target URL |
| AI involvement | 3-12+ calls (source analysis 4 + code-audit + SAST review + plan + extensions + triage), warm sessions auto-enabled | Many calls (agent-driven) |
| Custom payloads | Yes — from source analysis, SAST review, and master agent | No |
| Discovery | Optional (--discover) — crawling + spidering | Yes — agent decides |
| SAST | Automatic when --source provided + AI review sub-agent | No |
| Triage scope | All findings (extension + built-in) | Agent decides |
| Default timeout | 12 hours | 30 minutes |
| Best for | Deep targeted testing or full-scope structured scanning | Exploratory research |
agent swarm when you want structured, repeatable scanning — whether targeting a single endpoint for deep analysis or running full-scope scans with --discover.
Use agent autopilot when you want the AI to explore freely and decide its own approach.
Session Artifacts
Every swarm run creates a session directory (configurable viaagent.sessions_dir, defaults to ~/.vigolium/agent-sessions/<run-id>/). The session directory stores all artifacts from the run for debugging and auditability:
SwarmResult (session_dir field) and printed to stderr in CLI mode.
Key Files
| File | Purpose |
|---|---|
pkg/agent/swarm.go | Swarm orchestrator (multi-phase pipeline) |
pkg/agent/engine.go | Agent engine (RunSourceAnalysisParallel, Run, RunWithExtra) |
pkg/agent/input_normalizer.go | Input type detection and normalization |
pkg/agent/input_parsers.go | Curl and Burp XML parsers |
pkg/agent/pipeline_types.go | Data structures (SwarmPlan, SwarmResult, shared helpers) |
pkg/cli/agent_swarm.go | CLI command definition and callback wiring |
pkg/server/handlers_agent.go | REST API handlers |
pkg/database/models.go | AgentRun model for DB tracking |
public/presets/prompts/swarm/agent-swarm-plan.md | Plan agent prompt template |
public/presets/prompts/swarm/agent-swarm-extensions.md | Extension agent prompt template |
public/presets/prompts/swarm/swarm-source-explore.md | Source analysis: explore routes, auth, and sinks |
public/presets/prompts/swarm/swarm-source-format-routes.md | Source analysis: format route notes to JSONL http_records |
public/presets/prompts/swarm/swarm-source-format-session.md | Source analysis: format auth notes to session_config JSON |
public/presets/prompts/swarm/swarm-source-extensions.md | Source analysis: generate JS scanner extensions from notes |
public/presets/prompts/swarm/swarm-code-audit.md | Security code audit agent |
public/presets/prompts/swarm/swarm-sast-review.md | SAST review sub-agent |
public/presets/prompts/swarm/agent-swarm-triage.md | Triage agent prompt template |
