LangGraph integration

Wrap LangGraph tool nodes with Aegis policy checks and BYOK-signed APS-1 events.

BYOK setup

  1. Console → Agents → create agent or register BYOK public key.
  2. Store signing private key in your runtime secrets (never in git).
  3. Create ingest API key in Console → API keys.
typescript
import { createGovernanceBridge, wrapLangGraphTool } from "@salanor/aegis";

const bridge = createGovernanceBridge({
  apiBaseUrl: "https://api.salanor.com",
  ingestApiKey: process.env.AEGIS_INGEST_API_KEY!,
  organizationId: process.env.AEGIS_ORGANIZATION_ID!,
  agentId: process.env.AEGIS_AGENT_ID!,
  keyId: process.env.AEGIS_KEY_ID!,
  privateKeyB64: process.env.AEGIS_SIGNING_PRIVATE_KEY_B64!,
  actorPrincipal: "langgraph-agent",
});

const transferFunds = wrapLangGraphTool(bridge, {
  toolName: "app.payments.transfer",
  description: "Transfer funds after policy check",
  handler: async (input: { amount_usd: number }) => {
    return { ok: true, amount_usd: input.amount_usd };
  },
});

// Use transferFunds inside your LangGraph node — policy + signed events run automatically.
Manual policy check
import { createGovernanceBridge, evaluatePolicyViaApi } from "@salanor/aegis";

const bridge = createGovernanceBridge({
  apiBaseUrl: "https://api.salanor.com",
  ingestApiKey: process.env.AEGIS_INGEST_API_KEY!,
  organizationId: process.env.AEGIS_ORGANIZATION_ID!,
  agentId: process.env.AEGIS_AGENT_ID!,
  keyId: process.env.AEGIS_KEY_ID!,
  privateKeyB64: process.env.AEGIS_SIGNING_PRIVATE_KEY_B64!,
});

await bridge.withTrace({ businessContext: "langgraph-flow" }, async () => {
  const decision = await evaluatePolicyViaApi(
    "https://api.salanor.com",
    process.env.AEGIS_INGEST_API_KEY!,
    {
      organization_id: process.env.AEGIS_ORGANIZATION_ID!,
      agent_id: process.env.AEGIS_AGENT_ID!,
      tool_name: "app.payments.transfer",
      payload: { amount_usd: 2500 },
    },
  );
  if (decision.decision !== "allow") throw new Error(decision.reason);
});

For no-code workflows see n8n integration.