Request access
DocsSDK & ExamplesAPI Reference
Getting Started / Agent Firewall

Get started with the Agent Firewall

Authorize one semantic action with createAgentFirewallClient before the agent runs it. This page is public. Running the client is not.

RaksHex evaluates actions such as financial.refund against delegated authority, optionally brokers the credential so a DENY is enforced rather than advisory, and writes every decision to a hash-chained Action Ledger.

Install

The hello-world client lives at packages/sdkin this repository. Build that package, then add it by workspace path or filesystem path. Publishing to the public npm registry is a separate Build ticket — not this week's install path.

Clone this repo and build packages/sdk
git clone https://github.com/Akshu1245/Rakshex-complete-codebase.git
cd Rakshex-complete-codebase
pnpm install
pnpm --filter @rakshex/sdk build
Inside this repo: workspace path
pnpm add ./packages/sdk
From another project: filesystem path
pnpm add /path/to/Rakshex-complete-codebase/packages/sdk

Create the client

Import createAgentFirewallClient from @rakshex/sdk after the path install. The workspace key is a RaksHex rk_... key, not a provider key. The capability token is a delegated rk_cap_... authority for this agent.

createAgentFirewallClient
import { createAgentFirewallClient } from "@rakshex/sdk";

const firewall = createAgentFirewallClient({
  apiKey: process.env.RAKSHEX_API_KEY!, // rk_... workspace key
  workspaceId: 1,
  agentId: "agent_123",
  capabilityToken: process.env.RAKSHEX_CAPABILITY_TOKEN!, // rk_cap_... delegated authority
});

Authorize an action

Two ways to run work after a decision. Prefer credential brokering when the action can move money or change production data.

Option A — authorizeAndRun: your process still holds the real provider key. RaksHex decides; your code is responsible for honoring a DENY.

authorizeAndRun (caller holds the provider key)
const { decision, result } = await firewall.authorizeAndRun(
  { provider: "stripe", operation: "financial.refund", amountMinor: 5000, currency: "USD" },
  async () => stripe.refunds.create({/* ... */}),
);

Option B — executeWithCredential: RaksHex holds the provider key and makes the call. A DENY is enforced by RaksHex, not by whether your code chose to honor it.

executeWithCredential (RaksHex brokers the call)
const { decision: d2, response } = await firewall.executeWithCredential(
  { provider: "stripe", operation: "financial.refund", amountMinor: 5000, currency: "USD" },
  { credentialId: "cred_...", targetUrl: "https://api.stripe.com/v1/refunds" },
);

An API key scoped to agent:execute is enough for every call this client makes.

Reading vs running

You can read this guide with no account. To execute an action you need a private-beta workspace: a workspace API key (rk_...) and a capability token (rk_cap_...). There is no public self-serve checkout for keys.

Request private-beta access →

Optional later

After the Agent Firewall client is in place, you can add collection scanning or the editor extension. Neither is the first step.