SDK

Native TypeScript SDK for integrating Security Layer into agentic applications.


Why use the SDK?

The CLI integrations (hooks, shell shim) work without code changes — but they operate at the boundary. The SDK gives you in-process security with full context:

Shell ShimHooksSDK
Intercepts execYesYesYes
Intercepts file writesNoYesYes
Intercepts web fetchNoYesYes
Full session contextNoPartialYes
Taint tracking precisionCoarseModeratePer-operation
Bypass riskPATH manipulationNoneNone (in-process)
Works with any frameworkYes (shell only)Claude Code onlyAny framework
Integration effortZeroOne commandCode changes

The SDK is the right choice when you're building an agentic application and want structural security guarantees — not just command-line interception.

Installation

npm install @securitylayerai/sdk
yarn add @securitylayerai/sdk
pnpm add @securitylayerai/sdk
bun add @securitylayerai/sdk

Quick example

import { createSecurityLayer } from "@securitylayerai/sdk";

const sl = await createSecurityLayer();

// Check an action before executing it
const result = await sl.check("exec", { command: "rm -rf /tmp/output" });

if (result.decision === "DENY") {
  console.error(`Blocked: ${result.reason}`);
} else if (result.decision === "REQUIRE_APPROVAL") {
  const approved = await sl.waitForApproval(result.approvalId as string);
  if (!approved) console.error("Approval denied");
}

// Clean up when done
sl.destroy();

Integration patterns

The SDK supports three patterns depending on how your agent framework is structured:

Next steps

On this page