Docs/Predicate Secure/API Reference

API Reference

Complete API documentation for predicate-secure.


SecureAgent

The main class for wrapping your agent with security features.

Constructor

class SecureAgent:
    def __init__(
        self,
        agent: Any,
        policy: str | Path

Parameters

ParameterTypeDescription
agentAnyThe agent to wrap (browser-use, Playwright, LangChain, etc.)
policystring | nullPath to YAML policy file
modestringExecution mode: strict, permissive, debug, or audit
principalIdstring | nullAgent principal ID for authorization
sidecarUrlstring | nullSidecar URL (default: http://localhost:8787)
traceFormatstringTrace output format: console or json
traceFilestring | nullPath to write trace output

Properties

@property
def config(self) -> SecureAgentConfig: ...

@property
def wrapped(self) -> WrappedAgent: ..

Methods

# Run the agent with authorization
def run(self, task: str | None = None) -> Any: ...

# Get the pre-action authorizer callback
def

Tracing Methods

# Trace a step
def trace_step(self, action: str, resource: str = "") -> int | None: ...

Static Methods

@staticmethod
def attach(agent: Any, policy: str = None, mode: str = "strict", **kwargs) -> SecureAgent:

Exceptions

class AuthorizationDenied(Exception):
    """Raised when an action is denied by policy"""
    decision: Any  # The authorization decision

class VerificationFailed(Exception):
    """Raised when post-execution verification fails"""
    predicate: str  # The failed predicate

Mode Constants

MODE_STRICT = "strict"
MODE_PERMISSIVE = "permissive"
MODE_DEBUG = "debug"
MODE_AUDIT = "audit"

Framework Detection

from predicate_secure import FrameworkDetector, Framework

detection = FrameworkDetector.detect(my_agent)
print(detection.framework)   # Framework.BROWSER_USE
print(detection.confidence)  # 1.0
print

Framework Enum

ValueDescription
BROWSER_USEbrowser-use Agent
PLAYWRIGHTPlaywright Page
LANGCHAINLangChain AgentExecutor
PYDANTIC_AIPydanticAI Agent
OPENCLAWOpenClaw CLI (Python only)
UNKNOWNUnrecognized framework

Environment Variables

VariableDescription
PREDICATE_AUTHORITY_POLICY_FILEDefault policy file path
PREDICATE_PRINCIPAL_IDDefault agent principal ID
PREDICATE_AUTHORITY_SIGNING_KEYSigning key for mandates
PREDICATE_SECURE_VERBOSEEnable verbose logging

TypeScript Types

import type {
  SecureAgentOptions,
  SecureAgentConfig,
  WrappedAgent,
  DetectionResult,
  AdapterResult,
  TraceEvent,
  PolicyDecision,
  VerificationResult,
} from '@predicatesystems/predicate-secure';