JavaScript SDK
The leap360 npm package, version 1.9.1.
npm install leap360Node.js 18 or later, ESM and CommonJS, TypeScript types included. The package also contains the CLI.
Leap360
Traces model calls and governs tool calls for one agent.
import { Leap360 } from 'leap360';
const leap = new Leap360({ apiKey: process.env.LEAP360_API_KEY, projectId: 'my-app', serviceName: 'deploy-bot' });| Option | Default | Description |
|---|---|---|
apiKey | LEAP360_API_KEY | Your API key |
projectId | Project identifier | |
serviceName | The agent name shown in the console | |
mode | From the console | shadow or enforce |
failClosedAt | critical | When Leap360 can't be reached, block calls at this risk or above |
approvalWaitMs | 0 | Wait for a person to approve a held call |
decisions | Local | 'server' sends every decision to the server |
baseUrl | Hosted API | Override the API URL |
debug | false | Log trace submissions to the console |
| Method | What it does |
|---|---|
wrapTool(name, fn) | Govern a function an agent can call. See Govern tool calls. |
wrapOpenAI(client, agent) | Trace an OpenAI client |
wrapAnthropic(client, agent) | Trace an Anthropic client |
wrapBedrock(client, agent) | Trace an AWS BedrockRuntimeClient |
wrapGemini(client, agent) | Trace a Vertex AI Gemini client |
wrapGoogleGenAI(client, agent) | Trace a @google/generative-ai client |
traceCall(options) | Send a trace, or wrap and time a call with fn |
createAgent(id) | Returns an object with suspend() and resume() |
Leap360Client
Reads and manages the project the API key belongs to. Every method resolves to the API's JSON. Errors resolve too, never reject, with error, code and httpStatus (0 when the API can't be reached).
import { Leap360Client } from 'leap360';
const client = new Leap360Client(); // LEAP360_API_KEY, then ~/.leap360/config.json| Method | What it does |
|---|---|
traceCall(options), sendTrace(payload) | Record a model call |
getStats(), getTraces({ limit, offset }), getModels(), getAudit() | Project activity |
getAgents(), getAgentStatus(id) | Agents and their kill switch |
suspendAgent(id) | Stop an agent and its API keys |
resumeAgent(id) | Restart it (needs a signed-in person) |
getProjectStatus(), setProjectStatus('SUSPENDED' | 'ACTIVE') | The project kill switch (ACTIVE needs a signed-in person) |
getPolicies(), createPolicy(policy), getViolations() | Policies |
getApprovals(), decideApproval(id, 'approved' | 'rejected', note?) | The approval queue (deciding needs a signed-in person) |
getMode(), setMode('enforce' | 'shadow', days?) | Shadow mode (shadow needs a signed-in person) |
getShadowReport() | What policies would have blocked, each agent's tools, suggested policies |
getActions({ limit, since }) | Recorded tool calls |
getScans() | Reports uploaded by npx leap360 scan --report |
Calls that loosen governance return { code: 'PERSON_REQUIRED', httpStatus: 403 } when made with an API key.
Functions
| Function | What it does |
|---|---|
autoInit() | Read the key from the environment and register a global instance |
declareTools(options, tools, source) | Tell Leap360 which tools an agent can reach |
classifyAction, extractToolCalls, scanText, redactSecrets, decideAction, suggestPolicies, replayPolicy | The local engine |
scanProject (from leap360/scan) | Run the code scan from code |
Errors
| Error | When |
|---|---|
Leap360ActionBlockedError with code: 'ACTION_BLOCKED' | A policy blocked a wrapped tool call; err.gate.message says why |
Leap360ActionBlockedError with code: 'APPROVAL_REQUIRED' | A policy held the call for a person |
Leap360ActionBlockedError (wrapped tools) or an Error mentioning GOVERNANCE_HALT (wrapped model clients) | The agent or project is stopped by the kill switch |