Skip to main content

Installation

Install Pensar Apex as a dependency in your TypeScript/JavaScript project:
Pensar Apex requires Bun 1.0+ or Node.js 18+ as the runtime. The package is written in TypeScript and includes full type definitions.

Prerequisites

Before you start, you’ll need:
  1. An AI provider API key - Pensar Apex supports:
    • Anthropic (Claude) - recommended for best results
    • OpenAI (GPT-4)
    • AWS Bedrock
    • OpenRouter
  2. Environment variables for your AI provider:

Basic Usage

Here’s a complete example that runs a security assessment on a web application:
1

Import the API

Import the session manager and agent runner functions:
src/example.ts
2

Create a session

Sessions provide isolated workspaces for each assessment:
src/example.ts
3

Run the pentest agent

The pentest agent automatically:
  1. Discovers the attack surface (endpoints, pages, auth flows)
  2. Spawns targeted pentest agents for each discovered target
  3. Documents findings and generates proof-of-concept exploits
src/example.ts
4

Process the results

Findings are returned as structured objects and saved to disk:
src/example.ts

Complete Example

Here’s the full working example:
src/pentest-example.ts
Run it with:

Agent-Specific Examples

Attack Surface Discovery (Blackbox)

Discover endpoints, subdomains, and assets without source code access:

Attack Surface Discovery (Whitebox)

Analyze source code directly to map endpoints:

Authentication Testing

Test authentication mechanisms with credential management:
Credentials are secure: The username and password are stored in memory only via CredentialManager. The AI model never sees raw secrets—only credential IDs that are resolved at tool execution time.

Targeted Pentest

Test a specific endpoint with custom objectives:

Vulnerability Patching

Automatically generate and validate security patches:

TypeScript Support

The API includes full TypeScript definitions for all functions and types:

Callback Types

Callbacks are strongly typed for IDE autocomplete:

Aborting Long-Running Operations

All agents support abort signals for graceful cancellation:

Error Handling

Wrap agent calls in try-catch blocks for robust error handling:

Next Steps

Agent Reference

Detailed documentation for each agent type

Configuration

Session config, credentials, and scope constraints

Findings Format

Structure of vulnerability findings and POCs

Examples

Real-world integration patterns