CI and automation
Scan your agent after every deploy, fail the job when the score drops or a fixed finding comes back, and schedule recurring scans.
A CI job can start a scan, wait for it, and fail when the agent got worse.
Scan an endpoint agent
For an agent you linked by URL (in the dashboard or with agentConfigs.create), start a scan with its agent id. agentScans.run waits for the scan and throws if it fails or is cancelled.
import { ZeroLeaks } from "@zeroleaks/sdk";
const zeroleaks = new ZeroLeaks(); // reads ZEROLEAKS_API_KEY
const { report, comparison } = await zeroleaks.agentScans.run(agentConfigId, {
timeoutMs: 45 * 60_000,
});
console.log(`Score ${report.overallScore}/100`);
if (comparison) {
const { regressions } = comparison;
if (comparison.scoreDropped || (regressions?.regressed ?? 0) > 0) {
process.exitCode = 1;
}
}comparison compares the finished scan with the same agent's previous completed scan. It is null on the agent's first scan.
| Field | Meaning |
|---|---|
previousScanId, previousScore | The agent's previous completed scan and its score |
scoreDelta | This score minus the previous one |
scoreDropped | true when scoreDelta is below zero |
regressions.fixed | Earlier findings whose attack no longer lands |
regressions.stillOpen | Earlier findings whose attack still lands |
regressions.regressed | Findings that were fixed in an earlier scan and land again |
regressions.newFindings | Findings this scan found for the first time |
The REST API returns the same object on GET /api/v1/agent-scans/{id}, along with trigger (manual, scheduled, or api).
Run after every deploy with GitHub Actions
Save this workflow as .github/workflows/zeroleaks.yml and add your API key as the ZEROLEAKS_API_KEY repository secret. The "Run on every deploy" panel in the agent's dashboard drawer has it filled in with the agent's id.
name: ZeroLeaks agent scan
on:
deployment_status:
workflow_dispatch:
jobs:
scan:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.deployment_status.state == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install --no-save @zeroleaks/sdk
- name: Scan the agent and fail on a score drop
env:
ZEROLEAKS_API_KEY: ${{ secrets.ZEROLEAKS_API_KEY }}
ZEROLEAKS_AGENT_ID: your-agent-id
run: |
cat > zeroleaks-gate.mjs <<'EOF'
import { ZeroLeaks } from "@zeroleaks/sdk";
const zeroleaks = new ZeroLeaks();
const { report, comparison } = await zeroleaks.agentScans.run(
process.env.ZEROLEAKS_AGENT_ID,
{ timeoutMs: 45 * 60_000 }
);
console.log(`Score ${report.overallScore}/100`);
if (comparison) {
const { previousScore, scoreDelta, regressions } = comparison;
console.log(`Previous scan ${previousScore}/100, change ${scoreDelta}`);
if (regressions) {
console.log(
`Earlier findings: ${regressions.fixed} fixed, ${regressions.stillOpen} still open, ${regressions.regressed} regressed`
);
}
if (comparison.scoreDropped || (regressions?.regressed ?? 0) > 0) {
console.error("ZeroLeaks: the score dropped or a fixed finding came back.");
process.exit(1);
}
}
EOF
node zeroleaks-gate.mjsThe workflow runs when GitHub records a successful deployment, which Vercel, Netlify, Render and most hosts report, so each scan tests the version you just shipped. If you deploy from the same workflow instead, put the scan in a job with needs: set to your deploy job.
Scan a runtime agent
Runtime scans drive your agent in-process, so they run in server and CI environments. Keep the runner process running until the hosted workflow completes.
const controller = new AbortController();
const { report } = await zeroleaks.runtimeScans.run(target, {
signal: controller.signal,
timeoutMs: 45 * 60 * 1000,
eventConcurrency: 4,
workerStallTimeoutMs: 6 * 60_000,
onPoll: ({ currentPhase }) => console.log(currentPhase),
});
const replay = report.boundaryAssurance?.regressionReplay;
if (report.overallScore < 80 || (replay?.regressed ?? 0) > 0) {
process.exitCode = 1;
}A runtime target has no saved agent id, so ZeroLeaks matches it to its earlier scans by name, provider, and model. Keep those stable between runs for fix verification to work.
Gate a release
Deploy the agent with test credentials and isolated dependencies, and run unit and integration tests first. Keep the returned report as a CI artifact. Gate releases on a score drop, a regressed finding, vulnerability level, component scores, or finding severity.
How fix verification works
Each scan starts by replaying, unchanged, the attacks that landed on the same agent before: up to 20 per scan, open and regressed findings first. A fix that held for five scans in a row stops being replayed. Replays only ever use the same agent's own history; they never feed another agent's or another workspace's scans. The report's coverage tab lists each earlier finding as fixed, still open, or regressed.
A scan reports what to fix; it does not rerun exploits against your fixed agent on its own. The next scan, from CI, a schedule, or the dashboard, does.
Schedule scans
To scan without a deploy, set a daily or weekly schedule in the agent's drawer in the dashboard. Scheduled runs are ordinary scans and count against the same rate limits. A scheduled run is:
- skipped while an earlier scan of that agent is still going;
- retried for up to six hours while the plan's concurrency or hourly limit is full;
- skipped while the plan is inactive.
Each plan limits how many agents can hold a schedule, and the Pro trial schedules one agent weekly. The drawer shows your plan's limit.
Rate limits
Scans are unlimited on paid plans. Each plan limits how many scans run at once and how many start in a rolling hour, counted across runtime, endpoint, prompt, and skill scans. Starting a scan past either limit returns 429 with code SCAN_CONCURRENCY_LIMIT or SCAN_HOURLY_LIMIT and a message saying when the next scan can start. Serialize scans across parallel CI jobs, or use a plan with more concurrent scans. See pricing for each plan's limits and errors for the response headers.
Cancel a scan
For runtime scans, abort signals and local timeouts trigger best-effort cancellation of the hosted workflow. For endpoint scans, they only stop local polling. To cancel explicitly:
await zeroleaks.runtimeScans.cancel(runtimeScanId);
await zeroleaks.agentScans.cancel(agentScanId);If a runner exits unexpectedly, the current relay event eventually times out and the scan is marked failed rather than silently producing a partial success. The SDK also detects a hosted worker that stops making progress and cancels the run instead of polling indefinitely.