Leap360Leap360DocsBeta

JavaScript SDK

The leap360 npm package, version 1.9.1.

npm install leap360

Node.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' });
OptionDefaultDescription
apiKeyLEAP360_API_KEYYour API key
projectIdProject identifier
serviceNameThe agent name shown in the console
modeFrom the consoleshadow or enforce
failClosedAtcriticalWhen Leap360 can't be reached, block calls at this risk or above
approvalWaitMs0Wait for a person to approve a held call
decisionsLocal'server' sends every decision to the server
baseUrlHosted APIOverride the API URL
debugfalseLog trace submissions to the console
MethodWhat 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
MethodWhat 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

FunctionWhat 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, replayPolicyThe local engine
scanProject (from leap360/scan)Run the code scan from code

Errors

ErrorWhen
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

On this page