runTargetedPentestAgent
Runs a single pentest orchestrator against one target, with no attack surface discovery. The orchestrator plans its work from your objectives, spawns a worker agent per objective, and documents the vulnerabilities it confirms. This is what pensar targeted-pentest runs, and what runPentestAgent runs for each discovered endpoint.
If you don’t pass an eventBus, the agent’s text and tool calls are printed to stdout. A short summary of the findings and artifact paths is always printed when the run finishes.
Parameters
URL or host to test.
One or more testing objectives, for example "Test /api/users for SQL injection".
Session for artifacts and run configuration. See sessions.create().
Model ID. See Models.
AI provider credentials. See Configuration.
Free-form context for the agent prompt, such as the application’s name and purpose. The agent follows non-malicious instructions in it as guidance.
Streaming events. When omitted, output is printed to stdout. See AgentEventBus.
Cancels the run.
Shared registry that deduplicates findings across several concurrent agents.
external skips Apex’s finding judge and returns reportedFindings instead.
Extended-thinking setting. See Reasoning.
To run the agent as one worker that tests every objective itself, with no per-objective sub-agents, create the session with config: { disableSubagents: true }. It’s cheaper and faster, but less thorough.
Returns
Promise<TargetedPentestResult>
Documented vulnerabilities. Same shape as runPentestAgent findings.
Per-objective status. completed is false when an objective needs more testing.
Follow-up objectives the agent suggests for a future run.
Only set when findingPolicy is external.
Absolute path to the session’s findings/ directory.
Absolute path to the session’s pocs/ directory.
Example
startTargetedPentestAgent
Takes the same input as runTargetedPentestAgent, but returns right away with a handle. Use it when your host needs to force teardown, such as a worker that’s shutting down.
Settles with the same result as runTargetedPentestAgent. It can settle before background cleanup finishes.
Settles when background cleanup (browser disconnect, span teardown) is complete.
Aborts the run, force-disconnects its browser, and waits for cleanup. Idempotent, and never throws.